json-ld 3.1.10 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -10
- data/VERSION +1 -1
- data/lib/json/ld/api.rb +53 -16
- data/lib/json/ld/context.rb +8 -8
- data/lib/json/ld/expand.rb +2 -2
- data/lib/json/ld/flatten.rb +1 -1
- data/lib/json/ld/format.rb +2 -1
- data/lib/json/ld/reader.rb +2 -2
- data/lib/json/ld/streaming_reader.rb +2 -1
- data/lib/json/ld/to_rdf.rb +9 -8
- data/lib/json/ld/writer.rb +9 -10
- data/lib/json/ld.rb +3 -0
- data/spec/api_spec.rb +67 -19
- data/spec/format_spec.rb +7 -3
- data/spec/frame_spec.rb +25 -1
- data/spec/reader_spec.rb +14 -14
- data/spec/suite_helper.rb +1 -0
- data/spec/test-files/{test-1-compacted.json → test-1-compacted.jsonld} +0 -0
- data/spec/test-files/{test-1-context.json → test-1-context.jsonld} +0 -0
- data/spec/test-files/{test-1-expanded.json → test-1-expanded.jsonld} +0 -0
- data/spec/test-files/{test-1-input.json → test-1-input.jsonld} +0 -0
- data/spec/test-files/{test-2-compacted.json → test-2-compacted.jsonld} +0 -0
- data/spec/test-files/{test-2-context.json → test-2-context.jsonld} +0 -0
- data/spec/test-files/{test-2-expanded.json → test-2-expanded.jsonld} +0 -0
- data/spec/test-files/{test-2-input.json → test-2-input.jsonld} +0 -0
- data/spec/test-files/{test-3-compacted.json → test-3-compacted.jsonld} +0 -0
- data/spec/test-files/{test-3-context.json → test-3-context.jsonld} +0 -0
- data/spec/test-files/{test-3-expanded.json → test-3-expanded.jsonld} +0 -0
- data/spec/test-files/{test-3-input.json → test-3-input.jsonld} +0 -0
- data/spec/test-files/{test-4-compacted.json → test-4-compacted.jsonld} +0 -0
- data/spec/test-files/{test-4-context.json → test-4-context.jsonld} +0 -0
- data/spec/test-files/{test-4-expanded.json → test-4-expanded.jsonld} +0 -0
- data/spec/test-files/{test-4-input.json → test-4-input.jsonld} +0 -0
- data/spec/test-files/{test-5-compacted.json → test-5-compacted.jsonld} +0 -0
- data/spec/test-files/{test-5-context.json → test-5-context.jsonld} +0 -0
- data/spec/test-files/{test-5-expanded.json → test-5-expanded.jsonld} +0 -0
- data/spec/test-files/{test-5-input.json → test-5-input.jsonld} +0 -0
- data/spec/test-files/{test-6-compacted.json → test-6-compacted.jsonld} +0 -0
- data/spec/test-files/{test-6-context.json → test-6-context.jsonld} +0 -0
- data/spec/test-files/{test-6-expanded.json → test-6-expanded.jsonld} +0 -0
- data/spec/test-files/{test-6-input.json → test-6-input.jsonld} +0 -0
- data/spec/test-files/{test-7-compacted.json → test-7-compacted.jsonld} +0 -0
- data/spec/test-files/{test-7-context.json → test-7-context.jsonld} +0 -0
- data/spec/test-files/{test-7-expanded.json → test-7-expanded.jsonld} +0 -0
- data/spec/test-files/{test-7-input.json → test-7-input.jsonld} +0 -0
- data/spec/test-files/{test-8-compacted.json → test-8-compacted.jsonld} +0 -0
- data/spec/test-files/{test-8-context.json → test-8-context.jsonld} +0 -0
- data/spec/test-files/{test-8-expanded.json → test-8-expanded.jsonld} +0 -0
- data/spec/test-files/{test-8-frame.json → test-8-frame.jsonld} +0 -0
- data/spec/test-files/{test-8-framed.json → test-8-framed.jsonld} +0 -0
- data/spec/test-files/{test-8-input.json → test-8-input.jsonld} +0 -0
- data/spec/test-files/{test-9-compacted.json → test-9-compacted.jsonld} +0 -0
- data/spec/test-files/{test-9-context.json → test-9-context.jsonld} +0 -0
- data/spec/test-files/{test-9-expanded.json → test-9-expanded.jsonld} +0 -0
- data/spec/test-files/{test-9-input.json → test-9-input.jsonld} +0 -0
- metadata +110 -111
- data/spec/test-files/test-1-normalized.json +0 -8
- data/spec/test-files/test-2-normalized.json +0 -32
- data/spec/test-files/test-3-normalized.json +0 -13
data/spec/format_spec.rb
CHANGED
@@ -41,6 +41,10 @@ describe JSON::LD::Format do
|
|
41
41
|
specify {expect(described_class.to_sym).to eq :jsonld}
|
42
42
|
end
|
43
43
|
|
44
|
+
describe "#to_uri" do
|
45
|
+
specify {expect(described_class.to_uri).to eq RDF::URI('http://www.w3.org/ns/formats/JSON-LD')}
|
46
|
+
end
|
47
|
+
|
44
48
|
describe ".detect" do
|
45
49
|
{
|
46
50
|
jsonld: '{"@context" => "foo"}',
|
@@ -66,11 +70,11 @@ describe JSON::LD::Format do
|
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
69
|
-
describe ".cli_commands" do
|
73
|
+
describe ".cli_commands", skip: Gem.win_platform? do
|
70
74
|
require 'rdf/cli'
|
71
75
|
let(:ttl) {File.expand_path("../test-files/test-1-rdf.ttl", __FILE__)}
|
72
|
-
let(:json) {File.expand_path("../test-files/test-1-input.
|
73
|
-
let(:context) {File.expand_path("../test-files/test-1-context.
|
76
|
+
let(:json) {File.expand_path("../test-files/test-1-input.jsonld", __FILE__)}
|
77
|
+
let(:context) {File.expand_path("../test-files/test-1-context.jsonld", __FILE__)}
|
74
78
|
|
75
79
|
describe "#expand" do
|
76
80
|
it "expands RDF" do
|
data/spec/frame_spec.rb
CHANGED
@@ -2438,7 +2438,31 @@ describe JSON::LD::API do
|
|
2438
2438
|
"@id": "ex:entity1"
|
2439
2439
|
}),
|
2440
2440
|
processingMode: "json-ld-1.1"
|
2441
|
-
}
|
2441
|
+
},
|
2442
|
+
"don't embed list elements": {
|
2443
|
+
frame: %({
|
2444
|
+
"@context": {"ex": "http://example.org/"},
|
2445
|
+
"ex:embed": {
|
2446
|
+
"@list": [{"@embed": "@never"}]
|
2447
|
+
}
|
2448
|
+
}),
|
2449
|
+
input: %({
|
2450
|
+
"@context": {"ex": "http://example.org/"},
|
2451
|
+
"@id": "ex:Sub1",
|
2452
|
+
"ex:embed": {
|
2453
|
+
"@list": [{
|
2454
|
+
"@id": "ex:Sub2",
|
2455
|
+
"ex:prop": "property"
|
2456
|
+
}]
|
2457
|
+
}
|
2458
|
+
}),
|
2459
|
+
output: %({
|
2460
|
+
"@context": {"ex": "http://example.org/"},
|
2461
|
+
"@id": "ex:Sub1",
|
2462
|
+
"ex:embed": {"@list": [{"@id": "ex:Sub2"}]}
|
2463
|
+
}),
|
2464
|
+
processingMode: "json-ld-1.1"
|
2465
|
+
},
|
2442
2466
|
}.each do |title, params|
|
2443
2467
|
it title do
|
2444
2468
|
do_frame(params)
|
data/spec/reader_spec.rb
CHANGED
@@ -131,7 +131,7 @@ describe JSON::LD::Reader do
|
|
131
131
|
{
|
132
132
|
"@context": {"@base": "http://a/bb/ccc/d;p?q", "urn:ex:p": {"@type": "@id"}},
|
133
133
|
"@graph": [
|
134
|
-
{"@id": "urn:ex:s001", "urn:ex:p": "
|
134
|
+
{"@id": "urn:ex:s001", "urn:ex:p": "gg:h"},
|
135
135
|
{"@id": "urn:ex:s002", "urn:ex:p": "g"},
|
136
136
|
{"@id": "urn:ex:s003", "urn:ex:p": "./g"},
|
137
137
|
{"@id": "urn:ex:s004", "urn:ex:p": "g/"},
|
@@ -183,7 +183,7 @@ describe JSON::LD::Reader do
|
|
183
183
|
{
|
184
184
|
"@context": {"@base": "http://a/bb/ccc/d/", "urn:ex:p": {"@type": "@id"}},
|
185
185
|
"@graph": [
|
186
|
-
{"@id": "urn:ex:s043", "urn:ex:p": "
|
186
|
+
{"@id": "urn:ex:s043", "urn:ex:p": "gg:h"},
|
187
187
|
{"@id": "urn:ex:s044", "urn:ex:p": "g"},
|
188
188
|
{"@id": "urn:ex:s045", "urn:ex:p": "./g"},
|
189
189
|
{"@id": "urn:ex:s046", "urn:ex:p": "g/"},
|
@@ -235,7 +235,7 @@ describe JSON::LD::Reader do
|
|
235
235
|
{
|
236
236
|
"@context": {"@base": "http://a/bb/ccc/./d;p?q", "urn:ex:p": {"@type": "@id"}},
|
237
237
|
"@graph": [
|
238
|
-
{"@id": "urn:ex:s085", "urn:ex:p": "
|
238
|
+
{"@id": "urn:ex:s085", "urn:ex:p": "gg:h"},
|
239
239
|
{"@id": "urn:ex:s086", "urn:ex:p": "g"},
|
240
240
|
{"@id": "urn:ex:s087", "urn:ex:p": "./g"},
|
241
241
|
{"@id": "urn:ex:s088", "urn:ex:p": "g/"},
|
@@ -287,7 +287,7 @@ describe JSON::LD::Reader do
|
|
287
287
|
{
|
288
288
|
"@context": {"@base": "http://a/bb/ccc/../d;p?q", "urn:ex:p": {"@type": "@id"}},
|
289
289
|
"@graph": [
|
290
|
-
{"@id": "urn:ex:s127", "urn:ex:p": "
|
290
|
+
{"@id": "urn:ex:s127", "urn:ex:p": "gg:h"},
|
291
291
|
{"@id": "urn:ex:s128", "urn:ex:p": "g"},
|
292
292
|
{"@id": "urn:ex:s129", "urn:ex:p": "./g"},
|
293
293
|
{"@id": "urn:ex:s130", "urn:ex:p": "g/"},
|
@@ -339,7 +339,7 @@ describe JSON::LD::Reader do
|
|
339
339
|
{
|
340
340
|
"@context": {"@base": "http://a/bb/ccc/.", "urn:ex:p": {"@type": "@id"}},
|
341
341
|
"@graph": [
|
342
|
-
{"@id": "urn:ex:s169", "urn:ex:p": "
|
342
|
+
{"@id": "urn:ex:s169", "urn:ex:p": "gg:h"},
|
343
343
|
{"@id": "urn:ex:s170", "urn:ex:p": "g"},
|
344
344
|
{"@id": "urn:ex:s171", "urn:ex:p": "./g"},
|
345
345
|
{"@id": "urn:ex:s172", "urn:ex:p": "g/"},
|
@@ -391,7 +391,7 @@ describe JSON::LD::Reader do
|
|
391
391
|
{
|
392
392
|
"@context": {"@base": "http://a/bb/ccc/..", "urn:ex:p": {"@type": "@id"}},
|
393
393
|
"@graph": [
|
394
|
-
{"@id": "urn:ex:s211", "urn:ex:p": "
|
394
|
+
{"@id": "urn:ex:s211", "urn:ex:p": "gg:h"},
|
395
395
|
{"@id": "urn:ex:s212", "urn:ex:p": "g"},
|
396
396
|
{"@id": "urn:ex:s213", "urn:ex:p": "./g"},
|
397
397
|
{"@id": "urn:ex:s214", "urn:ex:p": "g/"},
|
@@ -443,7 +443,7 @@ describe JSON::LD::Reader do
|
|
443
443
|
{
|
444
444
|
"@context": {"@base": "file:///a/bb/ccc/d;p?q", "urn:ex:p": {"@type": "@id"}},
|
445
445
|
"@graph": [
|
446
|
-
{"@id": "urn:ex:s253", "urn:ex:p": "
|
446
|
+
{"@id": "urn:ex:s253", "urn:ex:p": "gg:h"},
|
447
447
|
{"@id": "urn:ex:s254", "urn:ex:p": "g"},
|
448
448
|
{"@id": "urn:ex:s255", "urn:ex:p": "./g"},
|
449
449
|
{"@id": "urn:ex:s256", "urn:ex:p": "g/"},
|
@@ -523,7 +523,7 @@ describe JSON::LD::Reader do
|
|
523
523
|
let(:nt) {%q{
|
524
524
|
# RFC3986 normal examples
|
525
525
|
|
526
|
-
<urn:ex:s001> <urn:ex:p> <
|
526
|
+
<urn:ex:s001> <urn:ex:p> <gg:h>.
|
527
527
|
<urn:ex:s002> <urn:ex:p> <http://a/bb/ccc/g>.
|
528
528
|
<urn:ex:s003> <urn:ex:p> <http://a/bb/ccc/g>.
|
529
529
|
<urn:ex:s004> <urn:ex:p> <http://a/bb/ccc/g/>.
|
@@ -571,7 +571,7 @@ describe JSON::LD::Reader do
|
|
571
571
|
|
572
572
|
# RFC3986 normal examples with trailing slash in base IRI
|
573
573
|
|
574
|
-
<urn:ex:s043> <urn:ex:p> <
|
574
|
+
<urn:ex:s043> <urn:ex:p> <gg:h>.
|
575
575
|
<urn:ex:s044> <urn:ex:p> <http://a/bb/ccc/d/g>.
|
576
576
|
<urn:ex:s045> <urn:ex:p> <http://a/bb/ccc/d/g>.
|
577
577
|
<urn:ex:s046> <urn:ex:p> <http://a/bb/ccc/d/g/>.
|
@@ -619,7 +619,7 @@ describe JSON::LD::Reader do
|
|
619
619
|
|
620
620
|
# RFC3986 normal examples with /. in the base IRI
|
621
621
|
|
622
|
-
<urn:ex:s085> <urn:ex:p> <
|
622
|
+
<urn:ex:s085> <urn:ex:p> <gg:h>.
|
623
623
|
<urn:ex:s086> <urn:ex:p> <http://a/bb/ccc/g>.
|
624
624
|
<urn:ex:s087> <urn:ex:p> <http://a/bb/ccc/g>.
|
625
625
|
<urn:ex:s088> <urn:ex:p> <http://a/bb/ccc/g/>.
|
@@ -667,7 +667,7 @@ describe JSON::LD::Reader do
|
|
667
667
|
|
668
668
|
# RFC3986 normal examples with /.. in the base IRI
|
669
669
|
|
670
|
-
<urn:ex:s127> <urn:ex:p> <
|
670
|
+
<urn:ex:s127> <urn:ex:p> <gg:h>.
|
671
671
|
<urn:ex:s128> <urn:ex:p> <http://a/bb/g>.
|
672
672
|
<urn:ex:s129> <urn:ex:p> <http://a/bb/g>.
|
673
673
|
<urn:ex:s130> <urn:ex:p> <http://a/bb/g/>.
|
@@ -715,7 +715,7 @@ describe JSON::LD::Reader do
|
|
715
715
|
|
716
716
|
# RFC3986 normal examples with trailing /. in the base IRI
|
717
717
|
|
718
|
-
<urn:ex:s169> <urn:ex:p> <
|
718
|
+
<urn:ex:s169> <urn:ex:p> <gg:h>.
|
719
719
|
<urn:ex:s170> <urn:ex:p> <http://a/bb/ccc/g>.
|
720
720
|
<urn:ex:s171> <urn:ex:p> <http://a/bb/ccc/g>.
|
721
721
|
<urn:ex:s172> <urn:ex:p> <http://a/bb/ccc/g/>.
|
@@ -763,7 +763,7 @@ describe JSON::LD::Reader do
|
|
763
763
|
|
764
764
|
# RFC3986 normal examples with trailing /.. in the base IRI
|
765
765
|
|
766
|
-
<urn:ex:s211> <urn:ex:p> <
|
766
|
+
<urn:ex:s211> <urn:ex:p> <gg:h>.
|
767
767
|
<urn:ex:s212> <urn:ex:p> <http://a/bb/ccc/g>.
|
768
768
|
<urn:ex:s213> <urn:ex:p> <http://a/bb/ccc/g>.
|
769
769
|
<urn:ex:s214> <urn:ex:p> <http://a/bb/ccc/g/>.
|
@@ -811,7 +811,7 @@ describe JSON::LD::Reader do
|
|
811
811
|
|
812
812
|
# RFC3986 normal examples with file path
|
813
813
|
|
814
|
-
<urn:ex:s253> <urn:ex:p> <
|
814
|
+
<urn:ex:s253> <urn:ex:p> <gg:h>.
|
815
815
|
<urn:ex:s254> <urn:ex:p> <file:///a/bb/ccc/g>.
|
816
816
|
<urn:ex:s255> <urn:ex:p> <file:///a/bb/ccc/g>.
|
817
817
|
<urn:ex:s256> <urn:ex:p> <file:///a/bb/ccc/g/>.
|
data/spec/suite_helper.rb
CHANGED
@@ -60,6 +60,7 @@ module RDF::Util
|
|
60
60
|
document_options[:headers][:content_type] = options[:contentType] if options[:contentType]
|
61
61
|
|
62
62
|
remote_document = RDF::Util::File::RemoteDocument.new(response.read, **document_options)
|
63
|
+
response.close
|
63
64
|
if block_given?
|
64
65
|
return yield remote_document
|
65
66
|
else
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|