Class: Gantree::Config
- Inherits:
-
Object
- Object
- Gantree::Config
- Defined in:
- lib/gantree/config.rb
Class Method Summary collapse
- .config_exists?(config) ⇒ Boolean
- .merge_config(options, config) ⇒ Object
- .merge_defaults(options = {}) ⇒ Object
Class Method Details
.config_exists?(config) ⇒ Boolean
20 21 22 |
# File 'lib/gantree/config.rb', line 20 def config_exists? config File.exist? config end |
.merge_config(options, config) ⇒ Object
15 16 17 18 |
# File 'lib/gantree/config.rb', line 15 def merge_config , config defaults = JSON.parse(File.open(config).read) defaults.merge() end |
.merge_defaults(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/gantree/config.rb', line 6 def merge_defaults(={}) configs = ["#{ENV['HOME']}/.gantreecfg",".gantreecfg"] hash = {} configs.each do |config| hash.merge!(merge_config(,config)) if config_exists?(config) end Hash[hash.map{ |k, v| [k.to_sym, v] }] end |