Class: Magellan::Gcs::Proxy::Config
- Inherits:
-
Object
- Object
- Magellan::Gcs::Proxy::Config
- Defined in:
- lib/magellan/gcs/proxy/config.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #data ⇒ Object
-
#initialize(path = './config.yml') ⇒ Config
constructor
A new instance of Config.
- #load_file ⇒ Object
- #reset ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize(path = './config.yml') ⇒ Config
Returns a new instance of Config.
12 13 14 |
# File 'lib/magellan/gcs/proxy/config.rb', line 12 def initialize(path = './config.yml') @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/magellan/gcs/proxy/config.rb', line 11 def path @path end |
Instance Method Details
#[](key) ⇒ Object
34 35 36 |
# File 'lib/magellan/gcs/proxy/config.rb', line 34 def [](key) data[key.to_s] end |
#data ⇒ Object
16 17 18 |
# File 'lib/magellan/gcs/proxy/config.rb', line 16 def data @data ||= load_file end |
#load_file ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/magellan/gcs/proxy/config.rb', line 24 def load_file erb = ERB.new(File.read(path), nil, '-') erb.filename = path t = erb.result puts '=' * 100 puts t puts '-' * 100 YAML.load(t) end |
#reset ⇒ Object
20 21 22 |
# File 'lib/magellan/gcs/proxy/config.rb', line 20 def reset @data = nil end |
#verbose? ⇒ Boolean
38 39 40 |
# File 'lib/magellan/gcs/proxy/config.rb', line 38 def verbose? ENV['VERBOSE'] =~ /true|yes|on|1/i end |