From 1e209c9bf3fcea671fcacfa01064fca40d49b21b Mon Sep 17 00:00:00 2001 From: Alex Kessinger Date: Wed, 10 Apr 2013 11:38:49 -0700 Subject: [PATCH] Upgrade --config to accept an array of files --- bin/jekyll | 4 ++-- lib/jekyll.rb | 5 +++-- test/test_configuration.rb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 1c3324ba..79c368d8 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -44,7 +44,7 @@ command :build do |c| c.syntax = 'jekyll build [options]' c.description = 'Build your site' - c.option '--config [CONFIG_FILE]', 'Custom configuration file' + c.option '--config [CONFIG_FILE]', Array, 'Custom configuration file' c.option '--future', 'Publishes posts with a future date' c.option '--limit_posts MAX_POSTS', 'Limits the number of posts to parse and publish' c.option '-w', '--watch', 'Watch for changes and rebuild' @@ -63,7 +63,7 @@ command :serve do |c| c.syntax = 'jekyll serve [options]' c.description = 'Serve your site locally' - c.option '--config [CONFIG_FILE]', 'Custom configuration file' + c.option '--config [CONFIG_FILE]', Array,'Custom configuration file' c.option '--future', 'Publishes posts with a future date' c.option '--limit_posts MAX_POSTS', 'Limits the number of posts to parse and publish' c.option '-w', '--watch', 'Watch for changes and rebuild' diff --git a/lib/jekyll.rb b/lib/jekyll.rb index a1f0cdfd..a88dedc7 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -138,8 +138,9 @@ module Jekyll # Get configuration from /_config.yml or / config_files = override.delete('config') config_files = File.join(source, "_config.yml") if config_files.to_s.empty? - # If config is a list of space separate config files - config_files = config_files.split(' ') + if not config_files.is_a? Array + config_files = [config_files] + end begin config = {} diff --git a/test/test_configuration.rb b/test/test_configuration.rb index ec42b8f5..361408d6 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -51,7 +51,7 @@ class TestConfiguration < Test::Unit::TestCase mock(YAML).safe_load_file(@paths[:other]) { Hash.new } mock($stdout).puts("Configuration file: #{@paths[:default]}") mock($stdout).puts("Configuration file: #{@paths[:other]}") - assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => "#{@paths[:default]} #{@paths[:other]}" }) + assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] }) end should "load multiple config files and last config should win" do @@ -59,7 +59,7 @@ class TestConfiguration < Test::Unit::TestCase mock(YAML).safe_load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} } mock($stdout).puts("Configuration file: #{@paths[:default]}") mock($stdout).puts("Configuration file: #{@paths[:other]}") - assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => "#{@paths[:default]} #{@paths[:other]}" }) + assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] }) end end end