Project

lumos

0.0
No commit activity in last 3 years
No release in over 3 years
Have you ever tried to highlight your Ruby objects from your controllers/models/whatever in the Rails log? Lumos can easily wrap and make any object perceptible amongs common Rails log mess!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

= 0.4.1
 Project Readme

Lumos

Build Status Code Climate Test Coverage

☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢
☢                            ☢
☢                            ☢
☢  Objects wrapping library  ☢
☢                            ☢
☢                            ☢
☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢☢

Have you ever tried to highlight your Ruby objects from your controllers/models/whatever in the Rails log? I bet you have ). I usually do something like that p "###"; p %w(foo bar baz ); p "###" and in general it works fine, until you have to repeat this construction again and again, with different objects, in different places. I have a good news – lumos helps to easily wrap any object to ascii-style markup and make it perceptible amongst ususal Rails log mess.

Installation

Add this line to your application's Gemfile:

gem 'lumos'

And call inside your controller/model/whatever

class My::MoviesController < ApplicationController
 def checked
   lumos params
   @movie = Movie.find(params[:movie_id])
   current_user.send(params[:scope]) << @movie
   #redirect_to root_path
 end
end

Usage

Depend on passed parameters, lumos can act as a divider or as a wrapper.

Divider

For example, simple call of lumos without params will print a ### message in your log. Of course you're able to change a divider sign (lumos :>, "☭" will print a ☭☭☭ message) and number of repetitions – lumos :>, "☢", 10.

lumos
print "###"

lumos :>, "☭"
print "☭☭☭"

lumos :>, "☢", 10
print "☢☢☢☢☢☢☢☢☢☢"

Wrapper

But main reason of lumos existence is necessity of objects highlighting besides ambient noise. So, initial array might be highlighted with lumos %w(foo bar baz) that will give us such output:

#########################
#                       #
# ["foo", "bar", "baz"] #
#                       #
#########################

Wrapping method also takes few options such as:

position:

:surround (by default), :top, :bottom, :left, :right, :horizontal, :vertical

domains = {ru: "Russia", th: "Thailand", "com.au" => "Australia", ph: "Philippines", la: "Laos"}
lumos domains, {position: :horizontal}
######################################################################
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippi
nes", :la=>"Laos"}
######################################################################

delimiter:

lumos domains, position: :horizontal, delimiter: "❤★"
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippi
nes", :la=>"Laos"}
❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★❤★

And as you know – everything is better with emoji, so lumos supports emoji delimiters as well!

lumos "Coffee smells like freshly ground heaven", delimiter: ":coffee:", position: :bottom

Coffee smells like freshly ground heaven

☕☕☕☕☕☕☕☕☕☕☕☕☕☕☕

padding:

lumos domains, delimiter: "❄", padding: 2
❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄
❄                                                                            ❄
❄                                                                            ❄
❄                                                                            ❄
❄   {:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippi   ❄
❄   nes", :la=>"Laos"}                                                       ❄
❄                                                                            ❄
❄                                                                            ❄
❄                                                                            ❄
❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄❄

length:

lumos domains, position: :horizontal, delimiter: "->", length: 140
->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->
{:ru=>"Russia", :th=>"Thailand", "com.au"=>"Australia", :ph=>"Philippines", :la=>"Laos"}
->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->->

Default options

You are able to specify one or few settings described above as a part of global default options.

If you're using Rails, you can define a Hash with default options in config/application.rb or in any of the config/environments/*.rb files on config.lumos_defaults. An example:

module YourApp
  class Application < Rails::Application
    # Other code...

    config.lumos_defaults = {position: :bottom, delimiter: ":poop:"}
  end
end

Another option is to directly modify the Lumos::Wrapper.default_options Hash - this method works for non-Rails applications or is an option if you prefer to place the Lumos default settings in an initializer.

Lumos::Wrapper.default_options[:padding] = 5
Lumos::Wrapper.default_options[:length] = 140
Lumos::Wrapper.default_options[:delimiter] = ":alien:"