Class: CS::CLI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cs/cli/cli.rb

Constant Summary collapse

@@config =
{}
@@loaded =
false
@@file =
""

Class Method Summary collapse

Class Method Details

.get(key = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cs/cli/cli.rb', line 16

def self.get(key=nil)
  if !@@loaded
    STDERR.puts("WARNING could not load '#{@@file}'. Is it exists ?")
  end

  if key.nil?
    return @@config
  else
    return @@config[key.to_s]
  end
end

.load_config(file = "#{ENV['HOME']}/.cs.yml") ⇒ Object



10
11
12
13
14
# File 'lib/cs/cli/cli.rb', line 10

def self.load_config(file="#{ENV['HOME']}/.cs.yml")
  @@file = file
  @@config = YAML.load_file(file)
  @@loaded = true
end