Rubocop: drop changes from v3.1 forward-ports
This commit is contained in:
parent
b353e181c1
commit
6f1e1d80cd
|
@ -5,9 +5,9 @@ module Jekyll
|
||||||
class DocumentDrop < Drop
|
class DocumentDrop < Drop
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
NESTED_OBJECT_FIELD_BLACKLIST = %w{
|
NESTED_OBJECT_FIELD_BLACKLIST = %w(
|
||||||
content output excerpt next previous
|
content output excerpt next previous
|
||||||
}.freeze
|
).freeze
|
||||||
|
|
||||||
mutable false
|
mutable false
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ module Jekyll
|
||||||
# Generate a Hash for use in generating JSON.
|
# Generate a Hash for use in generating JSON.
|
||||||
# This is useful if fields need to be cleared before the JSON can generate.
|
# 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.
|
# Returns a Hash ready for JSON generation.
|
||||||
def hash_for_json(state = nil)
|
def hash_for_json(state = nil)
|
||||||
to_h.tap do |hash|
|
to_h.tap do |hash|
|
||||||
|
|
|
@ -88,7 +88,9 @@ module Jekyll
|
||||||
# Returns an Array of strings which represent method-specific keys.
|
# Returns an Array of strings which represent method-specific keys.
|
||||||
def content_methods
|
def content_methods
|
||||||
@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|
|
).map(&:to_s).reject do |method|
|
||||||
method.end_with?("=")
|
method.end_with?("=")
|
||||||
end
|
end
|
||||||
|
@ -144,15 +146,17 @@ module Jekyll
|
||||||
# This is useful if fields need to be cleared before the JSON can generate.
|
# This is useful if fields need to be cleared before the JSON can generate.
|
||||||
#
|
#
|
||||||
# Returns a Hash ready for JSON generation.
|
# Returns a Hash ready for JSON generation.
|
||||||
def hash_for_json(state = nil)
|
def hash_for_json(*)
|
||||||
to_h
|
to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate a JSON representation of the Drop.
|
# 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.
|
# Returns a JSON representation of the Drop in a String.
|
||||||
def to_json(state = nil)
|
def to_json(state = nil)
|
||||||
require 'json'
|
require "json"
|
||||||
JSON.generate(hash_for_json(state), state)
|
JSON.generate(hash_for_json(state), state)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,7 +169,7 @@ module Jekyll
|
||||||
keys.each(&block)
|
keys.each(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each
|
||||||
each_key.each do |key|
|
each_key.each do |key|
|
||||||
yield key, self[key]
|
yield key, self[key]
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,13 +19,13 @@ module Jekyll
|
||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
@to_h ||= {
|
@to_h ||= {
|
||||||
"version" => version,
|
"version" => version,
|
||||||
"environment" => environment
|
"environment" => environment
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(state = nil)
|
def to_json(state = nil)
|
||||||
require 'json'
|
require "json"
|
||||||
JSON.generate(to_h, state)
|
JSON.generate(to_h, state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue