Rename those Utils functions.
This commit is contained in:
parent
5e8643d855
commit
7787d64bce
|
@ -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
|
||||
|
|
|
@ -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. " +
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 = {})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestKramdown < Test::Unit::TestCase
|
|||
assert_match /<p>(“|“)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 /<p>(«|«)Pit(›|›)hy(»|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue