Class: PuppetfileEditor::Logging Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppetfile_editor/cli.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Abstraction of logging methods for PuppetfileEditor::CLI

Instance Method Summary collapse

Constructor Details

#initializeLogging

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Logging.



111
112
113
114
115
116
117
118
119
120
121
122
# 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

Instance Method Details

#log(message, message_type = :undef) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



124
125
126
127
128
129
130
131
# 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) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



133
134
135
136
# File 'lib/puppetfile_editor/cli.rb', line 133

def log_and_exit(message)
  log(message, :warn)
  exit 1
end

#mod_message(mod, indent) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



138
139
140
# File 'lib/puppetfile_editor/cli.rb', line 138

def mod_message(mod, indent)
  log("#{mod.name.ljust(indent)} => #{mod.message}", mod.status)
end