json-ld 3.1.4 → 3.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +131 -48
- data/VERSION +1 -1
- data/bin/jsonld +31 -32
- data/lib/json/ld.rb +5 -2
- data/lib/json/ld/api.rb +35 -16
- data/lib/json/ld/compact.rb +41 -29
- data/lib/json/ld/conneg.rb +1 -1
- data/lib/json/ld/context.rb +51 -59
- data/lib/json/ld/expand.rb +72 -16
- data/lib/json/ld/extensions.rb +4 -4
- data/lib/json/ld/flatten.rb +137 -9
- data/lib/json/ld/format.rb +28 -8
- data/lib/json/ld/frame.rb +8 -8
- data/lib/json/ld/from_rdf.rb +46 -16
- data/lib/json/ld/reader.rb +2 -1
- data/lib/json/ld/streaming_reader.rb +5 -5
- data/lib/json/ld/streaming_writer.rb +4 -4
- data/lib/json/ld/to_rdf.rb +11 -7
- data/lib/json/ld/utils.rb +13 -13
- data/lib/json/ld/writer.rb +12 -5
- data/spec/api_spec.rb +1 -1
- data/spec/compact_spec.rb +207 -3
- data/spec/context_spec.rb +0 -2
- data/spec/expand_spec.rb +631 -0
- data/spec/flatten_spec.rb +517 -1
- data/spec/from_rdf_spec.rb +181 -0
- data/spec/matchers.rb +1 -1
- data/spec/rdfstar_spec.rb +25 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/suite_flatten_spec.rb +4 -0
- data/spec/suite_frame_spec.rb +7 -0
- data/spec/suite_helper.rb +13 -7
- data/spec/suite_to_rdf_spec.rb +1 -0
- data/spec/to_rdf_spec.rb +209 -3
- data/spec/writer_spec.rb +193 -0
- metadata +66 -64
data/spec/writer_spec.rb
CHANGED
@@ -189,6 +189,199 @@ describe JSON::LD::Writer do
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
context "RDF-star" do
|
193
|
+
{
|
194
|
+
"subject-iii": {
|
195
|
+
input: RDF::Statement(
|
196
|
+
RDF::Statement(
|
197
|
+
RDF::URI('http://example/s1'),
|
198
|
+
RDF::URI('http://example/p1'),
|
199
|
+
RDF::URI('http://example/o1')),
|
200
|
+
RDF::URI('http://example/p'),
|
201
|
+
RDF::URI('http://example/o')),
|
202
|
+
output: %({
|
203
|
+
"@context": {"ex": "http://example/"},
|
204
|
+
"@id": {
|
205
|
+
"@id": "ex:s1",
|
206
|
+
"ex:p1": {"@id": "ex:o1"}
|
207
|
+
},
|
208
|
+
"ex:p": {"@id": "ex:o"}
|
209
|
+
})
|
210
|
+
},
|
211
|
+
"subject-iib": {
|
212
|
+
input: RDF::Statement(
|
213
|
+
RDF::Statement(
|
214
|
+
RDF::URI('http://example/s1'),
|
215
|
+
RDF::URI('http://example/p1'),
|
216
|
+
RDF::Node.new('o1')),
|
217
|
+
RDF::URI('http://example/p'),
|
218
|
+
RDF::URI('http://example/o')),
|
219
|
+
output: %({
|
220
|
+
"@context": {"ex": "http://example/"},
|
221
|
+
"@id": {
|
222
|
+
"@id": "ex:s1",
|
223
|
+
"ex:p1": {"@id": "_:o1"}
|
224
|
+
},
|
225
|
+
"ex:p": {"@id": "ex:o"}
|
226
|
+
})
|
227
|
+
},
|
228
|
+
"subject-iil": {
|
229
|
+
input: RDF::Statement(
|
230
|
+
RDF::Statement(
|
231
|
+
RDF::URI('http://example/s1'),
|
232
|
+
RDF::URI('http://example/p1'),
|
233
|
+
RDF::Literal('o1')),
|
234
|
+
RDF::URI('http://example/p'),
|
235
|
+
RDF::URI('http://example/o')),
|
236
|
+
output: %({
|
237
|
+
"@context": {"ex": "http://example/"},
|
238
|
+
"@id": {
|
239
|
+
"@id": "ex:s1",
|
240
|
+
"ex:p1": "o1"
|
241
|
+
},
|
242
|
+
"ex:p": {"@id": "ex:o"}
|
243
|
+
})
|
244
|
+
},
|
245
|
+
"subject-bii": {
|
246
|
+
input: RDF::Statement(
|
247
|
+
RDF::Statement(
|
248
|
+
RDF::Node('s1'),
|
249
|
+
RDF::URI('http://example/p1'),
|
250
|
+
RDF::URI('http://example/o1')),
|
251
|
+
RDF::URI('http://example/p'),
|
252
|
+
RDF::URI('http://example/o')),
|
253
|
+
output: %({
|
254
|
+
"@context": {"ex": "http://example/"},
|
255
|
+
"@id": {
|
256
|
+
"@id": "_:s1",
|
257
|
+
"ex:p1": {"@id": "ex:o1"}
|
258
|
+
},
|
259
|
+
"ex:p": {"@id": "ex:o"}
|
260
|
+
})
|
261
|
+
},
|
262
|
+
"subject-bib": {
|
263
|
+
input: RDF::Statement(
|
264
|
+
RDF::Statement(
|
265
|
+
RDF::Node('s1'),
|
266
|
+
RDF::URI('http://example/p1'),
|
267
|
+
RDF::Node.new('o1')),
|
268
|
+
RDF::URI('http://example/p'), RDF::URI('http://example/o')),
|
269
|
+
output: %({
|
270
|
+
"@context": {"ex": "http://example/"},
|
271
|
+
"@id": {
|
272
|
+
"@id": "_:s1",
|
273
|
+
"ex:p1": {"@id": "_:o1"}
|
274
|
+
},
|
275
|
+
"ex:p": {"@id": "ex:o"}
|
276
|
+
})
|
277
|
+
},
|
278
|
+
"subject-bil": {
|
279
|
+
input: RDF::Statement(
|
280
|
+
RDF::Statement(
|
281
|
+
RDF::Node('s1'),
|
282
|
+
RDF::URI('http://example/p1'),
|
283
|
+
RDF::Literal('o1')),
|
284
|
+
RDF::URI('http://example/p'),
|
285
|
+
RDF::URI('http://example/o')),
|
286
|
+
output: %({
|
287
|
+
"@context": {"ex": "http://example/"},
|
288
|
+
"@id": {
|
289
|
+
"@id": "_:s1",
|
290
|
+
"ex:p1": "o1"
|
291
|
+
},
|
292
|
+
"ex:p": {"@id": "ex:o"}
|
293
|
+
})
|
294
|
+
},
|
295
|
+
"object-iii": {
|
296
|
+
input: RDF::Statement(
|
297
|
+
RDF::URI('http://example/s'),
|
298
|
+
RDF::URI('http://example/p'),
|
299
|
+
RDF::Statement(
|
300
|
+
RDF::URI('http://example/s1'),
|
301
|
+
RDF::URI('http://example/p1'),
|
302
|
+
RDF::URI('http://example/o1'))),
|
303
|
+
output: %({
|
304
|
+
"@context": {"ex": "http://example/"},
|
305
|
+
"@id": "ex:s",
|
306
|
+
"ex:p": {
|
307
|
+
"@id": {
|
308
|
+
"@id": "ex:s1",
|
309
|
+
"ex:p1": {"@id": "ex:o1"}
|
310
|
+
}
|
311
|
+
}
|
312
|
+
})
|
313
|
+
},
|
314
|
+
"object-iib": {
|
315
|
+
input: RDF::Statement(
|
316
|
+
RDF::URI('http://example/s'),
|
317
|
+
RDF::URI('http://example/p'),
|
318
|
+
RDF::Statement(
|
319
|
+
RDF::URI('http://example/s1'),
|
320
|
+
RDF::URI('http://example/p1'),
|
321
|
+
RDF::Node.new('o1'))),
|
322
|
+
output: %({
|
323
|
+
"@context": {"ex": "http://example/"},
|
324
|
+
"@id": "ex:s",
|
325
|
+
"ex:p": {
|
326
|
+
"@id": {
|
327
|
+
"@id": "ex:s1",
|
328
|
+
"ex:p1": {"@id": "_:o1"}
|
329
|
+
}
|
330
|
+
}
|
331
|
+
})
|
332
|
+
},
|
333
|
+
"object-iil": {
|
334
|
+
input: RDF::Statement(
|
335
|
+
RDF::URI('http://example/s'),
|
336
|
+
RDF::URI('http://example/p'),
|
337
|
+
RDF::Statement(
|
338
|
+
RDF::URI('http://example/s1'),
|
339
|
+
RDF::URI('http://example/p1'),
|
340
|
+
RDF::Literal('o1'))),
|
341
|
+
output: %({
|
342
|
+
"@context": {"ex": "http://example/"},
|
343
|
+
"@id": "ex:s",
|
344
|
+
"ex:p": {
|
345
|
+
"@id": {
|
346
|
+
"@id": "ex:s1",
|
347
|
+
"ex:p1": "o1"
|
348
|
+
}
|
349
|
+
}
|
350
|
+
})
|
351
|
+
},
|
352
|
+
"recursive-subject": {
|
353
|
+
input: RDF::Statement(
|
354
|
+
RDF::Statement(
|
355
|
+
RDF::Statement(
|
356
|
+
RDF::URI('http://example/s2'),
|
357
|
+
RDF::URI('http://example/p2'),
|
358
|
+
RDF::URI('http://example/o2')),
|
359
|
+
RDF::URI('http://example/p1'),
|
360
|
+
RDF::URI('http://example/o1')),
|
361
|
+
RDF::URI('http://example/p'),
|
362
|
+
RDF::URI('http://example/o')),
|
363
|
+
output: %({
|
364
|
+
"@context": {"ex": "http://example/"},
|
365
|
+
"@id": {
|
366
|
+
"@id": {
|
367
|
+
"@id": "ex:s2",
|
368
|
+
"ex:p2": {"@id": "ex:o2"}
|
369
|
+
},
|
370
|
+
"ex:p1": {"@id": "ex:o1"}
|
371
|
+
},
|
372
|
+
"ex:p": {"@id": "ex:o"}
|
373
|
+
})
|
374
|
+
},
|
375
|
+
}.each do |name, params|
|
376
|
+
it name do
|
377
|
+
graph = RDF::Graph.new {|g| g << params[:input]}
|
378
|
+
expect(
|
379
|
+
serialize(graph, rdfstar: true, prefixes: {ex: 'http://example/'})
|
380
|
+
).to produce_jsonld(JSON.parse(params[:output]), logger)
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
192
385
|
context "Writes fromRdf tests to isomorphic graph" do
|
193
386
|
require 'suite_helper'
|
194
387
|
m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}fromRdf-manifest.jsonld")
|
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.1.
|
4
|
+
version: 3.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -297,7 +297,7 @@ dependencies:
|
|
297
297
|
- !ruby/object:Gem::Version
|
298
298
|
version: '0.9'
|
299
299
|
description: JSON::LD parses and serializes JSON-LD into RDF and implements expansion,
|
300
|
-
compaction and framing API interfaces.
|
300
|
+
compaction and framing API interfaces for the Ruby RDF.rb library suite.
|
301
301
|
email: public-linked-json@w3.org
|
302
302
|
executables:
|
303
303
|
- jsonld
|
@@ -340,6 +340,7 @@ files:
|
|
340
340
|
- spec/frame_spec.rb
|
341
341
|
- spec/from_rdf_spec.rb
|
342
342
|
- spec/matchers.rb
|
343
|
+
- spec/rdfstar_spec.rb
|
343
344
|
- spec/reader_spec.rb
|
344
345
|
- spec/resource_spec.rb
|
345
346
|
- spec/spec_helper.rb
|
@@ -411,7 +412,7 @@ homepage: https://github.com/ruby-rdf/json-ld
|
|
411
412
|
licenses:
|
412
413
|
- Unlicense
|
413
414
|
metadata: {}
|
414
|
-
post_install_message:
|
415
|
+
post_install_message:
|
415
416
|
rdoc_options: []
|
416
417
|
require_paths:
|
417
418
|
- lib
|
@@ -426,85 +427,86 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
426
427
|
- !ruby/object:Gem::Version
|
427
428
|
version: '0'
|
428
429
|
requirements: []
|
429
|
-
rubygems_version: 3.
|
430
|
-
signing_key:
|
430
|
+
rubygems_version: 3.2.3
|
431
|
+
signing_key:
|
431
432
|
specification_version: 4
|
432
433
|
summary: JSON-LD reader/writer for Ruby.
|
433
434
|
test_files:
|
434
|
-
- spec/spec_helper.rb
|
435
|
-
- spec/matchers.rb
|
436
435
|
- spec/api_spec.rb
|
437
|
-
- spec/
|
436
|
+
- spec/compact_spec.rb
|
437
|
+
- spec/conneg_spec.rb
|
438
438
|
- spec/context_spec.rb
|
439
|
+
- spec/expand_spec.rb
|
440
|
+
- spec/flatten_spec.rb
|
441
|
+
- spec/format_spec.rb
|
442
|
+
- spec/frame_spec.rb
|
439
443
|
- spec/from_rdf_spec.rb
|
440
|
-
- spec/
|
444
|
+
- spec/matchers.rb
|
445
|
+
- spec/rdfstar_spec.rb
|
441
446
|
- spec/reader_spec.rb
|
442
|
-
- spec/streaming_writer_spec.rb
|
443
447
|
- spec/resource_spec.rb
|
444
|
-
- spec/
|
445
|
-
- spec/
|
446
|
-
- spec/
|
447
|
-
- spec/frame_spec.rb
|
448
|
-
- spec/to_rdf_spec.rb
|
449
|
-
- spec/conneg_spec.rb
|
450
|
-
- spec/support/extensions.rb
|
451
|
-
- spec/suite_html_spec.rb
|
452
|
-
- spec/flatten_spec.rb
|
453
|
-
- spec/suite_frame_spec.rb
|
448
|
+
- spec/spec_helper.rb
|
449
|
+
- spec/streaming_reader_spec.rb
|
450
|
+
- spec/streaming_writer_spec.rb
|
454
451
|
- spec/suite_compact_spec.rb
|
455
|
-
- spec/expand_spec.rb
|
456
452
|
- spec/suite_expand_spec.rb
|
457
453
|
- spec/suite_flatten_spec.rb
|
458
|
-
- spec/
|
454
|
+
- spec/suite_frame_spec.rb
|
455
|
+
- spec/suite_from_rdf_spec.rb
|
456
|
+
- spec/suite_helper.rb
|
457
|
+
- spec/suite_html_spec.rb
|
459
458
|
- spec/suite_http_spec.rb
|
460
|
-
- spec/
|
459
|
+
- spec/suite_remote_doc_spec.rb
|
460
|
+
- spec/suite_to_rdf_spec.rb
|
461
|
+
- spec/support/extensions.rb
|
462
|
+
- spec/to_rdf_spec.rb
|
461
463
|
- spec/writer_spec.rb
|
462
|
-
- spec/test-files/test-
|
463
|
-
- spec/test-files/test-
|
464
|
-
- spec/test-files/test-
|
465
|
-
- spec/test-files/test-
|
466
|
-
- spec/test-files/test-3-rdf.ttl
|
467
|
-
- spec/test-files/test-5-compacted.json
|
468
|
-
- spec/test-files/test-9-expanded.json
|
469
|
-
- spec/test-files/test-8-input.json
|
470
|
-
- spec/test-files/test-2-compacted.json
|
471
|
-
- spec/test-files/test-8-compacted.json
|
472
|
-
- spec/test-files/test-7-expanded.json
|
473
|
-
- spec/test-files/test-1-rdf.ttl
|
474
|
-
- spec/test-files/test-7-context.json
|
475
|
-
- spec/test-files/test-3-expanded.json
|
476
|
-
- spec/test-files/test-8-rdf.ttl
|
464
|
+
- spec/test-files/test-1-compacted.json
|
465
|
+
- spec/test-files/test-1-context.json
|
466
|
+
- spec/test-files/test-1-expanded.json
|
467
|
+
- spec/test-files/test-1-input.json
|
477
468
|
- spec/test-files/test-1-normalized.json
|
469
|
+
- spec/test-files/test-1-rdf.ttl
|
470
|
+
- spec/test-files/test-2-compacted.json
|
471
|
+
- spec/test-files/test-2-context.json
|
472
|
+
- spec/test-files/test-2-expanded.json
|
478
473
|
- spec/test-files/test-2-input.json
|
479
|
-
- spec/test-files/test-
|
480
|
-
- spec/test-files/test-
|
481
|
-
- spec/test-files/test-
|
482
|
-
- spec/test-files/test-
|
483
|
-
- spec/test-files/test-
|
484
|
-
- spec/test-files/test-
|
485
|
-
- spec/test-files/test-
|
486
|
-
- spec/test-files/test-
|
474
|
+
- spec/test-files/test-2-normalized.json
|
475
|
+
- spec/test-files/test-2-rdf.ttl
|
476
|
+
- spec/test-files/test-3-compacted.json
|
477
|
+
- spec/test-files/test-3-context.json
|
478
|
+
- spec/test-files/test-3-expanded.json
|
479
|
+
- spec/test-files/test-3-input.json
|
480
|
+
- spec/test-files/test-3-normalized.json
|
481
|
+
- spec/test-files/test-3-rdf.ttl
|
482
|
+
- spec/test-files/test-4-compacted.json
|
487
483
|
- spec/test-files/test-4-context.json
|
484
|
+
- spec/test-files/test-4-expanded.json
|
488
485
|
- spec/test-files/test-4-input.json
|
489
|
-
- spec/test-files/test-
|
490
|
-
- spec/test-files/test-5-
|
491
|
-
- spec/test-files/test-
|
492
|
-
- spec/test-files/test-9-input.json
|
493
|
-
- spec/test-files/test-8-framed.json
|
486
|
+
- spec/test-files/test-4-rdf.ttl
|
487
|
+
- spec/test-files/test-5-compacted.json
|
488
|
+
- spec/test-files/test-5-context.json
|
494
489
|
- spec/test-files/test-5-expanded.json
|
495
|
-
- spec/test-files/test-
|
496
|
-
- spec/test-files/test-
|
490
|
+
- spec/test-files/test-5-input.json
|
491
|
+
- spec/test-files/test-5-rdf.ttl
|
492
|
+
- spec/test-files/test-6-compacted.json
|
493
|
+
- spec/test-files/test-6-context.json
|
497
494
|
- spec/test-files/test-6-expanded.json
|
498
|
-
- spec/test-files/test-2-context.json
|
499
|
-
- spec/test-files/test-5-context.json
|
500
|
-
- spec/test-files/test-1-input.json
|
501
|
-
- spec/test-files/test-4-rdf.ttl
|
502
|
-
- spec/test-files/test-8-frame.json
|
503
495
|
- spec/test-files/test-6-input.json
|
504
|
-
- spec/test-files/test-8-context.json
|
505
|
-
- spec/test-files/test-8-expanded.json
|
506
496
|
- spec/test-files/test-6-rdf.ttl
|
497
|
+
- spec/test-files/test-7-compacted.json
|
498
|
+
- spec/test-files/test-7-context.json
|
499
|
+
- spec/test-files/test-7-expanded.json
|
500
|
+
- spec/test-files/test-7-input.json
|
507
501
|
- spec/test-files/test-7-rdf.ttl
|
508
|
-
- spec/test-files/test-
|
509
|
-
- spec/test-files/test-
|
502
|
+
- spec/test-files/test-8-compacted.json
|
503
|
+
- spec/test-files/test-8-context.json
|
504
|
+
- spec/test-files/test-8-expanded.json
|
505
|
+
- spec/test-files/test-8-frame.json
|
506
|
+
- spec/test-files/test-8-framed.json
|
507
|
+
- spec/test-files/test-8-input.json
|
508
|
+
- spec/test-files/test-8-rdf.ttl
|
509
|
+
- spec/test-files/test-9-compacted.json
|
510
510
|
- spec/test-files/test-9-context.json
|
511
|
+
- spec/test-files/test-9-expanded.json
|
512
|
+
- spec/test-files/test-9-input.json
|