diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 0f47e9af..7b661048 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -83,9 +83,7 @@ module Jekyll config = config.read_config_files(config.config_files(override)) # Merge DEFAULTS < _config.yml < override - config = Utils.hash_stringify_keys( - Utils.hash_deep_merge(config, override) - ) + config = 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 ee86dbf1..091bebc4 100644 --- a/lib/jekyll/configuration.rb +++ b/lib/jekyll/configuration.rb @@ -159,7 +159,7 @@ module Jekyll begin files.each do |config_file| new_config = read_config_file(config_file) - configuration = Utils.hash_deep_merge(configuration, new_config) + configuration = Utils.deep_merge_hashes(configuration, new_config) end rescue ArgumentError => err Jekyll.logger.warn "WARNING:", "Error reading configuration. " + diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index ed634cbe..cd1fdf9a 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -20,7 +20,7 @@ module Jekyll end end - Kramdown::Document.new(content, Utils.hash_symbolize_keys(@config["kramdown"])).to_html + Kramdown::Document.new(content, Utils.symbolize_hash_keys(@config["kramdown"])).to_html end end diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 5426c7bd..bc87f336 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -107,7 +107,7 @@ module Jekyll further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map { |attribute| [attribute, send(attribute)] }] - Utils.hash_deep_merge(data, further_data) + Utils.deep_merge_hashes(data, further_data) end # Recursively render layouts @@ -123,7 +123,7 @@ module Jekyll used = Set.new([layout]) while layout - payload = Utils.hash_deep_merge(payload, {"content" => output, "page" => layout.data}) + payload = Utils.deep_merge_hashes(payload, {"content" => output, "page" => layout.data}) self.output = render_liquid(layout.content, payload, diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index b786c55d..0c71c7d1 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -109,7 +109,7 @@ module Jekyll # # Returns nothing. def render(layouts, site_payload) - payload = Utils.hash_deep_merge({ + payload = Utils.deep_merge_hashes({ "page" => to_liquid, 'paginator' => pager.to_liquid }, site_payload) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 61ef6a20..180faa27 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -66,13 +66,13 @@ module Jekyll def populate_categories if categories.empty? - self.categories = Utils.hash_pluralized_array(data, 'category', 'categories').map {|c| c.to_s.downcase} + self.categories = Utils.pluralized_array_from_hash(data, 'category', 'categories').map {|c| c.to_s.downcase} end categories.flatten! end def populate_tags - self.tags = Utils.hash_pluralized_array(data, "tag", "tags").flatten + self.tags = Utils.pluralized_array_from_hash(data, "tag", "tags").flatten end # Get the full path to the directory containing the post files @@ -241,7 +241,7 @@ module Jekyll # Returns nothing. def render(layouts, site_payload) # construct payload - payload = Utils.hash_deep_merge({ + payload = Utils.deep_merge_hashes({ "site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) }, "page" => to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID) }, site_payload) diff --git a/lib/jekyll/utils.rb b/lib/jekyll/utils.rb index bb2a6ef5..d74174c4 100644 --- a/lib/jekyll/utils.rb +++ b/lib/jekyll/utils.rb @@ -16,7 +16,7 @@ module Jekyll other_hash.keys.each do |key| if other_hash[key].is_a? Hash and target[key].is_a? Hash - target[key] = Utils.hash_deep_merge(target[key], other_hash[key]) + target[key] = Utils.deep_merge_hashes(target[key], other_hash[key]) next end diff --git a/test/helper.rb b/test/helper.rb index ec0a7f91..b9b7e4cd 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -29,7 +29,7 @@ class Test::Unit::TestCase include RR::Adapters::TestUnit def build_configs(overrides, base_hash = Jekyll::Configuration::DEFAULTS) - Utils.hash_deep_merge(base_hash, overrides) + Utils.deep_merge_hashes(base_hash, overrides) end def site_configuration(overrides = {}) diff --git a/test/test_configuration.rb b/test/test_configuration.rb index be2cca5e..3a8918f9 100644 --- a/test/test_configuration.rb +++ b/test/test_configuration.rb @@ -156,7 +156,7 @@ class TestConfiguration < Test::Unit::TestCase should "load different config if specified" do mock(SafeYAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} } mock($stdout).puts("Configuration file: #{@paths[:other]}") - assert_equal Utils.hash_deep_merge(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] }) + assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] }) end should "load default config if path passed is empty" do @@ -186,7 +186,7 @@ class TestConfiguration < Test::Unit::TestCase mock(SafeYAML).load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} } mock($stdout).puts("Configuration file: #{@paths[:default]}") mock($stdout).puts("Configuration file: #{@paths[:other]}") - assert_equal Utils.hash_deep_merge(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] }) + assert_equal Utils.deep_merge_hashes(Jekyll::Configuration::DEFAULTS, { "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => [@paths[:default], @paths[:other]] }) end end end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index c1b80700..4bfe725e 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -35,7 +35,7 @@ class TestKramdown < Test::Unit::TestCase assert_match /
(“|“)Pit(’|’)hy(”|”)<\/p>/, @markdown.convert(%{"Pit'hy"}).strip override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } } - markdown = Converters::Markdown.new(Utils.hash_deep_merge(@config, override)) + markdown = Converters::Markdown.new(Utils.deep_merge_hashes(@config, override)) assert_match /
(«|«)Pit(›|›)hy(»|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip end diff --git a/test/test_utils.rb b/test/test_utils.rb index 223de687..cfd6c4a6 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -7,57 +7,57 @@ class TestUtils < Test::Unit::TestCase should "return empty array with no values" do data = {} - assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return empty array with no matching values" do data = { 'foo' => 'bar' } - assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return empty array with matching nil singular" do data = { 'foo' => 'bar', 'tag' => nil, 'tags' => ['dog', 'cat'] } - assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return single value array with matching singular" do data = { 'foo' => 'bar', 'tag' => 'dog', 'tags' => ['dog', 'cat'] } - assert_equal ['dog'], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal ['dog'], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return single value array with matching singular with spaces" do data = { 'foo' => 'bar', 'tag' => 'dog cat', 'tags' => ['dog', 'cat'] } - assert_equal ['dog cat'], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal ['dog cat'], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return empty array with matching nil plural" do data = { 'foo' => 'bar', 'tags' => nil } - assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return empty array with matching empty array" do data = { 'foo' => 'bar', 'tags' => [] } - assert_equal [], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal [], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return single value array with matching plural with single string value" do data = { 'foo' => 'bar', 'tags' => 'dog' } - assert_equal ['dog'], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal ['dog'], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return multiple value array with matching plural with single string value with spaces" do data = { 'foo' => 'bar', 'tags' => 'dog cat' } - assert_equal ['dog', 'cat'], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal ['dog', 'cat'], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return single value array with matching plural with single value array" do data = { 'foo' => 'bar', 'tags' => ['dog'] } - assert_equal ['dog'], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal ['dog'], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end should "return multiple value array with matching plural with multiple value array" do data = { 'foo' => 'bar', 'tags' => ['dog', 'cat'] } - assert_equal ['dog', 'cat'], Utils.hash_pluralized_array(data, 'tag', 'tags') + assert_equal ['dog', 'cat'], Utils.pluralized_array_from_hash(data, 'tag', 'tags') end end