Class: Figroll::Config

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

Overview

A configuration object for Figroll

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new Config instance



25
26
27
# File 'lib/figroll/config.rb', line 25

def initialize
  reset
end

Instance Attribute Details

#dataArray<String>? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Values defined in the configuration to inject into Figroll

Returns:

  • (Array<String>, nil)


21
22
23
# File 'lib/figroll/config.rb', line 21

def data
  @data
end

#environmentString? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The FIGROLL_ENV under which we’re running

Returns:

  • (String, nil)


16
17
18
# File 'lib/figroll/config.rb', line 16

def environment
  @environment
end

#requiredArray<String>? (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A list of required environment variables defined by the configuration

Returns:

  • (Array<String>, nil)


11
12
13
# File 'lib/figroll/config.rb', line 11

def required
  @required
end

Instance Method Details

#load_file(config_file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Given a config file name, load the configuration specified in that file.

Parameters:

  • config_file (String)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/figroll/config.rb', line 32

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(Util.normalize(key))
  end

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