Merge pull request #4949 from jekyll/fix-drop-rubocop-errors

Merge pull request 4949
This commit is contained in:
jekyllbot 2016-05-25 16:24:29 -07:00
commit a15958d5a7
3 changed files with 14 additions and 8 deletions

View File

@ -5,9 +5,9 @@ module Jekyll
class DocumentDrop < Drop
extend Forwardable
NESTED_OBJECT_FIELD_BLACKLIST = %w{
NESTED_OBJECT_FIELD_BLACKLIST = %w(
content output excerpt next previous
}.freeze
).freeze
mutable false
@ -40,6 +40,8 @@ module Jekyll
# Generate a Hash for use in generating JSON.
# This is useful if fields need to be cleared before the JSON can generate.
#
# state - the JSON::State object which determines the state of current processing.
#
# Returns a Hash ready for JSON generation.
def hash_for_json(state = nil)
to_h.tap do |hash|

View File

@ -88,7 +88,9 @@ module Jekyll
# Returns an Array of strings which represent method-specific keys.
def content_methods
@content_methods ||= (
self.class.instance_methods - Jekyll::Drops::Drop.instance_methods - NON_CONTENT_METHODS
self.class.instance_methods \
- Jekyll::Drops::Drop.instance_methods \
- NON_CONTENT_METHODS
).map(&:to_s).reject do |method|
method.end_with?("=")
end
@ -144,15 +146,17 @@ module Jekyll
# This is useful if fields need to be cleared before the JSON can generate.
#
# Returns a Hash ready for JSON generation.
def hash_for_json(state = nil)
def hash_for_json(*)
to_h
end
# Generate a JSON representation of the Drop.
#
# state - the JSON::State object which determines the state of current processing.
#
# Returns a JSON representation of the Drop in a String.
def to_json(state = nil)
require 'json'
require "json"
JSON.generate(hash_for_json(state), state)
end
@ -165,7 +169,7 @@ module Jekyll
keys.each(&block)
end
def each(&block)
def each
each_key.each do |key|
yield key, self[key]
end

View File

@ -19,13 +19,13 @@ module Jekyll
def to_h
@to_h ||= {
"version" => version,
"version" => version,
"environment" => environment
}
end
def to_json(state = nil)
require 'json'
require "json"
JSON.generate(to_h, state)
end
end