Skip to content

Commit 2fb2216

Browse files
committed
Expand and compact @container: @index where value is a graph. (reverted from commit 133bc3d)
1 parent 133bc3d commit 2fb2216

File tree

3 files changed

+1
-58
lines changed

3 files changed

+1
-58
lines changed

lib/json/ld/compact.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def compact(element, property: nil)
201201
# Do not compact using vocabulary-relative, which is not valid for @id
202202
compacted_item[al] = context.compact_iri(expanded_item['@id'], vocab: false, quiet: true).to_s
203203
end
204-
if expanded_item.has_key?('@index') && container != '@index'
204+
if expanded_item.has_key?('@index')
205205
key = context.compact_iri('@index', vocab: true, quiet: true)
206206
compacted_item[key] = expanded_item['@index']
207207
end

spec/compact_spec.rb

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -495,37 +495,6 @@
495495

496496
context "@container: @index" do
497497
{
498-
"named graph": {
499-
input: %([
500-
{
501-
"@id": "http://example.com/graphTest",
502-
"http://example.org/container": [{
503-
"@graph": [{"http://example.org/input": [{"@value": "de"}]}],
504-
"@index": "de"
505-
}, {
506-
"@graph": [{"http://example.org/input": [{"@value": "en"}]}],
507-
"@index": "en"
508-
}]
509-
}
510-
]),
511-
context: %({
512-
"@context": {
513-
"@vocab": "http://example.org/",
514-
"container": {"@container": "@index"}
515-
}
516-
}),
517-
output: %({
518-
"@context": {
519-
"@vocab": "http://example.org/",
520-
"container": {"@container": "@index"}
521-
},
522-
"@id": "http://example.com/graphTest",
523-
"container": {
524-
"en": {"@graph": [{"input": "en"}]},
525-
"de": {"@graph": [{"input": "de"}]}
526-
}
527-
})
528-
},
529498
"compact-0029" => {
530499
input: %([{
531500
"@id": "http://example.com/article",
@@ -1673,7 +1642,6 @@ def run_compact(params)
16731642
input = ::JSON.parse(input) if input.is_a?(String)
16741643
output = ::JSON.parse(output) if output.is_a?(String)
16751644
context = ::JSON.parse(context) if context.is_a?(String)
1676-
context = context['@context'] if context.has_key?('@context')
16771645
pending params.fetch(:pending, "test implementation") unless input
16781646
if params[:exception]
16791647
expect {JSON::LD::API.compact(input, context, params.merge(logger: logger))}.to raise_error(params[:exception])

spec/expand_spec.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -483,31 +483,6 @@
483483
}
484484
]
485485
},
486-
"graph" => {
487-
input: %({
488-
"@context": {
489-
"@vocab": "http://example.org/",
490-
"container": {"@container": "@index"}
491-
},
492-
"@id": "http://example.com/graphTest",
493-
"container": {
494-
"en": {"@graph": {"input": "en"}},
495-
"de": {"@graph": {"input": "de"}}
496-
}
497-
}),
498-
output: %([
499-
{
500-
"@id": "http://example.com/graphTest",
501-
"http://example.org/container": [{
502-
"@graph": [{"http://example.org/input": [{"@value": "de"}]}],
503-
"@index": "de"
504-
}, {
505-
"@graph": [{"http://example.org/input": [{"@value": "en"}]}],
506-
"@index": "en"
507-
}]
508-
}
509-
])
510-
},
511486
}.each do |title, params|
512487
it(title) {run_expand params}
513488
end

0 commit comments

Comments
 (0)