Class: Figroll::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/figroll/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



7
8
9
# File 'lib/figroll/config.rb', line 7

def initialize
  reset
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/figroll/config.rb', line 5

def data
  @data
end

#environmentObject (readonly)

Returns the value of attribute environment.



5
6
7
# File 'lib/figroll/config.rb', line 5

def environment
  @environment
end

#requiredObject (readonly)

Returns the value of attribute required.



5
6
7
# File 'lib/figroll/config.rb', line 5

def required
  @required
end

Instance Method Details

#load_file(config_file) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/figroll/config.rb', line 11

def load_file(config_file)
  return unless File.exists?(config_file)

  file_data = YAML.load_file(config_file) || {}

  # set up required keys
  file_data['required'] ||= []
  file_data['required'].each do |key|
    required.push(Figroll.normalize(key))
  end

  # load up the environment-specific data
  file_data['environments'] ||= {}
  @data = file_data['environments'][environment] || {}
end