Class: Sumodev::Config
- Inherits:
-
Object
- Object
- Sumodev::Config
- Includes:
- Singleton
- Defined in:
- lib/sumodev/config.rb
Constant Summary collapse
- Defaults =
{ 'SUMO_TEMP_PATH' => "/tmp/", }
Instance Attribute Summary collapse
-
#variables ⇒ Object
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sumodev/config.rb', line 12 def initialize sumofile_path = File.("~/.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
26 27 28 |
# File 'lib/sumodev/config.rb', line 26 def self.get(*args) instance.get(*args) end |
Instance Method Details
#get(name) ⇒ Object
30 31 32 |
# File 'lib/sumodev/config.rb', line 30 def get(name) @variables[name] || Defaults[name] || raise("Can't find setting for #{name} in ~/.sumorc") end |