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-1.0.3 lib/kafo/store.rb
kafo-0.9.7 lib/kafo/store.rb
kafo-1.0.2 lib/kafo/store.rb
kafo-1.0.1 lib/kafo/store.rb
kafo-1.0.0 lib/kafo/store.rb
kafo-0.9.6 lib/kafo/store.rb