Class: ServerStatus::Configuration
- Inherits:
-
Object
- Object
- ServerStatus::Configuration
- Defined in:
- lib/server-status/configuration.rb
Constant Summary collapse
- CONFIG_PATH =
File.join(Dir.home, '.server-status.json')
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #options ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 |
# File 'lib/server-status/configuration.rb', line 10 def initialize if File.exist?(CONFIG_PATH) @settings = JSON.parse(File.open(CONFIG_PATH).read) else @settings = {} end end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
7 8 9 |
# File 'lib/server-status/configuration.rb', line 7 def settings @settings end |
Instance Method Details
#options ⇒ Object
24 25 26 27 28 29 |
# File 'lib/server-status/configuration.rb', line 24 def # symbolize keys (settings['options'] || {}).each_with_object({}) do |(key, value), hash| hash[key.to_sym] = value end end |
#save ⇒ Object
18 19 20 21 22 |
# File 'lib/server-status/configuration.rb', line 18 def save File.open(CONFIG_PATH, 'w') do |file| file.write JSON.pretty_generate(@settings) end end |