module Reap class Project # = Project Settings # # Configuration settings (from .reap file). class Settings < Hash REAP_FILE = '{.reap,_reap,reapfile}{.yaml,.yml,}' def self.read(location, metadata) if File.file?(location) file = location else file = Dir.glob(File.join(location, REAP_FILE), File::FNM_CASEFOLD).first end if file data = YAML::load(File.open(file)) || {} else data = {} end new(data, metadata) end def initialize(data, metadata) super() @metadata = metadata settings = {} data.each do |key, value| settings[key] ||= {} settings[key].update(value) if value end update(settings) end # open hash def method_missing(s, *a) if s =~ /=$/ self[s] = a[0] elsif a.empty? self[s] else super end end end end end