Sha256: d46f5b5c2b629af0fe4413bcc6b102f9e2d805567b7f1cab36edd70080ab3089
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'singleton' require 'yaml' require 'erb' require "armoire/setting" require "armoire/version" if defined?(Rails::Railtie) require "armoire/railtie" elsif defined?(Rails.configuration) require "armoire/init" end class Armoire include Singleton attr_accessor :settings attr_writer :environment def self.[](key) instance.settings[key] end def self.load!(path_to_config_file) instance.settings = Setting.new(instance.load_settings(path_to_config_file)) end def self.environment=(environment) instance.environment = environment end def environment @environment ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' end def load_settings(path_to_config_file) YAML.load(ERB.new(File.read(path_to_config_file)).result)[environment] rescue Errno::ENOENT => e raise MissingSettingsFile.new('The settings file cannot be found') end # When the settings file cannot be read, this exception will be raised class MissingSettingsFile < StandardError; end # When a config setting isn't set, this exception will be raised class ConfigSettingMissing < StandardError; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
armoire-1.3.0 | lib/armoire.rb |