Sha256: cdd199a8e2a28f60ad82362008f56db55c1530bc28bb188ce863535633f77a14

Contents?: true

Size: 576 Bytes

Versions: 26

Compression:

Stored size: 576 Bytes

Contents

require 'yaml'

module Kafo
  class Store
    attr_accessor :data

    def initialize(path=nil)
      @data = {}
      load_path(path) if path
    end

    def load_path(path)
      if File.directory?(path)
        add_dir(path)
      else
        add_file(path)
      end
    end

    def add(data)
      @data.merge!(data)
    end

    def add_dir(path)
      Dir.glob(File.join(path, "*.yaml")).sort.each do |file|
        add_file(file)
      end
    end

    def add_file(file)
      add(YAML.load_file(file))
    end

    def get(key)
      @data[key]
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
kafo-6.1.1 lib/kafo/store.rb
kafo-6.1.0 lib/kafo/store.rb
kafo-6.0.0 lib/kafo/store.rb
kafo-5.1.0 lib/kafo/store.rb
kafo-5.0.1 lib/kafo/store.rb
kafo-5.0.0 lib/kafo/store.rb
kafo-4.1.0 lib/kafo/store.rb
kafo-4.0.1 lib/kafo/store.rb
kafo-4.0.0 lib/kafo/store.rb
kafo-3.0.0 lib/kafo/store.rb
kafo-2.1.0 lib/kafo/store.rb
kafo-2.0.2 lib/kafo/store.rb
kafo-2.0.1 lib/kafo/store.rb
kafo-2.0.0 lib/kafo/store.rb
kafo-1.0.8 lib/kafo/store.rb
kafo-1.0.7 lib/kafo/store.rb
kafo-1.0.6 lib/kafo/store.rb
kafo-1.0.5 lib/kafo/store.rb
kafo-1.0.4 lib/kafo/store.rb
kafo-0.9.8 lib/kafo/store.rb