diff --git a/lib/jekyll.rb b/lib/jekyll.rb index e9f4547b3..0d680842f 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -98,15 +98,14 @@ module Jekyll # list of option names and their defaults. # # Returns the final configuration Hash. - def configuration(override = {}) - config = Configuration[Configuration::DEFAULTS] - override = Configuration[override].stringify_keys + def configuration(override = Hash.new) + config = Configuration.new unless override.delete('skip_config_files') config = config.read_config_files(config.config_files(override)) end # Merge DEFAULTS < _config.yml < override - config = Utils.deep_merge_hashes(config, override).stringify_keys + config = Configuration.from Utils.deep_merge_hashes(config, override).stringify_keys set_timezone(config['timezone']) if config['timezone'] config diff --git a/lib/jekyll/configuration.rb b/lib/jekyll/configuration.rb index 4c36341d1..4af19a63f 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -74,6 +74,23 @@ module Jekyll } }].freeze + class << self + # Static: Produce a Configuration ready for use in a Site. + # It takes the input, fills in the defaults where values do not + # exist, and patches common issues including migrating options for + # backwards compatiblity. Except where a key or value is being fixed, + # the user configuration will override the defaults. + # + # user_config - a Hash or Configuration of overrides. + # + # Returns a Configuration filled with defaults and fixed for common + # problems and backwards-compatibility. + def from(user_config) + Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys). + fix_common_issues.backwards_compatibilize.add_default_collections + end + end + # Public: Turn all keys into string # # Return a copy of the hash where all its keys are strings @@ -237,7 +254,7 @@ module Jekyll " as a list of comma-separated values." config[option] = csv_to_array(config[option]) end - config[option].map!(&:to_s) + config[option].map!(&:to_s) if config[option] end if (config['kramdown'] || {}).key?('use_coderay')