class PuppetfileEditor::Logging
Abstraction of logging methods for PuppetfileEditor::CLI
@api private
Public Class Methods
new()
click to toggle source
# File lib/puppetfile_editor/cli.rb, line 111 def initialize @statuses = { updated: "[ \e[32;1m+\e[0m ]", matched: "[ \e[0;1m=\e[0m ]", skipped: "[ \e[33;1m~\e[0m ]", not_found: "[ \e[0;1m-\e[0m ]", type_mismatched: "[ \e[31;1mx\e[0m ]", wont_upgrade: "[ \e[33;1m!\e[0m ]", warn: "[ \e[31;1m!!\e[0m ]", undef: '', } end
Public Instance Methods
log(message, message_type = :undef)
click to toggle source
# File lib/puppetfile_editor/cli.rb, line 124 def log(message, message_type = :undef) if @statuses.key? message_type status = @statuses[message_type] else status = @statuses[:undef] end puts "#{status} #{message}" end
log_and_exit(message)
click to toggle source
# File lib/puppetfile_editor/cli.rb, line 133 def log_and_exit(message) log(message, :warn) exit 1 end
mod_message(mod, indent)
click to toggle source
# File lib/puppetfile_editor/cli.rb, line 138 def mod_message(mod, indent) log("#{mod.name.ljust(indent)} => #{mod.message}", mod.status) end