Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename those Utils functions.

  • Loading branch information...
commit 7787d64bce1288654c9f278f67bd88fe68bdbbac 1 parent 5e8643d
@parkr parkr authored
View
4 lib/jekyll.rb
@@ -83,9 +83,7 @@ def self.configuration(override)
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
View
2  lib/jekyll/configuration.rb
@@ -159,7 +159,7 @@ def read_config_files(files)
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. " +
View
2  lib/jekyll/converters/markdown/kramdown_parser.rb
@@ -20,7 +20,7 @@ def convert(content)
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
View
4 lib/jekyll/convertible.rb
@@ -107,7 +107,7 @@ def to_liquid(attrs = nil)
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 @@ def render_all_layouts(layouts, payload, info)
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,
View
2  lib/jekyll/page.rb
@@ -109,7 +109,7 @@ def process(name)
#
# 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)
View
6 lib/jekyll/post.rb
@@ -66,13 +66,13 @@ def initialize(site, source, dir, name)
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 @@ def related_posts(posts)
# 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)
View
2  lib/jekyll/utils.rb
@@ -16,7 +16,7 @@ def deep_merge_hashes(master_hash, other_hash)
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
View
2  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 = {})
View
4 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
View
2  test/test_kramdown.rb
@@ -35,7 +35,7 @@ class TestKramdown < Test::Unit::TestCase
assert_match /<p>(&#8220;|“)Pit(&#8217;|’)hy(&#8221;|”)<\/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>(&#171;|«)Pit(&#8250;|›)hy(&#187;|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip
end
View
22 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
Please sign in to comment.
Something went wrong with that request. Please try again.