Class: Canals::Config

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/canals/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(root = nil) ⇒ Config

Returns a new instance of Config.



10
11
12
13
# File 'lib/canals/config.rb', line 10

def initialize(root = nil)
  @root = root
  @config = load_config(global_config_file)
end

Instance Method Details

#load_config(config_file) ⇒ Object



17
18
19
20
21
# File 'lib/canals/config.rb', line 17

def load_config(config_file)
  valid_file = config_file && config_file.exist? && !config_file.size.zero?
  return {} if !valid_file
  return Canals::Tools::YAML.load_file(config_file)
end

#save!Object



23
24
25
26
# File 'lib/canals/config.rb', line 23

def save!
  FileUtils.mkdir_p(global_config_file.dirname)
  Canals::Tools::YAML.dump_file(global_config_file, @config)
end