json-ld 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.markdown → README.md} +15 -3
- data/VERSION +1 -1
- data/lib/json/ld.rb +50 -87
- data/lib/json/ld/api.rb +85 -96
- data/lib/json/ld/compact.rb +103 -170
- data/lib/json/ld/context.rb +1137 -0
- data/lib/json/ld/expand.rb +212 -171
- data/lib/json/ld/extensions.rb +17 -1
- data/lib/json/ld/flatten.rb +145 -78
- data/lib/json/ld/frame.rb +1 -1
- data/lib/json/ld/from_rdf.rb +73 -103
- data/lib/json/ld/reader.rb +3 -1
- data/lib/json/ld/resource.rb +3 -3
- data/lib/json/ld/to_rdf.rb +98 -109
- data/lib/json/ld/utils.rb +54 -4
- data/lib/json/ld/writer.rb +5 -5
- data/spec/api_spec.rb +3 -28
- data/spec/compact_spec.rb +76 -113
- data/spec/{evaluation_context_spec.rb → context_spec.rb} +307 -563
- data/spec/expand_spec.rb +163 -187
- data/spec/flatten_spec.rb +119 -114
- data/spec/frame_spec.rb +5 -5
- data/spec/from_rdf_spec.rb +44 -24
- data/spec/suite_compact_spec.rb +11 -8
- data/spec/suite_error_expand_spec.rb +23 -0
- data/spec/suite_expand_spec.rb +3 -7
- data/spec/suite_flatten_spec.rb +3 -3
- data/spec/suite_frame_spec.rb +6 -6
- data/spec/suite_from_rdf_spec.rb +3 -3
- data/spec/suite_helper.rb +13 -6
- data/spec/suite_to_rdf_spec.rb +16 -10
- data/spec/test-files/test-1-rdf.ttl +4 -3
- data/spec/test-files/test-3-rdf.ttl +2 -1
- data/spec/test-files/test-4-compacted.json +1 -1
- data/spec/test-files/test-5-rdf.ttl +3 -2
- data/spec/test-files/test-6-rdf.ttl +3 -2
- data/spec/test-files/test-7-compacted.json +3 -3
- data/spec/test-files/test-7-expanded.json +3 -3
- data/spec/test-files/test-7-rdf.ttl +7 -6
- data/spec/test-files/test-9-compacted.json +1 -1
- data/spec/to_rdf_spec.rb +67 -75
- data/spec/writer_spec.rb +2 -0
- metadata +36 -24
- checksums.yaml +0 -15
- data/lib/json/ld/evaluation_context.rb +0 -984
data/spec/expand_spec.rb
CHANGED
@@ -11,47 +11,6 @@ describe JSON::LD::API do
|
|
11
11
|
:input => {},
|
12
12
|
:output => []
|
13
13
|
},
|
14
|
-
"coerced IRI" => {
|
15
|
-
:input => {
|
16
|
-
"@context" => {
|
17
|
-
"a" => {"@id" => "http://example.com/a"},
|
18
|
-
"b" => {"@id" => "http://example.com/b", "@type" => "@id"},
|
19
|
-
"c" => {"@id" => "http://example.com/c"},
|
20
|
-
},
|
21
|
-
"@id" => "a",
|
22
|
-
"b" => "c"
|
23
|
-
},
|
24
|
-
:output => [{
|
25
|
-
"@id" => "http://example.com/a",
|
26
|
-
"http://example.com/b" => [{"@id" =>"http://example.com/c"}]
|
27
|
-
}]
|
28
|
-
},
|
29
|
-
"coerced IRI in array" => {
|
30
|
-
:input => {
|
31
|
-
"@context" => {
|
32
|
-
"a" => {"@id" => "http://example.com/a"},
|
33
|
-
"b" => {"@id" => "http://example.com/b", "@type" => "@id"},
|
34
|
-
"c" => {"@id" => "http://example.com/c"},
|
35
|
-
},
|
36
|
-
"@id" => "a",
|
37
|
-
"b" => ["c"]
|
38
|
-
},
|
39
|
-
:output => [{
|
40
|
-
"@id" => "http://example.com/a",
|
41
|
-
"http://example.com/b" => [{"@id" => "http://example.com/c"}]
|
42
|
-
}]
|
43
|
-
},
|
44
|
-
"empty term" => {
|
45
|
-
:input => {
|
46
|
-
"@context" => {"" => "http://example.com/"},
|
47
|
-
"@id" => "",
|
48
|
-
"@type" => "#{RDF::RDFS.Resource}"
|
49
|
-
},
|
50
|
-
:output => [{
|
51
|
-
"@id" => "http://example.com/",
|
52
|
-
"@type" => ["#{RDF::RDFS.Resource}"]
|
53
|
-
}]
|
54
|
-
},
|
55
14
|
"@list coercion" => {
|
56
15
|
:input => {
|
57
16
|
"@context" => {
|
@@ -84,14 +43,6 @@ describe JSON::LD::API do
|
|
84
43
|
{"http://example.com/bar" => [{"@value" => "bar"}]}
|
85
44
|
]
|
86
45
|
},
|
87
|
-
"@type with empty object" => {
|
88
|
-
:input => {
|
89
|
-
"@type" => {}
|
90
|
-
},
|
91
|
-
:output => [
|
92
|
-
{"@type" => [{}]}
|
93
|
-
]
|
94
|
-
},
|
95
46
|
"@type with CURIE" => {
|
96
47
|
:input => {
|
97
48
|
"@context" => {"ex" => "http://example.com/"},
|
@@ -110,9 +61,13 @@ describe JSON::LD::API do
|
|
110
61
|
{"@type" => ["http://example.com/type1", "http://example.com/type2"]}
|
111
62
|
]
|
112
63
|
},
|
64
|
+
"@value with false" => {
|
65
|
+
:input => {"http://example.com/ex" => {"@value" => false}},
|
66
|
+
:output => [{"http://example.com/ex" => [{"@value" => false}]}]
|
67
|
+
}
|
113
68
|
}.each_pair do |title, params|
|
114
69
|
it title do
|
115
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
70
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
116
71
|
jld.should produce(params[:output], @debug)
|
117
72
|
end
|
118
73
|
end
|
@@ -159,7 +114,7 @@ describe JSON::LD::API do
|
|
159
114
|
},
|
160
115
|
}.each do |title, params|
|
161
116
|
it title do
|
162
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
117
|
+
jld = JSON::LD::API.expand(params[:input], nil, :base => "http://example.org/", :debug => @debug)
|
163
118
|
jld.should produce(params[:output], @debug)
|
164
119
|
end
|
165
120
|
end
|
@@ -218,7 +173,7 @@ describe JSON::LD::API do
|
|
218
173
|
},
|
219
174
|
}.each do |title, params|
|
220
175
|
it title do
|
221
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
176
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
222
177
|
jld.should produce(params[:output], @debug)
|
223
178
|
end
|
224
179
|
end
|
@@ -273,7 +228,7 @@ describe JSON::LD::API do
|
|
273
228
|
},
|
274
229
|
}.each do |title, params|
|
275
230
|
it title do
|
276
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
231
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
277
232
|
jld.should produce(params[:output], @debug)
|
278
233
|
end
|
279
234
|
end
|
@@ -301,7 +256,7 @@ describe JSON::LD::API do
|
|
301
256
|
},
|
302
257
|
}.each do |title, params|
|
303
258
|
it title do
|
304
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
259
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
305
260
|
jld.should produce(params[:output], @debug)
|
306
261
|
end
|
307
262
|
end
|
@@ -310,45 +265,21 @@ describe JSON::LD::API do
|
|
310
265
|
context "null" do
|
311
266
|
{
|
312
267
|
"value" => {
|
313
|
-
:input => {
|
314
|
-
"http://example.com/foo" => nil
|
315
|
-
},
|
268
|
+
:input => {"http://example.com/foo" => nil},
|
316
269
|
:output => []
|
317
270
|
},
|
318
271
|
"@value" => {
|
319
|
-
:input => {
|
320
|
-
"http://example.com/foo" => {"@value" => nil}
|
321
|
-
},
|
272
|
+
:input => {"http://example.com/foo" => {"@value" => nil}},
|
322
273
|
:output => []
|
323
274
|
},
|
324
275
|
"@value and non-null @type" => {
|
325
|
-
:input => {
|
326
|
-
"http://example.com/foo" => {"@value" => nil, "@type" => "http://type"}
|
327
|
-
},
|
276
|
+
:input => {"http://example.com/foo" => {"@value" => nil, "@type" => "http://type"}},
|
328
277
|
:output => []
|
329
278
|
},
|
330
279
|
"@value and non-null @language" => {
|
331
|
-
:input => {
|
332
|
-
"http://example.com/foo" => {"@value" => nil, "@language" => "en"}
|
333
|
-
},
|
280
|
+
:input => {"http://example.com/foo" => {"@value" => nil, "@language" => "en"}},
|
334
281
|
:output => []
|
335
282
|
},
|
336
|
-
"non-null @value and null @type" => {
|
337
|
-
:input => {
|
338
|
-
"http://example.com/foo" => {"@value" => "foo", "@type" => nil}
|
339
|
-
},
|
340
|
-
:output => [{
|
341
|
-
"http://example.com/foo" => [{"@value" => "foo"}]
|
342
|
-
}]
|
343
|
-
},
|
344
|
-
"non-null @value and null @language" => {
|
345
|
-
:input => {
|
346
|
-
"http://example.com/foo" => {"@value" => "foo", "@language" => nil}
|
347
|
-
},
|
348
|
-
:output => [{
|
349
|
-
"http://example.com/foo" => [{"@value" => "foo"}]
|
350
|
-
}]
|
351
|
-
},
|
352
283
|
"array with null elements" => {
|
353
284
|
:input => {
|
354
285
|
"http://example.com/foo" => [nil]
|
@@ -369,7 +300,7 @@ describe JSON::LD::API do
|
|
369
300
|
}
|
370
301
|
}.each do |title, params|
|
371
302
|
it title do
|
372
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
303
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
373
304
|
jld.should produce(params[:output], @debug)
|
374
305
|
end
|
375
306
|
end
|
@@ -377,15 +308,6 @@ describe JSON::LD::API do
|
|
377
308
|
|
378
309
|
context "default language" do
|
379
310
|
{
|
380
|
-
"value with null language" => {
|
381
|
-
:input => {
|
382
|
-
"@context" => {"@language" => "en"},
|
383
|
-
"http://example.org/nolang" => {"@value" => "no language", "@language" => nil}
|
384
|
-
},
|
385
|
-
:output => [{
|
386
|
-
"http://example.org/nolang" => [{"@value" => "no language"}]
|
387
|
-
}]
|
388
|
-
},
|
389
311
|
"value with coerced null language" => {
|
390
312
|
:input => {
|
391
313
|
"@context" => {
|
@@ -406,7 +328,7 @@ describe JSON::LD::API do
|
|
406
328
|
},
|
407
329
|
}.each do |title, params|
|
408
330
|
it title do
|
409
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
331
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
410
332
|
jld.should produce(params[:output], @debug)
|
411
333
|
end
|
412
334
|
end
|
@@ -472,7 +394,7 @@ describe JSON::LD::API do
|
|
472
394
|
}
|
473
395
|
}.each do |title, params|
|
474
396
|
it title do
|
475
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
397
|
+
jld = JSON::LD::API.expand(params[:input], nil,
|
476
398
|
:base => "http://foo/bar/",
|
477
399
|
:debug => @debug)
|
478
400
|
jld.should produce(params[:output], @debug)
|
@@ -493,7 +415,7 @@ describe JSON::LD::API do
|
|
493
415
|
"http://example.com/foo" => {"@value" => "bar", "@type" => "baz"}
|
494
416
|
},
|
495
417
|
:output => [{
|
496
|
-
"http://example.com/foo" => [{"@value" => "bar"}]
|
418
|
+
"http://example.com/foo" => [{"@value" => "bar", "@type" => "http://example/baz"}]
|
497
419
|
}]
|
498
420
|
},
|
499
421
|
"unknown keyword" => {
|
@@ -529,7 +451,7 @@ describe JSON::LD::API do
|
|
529
451
|
]}
|
530
452
|
}.each do |title, params|
|
531
453
|
it title do
|
532
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
454
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug, :base => 'http://example/')
|
533
455
|
jld.should produce(params[:output], @debug)
|
534
456
|
end
|
535
457
|
end
|
@@ -538,30 +460,22 @@ describe JSON::LD::API do
|
|
538
460
|
context "lists" do
|
539
461
|
{
|
540
462
|
"empty" => {
|
541
|
-
:input => {
|
542
|
-
|
543
|
-
},
|
544
|
-
:output => [{
|
545
|
-
"http://example.com/foo" => [{"@list" => []}]
|
546
|
-
}]
|
463
|
+
:input => {"http://example.com/foo" => {"@list" => []}},
|
464
|
+
:output => [{"http://example.com/foo" => [{"@list" => []}]}]
|
547
465
|
},
|
548
466
|
"coerced empty" => {
|
549
467
|
:input => {
|
550
468
|
"@context" => {"http://example.com/foo" => {"@container" => "@list"}},
|
551
469
|
"http://example.com/foo" => []
|
552
470
|
},
|
553
|
-
:output => [{
|
554
|
-
"http://example.com/foo" => [{"@list" => []}]
|
555
|
-
}]
|
471
|
+
:output => [{"http://example.com/foo" => [{"@list" => []}]}]
|
556
472
|
},
|
557
473
|
"coerced single element" => {
|
558
474
|
:input => {
|
559
475
|
"@context" => {"http://example.com/foo" => {"@container" => "@list"}},
|
560
476
|
"http://example.com/foo" => [ "foo" ]
|
561
477
|
},
|
562
|
-
:output => [{
|
563
|
-
"http://example.com/foo" => [{"@list" => [{"@value" => "foo"}]}]
|
564
|
-
}]
|
478
|
+
:output => [{"http://example.com/foo" => [{"@list" => [{"@value" => "foo"}]}]}]
|
565
479
|
},
|
566
480
|
"coerced multiple elements" => {
|
567
481
|
:input => {
|
@@ -590,9 +504,33 @@ describe JSON::LD::API do
|
|
590
504
|
"http://example.com/foo" => [{"@list" => [{"@value" => "2012-04-12", "@type" => RDF::XSD.date.to_s}]}]
|
591
505
|
}]
|
592
506
|
},
|
507
|
+
"expand-0004" => {
|
508
|
+
:input => ::JSON.parse(%({
|
509
|
+
"@context": {
|
510
|
+
"mylist1": {"@id": "http://example.com/mylist1", "@container": "@list"},
|
511
|
+
"mylist2": {"@id": "http://example.com/mylist2", "@container": "@list"},
|
512
|
+
"myset2": {"@id": "http://example.com/myset2", "@container": "@set"},
|
513
|
+
"myset3": {"@id": "http://example.com/myset3", "@container": "@set"}
|
514
|
+
},
|
515
|
+
"http://example.org/property": { "@list": "one item" }
|
516
|
+
})),
|
517
|
+
:output => ::JSON.parse(%([
|
518
|
+
{
|
519
|
+
"http://example.org/property": [
|
520
|
+
{
|
521
|
+
"@list": [
|
522
|
+
{
|
523
|
+
"@value": "one item"
|
524
|
+
}
|
525
|
+
]
|
526
|
+
}
|
527
|
+
]
|
528
|
+
}
|
529
|
+
]))
|
530
|
+
}
|
593
531
|
}.each do |title, params|
|
594
532
|
it title do
|
595
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
533
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
596
534
|
jld.should produce(params[:output], @debug)
|
597
535
|
end
|
598
536
|
end
|
@@ -645,7 +583,7 @@ describe JSON::LD::API do
|
|
645
583
|
},
|
646
584
|
}.each do |title, params|
|
647
585
|
it title do
|
648
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
586
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
649
587
|
jld.should produce(params[:output], @debug)
|
650
588
|
end
|
651
589
|
end
|
@@ -713,13 +651,110 @@ describe JSON::LD::API do
|
|
713
651
|
}
|
714
652
|
}.each do |title, params|
|
715
653
|
it title do
|
716
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
654
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
655
|
+
jld.should produce(params[:output], @debug)
|
656
|
+
end
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
660
|
+
context "@reverse" do
|
661
|
+
{
|
662
|
+
"expand-0037" => {
|
663
|
+
:input => ::JSON.parse(%({
|
664
|
+
"@context": {
|
665
|
+
"name": "http://xmlns.com/foaf/0.1/name"
|
666
|
+
},
|
667
|
+
"@id": "http://example.com/people/markus",
|
668
|
+
"name": "Markus Lanthaler",
|
669
|
+
"@reverse": {
|
670
|
+
"http://xmlns.com/foaf/0.1/knows": {
|
671
|
+
"@id": "http://example.com/people/dave",
|
672
|
+
"name": "Dave Longley"
|
673
|
+
}
|
674
|
+
}
|
675
|
+
})),
|
676
|
+
:output => ::JSON.parse(%([
|
677
|
+
{
|
678
|
+
"@id": "http://example.com/people/markus",
|
679
|
+
"@reverse": {
|
680
|
+
"http://xmlns.com/foaf/0.1/knows": [
|
681
|
+
{
|
682
|
+
"@id": "http://example.com/people/dave",
|
683
|
+
"http://xmlns.com/foaf/0.1/name": [
|
684
|
+
{
|
685
|
+
"@value": "Dave Longley"
|
686
|
+
}
|
687
|
+
]
|
688
|
+
}
|
689
|
+
]
|
690
|
+
},
|
691
|
+
"http://xmlns.com/foaf/0.1/name": [
|
692
|
+
{
|
693
|
+
"@value": "Markus Lanthaler"
|
694
|
+
}
|
695
|
+
]
|
696
|
+
}
|
697
|
+
]))
|
698
|
+
},
|
699
|
+
"expand-0043" => {
|
700
|
+
:input => ::JSON.parse(%({
|
701
|
+
"@context": {
|
702
|
+
"name": "http://xmlns.com/foaf/0.1/name",
|
703
|
+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
|
704
|
+
},
|
705
|
+
"@id": "http://example.com/people/markus",
|
706
|
+
"name": "Markus Lanthaler",
|
707
|
+
"@reverse": {
|
708
|
+
"isKnownBy": [
|
709
|
+
{
|
710
|
+
"@id": "http://example.com/people/dave",
|
711
|
+
"name": "Dave Longley"
|
712
|
+
},
|
713
|
+
{
|
714
|
+
"@id": "http://example.com/people/gregg",
|
715
|
+
"name": "Gregg Kellogg"
|
716
|
+
}
|
717
|
+
]
|
718
|
+
}
|
719
|
+
})),
|
720
|
+
:output => ::JSON.parse(%([
|
721
|
+
{
|
722
|
+
"@id": "http://example.com/people/markus",
|
723
|
+
"http://xmlns.com/foaf/0.1/knows": [
|
724
|
+
{
|
725
|
+
"@id": "http://example.com/people/dave",
|
726
|
+
"http://xmlns.com/foaf/0.1/name": [
|
727
|
+
{
|
728
|
+
"@value": "Dave Longley"
|
729
|
+
}
|
730
|
+
]
|
731
|
+
},
|
732
|
+
{
|
733
|
+
"@id": "http://example.com/people/gregg",
|
734
|
+
"http://xmlns.com/foaf/0.1/name": [
|
735
|
+
{
|
736
|
+
"@value": "Gregg Kellogg"
|
737
|
+
}
|
738
|
+
]
|
739
|
+
}
|
740
|
+
],
|
741
|
+
"http://xmlns.com/foaf/0.1/name": [
|
742
|
+
{
|
743
|
+
"@value": "Markus Lanthaler"
|
744
|
+
}
|
745
|
+
]
|
746
|
+
}
|
747
|
+
]))
|
748
|
+
},
|
749
|
+
}.each do |title, params|
|
750
|
+
it title do
|
751
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
717
752
|
jld.should produce(params[:output], @debug)
|
718
753
|
end
|
719
754
|
end
|
720
755
|
end
|
721
756
|
|
722
|
-
context "
|
757
|
+
context "@index" do
|
723
758
|
{
|
724
759
|
"string annotation" => {
|
725
760
|
:input => {
|
@@ -748,88 +783,29 @@ describe JSON::LD::API do
|
|
748
783
|
},
|
749
784
|
}.each do |title, params|
|
750
785
|
it title do
|
751
|
-
jld = JSON::LD::API.expand(params[:input], nil,
|
786
|
+
jld = JSON::LD::API.expand(params[:input], nil, :debug => @debug)
|
752
787
|
jld.should produce(params[:output], @debug)
|
753
788
|
end
|
754
789
|
end
|
755
790
|
end
|
756
791
|
|
757
|
-
context "
|
792
|
+
context "exceptions" do
|
758
793
|
{
|
759
|
-
"
|
760
|
-
:input => {
|
761
|
-
|
762
|
-
"site" => "http://example.com/",
|
763
|
-
"field_tags" => {
|
764
|
-
"@id" => [ "site:vocab/field_tags", "http://schema.org/about" ]
|
765
|
-
},
|
766
|
-
"field_related" => {
|
767
|
-
"@id" => [ "site:vocab/field_related", "http://schema.org/about" ]
|
768
|
-
}
|
769
|
-
},
|
770
|
-
"@id" => "site:node/1",
|
771
|
-
"field_tags" => [
|
772
|
-
{ "@id" => "site:term/this-is-a-tag" }
|
773
|
-
],
|
774
|
-
"field_related" => [
|
775
|
-
{ "@id" => "site:node/this-is-related-news" }
|
776
|
-
]
|
777
|
-
},
|
778
|
-
:output => [{
|
779
|
-
"@id" => "http://example.com/node/1",
|
780
|
-
"http://example.com/vocab/field_related" => [{
|
781
|
-
"@id" => "http://example.com/node/this-is-related-news"
|
782
|
-
}],
|
783
|
-
"http://schema.org/about" => [{
|
784
|
-
"@id" => "http://example.com/node/this-is-related-news"
|
785
|
-
}, {
|
786
|
-
"@id" => "http://example.com/term/this-is-a-tag"
|
787
|
-
}],
|
788
|
-
"http://example.com/vocab/field_tags" => [{
|
789
|
-
"@id" => "http://example.com/term/this-is-a-tag"
|
790
|
-
}]
|
791
|
-
}]
|
794
|
+
"non-null @value and null @type" => {
|
795
|
+
:input => {"http://example.com/foo" => {"@value" => "foo", "@type" => nil}},
|
796
|
+
:exception => JSON::LD::ProcessingError::InvalidTypeValue
|
792
797
|
},
|
793
|
-
"
|
798
|
+
"non-null @value and null @language" => {
|
799
|
+
:input => {"http://example.com/foo" => {"@value" => "foo", "@language" => nil}},
|
800
|
+
:exception => JSON::LD::ProcessingError::InvalidLanguageTaggedString
|
801
|
+
},
|
802
|
+
"value with null language" => {
|
794
803
|
:input => {
|
795
|
-
"@context" => {
|
796
|
-
|
797
|
-
"field_tags" => {
|
798
|
-
"@id" => [ "site:vocab/field_tags", "http://schema.org/about" ]
|
799
|
-
}
|
800
|
-
},
|
801
|
-
"@id" => "site:node/1",
|
802
|
-
"field_tags" => [
|
803
|
-
{ "@type" => "site:term/this-is-a-tag" },
|
804
|
-
"foo"
|
805
|
-
]
|
804
|
+
"@context" => {"@language" => "en"},
|
805
|
+
"http://example.org/nolang" => {"@value" => "no language", "@language" => nil}
|
806
806
|
},
|
807
|
-
:
|
808
|
-
|
809
|
-
"http://schema.org/about" => [{
|
810
|
-
"@id" => "_:t0",
|
811
|
-
"@type" => ["http://example.com/term/this-is-a-tag"]
|
812
|
-
}, {
|
813
|
-
"@value" => "foo"
|
814
|
-
}],
|
815
|
-
"http://example.com/vocab/field_tags" => [{
|
816
|
-
"@id" => "_:t0",
|
817
|
-
"@type" => ["http://example.com/term/this-is-a-tag"]
|
818
|
-
}, {
|
819
|
-
"@value" => "foo"
|
820
|
-
}]
|
821
|
-
}]
|
822
|
-
}
|
823
|
-
}.each do |title, params|
|
824
|
-
it title do
|
825
|
-
jld = JSON::LD::API.expand(params[:input], nil, nil, :debug => @debug)
|
826
|
-
jld.should produce(params[:output], @debug)
|
827
|
-
end
|
828
|
-
end
|
829
|
-
end
|
830
|
-
|
831
|
-
context "exceptions" do
|
832
|
-
{
|
807
|
+
:exception => JSON::LD::ProcessingError::InvalidLanguageTaggedString
|
808
|
+
},
|
833
809
|
"@list containing @list" => {
|
834
810
|
:input => {
|
835
811
|
"http://example.com/foo" => {"@list" => [{"@list" => ["baz"]}]}
|
@@ -852,8 +828,8 @@ describe JSON::LD::API do
|
|
852
828
|
},
|
853
829
|
}.each do |title, params|
|
854
830
|
it title do
|
855
|
-
#JSON::LD::API.expand(params[:input], nil,
|
856
|
-
lambda {JSON::LD::API.expand(params[:input], nil
|
831
|
+
#JSON::LD::API.expand(params[:input], nil, :debug => @debug).should produce([], @debug)
|
832
|
+
lambda {JSON::LD::API.expand(params[:input], nil)}.should raise_error(params[:exception])
|
857
833
|
end
|
858
834
|
end
|
859
835
|
end
|