lib/json/ld/compact.rb in json-ld-1.1.7 vs lib/json/ld/compact.rb in json-ld-1.1.8

- old
+ new

@@ -34,11 +34,11 @@ # @null objects are used in framing return nil if element.has_key?('@null') if element.keys.any? {|k| %w(@id @value).include?(k)} - result = context.compact_value(property, element, :depth => @depth) + result = context.compact_value(property, element, depth: @depth) unless result.is_a?(Hash) debug("") {"=> scalar result: #{result.inspect}"} return result end end @@ -50,15 +50,15 @@ expanded_value = element[expanded_property] debug("") {"#{expanded_property}: #{expanded_value.inspect}"} if %w(@id @type).include?(expanded_property) compacted_value = [expanded_value].flatten.compact.map do |expanded_type| - depth {context.compact_iri(expanded_type, :vocab => (expanded_property == '@type'), :depth => @depth)} + depth {context.compact_iri(expanded_type, vocab: (expanded_property == '@type'), depth: @depth)} end compacted_value = compacted_value.first if compacted_value.length == 1 - al = context.compact_iri(expanded_property, :vocab => true, :quiet => true) + al = context.compact_iri(expanded_property, vocab: true, quiet: true) debug(expanded_property) {"result[#{al}] = #{compacted_value.inspect}"} result[al] = compacted_value next end @@ -74,11 +74,11 @@ compacted_value.delete(prop) end end unless compacted_value.empty? - al = context.compact_iri('@reverse', :quiet => true) + al = context.compact_iri('@reverse', quiet: true) debug("") {"remainder: #{al} => #{compacted_value.inspect}"} result[al] = compacted_value end next end @@ -88,49 +88,49 @@ next end # Otherwise, if expanded property is @index, @value, or @language: if %w(@index @value @language).include?(expanded_property) - al = context.compact_iri(expanded_property, :vocab => true, :quiet => true) + al = context.compact_iri(expanded_property, vocab: true, quiet: true) debug(expanded_property) {"#{al} => #{expanded_value.inspect}"} result[al] = expanded_value next end if expanded_value == [] item_active_property = depth do context.compact_iri(expanded_property, - :value => expanded_value, - :vocab => true, - :reverse => inside_reverse, - :depth => @depth) + value: expanded_value, + vocab: true, + reverse: inside_reverse, + depth: @depth) end iap = result[item_active_property] ||= [] result[item_active_property] = [iap] unless iap.is_a?(Array) end # At this point, expanded value must be an array due to the Expansion algorithm. expanded_value.each do |expanded_item| item_active_property = depth do context.compact_iri(expanded_property, - :value => expanded_item, - :vocab => true, - :reverse => inside_reverse, - :depth => @depth) + value: expanded_item, + vocab: true, + reverse: inside_reverse, + depth: @depth) end container = context.container(item_active_property) value = list?(expanded_item) ? expanded_item['@list'] : expanded_item compacted_item = depth {compact(value, item_active_property)} 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' - al = context.compact_iri('@list', :vocab => true, :quiet => true) + al = context.compact_iri('@list', vocab: true, quiet: true) compacted_item = {al => compacted_item} if expanded_item.has_key?('@index') - key = context.compact_iri('@index', :vocab => true, :quiet => true) + key = context.compact_iri('@index', vocab: true, quiet: true) compacted_item[key] = expanded_item['@index'] end else raise JsonLdError::CompactionToListOfLists, "key cannot have more than one list value" if result.has_key?(item_active_property)