Class: Most::Environment
- Includes:
- Singleton
- Defined in:
- lib/most/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
- #show_message(message, is_log_data = false) ⇒ Object
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
31 32 33 34 35 36 37 38 39 |
# File 'lib/most/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/most/environment.rb', line 26 def arguments @arguments end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
28 29 30 |
# File 'lib/most/environment.rb', line 28 def logger @logger end |
#modes ⇒ Object (readonly)
Returns the value of attribute modes.
29 30 31 |
# File 'lib/most/environment.rb', line 29 def modes @modes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/most/environment.rb', line 29 def @options end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
29 30 31 |
# File 'lib/most/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 |
# File 'lib/most/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[:exit_code] = 1 end |
#log_message(text) ⇒ Object
57 58 59 |
# File 'lib/most/environment.rb', line 57 def (text) @logger.info(text) end |
#log_warning(text) ⇒ Object
53 54 55 |
# File 'lib/most/environment.rb', line 53 def log_warning(text) @logger.warn(text) end |
#show_message(message, is_log_data = false) ⇒ Object
61 62 63 64 |
# File 'lib/most/environment.rb', line 61 def (, is_log_data = false) puts "#{}" () if is_log_data end |