Class: Clerq::Settings
- Inherits:
-
Object
- Object
- Clerq::Settings
- Extended by:
- Properties
- Defined in:
- lib/clerq/settings.rb
Constant Summary collapse
- STORAGE =
'clerq.yml'.freeze
Instance Method Summary collapse
- #folders ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
-
#load ⇒ Object
TODO: load settings than can be changed by user.
-
#save ⇒ Object
TODO: it saves only changed properties properties with default values won’t be saved.
Methods included from Properties
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
31 32 33 |
# File 'lib/clerq/settings.rb', line 31 def initialize load end |
Instance Method Details
#folders ⇒ Object
27 28 29 |
# File 'lib/clerq/settings.rb', line 27 def folders [bin, src, knb, lib, tt, assets] end |
#load ⇒ Object
TODO: load settings than can be changed by user
36 37 38 39 40 41 |
# File 'lib/clerq/settings.rb', line 36 def load return unless File.exist?(STORAGE) props = YAML.load(File.read(STORAGE)) props.each{|k, v| instance_variable_set("@#{k}", v) } end |
#save ⇒ Object
TODO: it saves only changed properties
properties with default values won't be saved
45 46 47 48 49 50 51 52 53 |
# File 'lib/clerq/settings.rb', line 45 def save props = {} instance_variables.each{|v| # props[v.to_s[1..-1]] = instance_variable_get("#{v}") p = v.to_s[1..-1] props[p] = self.send(p) } File.write(STORAGE, YAML.dump(props)) end |