Class: MarhanCli::Config

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

Class Method Summary collapse

Class Method Details

.default_config_fileObject



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

def self.default_config_file
  File.expand_path(File.join(Dir.home, ".marhan_cli.yml"))
end

.init(config_file = nil) ⇒ Object



7
8
9
10
# File 'lib/marhan_cli/config.rb', line 7

def self.init(config_file = nil)
  @config_file = config_file || default_config_file
  load_config(@config_file)
end

.load_config(config_file) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/marhan_cli/config.rb', line 12

def self.load_config(config_file)
  unless File.exists?(config_file)
    raise "Stop processing! Command needs the configuration file '#{config_file}' in you're home directory."
  end
  begin
    Ambience.create(config_file).to_mash
  rescue Exception => e
    raise "Configuration file could not pared: #{e}"
  end
end