json-ld 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,13 +8,13 @@ describe JSON::LD::API do
8
8
  describe ".flatten" do
9
9
  {
10
10
  "single object" => {
11
- :input => {"@id" => "http://example.com", "@type" => RDF::RDFS.Resource.to_s},
12
- :output => [
11
+ input: {"@id" => "http://example.com", "@type" => RDF::RDFS.Resource.to_s},
12
+ output: [
13
13
  {"@id" => "http://example.com", "@type" => [RDF::RDFS.Resource.to_s]}
14
14
  ]
15
15
  },
16
16
  "embedded object" => {
17
- :input => {
17
+ input: {
18
18
  "@context" => {
19
19
  "foaf" => RDF::FOAF.to_s
20
20
  },
@@ -25,7 +25,7 @@ describe JSON::LD::API do
25
25
  "@type" => ["foaf:Person"]
26
26
  }]
27
27
  },
28
- :output => [
28
+ output: [
29
29
  {
30
30
  "@id" => "http://greggkellogg.net/foaf",
31
31
  "@type" => [RDF::FOAF.PersonalProfileDocument.to_s],
@@ -38,7 +38,7 @@ describe JSON::LD::API do
38
38
  ]
39
39
  },
40
40
  "embedded anon" => {
41
- :input => {
41
+ input: {
42
42
  "@context" => {
43
43
  "foaf" => RDF::FOAF.to_s
44
44
  },
@@ -48,7 +48,7 @@ describe JSON::LD::API do
48
48
  "@type" => "foaf:Person"
49
49
  }
50
50
  },
51
- :output => [
51
+ output: [
52
52
  {
53
53
  "@id" => "_:b0",
54
54
  "@type" => [RDF::FOAF.Person.to_s]
@@ -61,7 +61,7 @@ describe JSON::LD::API do
61
61
  ]
62
62
  },
63
63
  "reverse properties" => {
64
- :input => ::JSON.parse(%([
64
+ input: ::JSON.parse(%([
65
65
  {
66
66
  "@id": "http://example.com/people/markus",
67
67
  "@reverse": {
@@ -77,7 +77,7 @@ describe JSON::LD::API do
77
77
  "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
78
78
  }
79
79
  ])),
80
- :output => ::JSON.parse(%([
80
+ output: ::JSON.parse(%([
81
81
  {
82
82
  "@id": "http://example.com/people/dave",
83
83
  "http://xmlns.com/foaf/0.1/knows": [
@@ -105,7 +105,7 @@ describe JSON::LD::API do
105
105
  ]))
106
106
  },
107
107
  "Simple named graph (Wikidata)" => {
108
- :input => ::JSON.parse(%q({
108
+ input: ::JSON.parse(%q({
109
109
  "@context": {
110
110
  "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
111
111
  "ex": "http://example.org/",
@@ -135,7 +135,7 @@ describe JSON::LD::API do
135
135
  }
136
136
  ]
137
137
  })),
138
- :output => ::JSON.parse(%q([{
138
+ output: ::JSON.parse(%q([{
139
139
  "@id": "http://example.org/ParisFact1",
140
140
  "@type": ["http://www.w3.org/1999/02/22-rdf-syntax-ns#Graph"],
141
141
  "http://example.org/hasReference": [
@@ -158,7 +158,7 @@ describe JSON::LD::API do
158
158
  }])),
159
159
  },
160
160
  "Test Manifest (shortened)" => {
161
- :input => ::JSON.parse(%q{
161
+ input: ::JSON.parse(%q{
162
162
  {
163
163
  "@id": "",
164
164
  "http://example/sequence": {"@list": [
@@ -170,7 +170,7 @@ describe JSON::LD::API do
170
170
  ]}
171
171
  }
172
172
  }),
173
- :output => ::JSON.parse(%q{
173
+ output: ::JSON.parse(%q{
174
174
  [{
175
175
  "@id": "",
176
176
  "http://example/sequence": [{"@list": [{"@id": "#t0001"}]}]
@@ -180,10 +180,10 @@ describe JSON::LD::API do
180
180
  "http://example/name": [{"@value": "Keywords cannot be aliased to other keywords"}]
181
181
  }]
182
182
  }),
183
- :options => {}
183
+ options: {}
184
184
  },
185
185
  "@reverse bnode issue (0045)" => {
186
- :input => ::JSON.parse(%q{
186
+ input: ::JSON.parse(%q{
187
187
  {
188
188
  "@context": {
189
189
  "foo": "http://example.org/foo",
@@ -193,7 +193,7 @@ describe JSON::LD::API do
193
193
  "bar": [ "http://example.org/origin", "_:b0" ]
194
194
  }
195
195
  }),
196
- :output => ::JSON.parse(%q{
196
+ output: ::JSON.parse(%q{
197
197
  [
198
198
  {
199
199
  "@id": "_:b0",
@@ -209,12 +209,12 @@ describe JSON::LD::API do
209
209
  }
210
210
  ]
211
211
  }),
212
- :options => {}
212
+ options: {}
213
213
  }
214
214
  }.each do |title, params|
215
215
  it title do
216
216
  @debug = []
217
- jld = JSON::LD::API.flatten(params[:input], nil, (params[:options] || {}).merge(:debug => @debug))
217
+ jld = JSON::LD::API.flatten(params[:input], nil, (params[:options] || {}).merge(debug: @debug))
218
218
  expect(jld).to produce(params[:output], @debug)
219
219
  end
220
220
  end
@@ -14,10 +14,10 @@ describe JSON::LD::Format do
14
14
  formats = [
15
15
  :jsonld,
16
16
  "etc/doap.jsonld",
17
- {:file_name => 'etc/doap.jsonld'},
18
- {:file_extension => 'jsonld'},
19
- {:content_type => 'application/ld+json'},
20
- {:content_type => 'application/x-ld+json'},
17
+ {file_name: 'etc/doap.jsonld'},
18
+ {file_extension: 'jsonld'},
19
+ {content_type: 'application/ld+json'},
20
+ {content_type: 'application/x-ld+json'},
21
21
  ].each do |arg|
22
22
  it "discovers with #{arg.inspect}" do
23
23
  expect(RDF::Format.for(arg)).to eq @format_class
@@ -25,10 +25,10 @@ describe JSON::LD::Format do
25
25
  end
26
26
 
27
27
  {
28
- :jsonld => '{"@context" => "foo"}',
29
- :context => %({\n"@context": {),
30
- :id => %({\n"@id": {),
31
- :type => %({\n"@type": {),
28
+ jsonld: '{"@context" => "foo"}',
29
+ context: %({\n"@context": {),
30
+ id: %({\n"@id": {),
31
+ type: %({\n"@type": {),
32
32
  }.each do |sym, str|
33
33
  it "detects #{sym}" do
34
34
  expect(@format_class.for {str}).to eq @format_class
@@ -46,7 +46,7 @@ describe JSON::LD::Format do
46
46
 
47
47
  describe ".detect" do
48
48
  {
49
- :jsonld => '{"@context" => "foo"}',
49
+ jsonld: '{"@context" => "foo"}',
50
50
  }.each do |sym, str|
51
51
  it "detects #{sym}" do
52
52
  expect(@format_class.detect(str)).to be_truthy
@@ -54,14 +54,14 @@ describe JSON::LD::Format do
54
54
  end
55
55
 
56
56
  {
57
- :n3 => "@prefix foo: <bar> .\nfoo:bar = {<a> <b> <c>} .",
58
- :nquads => "<a> <b> <c> <d> . ",
59
- :rdfxml => '<rdf:RDF about="foo"></rdf:RDF>',
60
- :rdfa => '<div about="foo"></div>',
61
- :microdata => '<div itemref="bar"></div>',
62
- :ntriples => "<a> <b> <c> .",
63
- :multi_line => '<a>\n <b>\n "literal"\n .',
64
- :turtle => "@prefix foo: <bar> .\n foo:a foo:b <c> .",
57
+ n3: "@prefix foo: <bar> .\nfoo:bar = {<a> <b> <c>} .",
58
+ nquads: "<a> <b> <c> <d> . ",
59
+ rdfxml: '<rdf:RDF about="foo"></rdf:RDF>',
60
+ rdfa: '<div about="foo"></div>',
61
+ microdata: '<div itemref="bar"></div>',
62
+ ntriples: "<a> <b> <c> .",
63
+ multi_line: '<a>\n <b>\n "literal"\n .',
64
+ turtle: "@prefix foo: <bar> .\n foo:a foo:b <c> .",
65
65
  }.each do |sym, str|
66
66
  it "does not detect #{sym}" do
67
67
  expect(@format_class.detect(str)).to be_falsey
@@ -8,11 +8,11 @@ describe JSON::LD::API do
8
8
  describe ".frame" do
9
9
  {
10
10
  "frame with @type matches subject with @type" => {
11
- :frame => {
11
+ frame: {
12
12
  "@context" => {"ex" => "http://example.org/"},
13
13
  "@type" => "ex:Type1"
14
14
  },
15
- :input => [
15
+ input: [
16
16
  {
17
17
  "@context" => {"ex" => "http://example.org/"},
18
18
  "@id" => "ex:Sub1",
@@ -24,7 +24,7 @@ describe JSON::LD::API do
24
24
  "@type" => "ex:Type2"
25
25
  },
26
26
  ],
27
- :output => {
27
+ output: {
28
28
  "@context" => {"ex" => "http://example.org/"},
29
29
  "@graph" => [{
30
30
  "@id" => "ex:Sub1",
@@ -33,11 +33,11 @@ describe JSON::LD::API do
33
33
  }
34
34
  },
35
35
  "implicitly includes unframed properties" => {
36
- :frame => {
36
+ frame: {
37
37
  "@context" => {"ex" => "http://example.org/"},
38
38
  "@type" => "ex:Type1"
39
39
  },
40
- :input => [
40
+ input: [
41
41
  {
42
42
  "@context" => {"ex" => "http://example.org/"},
43
43
  "@id" => "ex:Sub1",
@@ -46,7 +46,7 @@ describe JSON::LD::API do
46
46
  "ex:prop2" => {"@id" => "ex:Obj1"}
47
47
  }
48
48
  ],
49
- :output => {
49
+ output: {
50
50
  "@context" => {"ex" => "http://example.org/"},
51
51
  "@graph" => [{
52
52
  "@id" => "ex:Sub1",
@@ -57,12 +57,12 @@ describe JSON::LD::API do
57
57
  }
58
58
  },
59
59
  "explicitly excludes unframed properties" => {
60
- :frame => {
60
+ frame: {
61
61
  "@context" => {"ex" => "http://example.org/"},
62
62
  "@explicit" => true,
63
63
  "@type" => "ex:Type1"
64
64
  },
65
- :input => [
65
+ input: [
66
66
  {
67
67
  "@context" => {"ex" => "http://example.org/"},
68
68
  "@id" => "ex:Sub1",
@@ -71,7 +71,7 @@ describe JSON::LD::API do
71
71
  "ex:prop2" => {"@id" => "ex:Obj1"}
72
72
  }
73
73
  ],
74
- :output => {
74
+ output: {
75
75
  "@context" => {"ex" => "http://example.org/"},
76
76
  "@graph" => [{
77
77
  "@id" => "ex:Sub1",
@@ -80,12 +80,12 @@ describe JSON::LD::API do
80
80
  }
81
81
  },
82
82
  "explicitly includes unframed properties" => {
83
- :frame => {
83
+ frame: {
84
84
  "@context" => {"ex" => "http://example.org/"},
85
85
  "@explicit" => false,
86
86
  "@type" => "ex:Type1"
87
87
  },
88
- :input => [
88
+ input: [
89
89
  {
90
90
  "@context" => {"ex" => "http://example.org/"},
91
91
  "@id" => "ex:Sub1",
@@ -94,7 +94,7 @@ describe JSON::LD::API do
94
94
  "ex:prop2" => {"@id" => "ex:Obj1"}
95
95
  }
96
96
  ],
97
- :output => {
97
+ output: {
98
98
  "@context" => {"ex" => "http://example.org/"},
99
99
  "@graph" => [{
100
100
  "@id" => "ex:Sub1",
@@ -105,12 +105,12 @@ describe JSON::LD::API do
105
105
  }
106
106
  },
107
107
  "frame without @type matches only subjects containing listed properties (duck typing)" => {
108
- :frame => {
108
+ frame: {
109
109
  "@context" => {"ex" => "http://example.org/"},
110
110
  "ex:prop1" => {},
111
111
  "ex:prop2" => {}
112
112
  },
113
- :input => [
113
+ input: [
114
114
  {
115
115
  "@context" => {"ex" => "http://example.org/"},
116
116
  "@id" => "ex:Sub1",
@@ -128,7 +128,7 @@ describe JSON::LD::API do
128
128
  "ex:prop2" => "Property 2"
129
129
  },
130
130
  ],
131
- :output => {
131
+ output: {
132
132
  "@context" => {"ex" => "http://example.org/"},
133
133
  "@graph" => [{
134
134
  "@id" => "ex:Sub3",
@@ -138,14 +138,14 @@ describe JSON::LD::API do
138
138
  }
139
139
  },
140
140
  "embed matched frames" => {
141
- :frame => {
141
+ frame: {
142
142
  "@context" => {"ex" => "http://example.org/"},
143
143
  "@type" => "ex:Type1",
144
144
  "ex:includes" => {
145
145
  "@type" => "ex:Type2"
146
146
  }
147
147
  },
148
- :input => [
148
+ input: [
149
149
  {
150
150
  "@context" => {"ex" => "http://example.org/"},
151
151
  "@id" => "ex:Sub1",
@@ -159,7 +159,7 @@ describe JSON::LD::API do
159
159
  "ex:includes" => {"@id" => "ex:Sub1"}
160
160
  },
161
161
  ],
162
- :output =>{
162
+ output:{
163
163
  "@context" => {"ex" => "http://example.org/"},
164
164
  "@graph" => [{
165
165
  "@id" => "ex:Sub1",
@@ -173,11 +173,11 @@ describe JSON::LD::API do
173
173
  }
174
174
  },
175
175
  "multiple matches" => {
176
- :frame => {
176
+ frame: {
177
177
  "@context" => {"ex" => "http://example.org/"},
178
178
  "@type" => "ex:Type1"
179
179
  },
180
- :input => [
180
+ input: [
181
181
  {
182
182
  "@context" => {"ex" => "http://example.org/"},
183
183
  "@id" => "ex:Sub1",
@@ -189,7 +189,7 @@ describe JSON::LD::API do
189
189
  "@type" => "ex:Type1"
190
190
  },
191
191
  ],
192
- :output => {
192
+ output: {
193
193
  "@context" => {"ex" => "http://example.org/"},
194
194
  "@graph" => [
195
195
  {
@@ -204,12 +204,12 @@ describe JSON::LD::API do
204
204
  }
205
205
  },
206
206
  "non-existent framed properties create null property" => {
207
- :frame => {
207
+ frame: {
208
208
  "@context" => {"ex" => "http://example.org/"},
209
209
  "@type" => "ex:Type1",
210
210
  "ex:null" => []
211
211
  },
212
- :input => [
212
+ input: [
213
213
  {
214
214
  "@context" => {"ex" => "http://example.org/"},
215
215
  "@id" => "ex:Sub1",
@@ -218,7 +218,7 @@ describe JSON::LD::API do
218
218
  "ex:prop2" => {"@id" => "ex:Obj1"}
219
219
  }
220
220
  ],
221
- :output => {
221
+ output: {
222
222
  "@context" => {"ex" => "http://example.org/"},
223
223
  "@graph" => [{
224
224
  "@id" => "ex:Sub1",
@@ -230,12 +230,12 @@ describe JSON::LD::API do
230
230
  }
231
231
  },
232
232
  "non-existent framed properties create default property" => {
233
- :frame => {
233
+ frame: {
234
234
  "@context" => {"ex" => "http://example.org/", "ex:null" => {"@container" => "@set"}},
235
235
  "@type" => "ex:Type1",
236
236
  "ex:null" => [{"@default" => "foo"}]
237
237
  },
238
- :input => [
238
+ input: [
239
239
  {
240
240
  "@context" => {"ex" => "http://example.org/"},
241
241
  "@id" => "ex:Sub1",
@@ -244,7 +244,7 @@ describe JSON::LD::API do
244
244
  "ex:prop2" => {"@id" => "ex:Obj1"}
245
245
  }
246
246
  ],
247
- :output => {
247
+ output: {
248
248
  "@context" => {"ex" => "http://example.org/", "ex:null" => {"@container" => "@set"}},
249
249
  "@graph" => [{
250
250
  "@id" => "ex:Sub1",
@@ -256,11 +256,11 @@ describe JSON::LD::API do
256
256
  }
257
257
  },
258
258
  "mixed content" => {
259
- :frame => {
259
+ frame: {
260
260
  "@context" => {"ex" => "http://example.org/"},
261
261
  "ex:mixed" => {"@embed" => false}
262
262
  },
263
- :input => [
263
+ input: [
264
264
  {
265
265
  "@context" => {"ex" => "http://example.org/"},
266
266
  "@id" => "ex:Sub1",
@@ -270,7 +270,7 @@ describe JSON::LD::API do
270
270
  ]
271
271
  }
272
272
  ],
273
- :output => {
273
+ output: {
274
274
  "@context" => {"ex" => "http://example.org/"},
275
275
  "@graph" => [{
276
276
  "@id" => "ex:Sub1",
@@ -282,11 +282,11 @@ describe JSON::LD::API do
282
282
  }
283
283
  },
284
284
  "no embedding" => {
285
- :frame => {
285
+ frame: {
286
286
  "@context" => {"ex" => "http://example.org/"},
287
287
  "ex:embed" => {"@embed" => false}
288
288
  },
289
- :input => [
289
+ input: [
290
290
  {
291
291
  "@context" => {"ex" => "http://example.org/"},
292
292
  "@id" => "ex:Sub1",
@@ -296,7 +296,7 @@ describe JSON::LD::API do
296
296
  }
297
297
  }
298
298
  ],
299
- :output => {
299
+ output: {
300
300
  "@context" => {"ex" => "http://example.org/"},
301
301
  "@graph" => [{
302
302
  "@id" => "ex:Sub1",
@@ -305,11 +305,11 @@ describe JSON::LD::API do
305
305
  }
306
306
  },
307
307
  "mixed list" => {
308
- :frame => {
308
+ frame: {
309
309
  "@context" => {"ex" => "http://example.org/"},
310
310
  "ex:mixedlist" => {}
311
311
  },
312
- :input => {
312
+ input: {
313
313
  "@context" => {"ex" => "http://example.org/"},
314
314
  "@id" => "ex:Sub1",
315
315
  "@type" => "ex:Type1",
@@ -321,7 +321,7 @@ describe JSON::LD::API do
321
321
  "literal1"
322
322
  ]}
323
323
  },
324
- :output => {
324
+ output: {
325
325
  "@context" => {"ex" => "http://example.org/"},
326
326
  "@graph" => [{
327
327
  "@id" => "ex:Sub1",
@@ -337,7 +337,7 @@ describe JSON::LD::API do
337
337
  }
338
338
  },
339
339
  "presentation example" => {
340
- :frame => {
340
+ frame: {
341
341
  "@context" => {
342
342
  "primaryTopic" => {"@id" => "http://xmlns.com/foaf/0.1/primaryTopic","@type" => "@id"},
343
343
  "sameAs" => {"@id" => "http://www.w3.org/2002/07/owl#sameAs","@type" => "@id"},
@@ -347,7 +347,7 @@ describe JSON::LD::API do
347
347
  "sameAs" => {}
348
348
  }
349
349
  },
350
- :input => [
350
+ input: [
351
351
  {
352
352
  "@id" => "http://en.wikipedia.org/wiki/Linked_Data",
353
353
  "http://xmlns.com/foaf/0.1/primaryTopic" => [{"@id" => "http://dbpedia.org/resource/Linked_Data"}]
@@ -366,7 +366,7 @@ describe JSON::LD::API do
366
366
  "http://www.w3.org/2002/07/owl#sameAs" => [{"@id" => "http://dbpedia.org/resource/Linked_Data"}]
367
367
  }
368
368
  ],
369
- :output => {
369
+ output: {
370
370
  "@context" => {
371
371
  "primaryTopic" => {
372
372
  "@id" => "http://xmlns.com/foaf/0.1/primaryTopic",
@@ -390,7 +390,7 @@ describe JSON::LD::API do
390
390
  }
391
391
  },
392
392
  "microdata manifest" => {
393
- :frame => {
393
+ frame: {
394
394
  "@context" => {
395
395
  "xsd" => "http://www.w3.org/2001/XMLSchema#",
396
396
  "rdfs" => "http://www.w3.org/2000/01/rdf-schema#",
@@ -413,7 +413,7 @@ describe JSON::LD::API do
413
413
  }
414
414
  }]
415
415
  },
416
- :input => {
416
+ input: {
417
417
  "@context" => {
418
418
  "md" => "http://www.w3.org/ns/md#",
419
419
  "mf" => "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#",
@@ -449,7 +449,7 @@ describe JSON::LD::API do
449
449
  }
450
450
  ]
451
451
  },
452
- :output => {
452
+ output: {
453
453
  "@context" => {
454
454
  "xsd" => "http://www.w3.org/2001/XMLSchema#",
455
455
  "rdfs" => "http://www.w3.org/2000/01/rdf-schema#",
@@ -503,7 +503,7 @@ describe JSON::LD::API do
503
503
  it title do
504
504
  @debug = []
505
505
  begin
506
- jld = JSON::LD::API.frame(params[:input], params[:frame], :debug => @debug)
506
+ jld = JSON::LD::API.frame(params[:input], params[:frame], debug: @debug)
507
507
  expect(jld).to produce(params[:output], @debug)
508
508
  rescue JSON::LD::JsonLdError, JSON::LD::JsonLdError, JSON::LD::InvalidFrame => e
509
509
  fail("#{e.class}: #{e.message}\n" +
@@ -516,14 +516,14 @@ describe JSON::LD::API do
516
516
  describe "@reverse", skip:true do
517
517
  {
518
518
  "embed matched frames with @reverse" => {
519
- :frame => {
519
+ frame: {
520
520
  "@context" => {"ex" => "http://example.org/"},
521
521
  "@type" => "ex:Type1",
522
522
  "@reverse" => {
523
523
  "ex:includes" => {}
524
524
  }
525
525
  },
526
- :input => [
526
+ input: [
527
527
  {
528
528
  "@context" => {"ex" => "http://example.org/"},
529
529
  "@id" => "ex:Sub1",
@@ -536,7 +536,7 @@ describe JSON::LD::API do
536
536
  "ex:includes" => {"@id" => "ex:Sub1"}
537
537
  },
538
538
  ],
539
- :output =>{
539
+ output:{
540
540
  "@context" => {"ex" => "http://example.org/"},
541
541
  "@graph" => [{
542
542
  "@id" => "ex:Sub1",
@@ -555,7 +555,7 @@ describe JSON::LD::API do
555
555
  it title do
556
556
  @debug = []
557
557
  begin
558
- jld = JSON::LD::API.frame(params[:input], params[:frame], :debug => @debug)
558
+ jld = JSON::LD::API.frame(params[:input], params[:frame], debug: @debug)
559
559
  expect(jld).to produce(params[:output], @debug)
560
560
  rescue JSON::LD::JsonLdError, JSON::LD::JsonLdError, JSON::LD::InvalidFrame => e
561
561
  fail("#{e.class}: #{e.message}\n" +