Class: PuppetfileEditor::Logging
- Inherits:
-
Object
- Object
- PuppetfileEditor::Logging
- Defined in:
- lib/puppetfile_editor/cli.rb
Instance Method Summary collapse
-
#initialize ⇒ Logging
constructor
A new instance of Logging.
- #log(message, message_type = :undef) ⇒ Object
- #log_and_exit(message) ⇒ Object
- #mod_message(mod, indent) ⇒ Object
Constructor Details
#initialize ⇒ Logging
Returns a new instance of Logging.
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/puppetfile_editor/cli.rb', line 99 def initialize @statuses = { updated: "[ \e[32;1m+\e[0m ]", matched: "[ \e[0;1m=\e[0m ]", skipped: "[ \e[33;1m~\e[0m ]", not_found: "[ \e[31;1mx\e[0m ]", type_mismatched: "[ \e[31;1mx\e[0m ]", wont_upgrade: "[ \e[33;1m!\e[0m ]", warn: "[ \e[31;1m!!\e[0m ]", undef: '', } end |
Instance Method Details
#log(message, message_type = :undef) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/puppetfile_editor/cli.rb', line 112 def log(, = :undef) status = if @statuses.key? @statuses[] else @statuses[:undef] end puts "#{status} #{message}" end |
#log_and_exit(message) ⇒ Object
121 122 123 124 |
# File 'lib/puppetfile_editor/cli.rb', line 121 def log_and_exit() log(, :warn) exit 1 end |
#mod_message(mod, indent) ⇒ Object
126 127 128 |
# File 'lib/puppetfile_editor/cli.rb', line 126 def (mod, indent) log("#{mod.name.ljust(indent)} => #{mod.message}", mod.status) end |