json-ld 3.2.2 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/json/ld/api.rb +26 -17
- data/lib/json/ld/compact.rb +16 -16
- data/lib/json/ld/context.rb +52 -84
- data/lib/json/ld/expand.rb +23 -23
- data/lib/json/ld/format.rb +81 -115
- data/lib/json/ld/from_rdf.rb +56 -17
- data/lib/json/ld/streaming_writer.rb +6 -6
- data/lib/json/ld/to_rdf.rb +10 -8
- data/lib/json/ld/writer.rb +3 -3
- data/spec/context_spec.rb +31 -11
- data/spec/frame_spec.rb +43 -0
- data/spec/from_rdf_spec.rb +67 -0
- data/spec/to_rdf_spec.rb +133 -0
- metadata +33 -15
data/spec/from_rdf_spec.rb
CHANGED
@@ -268,6 +268,73 @@ describe JSON::LD::API do
|
|
268
268
|
it(title) {do_fromRdf(processingMode: "json-ld-1.1", **params)}
|
269
269
|
end
|
270
270
|
end
|
271
|
+
|
272
|
+
context "extendedRepresentation: true" do
|
273
|
+
{
|
274
|
+
"true": {
|
275
|
+
output: [{
|
276
|
+
"@id" => "http://example.org/vocab#id",
|
277
|
+
"http://example.org/vocab#bool" => [{"@value" => RDF::Literal(true)}]
|
278
|
+
}],
|
279
|
+
input:%(
|
280
|
+
@prefix ex: <http://example.org/vocab#> .
|
281
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
282
|
+
ex:id ex:bool true .
|
283
|
+
)
|
284
|
+
},
|
285
|
+
"false": {
|
286
|
+
output: [{
|
287
|
+
"@id" => "http://example.org/vocab#id",
|
288
|
+
"http://example.org/vocab#bool" => [{"@value" => RDF::Literal(false)}]
|
289
|
+
}],
|
290
|
+
input: %(
|
291
|
+
@prefix ex: <http://example.org/vocab#> .
|
292
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
293
|
+
ex:id ex:bool false .
|
294
|
+
)
|
295
|
+
},
|
296
|
+
"double": {
|
297
|
+
output: [{
|
298
|
+
"@id" => "http://example.org/vocab#id",
|
299
|
+
"http://example.org/vocab#double" => [{"@value" => RDF::Literal(1.23E0)}]
|
300
|
+
}],
|
301
|
+
input: %(
|
302
|
+
@prefix ex: <http://example.org/vocab#> .
|
303
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
304
|
+
ex:id ex:double 1.23E0 .
|
305
|
+
)
|
306
|
+
},
|
307
|
+
"double-zero": {
|
308
|
+
output: [{
|
309
|
+
"@id" => "http://example.org/vocab#id",
|
310
|
+
"http://example.org/vocab#double" => [{"@value" => RDF::Literal(0, datatype: RDF::XSD.double)}]
|
311
|
+
}],
|
312
|
+
input: %(
|
313
|
+
@prefix ex: <http://example.org/vocab#> .
|
314
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
315
|
+
ex:id ex:double 0.0E0 .
|
316
|
+
)
|
317
|
+
},
|
318
|
+
"integer": {
|
319
|
+
output: [{
|
320
|
+
"@id" => "http://example.org/vocab#id",
|
321
|
+
"http://example.org/vocab#integer" => [{"@value" => RDF::Literal(123)}]
|
322
|
+
}],
|
323
|
+
input: %(
|
324
|
+
@prefix ex: <http://example.org/vocab#> .
|
325
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
326
|
+
ex:id ex:integer 123 .
|
327
|
+
)
|
328
|
+
},
|
329
|
+
}.each do |title, params|
|
330
|
+
params[:input] = RDF::Graph.new << RDF::Turtle::Reader.new(params[:input])
|
331
|
+
it(title) {
|
332
|
+
do_fromRdf(processingMode: "json-ld-1.1",
|
333
|
+
useNativeTypes: true,
|
334
|
+
extendedRepresentation: true,
|
335
|
+
**params)}
|
336
|
+
end
|
337
|
+
end
|
271
338
|
end
|
272
339
|
|
273
340
|
context "anons" do
|
data/spec/to_rdf_spec.rb
CHANGED
@@ -409,6 +409,139 @@ describe JSON::LD::API do
|
|
409
409
|
end
|
410
410
|
end
|
411
411
|
end
|
412
|
+
|
413
|
+
context "with xsd: true" do
|
414
|
+
{
|
415
|
+
"true": {
|
416
|
+
input: {
|
417
|
+
"@context" => {
|
418
|
+
"e" => "http://example.org/vocab#e"
|
419
|
+
},
|
420
|
+
"e" => RDF::Literal(true)
|
421
|
+
},
|
422
|
+
output: %(
|
423
|
+
@prefix ex: <http://example.org/vocab#> .
|
424
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
425
|
+
[ex:e true] .
|
426
|
+
)
|
427
|
+
},
|
428
|
+
"integer": {
|
429
|
+
input: {
|
430
|
+
"@context" => {
|
431
|
+
"e" => "http://example.org/vocab#e"
|
432
|
+
},
|
433
|
+
"e" => RDF::Literal(1)
|
434
|
+
},
|
435
|
+
output: %(
|
436
|
+
@prefix ex: <http://example.org/vocab#> .
|
437
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
438
|
+
[ex:e 1] .
|
439
|
+
)
|
440
|
+
},
|
441
|
+
"decimal": {
|
442
|
+
input: {
|
443
|
+
"@context" => {
|
444
|
+
"e" => "http://example.org/vocab#e"
|
445
|
+
},
|
446
|
+
"e" => RDF::Literal::Decimal.new("1.1")
|
447
|
+
},
|
448
|
+
output: %(
|
449
|
+
@prefix ex: <http://example.org/vocab#> .
|
450
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
451
|
+
[ex:e 1.1] .
|
452
|
+
)
|
453
|
+
},
|
454
|
+
"float": {
|
455
|
+
input: {
|
456
|
+
"@context" => {
|
457
|
+
"e" => "http://example.org/vocab#e"
|
458
|
+
},
|
459
|
+
"e" => RDF::Literal.new("1.1e1", datatype: RDF::XSD.float)
|
460
|
+
},
|
461
|
+
output: %(
|
462
|
+
@prefix ex: <http://example.org/vocab#> .
|
463
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
464
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
465
|
+
[ex:e "1.1e1"^^xsd:float] .
|
466
|
+
)
|
467
|
+
},
|
468
|
+
"double": {
|
469
|
+
input: {
|
470
|
+
"@context" => {
|
471
|
+
"e" => "http://example.org/vocab#e"
|
472
|
+
},
|
473
|
+
"e" => RDF::Literal.new("1.1e1", datatype: RDF::XSD.double)
|
474
|
+
},
|
475
|
+
output: %(
|
476
|
+
@prefix ex: <http://example.org/vocab#> .
|
477
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
478
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
479
|
+
[ex:e 1.1e1] .
|
480
|
+
)
|
481
|
+
},
|
482
|
+
"date": {
|
483
|
+
input: {
|
484
|
+
"@context" => {
|
485
|
+
"e" => "http://example.org/vocab#e"
|
486
|
+
},
|
487
|
+
"e" => RDF::Literal.new("2022-08-27", datatype: RDF::XSD.date)
|
488
|
+
},
|
489
|
+
output: %(
|
490
|
+
@prefix ex: <http://example.org/vocab#> .
|
491
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
492
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
493
|
+
[ex:e "2022-08-27"^^xsd:date] .
|
494
|
+
)
|
495
|
+
},
|
496
|
+
"time": {
|
497
|
+
input: {
|
498
|
+
"@context" => {
|
499
|
+
"e" => "http://example.org/vocab#e"
|
500
|
+
},
|
501
|
+
"e" => RDF::Literal.new("12:00:00", datatype: RDF::XSD.time)
|
502
|
+
},
|
503
|
+
output: %(
|
504
|
+
@prefix ex: <http://example.org/vocab#> .
|
505
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
506
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
507
|
+
[ex:e "12:00:00"^^xsd:time] .
|
508
|
+
)
|
509
|
+
},
|
510
|
+
"dateTime": {
|
511
|
+
input: {
|
512
|
+
"@context" => {
|
513
|
+
"e" => "http://example.org/vocab#e"
|
514
|
+
},
|
515
|
+
"e" => RDF::Literal.new("2022-08-27T12:00:00", datatype: RDF::XSD.dateTime)
|
516
|
+
},
|
517
|
+
output: %(
|
518
|
+
@prefix ex: <http://example.org/vocab#> .
|
519
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
520
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
521
|
+
[ex:e "2022-08-27T12:00:00"^^xsd:dateTime] .
|
522
|
+
)
|
523
|
+
},
|
524
|
+
"language": {
|
525
|
+
input: {
|
526
|
+
"@context" => {
|
527
|
+
"e" => "http://example.org/vocab#e"
|
528
|
+
},
|
529
|
+
"e" => RDF::Literal.new("language", language: :"en-us")
|
530
|
+
},
|
531
|
+
output: %(
|
532
|
+
@prefix ex: <http://example.org/vocab#> .
|
533
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
534
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
535
|
+
[ex:e "language"@en-us] .
|
536
|
+
)
|
537
|
+
},
|
538
|
+
}.each do |title, params|
|
539
|
+
it title do
|
540
|
+
params[:output] = RDF::Graph.new << RDF::Turtle::Reader.new(params[:output])
|
541
|
+
run_to_rdf(params.merge(xsd: true))
|
542
|
+
end
|
543
|
+
end
|
544
|
+
end
|
412
545
|
end
|
413
546
|
|
414
547
|
context "prefixes" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-ld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.2.10
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.2.10
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: multi_json
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,58 +96,64 @@ dependencies:
|
|
90
96
|
name: rack
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
92
98
|
requirements:
|
93
|
-
- - "
|
99
|
+
- - ">="
|
94
100
|
- !ruby/object:Gem::Version
|
95
101
|
version: '2.2'
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '4'
|
96
105
|
type: :runtime
|
97
106
|
prerelease: false
|
98
107
|
version_requirements: !ruby/object:Gem::Requirement
|
99
108
|
requirements:
|
100
|
-
- - "
|
109
|
+
- - ">="
|
101
110
|
- !ruby/object:Gem::Version
|
102
111
|
version: '2.2'
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '4'
|
103
115
|
- !ruby/object:Gem::Dependency
|
104
116
|
name: sinatra-linkeddata
|
105
117
|
requirement: !ruby/object:Gem::Requirement
|
106
118
|
requirements:
|
107
119
|
- - "~>"
|
108
120
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
121
|
+
version: '3.2'
|
110
122
|
type: :development
|
111
123
|
prerelease: false
|
112
124
|
version_requirements: !ruby/object:Gem::Requirement
|
113
125
|
requirements:
|
114
126
|
- - "~>"
|
115
127
|
- !ruby/object:Gem::Version
|
116
|
-
version: '3.
|
128
|
+
version: '3.2'
|
117
129
|
- !ruby/object:Gem::Dependency
|
118
130
|
name: jsonlint
|
119
131
|
requirement: !ruby/object:Gem::Requirement
|
120
132
|
requirements:
|
121
133
|
- - "~>"
|
122
134
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0.
|
135
|
+
version: '0.4'
|
124
136
|
type: :development
|
125
137
|
prerelease: false
|
126
138
|
version_requirements: !ruby/object:Gem::Requirement
|
127
139
|
requirements:
|
128
140
|
- - "~>"
|
129
141
|
- !ruby/object:Gem::Version
|
130
|
-
version: '0.
|
142
|
+
version: '0.4'
|
131
143
|
- !ruby/object:Gem::Dependency
|
132
144
|
name: oj
|
133
145
|
requirement: !ruby/object:Gem::Requirement
|
134
146
|
requirements:
|
135
147
|
- - "~>"
|
136
148
|
- !ruby/object:Gem::Version
|
137
|
-
version: '3.
|
149
|
+
version: '3.14'
|
138
150
|
type: :development
|
139
151
|
prerelease: false
|
140
152
|
version_requirements: !ruby/object:Gem::Requirement
|
141
153
|
requirements:
|
142
154
|
- - "~>"
|
143
155
|
- !ruby/object:Gem::Version
|
144
|
-
version: '3.
|
156
|
+
version: '3.14'
|
145
157
|
- !ruby/object:Gem::Dependency
|
146
158
|
name: yajl-ruby
|
147
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,16 +172,22 @@ dependencies:
|
|
160
172
|
name: rack-test
|
161
173
|
requirement: !ruby/object:Gem::Requirement
|
162
174
|
requirements:
|
163
|
-
- - "
|
175
|
+
- - ">="
|
164
176
|
- !ruby/object:Gem::Version
|
165
177
|
version: '1.1'
|
178
|
+
- - "<"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '3'
|
166
181
|
type: :development
|
167
182
|
prerelease: false
|
168
183
|
version_requirements: !ruby/object:Gem::Requirement
|
169
184
|
requirements:
|
170
|
-
- - "
|
185
|
+
- - ">="
|
171
186
|
- !ruby/object:Gem::Version
|
172
187
|
version: '1.1'
|
188
|
+
- - "<"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '3'
|
173
191
|
- !ruby/object:Gem::Dependency
|
174
192
|
name: rdf-isomorphic
|
175
193
|
requirement: !ruby/object:Gem::Requirement
|
@@ -260,14 +278,14 @@ dependencies:
|
|
260
278
|
requirements:
|
261
279
|
- - "~>"
|
262
280
|
- !ruby/object:Gem::Version
|
263
|
-
version: '3.
|
281
|
+
version: '3.12'
|
264
282
|
type: :development
|
265
283
|
prerelease: false
|
266
284
|
version_requirements: !ruby/object:Gem::Requirement
|
267
285
|
requirements:
|
268
286
|
- - "~>"
|
269
287
|
- !ruby/object:Gem::Version
|
270
|
-
version: '3.
|
288
|
+
version: '3.12'
|
271
289
|
- !ruby/object:Gem::Dependency
|
272
290
|
name: rspec-its
|
273
291
|
requirement: !ruby/object:Gem::Requirement
|
@@ -429,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
429
447
|
- !ruby/object:Gem::Version
|
430
448
|
version: '0'
|
431
449
|
requirements: []
|
432
|
-
rubygems_version: 3.
|
450
|
+
rubygems_version: 3.4.6
|
433
451
|
signing_key:
|
434
452
|
specification_version: 4
|
435
453
|
summary: JSON-LD reader/writer for Ruby.
|