Class: EDango::Environment
- Includes:
- Singleton
- Defined in:
- lib/edango/environment.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#modes ⇒ Object
readonly
Returns the value of attribute modes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
- #log_error(exception, message) ⇒ Object
- #log_message(text) ⇒ Object
- #log_warning(text) ⇒ Object
- #save_options(*args) ⇒ Object
- #show_message(message, log = false) ⇒ Object
- #state(message) ⇒ Object
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
31 32 33 34 35 36 37 38 39 |
# File 'lib/edango/environment.rb', line 31 def initialize @arguments = ARGV @logger = SERVICES[:logger] @options = PARAMETERS[:options] @modes = PARAMETERS[:modes] @tasks = PARAMETERS[:tasks] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
26 27 28 |
# File 'lib/edango/environment.rb', line 26 def arguments @arguments end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
28 29 30 |
# File 'lib/edango/environment.rb', line 28 def logger @logger end |
#modes ⇒ Object (readonly)
Returns the value of attribute modes.
29 30 31 |
# File 'lib/edango/environment.rb', line 29 def modes @modes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/edango/environment.rb', line 29 def @options end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
29 30 31 |
# File 'lib/edango/environment.rb', line 29 def tasks @tasks end |
Instance Method Details
#log_error(exception, message) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/edango/environment.rb', line 41 def log_error(exception, ) @logger.error() @logger.error(exception.) unless @modes.nil? @logger.error(exception.backtrace) if @modes[:verbose] or @modes[:debug] end GLOBALS[:errors_number] ||= 0 GLOBALS[:errors_number] += 1 end |
#log_message(text) ⇒ Object
58 59 60 |
# File 'lib/edango/environment.rb', line 58 def (text) @logger.info(text) end |
#log_warning(text) ⇒ Object
54 55 56 |
# File 'lib/edango/environment.rb', line 54 def log_warning(text) @logger.warn(text) end |
#save_options(*args) ⇒ Object
72 73 74 |
# File 'lib/edango/environment.rb', line 72 def (*args) PARAMETERS.update(*args) end |
#show_message(message, log = false) ⇒ Object
62 63 64 65 |
# File 'lib/edango/environment.rb', line 62 def (, log = false) puts() unless @modes[:quiet] () if log end |
#state(message) ⇒ Object
67 68 69 70 |
# File 'lib/edango/environment.rb', line 67 def state() puts() if @modes[:verbose] () end |