Sha256: 7728dc2924e315214ba7f6f7bbcda1f73dfe3a25afd87ed28b6a3921cdcef5e7

Contents?: true

Size: 800 Bytes

Versions: 11

Compression:

Stored size: 800 Bytes

Contents

require 'active_support/hash_with_indifferent_access'

module Amiba
  class Configuration

    class << self

      def method_missing(name, *args, &block)
        raise ArgumentError if args.length > 1
        if name.to_s[-1] == '='
          write_setting(name[0..-2].to_sym, args[0])
        else
          read_setting(name)
        end
      end

      protected

      def load_defaults
        defaults = YAML.load(File.read('.amiba'))
        @config.merge!(defaults)
      end

      def write_setting(name, value)
        config[name] = value
      end

      def read_setting(name)
        config[name]
      end

      def config
        return @config unless @config.nil?
        @config = HashWithIndifferentAccess.new
        load_defaults
        @config
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
amiba-1.0.2 lib/amiba/configuration.rb
amiba-1.0.1 lib/amiba/configuration.rb
amiba-1.0.0 lib/amiba/configuration.rb
amiba-0.0.9 lib/amiba/configuration.rb
amiba-0.0.8 lib/amiba/configuration.rb
amiba-0.0.7 lib/amiba/configuration.rb
amiba-0.0.6 lib/amiba/configuration.rb
amiba-0.0.5 lib/amiba/configuration.rb
amiba-0.0.4 lib/amiba/configuration.rb
amiba-0.0.3 lib/amiba/configuration.rb
amiba-0.0.2 lib/amiba/configuration.rb