module Humidifier module Reservoir # A container class for the user-specified Reservoir configuration. class Config attr_reader :mappings, :stack_path attr_accessor :stack_prefix def initialize @mappings = {} end def files_for(name) raise Error, 'You must configure a stack path' if stack_path.nil? Dir["#{stack_path}/#{name}/*.yml"] end def map(type, opts = {}, &block) mappings[type.to_sym] = Mapping.new(opts, &block) end def mapping_for(type) mappings[type.to_sym] end def stack_path=(stack_path) raise Error, "Invalid filepath: #{stack_path}" unless File.exist?(stack_path) @stack_path = stack_path end def stacks Dir["#{stack_path}/*"].each_with_object([]) do |name, names| names << File.basename(name) if File.directory?(name) end end end end end