Class: Humidifier::Reservoir::Config

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

Overview

A container class for the user-specified Reservoir configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
# File 'lib/humidifier/reservoir/config.rb', line 8

def initialize
  @mappings = {}
end

Instance Attribute Details

#mappingsObject (readonly)

Returns the value of attribute mappings.



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

def mappings
  @mappings
end

#stack_pathObject

Returns the value of attribute stack_path.



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

def stack_path
  @stack_path
end

#stack_prefixObject

Returns the value of attribute stack_prefix.



6
7
8
# File 'lib/humidifier/reservoir/config.rb', line 6

def stack_prefix
  @stack_prefix
end

Instance Method Details

#files_for(name) ⇒ Object

Raises:



12
13
14
15
# File 'lib/humidifier/reservoir/config.rb', line 12

def files_for(name)
  raise Error, 'You must configure a stack path' if stack_path.nil?
  Dir["#{stack_path}/#{name}/*.yml"]
end

#map(type, opts = {}, &block) ⇒ Object



17
18
19
# File 'lib/humidifier/reservoir/config.rb', line 17

def map(type, opts = {}, &block)
  mappings[type.to_sym] = Mapping.new(opts, &block)
end

#mapping_for(type) ⇒ Object



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

def mapping_for(type)
  mappings[type.to_sym]
end

#stacksObject



32
33
34
35
36
# File 'lib/humidifier/reservoir/config.rb', line 32

def stacks
  Dir["#{stack_path}/*"].each_with_object([]) do |name, names|
    names << File.basename(name) if File.directory?(name)
  end
end