json-ld 3.1.1 → 3.1.6

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.
@@ -13,7 +13,7 @@ describe JSON::LD do
13
13
  t.options[:ordered] = false
14
14
  if %w(#t0068).include?(t.property('@id'))
15
15
  expect{t.run self}.to write("[DEPRECATION]").to(:error)
16
- elsif %w(#t0005 #tpr34 #tpr35 #tpr36 #tpr37 #t0119 #t0120).include?(t.property('@id'))
16
+ elsif %w(#t0005 #tpr34 #tpr35 #tpr36 #tpr37 #tpr38 #tpr39 #t0119 #t0120).include?(t.property('@id'))
17
17
  expect{t.run self}.to write("beginning with '@' are reserved for future use").to(:error)
18
18
  else
19
19
  expect {t.run self}.not_to write.to(:error)
@@ -24,7 +24,7 @@ describe JSON::LD do
24
24
  t.options[:ordered] = true
25
25
  if %w(#t0068).include?(t.property('@id'))
26
26
  expect{t.run self}.to write("[DEPRECATION]").to(:error)
27
- elsif %w(#t0005 #tpr34 #tpr35 #tpr36 #tpr37 #t0119 #t0120).include?(t.property('@id'))
27
+ elsif %w(#t0005 #tpr34 #tpr35 #tpr36 #tpr37 #tpr38 #tpr39 #t0119 #t0120).include?(t.property('@id'))
28
28
  expect{t.run self}.to write("beginning with '@' are reserved for future use").to(:error)
29
29
  else
30
30
  expect {t.run self}.not_to write.to(:error)
@@ -13,7 +13,6 @@ describe JSON::LD do
13
13
  end
14
14
 
15
15
  specify "#{t.property('@id')}: #{t.name} ordered#{' (negative test)' unless t.positiveTest?}" do
16
- pending "Ordered version of in03" if %w(#tin03).include?(t.property('@id'))
17
16
  t.options[:ordered] = true
18
17
  expect {t.run self}.not_to write.to(:error)
19
18
  end
@@ -6,6 +6,7 @@ module RDF::Util
6
6
  LOCAL_PATHS = {
7
7
  "https://w3c.github.io/json-ld-api/tests/" => ::File.expand_path("../json-ld-api/tests", __FILE__) + '/',
8
8
  "https://w3c.github.io/json-ld-framing/tests/" => ::File.expand_path("../json-ld-framing/tests", __FILE__) + '/',
9
+ "https://w3c.github.io/json-ld-streaming/tests/" => ::File.expand_path("../json-ld-streaming/tests", __FILE__) + '/',
9
10
  "file:" => ""
10
11
  }
11
12
 
@@ -74,6 +75,7 @@ module Fixtures
74
75
  module SuiteTest
75
76
  SUITE = RDF::URI("https://w3c.github.io/json-ld-api/tests/")
76
77
  FRAME_SUITE = RDF::URI("https://w3c.github.io/json-ld-framing/tests/")
78
+ STREAM_SUITE = RDF::URI("https://w3c.github.io/json-ld-streaming/tests/")
77
79
 
78
80
  class Manifest < JSON::LD::Resource
79
81
  attr_accessor :manifest_url
@@ -182,6 +184,10 @@ module Fixtures
182
184
  def positiveTest?
183
185
  property('@type').to_s.include?('Positive')
184
186
  end
187
+
188
+ def syntaxTest?
189
+ property('@type').to_s.include?('Syntax')
190
+ end
185
191
 
186
192
 
187
193
  # Execute the test
@@ -224,14 +230,14 @@ module Fixtures
224
230
  JSON::LD::API.fromRdf(repo, logger: logger, **options)
225
231
  when "jld:ToRDFTest"
226
232
  repo = RDF::Repository.new
227
- JSON::LD::API.toRdf(input_loc, logger: logger, **options) do |statement|
228
- # To properly compare values of rdf:language and i18n datatypes, normalize to lower case
229
- if statement.predicate == RDF.to_uri + 'language'
230
- statement.object = RDF::Literal(statement.object.to_s.downcase) if statement.object.literal?
231
- elsif statement.object.literal? && statement.object.datatype.to_s.start_with?('https://www.w3.org/ns/i18n#')
232
- statement.object.datatype = RDF::URI(statement.object.datatype.to_s.downcase)
233
+ if manifest_url.to_s.include?('stream')
234
+ JSON::LD::Reader.open(input_loc, stream: true, logger: logger, **options) do |statement|
235
+ repo << statement
236
+ end
237
+ else
238
+ JSON::LD::API.toRdf(input_loc, logger: logger, **options) do |statement|
239
+ repo << statement
233
240
  end
234
- repo << statement
235
241
  end
236
242
  logger.info "nq: #{repo.map(&:to_nquads)}"
237
243
  repo
@@ -316,7 +322,11 @@ module Fixtures
316
322
  raise "Expected status #{t.property('expectErrorCode')}, not #{last_response.status}"
317
323
  end
318
324
  when "jld:ToRDFTest"
319
- JSON::LD::API.toRdf(t.input_loc, logger: logger, **options) {}
325
+ if t.manifest_url.to_s.include?('stream')
326
+ JSON::LD::Reader.open(t.input_loc, stream: true, logger: logger, **options).each_statement {}
327
+ else
328
+ JSON::LD::API.toRdf(t.input_loc, logger: logger, **options) {}
329
+ end
320
330
  else
321
331
  success("Unknown test type: #{testType}")
322
332
  end
@@ -9,11 +9,12 @@ describe JSON::LD do
9
9
  m.entries.each do |t|
10
10
  specify "#{t.property('@id')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
11
11
  pending "Generalized RDF" if t.options[:produceGeneralizedRdf]
12
+ pending "RDF*" if t.property('@id') == '#te122'
12
13
  if %w(#t0118).include?(t.property('@id'))
13
14
  expect {t.run self}.to write(/Statement .* is invalid/).to(:error)
14
15
  elsif %w(#te075).include?(t.property('@id'))
15
16
  expect {t.run self}.to write(/is invalid/).to(:error)
16
- elsif %w(#te005 #tpr34 #tpr35 #tpr36 #tpr37 #te119 #te120).include?(t.property('@id'))
17
+ elsif %w(#te005 #tpr34 #tpr35 #tpr36 #tpr37 #tpr38 #tpr39 #te119 #te120).include?(t.property('@id'))
17
18
  expect {t.run self}.to write("beginning with '@' are reserved for future use").to(:error)
18
19
  elsif %w(#te068).include?(t.property('@id'))
19
20
  expect {t.run self}.to write("[DEPRECATION]").to(:error)
@@ -1175,6 +1175,212 @@ describe JSON::LD::API do
1175
1175
  end
1176
1176
  end
1177
1177
 
1178
+ context "JSON-LD*" do
1179
+ {
1180
+ "node with embedded subject without rdfstar option": {
1181
+ input: %({
1182
+ "@id": {
1183
+ "@id": "ex:rei",
1184
+ "ex:prop": "value"
1185
+ },
1186
+ "ex:prop": "value2"
1187
+ }),
1188
+ exception: JSON::LD::JsonLdError::InvalidIdValue
1189
+ },
1190
+ }.each do |title, params|
1191
+ it(title) {run_to_rdf params}
1192
+ end
1193
+
1194
+ {
1195
+ "node with embedded subject having no @id": {
1196
+ input: %({
1197
+ "@id": {
1198
+ "ex:prop": "value"
1199
+ },
1200
+ "ex:prop": "value2"
1201
+ }),
1202
+ expected: %(
1203
+ <<_:b0 <ex:prop> "value">> <ex:prop> "value2" .
1204
+ ),
1205
+ },
1206
+ "node with embedded subject having IRI @id": {
1207
+ input: %({
1208
+ "@id": {
1209
+ "@id": "ex:rei",
1210
+ "ex:prop": "value"
1211
+ },
1212
+ "ex:prop": "value2"
1213
+ }),
1214
+ expected: %(
1215
+ <<<ex:rei> <ex:prop> "value">> <ex:prop> "value2" .
1216
+ ),
1217
+ },
1218
+ "node with embedded subject having BNode @id": {
1219
+ input: %({
1220
+ "@id": {
1221
+ "@id": "_:rei",
1222
+ "ex:prop": "value"
1223
+ },
1224
+ "ex:prop": "value2"
1225
+ }),
1226
+ expected: %(
1227
+ <<_:b0 <ex:prop> "value">> <ex:prop> "value2" .
1228
+ ),
1229
+ },
1230
+ "node with embedded subject having a type": {
1231
+ input: %({
1232
+ "@id": {
1233
+ "@id": "ex:rei",
1234
+ "@type": "ex:Type"
1235
+ },
1236
+ "ex:prop": "value2"
1237
+ }),
1238
+ expected: %(
1239
+ <<<ex:rei> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <ex:Type>>> <ex:prop> "value2" .
1240
+ ),
1241
+ },
1242
+ "node with embedded subject having an IRI value": {
1243
+ input: %({
1244
+ "@id": {
1245
+ "@id": "ex:rei",
1246
+ "ex:prop": {"@id": "ex:value"}
1247
+ },
1248
+ "ex:prop": "value2"
1249
+ }),
1250
+ expected: %(
1251
+ <<<ex:rei> <ex:prop> <ex:value>>> <ex:prop> "value2" .
1252
+ ),
1253
+ },
1254
+ "node with embedded subject having an BNode value": {
1255
+ input: %({
1256
+ "@id": {
1257
+ "@id": "ex:rei",
1258
+ "ex:prop": {"@id": "_:value"}
1259
+ },
1260
+ "ex:prop": "value2"
1261
+ }),
1262
+ expected: %(
1263
+ <<<ex:rei> <ex:prop> _:b0>> <ex:prop> "value2" .
1264
+ ),
1265
+ },
1266
+ "node with recursive embedded subject": {
1267
+ input: %({
1268
+ "@id": {
1269
+ "@id": {
1270
+ "@id": "ex:rei",
1271
+ "ex:prop": "value3"
1272
+ },
1273
+ "ex:prop": "value"
1274
+ },
1275
+ "ex:prop": "value2"
1276
+ }),
1277
+ expected: %(
1278
+ <<<<<ex:rei> <ex:prop> "value3">> <ex:prop> "value">> <ex:prop> "value2" .
1279
+ ),
1280
+ },
1281
+ "illegal node with subject having no property": {
1282
+ input: %({
1283
+ "@id": {
1284
+ "@id": "ex:rei"
1285
+ },
1286
+ "ex:prop": "value3"
1287
+ }),
1288
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1289
+ },
1290
+ "illegal node with subject having multiple properties": {
1291
+ input: %({
1292
+ "@id": {
1293
+ "@id": "ex:rei",
1294
+ "ex:prop": ["value1", "value2"]
1295
+ },
1296
+ "ex:prop": "value3"
1297
+ }),
1298
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1299
+ },
1300
+ "illegal node with subject having multiple types": {
1301
+ input: %({
1302
+ "@id": {
1303
+ "@id": "ex:rei",
1304
+ "@type": ["ex:Type1", "ex:Type2"]
1305
+ },
1306
+ "ex:prop": "value3"
1307
+ }),
1308
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1309
+ },
1310
+ "illegal node with subject having type and property": {
1311
+ input: %({
1312
+ "@id": {
1313
+ "@id": "ex:rei",
1314
+ "@type": "ex:Type",
1315
+ "ex:prop": "value"
1316
+ },
1317
+ "ex:prop": "value2"
1318
+ }),
1319
+ exception: JSON::LD::JsonLdError::InvalidEmbeddedNode
1320
+ },
1321
+ "node with embedded object": {
1322
+ input: %({
1323
+ "@id": "ex:subj",
1324
+ "ex:value": {
1325
+ "@id": {
1326
+ "@id": "ex:rei",
1327
+ "ex:prop": "value"
1328
+ }
1329
+ }
1330
+ }),
1331
+ expected: %(
1332
+ <ex:subj> <ex:value> <<<ex:rei> <ex:prop> "value">> .
1333
+ ),
1334
+ },
1335
+ "node with embedded object having properties": {
1336
+ input: %({
1337
+ "@id": "ex:subj",
1338
+ "ex:value": {
1339
+ "@id": {
1340
+ "@id": "ex:rei",
1341
+ "ex:prop": "value"
1342
+ },
1343
+ "ex:prop": "value2"
1344
+ }
1345
+ }),
1346
+ expected: %(
1347
+ <ex:subj> <ex:value> <<<ex:rei> <ex:prop> "value">> .
1348
+ <<<ex:rei> <ex:prop> "value">> <ex:prop> "value2" .
1349
+ ),
1350
+ },
1351
+ "node with recursive embedded object": {
1352
+ input: %({
1353
+ "@id": "ex:subj",
1354
+ "ex:value": {
1355
+ "@id": {
1356
+ "@id": {
1357
+ "@id": "ex:rei",
1358
+ "ex:prop": "value3"
1359
+ },
1360
+ "ex:prop": "value"
1361
+ },
1362
+ "ex:prop": "value2"
1363
+ }
1364
+ }),
1365
+ expected: %(
1366
+ <ex:subj> <ex:value> <<<<<ex:rei> <ex:prop> "value3">> <ex:prop> "value">> .
1367
+ <<<<<ex:rei> <ex:prop> "value3">> <ex:prop> "value">> <ex:prop> "value2" .
1368
+ ),
1369
+ },
1370
+ }.each do |title, params|
1371
+ context(title) do
1372
+ it "Generates statements" do
1373
+ output_graph = RDF::Graph.new {|g| g << RDF::NTriples::Reader.new(params[:expected], rdfstar: true)}
1374
+ run_to_rdf params.merge(rdfstar: true, output: output_graph)
1375
+ end if params[:expected]
1376
+
1377
+ it "Exception" do
1378
+ run_to_rdf params.merge(rdfstar: true)
1379
+ end if params[:exception]
1380
+ end
1381
+ end
1382
+ end
1383
+
1178
1384
  context "exceptions" do
1179
1385
  {
1180
1386
  "Invalid subject" => {
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.1
4
+ version: 3.1.6
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: 2020-02-19 00:00:00.000000000 Z
11
+ date: 2020-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -324,6 +324,7 @@ files:
324
324
  - lib/json/ld/html/rexml.rb
325
325
  - lib/json/ld/reader.rb
326
326
  - lib/json/ld/resource.rb
327
+ - lib/json/ld/streaming_reader.rb
327
328
  - lib/json/ld/streaming_writer.rb
328
329
  - lib/json/ld/to_rdf.rb
329
330
  - lib/json/ld/utils.rb
@@ -342,6 +343,7 @@ files:
342
343
  - spec/reader_spec.rb
343
344
  - spec/resource_spec.rb
344
345
  - spec/spec_helper.rb
346
+ - spec/streaming_reader_spec.rb
345
347
  - spec/streaming_writer_spec.rb
346
348
  - spec/suite_compact_spec.rb
347
349
  - spec/suite_expand_spec.rb
@@ -409,7 +411,7 @@ homepage: https://github.com/ruby-rdf/json-ld
409
411
  licenses:
410
412
  - Unlicense
411
413
  metadata: {}
412
- post_install_message:
414
+ post_install_message:
413
415
  rdoc_options: []
414
416
  require_paths:
415
417
  - lib
@@ -424,84 +426,85 @@ required_rubygems_version: !ruby/object:Gem::Requirement
424
426
  - !ruby/object:Gem::Version
425
427
  version: '0'
426
428
  requirements: []
427
- rubygems_version: 3.1.2
428
- signing_key:
429
+ rubygems_version: 3.2.0.rc.2
430
+ signing_key:
429
431
  specification_version: 4
430
432
  summary: JSON-LD reader/writer for Ruby.
431
433
  test_files:
432
- - spec/spec_helper.rb
433
- - spec/matchers.rb
434
434
  - spec/api_spec.rb
435
- - spec/suite_from_rdf_spec.rb
435
+ - spec/compact_spec.rb
436
+ - spec/conneg_spec.rb
436
437
  - spec/context_spec.rb
438
+ - spec/expand_spec.rb
439
+ - spec/flatten_spec.rb
440
+ - spec/format_spec.rb
441
+ - spec/frame_spec.rb
437
442
  - spec/from_rdf_spec.rb
438
- - spec/suite_helper.rb
443
+ - spec/matchers.rb
439
444
  - spec/reader_spec.rb
440
- - spec/streaming_writer_spec.rb
441
445
  - spec/resource_spec.rb
442
- - spec/suite_to_rdf_spec.rb
443
- - spec/suite_remote_doc_spec.rb
444
- - spec/format_spec.rb
445
- - spec/frame_spec.rb
446
- - spec/to_rdf_spec.rb
447
- - spec/conneg_spec.rb
448
- - spec/support/extensions.rb
449
- - spec/suite_html_spec.rb
450
- - spec/flatten_spec.rb
451
- - spec/suite_frame_spec.rb
446
+ - spec/spec_helper.rb
447
+ - spec/streaming_reader_spec.rb
448
+ - spec/streaming_writer_spec.rb
452
449
  - spec/suite_compact_spec.rb
453
- - spec/expand_spec.rb
454
450
  - spec/suite_expand_spec.rb
455
451
  - spec/suite_flatten_spec.rb
456
- - spec/compact_spec.rb
452
+ - spec/suite_frame_spec.rb
453
+ - spec/suite_from_rdf_spec.rb
454
+ - spec/suite_helper.rb
455
+ - spec/suite_html_spec.rb
457
456
  - spec/suite_http_spec.rb
457
+ - spec/suite_remote_doc_spec.rb
458
+ - spec/suite_to_rdf_spec.rb
459
+ - spec/support/extensions.rb
460
+ - spec/to_rdf_spec.rb
458
461
  - spec/writer_spec.rb
459
- - spec/test-files/test-3-compacted.json
460
- - spec/test-files/test-2-rdf.ttl
461
- - spec/test-files/test-4-compacted.json
462
- - spec/test-files/test-5-input.json
463
- - spec/test-files/test-3-rdf.ttl
464
- - spec/test-files/test-5-compacted.json
465
- - spec/test-files/test-9-expanded.json
466
- - spec/test-files/test-8-input.json
467
- - spec/test-files/test-2-compacted.json
468
- - spec/test-files/test-8-compacted.json
469
- - spec/test-files/test-7-expanded.json
470
- - spec/test-files/test-1-rdf.ttl
471
- - spec/test-files/test-7-context.json
472
- - spec/test-files/test-3-expanded.json
473
- - spec/test-files/test-8-rdf.ttl
462
+ - spec/test-files/test-1-compacted.json
463
+ - spec/test-files/test-1-context.json
464
+ - spec/test-files/test-1-expanded.json
465
+ - spec/test-files/test-1-input.json
474
466
  - spec/test-files/test-1-normalized.json
467
+ - spec/test-files/test-1-rdf.ttl
468
+ - spec/test-files/test-2-compacted.json
469
+ - spec/test-files/test-2-context.json
470
+ - spec/test-files/test-2-expanded.json
475
471
  - spec/test-files/test-2-input.json
476
- - spec/test-files/test-7-compacted.json
477
- - spec/test-files/test-1-context.json
478
- - spec/test-files/test-6-context.json
479
- - spec/test-files/test-6-compacted.json
480
- - spec/test-files/test-7-input.json
481
- - spec/test-files/test-1-compacted.json
482
- - spec/test-files/test-4-expanded.json
483
- - spec/test-files/test-9-compacted.json
472
+ - spec/test-files/test-2-normalized.json
473
+ - spec/test-files/test-2-rdf.ttl
474
+ - spec/test-files/test-3-compacted.json
475
+ - spec/test-files/test-3-context.json
476
+ - spec/test-files/test-3-expanded.json
477
+ - spec/test-files/test-3-input.json
478
+ - spec/test-files/test-3-normalized.json
479
+ - spec/test-files/test-3-rdf.ttl
480
+ - spec/test-files/test-4-compacted.json
484
481
  - spec/test-files/test-4-context.json
482
+ - spec/test-files/test-4-expanded.json
485
483
  - spec/test-files/test-4-input.json
486
- - spec/test-files/test-3-context.json
487
- - spec/test-files/test-5-rdf.ttl
488
- - spec/test-files/test-1-expanded.json
489
- - spec/test-files/test-9-input.json
490
- - spec/test-files/test-8-framed.json
484
+ - spec/test-files/test-4-rdf.ttl
485
+ - spec/test-files/test-5-compacted.json
486
+ - spec/test-files/test-5-context.json
491
487
  - spec/test-files/test-5-expanded.json
492
- - spec/test-files/test-3-normalized.json
493
- - spec/test-files/test-2-expanded.json
488
+ - spec/test-files/test-5-input.json
489
+ - spec/test-files/test-5-rdf.ttl
490
+ - spec/test-files/test-6-compacted.json
491
+ - spec/test-files/test-6-context.json
494
492
  - spec/test-files/test-6-expanded.json
495
- - spec/test-files/test-2-context.json
496
- - spec/test-files/test-5-context.json
497
- - spec/test-files/test-1-input.json
498
- - spec/test-files/test-4-rdf.ttl
499
- - spec/test-files/test-8-frame.json
500
493
  - spec/test-files/test-6-input.json
501
- - spec/test-files/test-8-context.json
502
- - spec/test-files/test-8-expanded.json
503
494
  - spec/test-files/test-6-rdf.ttl
495
+ - spec/test-files/test-7-compacted.json
496
+ - spec/test-files/test-7-context.json
497
+ - spec/test-files/test-7-expanded.json
498
+ - spec/test-files/test-7-input.json
504
499
  - spec/test-files/test-7-rdf.ttl
505
- - spec/test-files/test-3-input.json
506
- - spec/test-files/test-2-normalized.json
500
+ - spec/test-files/test-8-compacted.json
501
+ - spec/test-files/test-8-context.json
502
+ - spec/test-files/test-8-expanded.json
503
+ - spec/test-files/test-8-frame.json
504
+ - spec/test-files/test-8-framed.json
505
+ - spec/test-files/test-8-input.json
506
+ - spec/test-files/test-8-rdf.ttl
507
+ - spec/test-files/test-9-compacted.json
507
508
  - spec/test-files/test-9-context.json
509
+ - spec/test-files/test-9-expanded.json
510
+ - spec/test-files/test-9-input.json