Sha256: 9da8b42e7868e903b332d51ab93adf6b8582a37573cd7703a2f9d3d9e301c306

Contents?: true

Size: 962 Bytes

Versions: 52

Compression:

Stored size: 962 Bytes

Contents

module Refinery #:nodoc:
  # Configuration class.
  class Config
    # Get a shared configuration
    def self.default
      @default ||= new({
        'aws' => {
          'credentials' => {}
        },
        'processors' => {}
      })
    end
    
    # Initialize the config with the given data
    def initialize(data={})
      @data = data
    end
    
    # Get the configuration value
    def [](key)
      data[key.to_s]
    end
    
    # Set the configuration value
    def []=(key, value)
      data[key.to_s] = value
    end
    
    # Load configuration from a YAML file
    def load_file(file)
      @file = file
      @data = YAML::load_file(@file)
      @last_load = File.mtime(@file)
    end
    
    # Refresh the configuration from the YAML file if necessary.
    def refresh
      if File.mtime(@file) != @last_load
        @data = YAML::load_file(@file)
      end
    end
    
    private
    def data
      @data ||= {}
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
aeden-refinery-0.10.0 lib/refinery/config.rb
aeden-refinery-0.10.1 lib/refinery/config.rb
aeden-refinery-0.10.10 lib/refinery/config.rb
aeden-refinery-0.10.2 lib/refinery/config.rb
aeden-refinery-0.10.3 lib/refinery/config.rb
aeden-refinery-0.10.5 lib/refinery/config.rb
aeden-refinery-0.10.6 lib/refinery/config.rb
aeden-refinery-0.10.8 lib/refinery/config.rb
aeden-refinery-0.9.1 lib/refinery/config.rb
aeden-refinery-0.9.10 lib/refinery/config.rb
aeden-refinery-0.9.11 lib/refinery/config.rb
aeden-refinery-0.9.12 lib/refinery/config.rb
aeden-refinery-0.9.13 lib/refinery/config.rb
aeden-refinery-0.9.14 lib/refinery/config.rb
aeden-refinery-0.9.15 lib/refinery/config.rb
aeden-refinery-0.9.2 lib/refinery/config.rb
aeden-refinery-0.9.4 lib/refinery/config.rb
aeden-refinery-0.9.5 lib/refinery/config.rb
aeden-refinery-0.9.6 lib/refinery/config.rb
aeden-refinery-0.9.7 lib/refinery/config.rb