Class: Msgtrail::Config
- Inherits:
-
Object
- Object
- Msgtrail::Config
- Defined in:
- lib/msgtrail/config.rb
Constant Summary collapse
- CONFIG_FILE =
'config.json'.freeze
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#working_directory ⇒ Object
Returns the value of attribute working_directory.
Instance Method Summary collapse
-
#initialize(working_directory) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(working_directory) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/msgtrail/config.rb', line 8 def initialize(working_directory) self.working_directory = working_directory # Used by several classes begin filepath = File.join(working_directory, CONFIG_FILE) config = File.read(filepath) rescue puts("Can't find '#{filepath}' (#{$!})") exit(2) end begin self.settings = MultiJson.load(config, symbolize_keys: true, object_class: OpenStruct) rescue puts("Invalid JSON in '#{filepath}' (#{$!})") exit(2) end end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
6 7 8 |
# File 'lib/msgtrail/config.rb', line 6 def settings @settings end |
#working_directory ⇒ Object
Returns the value of attribute working_directory.
6 7 8 |
# File 'lib/msgtrail/config.rb', line 6 def working_directory @working_directory end |