Class: Reap::Project::Settings
Overview
Project Settings
Configuration settings (from .reap file).
Constant Summary collapse
- REAP_FILE =
'{.reap,_reap,reapfile}{.yaml,.yml,}'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data, metadata) ⇒ Settings
constructor
A new instance of Settings.
-
#method_missing(s, *a) ⇒ Object
open hash.
Methods included from Extensions::Hash
#argumentize, #to_console, #to_ostruct
Constructor Details
#initialize(data, metadata) ⇒ Settings
Returns a new instance of Settings.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/reap/settings.rb', line 28 def initialize(data, ) super() @metadata = settings = {} data.each do |key, value| settings[key] ||= {} settings[key].update(value) if value end update(settings) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(s, *a) ⇒ Object
open hash
41 42 43 44 45 46 47 48 49 |
# File 'lib/reap/settings.rb', line 41 def method_missing(s, *a) if s =~ /=$/ self[s] = a[0] elsif a.empty? self[s] else super end end |
Class Method Details
.read(location, metadata) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reap/settings.rb', line 13 def self.read(location, ) 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, ) end |