lib/json/ld/compact.rb in json-ld-2.1.0 vs lib/json/ld/compact.rb in json-ld-2.1.1
- old
+ new
@@ -8,20 +8,20 @@
# This algorithm compacts a JSON-LD document, such that the given context is applied. This must result in shortening any applicable IRIs to terms or compact IRIs, any applicable keywords to keyword aliases, and any applicable JSON-LD values expressed in expanded form to simple values such as strings or numbers.
#
# @param [Array, Hash] element
# @param [String] property (nil)
# @return [Array, Hash]
- def compact(element, property = nil)
+ def compact(element, property: nil)
#if property.nil?
# log_debug("compact") {"element: #{element.inspect}, ec: #{context.inspect}"}
#else
# log_debug("compact") {"property: #{property.inspect}"}
#end
case element
when Array
#log_debug("") {"Array #{element.inspect}"}
- result = element.map {|item| compact(item, property)}.compact
+ result = element.map {|item| compact(item, property: property)}.compact
# If element has a single member and the active property has no
# @container mapping to @list or @set, the compacted value is that
# member; otherwise the compacted value is element
if result.length == 1 && context.container(property).nil? && @options[:compactArrays]
@@ -63,11 +63,11 @@
result[al] = compacted_value
next
end
if expanded_property == '@reverse'
- compacted_value = compact(expanded_value, '@reverse')
+ compacted_value = compact(expanded_value, property: '@reverse')
#log_debug("@reverse") {"compacted_value: #{compacted_value.inspect}"}
compacted_value.each do |prop, value|
if context.reverse?(prop)
value = [value] if !value.is_a?(Array) &&
(context.container(prop) == '@set' || !@options[:compactArrays])
@@ -119,10 +119,10 @@
reverse: inside_reverse,
log_depth: @options[:log_depth])
container = context.container(item_active_property)
value = list?(expanded_item) ? expanded_item['@list'] : expanded_item
- compacted_item = compact(value, item_active_property)
+ compacted_item = compact(value, property: item_active_property)
#log_debug("") {" => compacted key: #{item_active_property.inspect} for #{compacted_item.inspect}"}
if list?(expanded_item)
compacted_item = [compacted_item] unless compacted_item.is_a?(Array)
unless container == '@list'