Sha256: 27fdd3c133560670d26570336fbe0f4df6115e9a58f72f974b51347519ce839c

Contents?: true

Size: 562 Bytes

Versions: 7

Compression:

Stored size: 562 Bytes

Contents

module YamlConfigurator

  def self.config_for(name, env)
    yaml = Pathname.new("config/#{name}.yml")

    #puts "Loading #{name} for environment: #{env}"

    if yaml.exist?
      require "erb"
      (YAML.load(ERB.new(yaml.read).result) || {})[env] || {}
    else
      raise "Could not load configuration. No such file - #{yaml}"
    end
  rescue Psych::SyntaxError => e
    raise "YAML syntax error occurred while parsing #{yaml}. " "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " "Error: #{e.message}"
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
surikat-0.3.2 lib/surikat/yaml_configurator.rb
surikat-0.3.1 lib/surikat/yaml_configurator.rb
surikat-0.3.0 lib/surikat/yaml_configurator.rb
surikat-0.2.5 lib/surikat/yaml_configurator.rb
surikat-0.2.4 lib/surikat/yaml_configurator.rb
surikat-0.2.3 lib/surikat/yaml_configurator.rb
surikat-0.2.2 lib/surikat/yaml_configurator.rb