Class: Most::Environment

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/most/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnvironment

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

#argumentsObject (readonly)

Returns the value of attribute arguments.



26
27
28
# File 'lib/most/environment.rb', line 26

def arguments
  @arguments
end

#loggerObject (readonly)

Returns the value of attribute logger.



28
29
30
# File 'lib/most/environment.rb', line 28

def logger
  @logger
end

#modesObject (readonly)

Returns the value of attribute modes.



29
30
31
# File 'lib/most/environment.rb', line 29

def modes
  @modes
end

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/most/environment.rb', line 29

def options
  @options
end

#tasksObject (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, message)
  @logger.error(message)
  @logger.error(exception.message)

  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 log_message(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 show_message(message, is_log_data = false)
  puts "#{message}"
  log_message(message) if is_log_data
end