Class: Gantree::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gantree/config.rb

Class Method Summary collapse

Class Method Details

.config_exists?(config) ⇒ Boolean

Returns:

  • (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 options, config
  defaults = JSON.parse(File.open(config).read)
  defaults.merge(options)
end

.merge_defaults(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/gantree/config.rb', line 6

def merge_defaults(options={})
  configs = ["#{ENV['HOME']}/.gantreecfg",".gantreecfg"]
  hash = {}
  configs.each do |config|
    hash.merge!(merge_config(options,config)) if config_exists?(config)
  end
  Hash[hash.map{ |k, v| [k.to_sym, v] }]
end