lib/staticpress/configuration.rb in staticpress-0.5.2 vs lib/staticpress/configuration.rb in staticpress-0.6.0
- old
+ new
@@ -1,10 +1,7 @@
require 'yaml'
-require 'staticpress'
-require 'staticpress/js_object'
-
module Staticpress
# IDEA look into configatron https://github.com/markbates/configatron
# FIXME this class is hard to test
class Configuration < JSObject
def save
@@ -13,27 +10,15 @@
YAML.dump(custom_values.to_hash, f)
end
end
def self.default
- @default ||= lambda do
- reply = YAML.load_file(Staticpress.root + 'skeleton' + 'config.yml')
-
- reply[:template_engine_options] ||= {}
-
- if defined? Compass
- [ :sass, :scss ].each do |template_engine|
- (reply[:template_engine_options][template_engine] ||= {}).merge!(Compass.sass_engine_options) do |key, first_choice, second_choice|
- reply[:template_engine_options][template_engine].key?(key) ? first_choice : second_choice
- end
- end
- end
-
- new reply
- end.call
+ @default ||= new(YAML.load_file(Staticpress.root + 'skeleton' + 'config.yml'))
end
def self.instance
- new(default.to_hash.merge(YAML.load_file(Staticpress.blog_path + 'config.yml')))
+ custom_file = Staticpress.blog_path + 'config.yml'
+ custom = custom_file.file? ? YAML.load_file(custom_file) : {}
+ new(default.to_hash.merge(custom))
end
end
end