class Kafo::Store

Attributes

data[RW]

Public Class Methods

new(path = nil) click to toggle source
# File lib/kafo/store.rb, line 7
def initialize(path = nil)
  @data = {}
  load_path(path) if path
end

Public Instance Methods

add(data) click to toggle source
# File lib/kafo/store.rb, line 20
def add(data)
  @data.merge!(data)
end
add_dir(path) click to toggle source
# File lib/kafo/store.rb, line 24
def add_dir(path)
  Dir.glob(File.join(path, "*.yaml")).sort.each do |file|
    add_file(file)
  end
end
add_file(file) click to toggle source
# File lib/kafo/store.rb, line 30
def add_file(file)
  add(YAML.load_file(file))
end
get(key) click to toggle source
# File lib/kafo/store.rb, line 34
def get(key)
  @data[key]
end
load_path(path) click to toggle source
# File lib/kafo/store.rb, line 12
def load_path(path)
  if File.directory?(path)
    add_dir(path)
  else
    add_file(path)
  end
end