Class: Magellan::Gcs::Proxy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/magellan/gcs/proxy/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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

#dataObject



16
17
18
# File 'lib/magellan/gcs/proxy/config.rb', line 16

def data
  @data ||= load_file
end

#load_fileObject



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

#resetObject



20
21
22
# File 'lib/magellan/gcs/proxy/config.rb', line 20

def reset
  @data = nil
end

#verbose?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/magellan/gcs/proxy/config.rb', line 38

def verbose?
  ENV['VERBOSE'] =~ /true|yes|on|1/i
end