json-ld 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.3
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: 2022-08-07 00:00:00.000000000 Z
11
+ date: 2023-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.2'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 3.2.9
22
+ version: 3.2.10
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.2'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 3.2.9
32
+ version: 3.2.10
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: multi_json
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -96,16 +96,22 @@ dependencies:
96
96
  name: rack
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - "~>"
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '2.2'
102
+ - - "<"
103
+ - !ruby/object:Gem::Version
104
+ version: '4'
102
105
  type: :runtime
103
106
  prerelease: false
104
107
  version_requirements: !ruby/object:Gem::Requirement
105
108
  requirements:
106
- - - "~>"
109
+ - - ">="
107
110
  - !ruby/object:Gem::Version
108
111
  version: '2.2'
112
+ - - "<"
113
+ - !ruby/object:Gem::Version
114
+ version: '4'
109
115
  - !ruby/object:Gem::Dependency
110
116
  name: sinatra-linkeddata
111
117
  requirement: !ruby/object:Gem::Requirement
@@ -126,28 +132,28 @@ dependencies:
126
132
  requirements:
127
133
  - - "~>"
128
134
  - !ruby/object:Gem::Version
129
- version: '0.3'
135
+ version: '0.4'
130
136
  type: :development
131
137
  prerelease: false
132
138
  version_requirements: !ruby/object:Gem::Requirement
133
139
  requirements:
134
140
  - - "~>"
135
141
  - !ruby/object:Gem::Version
136
- version: '0.3'
142
+ version: '0.4'
137
143
  - !ruby/object:Gem::Dependency
138
144
  name: oj
139
145
  requirement: !ruby/object:Gem::Requirement
140
146
  requirements:
141
147
  - - "~>"
142
148
  - !ruby/object:Gem::Version
143
- version: '3.13'
149
+ version: '3.14'
144
150
  type: :development
145
151
  prerelease: false
146
152
  version_requirements: !ruby/object:Gem::Requirement
147
153
  requirements:
148
154
  - - "~>"
149
155
  - !ruby/object:Gem::Version
150
- version: '3.13'
156
+ version: '3.14'
151
157
  - !ruby/object:Gem::Dependency
152
158
  name: yajl-ruby
153
159
  requirement: !ruby/object:Gem::Requirement
@@ -166,16 +172,22 @@ dependencies:
166
172
  name: rack-test
167
173
  requirement: !ruby/object:Gem::Requirement
168
174
  requirements:
169
- - - "~>"
175
+ - - ">="
170
176
  - !ruby/object:Gem::Version
171
177
  version: '1.1'
178
+ - - "<"
179
+ - !ruby/object:Gem::Version
180
+ version: '3'
172
181
  type: :development
173
182
  prerelease: false
174
183
  version_requirements: !ruby/object:Gem::Requirement
175
184
  requirements:
176
- - - "~>"
185
+ - - ">="
177
186
  - !ruby/object:Gem::Version
178
187
  version: '1.1'
188
+ - - "<"
189
+ - !ruby/object:Gem::Version
190
+ version: '3'
179
191
  - !ruby/object:Gem::Dependency
180
192
  name: rdf-isomorphic
181
193
  requirement: !ruby/object:Gem::Requirement
@@ -266,14 +278,14 @@ dependencies:
266
278
  requirements:
267
279
  - - "~>"
268
280
  - !ruby/object:Gem::Version
269
- version: '3.11'
281
+ version: '3.12'
270
282
  type: :development
271
283
  prerelease: false
272
284
  version_requirements: !ruby/object:Gem::Requirement
273
285
  requirements:
274
286
  - - "~>"
275
287
  - !ruby/object:Gem::Version
276
- version: '3.11'
288
+ version: '3.12'
277
289
  - !ruby/object:Gem::Dependency
278
290
  name: rspec-its
279
291
  requirement: !ruby/object:Gem::Requirement
@@ -435,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
435
447
  - !ruby/object:Gem::Version
436
448
  version: '0'
437
449
  requirements: []
438
- rubygems_version: 3.3.3
450
+ rubygems_version: 3.4.6
439
451
  signing_key:
440
452
  specification_version: 4
441
453
  summary: JSON-LD reader/writer for Ruby.