Sha256: 0f7dd6d8332b56fd9af19e79cf5a6a7a9d15160f0c695e755307deda7ca0839b

Contents?: true

Size: 578 Bytes

Versions: 15

Compression:

Stored size: 578 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

15 entries across 15 versions & 1 rubygems

Version Path
kafo-7.6.0 lib/kafo/store.rb
kafo-7.5.1 lib/kafo/store.rb
kafo-7.5.0 lib/kafo/store.rb
kafo-7.4.0 lib/kafo/store.rb
kafo-7.3.0 lib/kafo/store.rb
kafo-7.2.0 lib/kafo/store.rb
kafo-7.1.0 lib/kafo/store.rb
kafo-7.0.0 lib/kafo/store.rb
kafo-6.5.0 lib/kafo/store.rb
kafo-6.4.1 lib/kafo/store.rb
kafo-6.4.0 lib/kafo/store.rb
kafo-6.3.0 lib/kafo/store.rb
kafo-6.2.1 lib/kafo/store.rb
kafo-6.2.0 lib/kafo/store.rb
kafo-6.1.2 lib/kafo/store.rb