Module: Dapp::Dapp::Logging::Paint
- Included in:
- Dapp::Dapp
- Defined in:
- lib/dapp/dapp/logging/paint.rb
Constant Summary collapse
- FORMAT =
{ step: [:yellow, :bold], info: [:blue], success: [:green, :bold], warning: [:red, :bold], secondary: [:white, :bold], default: [:white] }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
38 39 40 |
# File 'lib/dapp/dapp/logging/paint.rb', line 38 def included(base) base.extend(self) end |
.initialize(mode) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/dapp/dapp/logging/paint.rb', line 14 def self.initialize(mode) ::Paint.mode = case mode when 'auto' then (ENV['TRAVIS'] || ENV['GITLAB_CI'] || STDOUT.tty?) ? 8 : 0 when 'on' then 8 when 'off' then 0 else raise end end |
Instance Method Details
#paint_string(object, style_name) ⇒ Object
29 30 31 |
# File 'lib/dapp/dapp/logging/paint.rb', line 29 def paint_string(object, style_name) ::Paint[unpaint(object.to_s), *paint_style(style_name)] end |
#paint_style(name) ⇒ Object
23 24 25 26 27 |
# File 'lib/dapp/dapp/logging/paint.rb', line 23 def paint_style(name) FORMAT[name].tap do |format| raise if format.nil? end end |
#unpaint(str) ⇒ Object
33 34 35 |
# File 'lib/dapp/dapp/logging/paint.rb', line 33 def unpaint(str) ::Paint.unpaint(str) end |