Module: LitCLI
- Defined in:
- lib/config.rb,
lib/lit_cli.rb
Defined Under Namespace
Classes: Config
Constant Summary collapse
- @@pastel =
Pastel.new
- @@config =
Config.new
- @@is_prying =
false
Class Method Summary collapse
- .colorize(text, color) ⇒ Object
-
.configure {|@@config| ... } ⇒ Object
Override config from application.
- .delay ⇒ Object
- .filter?(type) ⇒ Boolean
- .is_prying? ⇒ Boolean
- .render(type) ⇒ Object
- .step ⇒ Object
Instance Method Summary collapse
- #lit(message, type = :info) ⇒ Object (also: #🔥)
Class Method Details
.colorize(text, color) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/lit_cli.rb', line 60 def self.colorize(text, color) case color when :blue return @@pastel.bright_blue(text) when :green return @@pastel.green(text) when :yellow return @@pastel.yellow(text) when :red return @@pastel.red(text) when :purple, :magenta return @@pastel.magenta(text) when :cyan return @@pastel.cyan(text) else return text end end |
.configure {|@@config| ... } ⇒ Object
Override config from application.
80 81 82 83 84 85 |
# File 'lib/lit_cli.rb', line 80 def self.configure() yield(@@config) # Override config from command line. @@config.cli_configure() end |
.delay ⇒ Object
50 51 52 53 54 |
# File 'lib/lit_cli.rb', line 50 def self.delay() if @@config.delay > 0 sleep(@@config.delay) end end |
.filter?(type) ⇒ Boolean
42 43 44 45 46 47 48 |
# File 'lib/lit_cli.rb', line 42 def self.filter? type unless @@config.type.nil? || @@config.type.include?(type) return true end false end |
.is_prying? ⇒ Boolean
56 57 58 |
# File 'lib/lit_cli.rb', line 56 def self. @@config.step && end |
.render(type) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lit_cli.rb', line 21 def self.render(type) type_config = @@config.types[type] time_text = LitCLI.colorize(Time.now().strftime("%k:%M"), :cyan) type_text = type_config[:icon] + " " + type.to_s type_text_color = LitCLI.colorize(type_text, type_config[:color]) = "🔥 #{time_text} #{type_text_color} #{message}" puts end |
.step ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/lit_cli.rb', line 33 def self.step() if @@config.step puts "🔥 Press ENTER to step or P to Pry:" input = gets.chomp binding while input == nil = true if input.downcase == "p" end end |
Instance Method Details
#lit(message, type = :info) ⇒ Object Also known as: 🔥
11 12 13 14 15 16 17 18 |
# File 'lib/lit_cli.rb', line 11 def lit(, type = :info) if @@config.enabled return if LitCLI.filter? type LitCLI.render(type) LitCLI.step() LitCLI.delay() end end |