lib/json/ld/compact.rb in json-ld-0.9.0 vs lib/json/ld/compact.rb in json-ld-0.9.1

- old
+ new

@@ -60,13 +60,13 @@ # Return either the result as an array, as an object with a key of @list (or appropriate alias from active context v = [v].compact unless v.is_a?(Array) unless context.container(property) == '@list' v = {compacted_key => v} - if element['@annotation'] - compacted_key = context.compact_iri('@annotation', :position => :predicate, :depth => @depth) - v[compacted_key] = element['@annotation'] + if element['@index'] + compacted_key = context.compact_iri('@index', :position => :predicate, :depth => @depth) + v[compacted_key] = element['@index'] end end debug("compact") {"@list result, return as #{v.inspect}"} return v end @@ -139,11 +139,11 @@ compacted_value = value.map {|v2| context.compact_iri(v2, :position => position, :depth => @depth)} debug {" => compacted value(#{key}): #{compacted_value.inspect}"} compacted_value = compacted_value.first if compacted_value.length == 1 && @options[:compactArrays] compacted_value end - elsif key == '@annotation' && context.container(property) == '@annotation' + elsif key == '@index' && context.container(property) == '@index' # Skip the annotation key if annotations being applied next else if value.empty? # Make sure that an empty array is preserved @@ -152,11 +152,11 @@ result[compacted_key] = value next end # For each item in value: - value = [value] if key == '@annotation' && value.is_a?(String) + value = [value] if key == '@index' && value.is_a?(String) raise ProcessingError, "found #{value.inspect} for #{key} of #{element.inspect}" unless value.is_a?(Array) value.each do |item| compacted_key = context.compact_iri(key, :position => :predicate, :value => item, :depth => @depth) # Result for this item, typically the output object itself @@ -164,11 +164,11 @@ item_key = compacted_key debug {" => compacted key: #{compacted_key.inspect} for #{item.inspect}"} next if compacted_key.nil? # Language maps and annotations - if field = %w(@language @annotation).detect {|kk| context.container(compacted_key) == kk} + if field = %w(@language @index).detect {|kk| context.container(compacted_key) == kk} item_result = result[compacted_key] ||= Hash.new item_key = item[field] end compacted_item = depth {self.compact(item, compacted_key)} @@ -217,10 +217,10 @@ equiv elsif value?(n1) && value?(n2) n1 == n2 elsif list?(n1) list?(n2) && - n1.fetch('@annotation', true) == n2.fetch('@annotation', true) && + n1.fetch('@index', true) == n2.fetch('@index', true) && nodesEquivalent?(n1['@list'], n2['@list']) elsif (node?(n1) || node_reference?(n2)) (node?(n2) || node_reference?(n2)) && n1['@id'] == n2['@id'] else false