Class: Sumodev::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sumodev/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Config

Returns a new instance of Config.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sumodev/config.rb', line 8

def initialize
  sumofile_path = File.expand_path("~/.sumorc")

  if File.file?(sumofile_path)
      @variables = File.readlines(sumofile_path).inject({}) do |env,line|
        line = line.strip.gsub('export', '')
        name, value = line.split("=", 2)
        env.merge name.strip => value.strip.tr("'\"", '')
      end
  else
    raise("No .sumorc-file found in ~/.sumorc")
  end
end

Instance Attribute Details

#variables ⇒ Object

Returns the value of attribute variables.



6
7
8
# File 'lib/sumodev/config.rb', line 6

def variables
  @variables
end

Class Method Details

.get(*args) ⇒ Object



22
23
24
# File 'lib/sumodev/config.rb', line 22

def self.get(*args)
  instance.get(*args)
end

Instance Method Details

#get(name) ⇒ Object



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

def get(name)
    @variables[name]
end