From e2967c96cd0309a7be7702288690a02857c58a7a Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 12 Apr 2013 21:20:30 +0200 Subject: [PATCH] Jekyll.configuration should use the new Jekyll::Configuration class --- lib/jekyll.rb | 46 +++++----------------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 12082194..fad6c769 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -64,48 +64,12 @@ module Jekyll # # Returns the final configuration Hash. def self.configuration(override) - # Convert any symbol keys to strings and remove the old key/values - override = override.reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) } - - # _config.yml may override default source location, but until - # then, we need to know where to look for _config.yml - source = override['source'] || Jekyll::DEFAULTS['source'] - - # Get configuration from /_config.yml or / - config_files = override.delete('config') - config_files = File.join(source, "_config.yml") if config_files.to_s.empty? - unless config_files.is_a? Array - config_files = [config_files] - end - - begin - config = {} - config_files.each do |config_file| - next_config = YAML.safe_load_file(config_file) - raise "Configuration file: (INVALID) #{config_file}" if !next_config.is_a?(Hash) - $stdout.puts "Configuration file: #{config_file}" - config = config.deep_merge(next_config) - end - rescue SystemCallError - # Errno:ENOENT = file not found - $stderr.puts "Configuration file: none" - config = {} - rescue => err - $stderr.puts " " + - "WARNING: Error reading configuration. " + - "Using defaults (and options)." - $stderr.puts "#{err}" - config = {} - end - - # Provide backwards-compatibility - if config['auto'] - $stderr.puts "Deprecation: ".rjust(20) + "'auto' has been changed to " + - "'watch'. Please update your configuration to use 'watch'." - config['watch'] = config['auto'] - end + config = Configuration[Configuration::DEFAULTS] + override = Configuration[override].stringify_keys + config = config.read_config_files(config.config_files(override)) + config = config.backwards_compatibilize # Merge DEFAULTS < _config.yml < override - Jekyll::DEFAULTS.deep_merge(config).deep_merge(override) + config.deep_merge(override).stringify_keys end end