lib/ripple.rb in ripple-0.8.0.beta2 vs lib/ripple.rb in ripple-0.8.0

- old
+ new

@@ -55,29 +55,35 @@ # @param [Riak::Client] value the client def client=(value) Thread.current[:ripple_client] = value end + # Sets the global Ripple configuration. def config=(hash) self.client = nil @config = hash.symbolize_keys end + # Reads the global Ripple configuration. def config @config ||= {} end + # Loads the Ripple configuration from a given YAML file. + # Evaluates the configuration with ERB before loading. def load_configuration(config_file, config_keys = [:ripple]) config_file = File.expand_path(config_file) config_hash = YAML.load(ERB.new(File.read(config_file)).result).with_indifferent_access config_keys.each {|k| config_hash = config_hash[k]} self.config = config_hash || {} rescue Errno::ENOENT raise Ripple::MissingConfiguration.new(config_file) end alias_method :load_config, :load_configuration end - + + # Exception raised when the path passed to + # {Ripple::load_configuration} does not point to a existing file. class MissingConfiguration < StandardError include Translation def initialize(file_path) super(t("missing_configuration", :file => file_path)) end