Class: Karo::Config

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

Class Method Summary collapse

Class Method Details

.default_file_nameObject



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

def self.default_file_name
  ".karo.yml"
end

.load_configuration(options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/karo/config.rb', line 14

def self.load_configuration(options)
  begin
     config_file = File.expand_path(options[:config_file])
    configuration = read_configuration(config_file)[options[:environment]]

  if configuration.nil? || configuration.empty?
    raise Thor::Error, "Please pass a valid configuration for an environment '#{options[:environment]}' within this file '#{config_file}'"
  else
    configuration
  end
 rescue Karo::NoConfigFileFoundError
  puts "You can use 'karo generate' to generate a skeleton .karo.yml file"
  puts "Please make sure that this configuration file exists? '#{config_file}'"
  raise Thor::Error, "and run the command again"
 end
end