Module: Figroll

Defined in:
lib/figroll.rb,
lib/figroll/util.rb,
lib/figroll/config.rb,
lib/figroll/storage.rb,
lib/figroll/version.rb

Overview

A simple universal ENV-focused configuration library

Defined Under Namespace

Modules: Util Classes: Config, Storage

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.configure(config_file) ⇒ Object

Given a config file, set up Figroll for ENV consumption

Parameters:

  • config_file (String)

    the figroll configuration for your app



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

def self.configure(config_file)
  setup

  # Load the config file
  config.load_file(config_file)

  # Import the environment configuration from the config
  storage.import(config.data)

  # Import the actual ENV hash
  storage.import(ENV)

  # verify all required variables are set
  validate_configuration
end

.fetch(key) ⇒ String

Retrieve the value of an environment configuration variable. The key may be either a String or a Symbol, non-case-sensitive. For example, these all reference the same value:

  • 'i am a variable'
  • 'i_am_a_variable'
  • 'I_AM_A_VARIABLE'
  • :i_am_a_variable

Parameters:

  • key (String, Symbol)

    the stringified or symbolized name of the variable for which you want to know the value.

Returns:

  • (String)

    the value of the variable when Figroll was configured

Raises:

  • (RuntimeError)

    if the varible was not known at configuration time



36
37
38
# File 'lib/figroll.rb', line 36

def self.fetch(key)
  storage.fetch(key)
end