Sha256: 9bb5c4195b7abb5d3bd659ca6266c850a2404da2cedec20822542eda0199bf7a

Contents?: true

Size: 635 Bytes

Versions: 13

Compression:

Stored size: 635 Bytes

Contents

require 'yaml'
require 'wrapbox/configuration'

module Wrapbox
  class ConfigRepository
    def initialize
      @configs = {}
    end

    def load_yaml(yaml_file)
      configs = YAML.load(ERB.new(File.read(yaml_file)).result)
      configs.each do |name, configuration|
        load_config(name, configuration.merge("name" => name))
      end
    end

    def load_config(name, configuration)
      @configs[name.to_sym] = Configuration.load_config(configuration)
    end

    def default
      @configs[:default]
    end

    def get(name)
      name ? @configs[name.to_sym] : default
    end
    alias_method(:[], :get)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wrapbox-0.9.0 lib/wrapbox/config_repository.rb
wrapbox-0.8.2 lib/wrapbox/config_repository.rb
wrapbox-0.8.1 lib/wrapbox/config_repository.rb
wrapbox-0.8.0 lib/wrapbox/config_repository.rb
wrapbox-0.7.0 lib/wrapbox/config_repository.rb
wrapbox-0.6.0 lib/wrapbox/config_repository.rb
wrapbox-0.5.2 lib/wrapbox/config_repository.rb
wrapbox-0.5.1 lib/wrapbox/config_repository.rb
wrapbox-0.5.0 lib/wrapbox/config_repository.rb
wrapbox-0.4.1 lib/wrapbox/config_repository.rb
wrapbox-0.4.0 lib/wrapbox/config_repository.rb
wrapbox-0.3.0 lib/wrapbox/config_repository.rb
wrapbox-0.2.0 lib/wrapbox/config_repository.rb