Module: Kumome::Config

Defined in:
lib/kumome/config.rb

Class Method Summary collapse

Class Method Details

.configObject



5
6
7
# File 'lib/kumome/config.rb', line 5

def self.config
  @config
end

.loadObject



25
26
27
28
# File 'lib/kumome/config.rb', line 25

def self.load
  @config = YAML.load_file(parse_argv(ARGV))
  @config
end

.parse_argv(argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kumome/config.rb', line 9

def self.parse_argv(argv)
  default_config_path = File.expand_path('./default.yml', File.dirname(__FILE__))
  config_option = argv.find do |arg|
    arg =~ /\A(--config=?|-c=?).*\z/
  end
  if config_option
    config_path = if config_option =~ /=/
                    config_option.gsub(/\A(--config=?|-c=?)/, '')
                  else
                    argv[argv.index(config_option) + 1]
                  end
  end
  config_path = default_config_path if config_path.nil?
  config_path
end