json-ld 3.1.0 → 3.1.5

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.
@@ -7,11 +7,13 @@ describe JSON::LD do
7
7
  m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}expand-manifest.jsonld")
8
8
  describe m.name do
9
9
  m.entries.each do |t|
10
+ # MultiJson use OJ, by default, which doesn't handle native numbers the same as the JSON gem.
11
+ t.options[:adapter] = :json_gem if %w(#tjs12).include?(t.property('@id'))
10
12
  specify "#{t.property('@id')}: #{t.name} unordered#{' (negative test)' unless t.positiveTest?}" do
11
13
  t.options[:ordered] = false
12
14
  if %w(#t0068).include?(t.property('@id'))
13
15
  expect{t.run self}.to write("[DEPRECATION]").to(:error)
14
- 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'))
15
17
  expect{t.run self}.to write("beginning with '@' are reserved for future use").to(:error)
16
18
  else
17
19
  expect {t.run self}.not_to write.to(:error)
@@ -22,7 +24,7 @@ describe JSON::LD do
22
24
  t.options[:ordered] = true
23
25
  if %w(#t0068).include?(t.property('@id'))
24
26
  expect{t.run self}.to write("[DEPRECATION]").to(:error)
25
- 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'))
26
28
  expect{t.run self}.to write("beginning with '@' are reserved for future use").to(:error)
27
29
  else
28
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
@@ -132,6 +134,10 @@ module Fixtures
132
134
  {'specVersion' => "json-ld-1.1"}.merge(property('option') || {}).each do |k, v|
133
135
  opts[k.to_sym] = v
134
136
  end
137
+ if opts[:expandContext] && !RDF::URI(opts[:expandContext]).absolute?
138
+ # Resolve relative to manifest location
139
+ opts[:expandContext] = manifest_url.join(opts[:expandContext]).to_s
140
+ end
135
141
  opts
136
142
  end
137
143
  end
@@ -144,6 +150,7 @@ module Fixtures
144
150
  file = self.send("#{m}_loc".to_sym)
145
151
 
146
152
  dl_opts = {safe: true}
153
+ dl_opts[:contentType] = options[:contentType] if m == 'input' && options[:contentType]
147
154
  RDF::Util::File.open_file(file, **dl_opts) do |remote_doc|
148
155
  res = remote_doc.read
149
156
  end
@@ -177,6 +184,10 @@ module Fixtures
177
184
  def positiveTest?
178
185
  property('@type').to_s.include?('Positive')
179
186
  end
187
+
188
+ def syntaxTest?
189
+ property('@type').to_s.include?('Syntax')
190
+ end
180
191
 
181
192
 
182
193
  # Execute the test
@@ -219,14 +230,14 @@ module Fixtures
219
230
  JSON::LD::API.fromRdf(repo, logger: logger, **options)
220
231
  when "jld:ToRDFTest"
221
232
  repo = RDF::Repository.new
222
- JSON::LD::API.toRdf(input_loc, logger: logger, **options) do |statement|
223
- # To properly compare values of rdf:language and i18n datatypes, normalize to lower case
224
- if statement.predicate == RDF.to_uri + 'language'
225
- statement.object = RDF::Literal(statement.object.to_s.downcase) if statement.object.literal?
226
- elsif statement.object.literal? && statement.object.datatype.to_s.start_with?('https://www.w3.org/ns/i18n#')
227
- 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
228
240
  end
229
- repo << statement
230
241
  end
231
242
  logger.info "nq: #{repo.map(&:to_nquads)}"
232
243
  repo
@@ -311,7 +322,11 @@ module Fixtures
311
322
  raise "Expected status #{t.property('expectErrorCode')}, not #{last_response.status}"
312
323
  end
313
324
  when "jld:ToRDFTest"
314
- 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
315
330
  else
316
331
  success("Unknown test type: #{testType}")
317
332
  end
@@ -13,7 +13,7 @@ describe JSON::LD do
13
13
  expect {t.run self}.to write(/Statement .* is invalid/).to(:error)
14
14
  elsif %w(#te075).include?(t.property('@id'))
15
15
  expect {t.run self}.to write(/is invalid/).to(:error)
16
- elsif %w(#te005 #tpr34 #tpr35 #tpr36 #tpr37 #te119 #te120).include?(t.property('@id'))
16
+ elsif %w(#te005 #tpr34 #tpr35 #tpr36 #tpr37 #tpr38 #tpr39 #te119 #te120).include?(t.property('@id'))
17
17
  expect {t.run self}.to write("beginning with '@' are reserved for future use").to(:error)
18
18
  elsif %w(#te068).include?(t.property('@id'))
19
19
  expect {t.run self}.to write("[DEPRECATION]").to(:error)
@@ -1133,7 +1133,7 @@ describe JSON::LD::API do
1133
1133
  ],
1134
1134
  "en-US rtl": [
1135
1135
  %q({"http://example.org/label": {"@value": "en-US", "@language": "en-US", "@direction": "rtl"}}),
1136
- %q(_:a <http://example.org/label> "en-US"^^<https://www.w3.org/ns/i18n#en-US_rtl> .)
1136
+ %q(_:a <http://example.org/label> "en-US"^^<https://www.w3.org/ns/i18n#en-us_rtl> .)
1137
1137
  ]
1138
1138
  }.each do |title, (js, ttl)|
1139
1139
  it title do
@@ -1161,7 +1161,7 @@ describe JSON::LD::API do
1161
1161
  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
1162
1162
  _:a <http://example.org/label> [
1163
1163
  rdf:value "en-US";
1164
- rdf:language "en-US";
1164
+ rdf:language "en-us";
1165
1165
  rdf:direction "rtl"
1166
1166
  ] .
1167
1167
  )
@@ -1218,7 +1218,7 @@ describe JSON::LD::API do
1218
1218
  "@id": "http://example.com/foo",
1219
1219
  "http://example.com/bar": {"@value": "bar", "@type": "http://example.com/baz z"}
1220
1220
  }),
1221
- output: %()
1221
+ exception: JSON::LD::JsonLdError::InvalidTypedValue
1222
1222
  },
1223
1223
  "Injected IRIs check" => {
1224
1224
  input: %({
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.0
4
+ version: 3.1.5
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: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2020-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.1'
67
+ version: '0.2'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.1'
74
+ version: '0.2'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: htmlentities
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -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,8 +426,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
424
426
  - !ruby/object:Gem::Version
425
427
  version: '0'
426
428
  requirements: []
427
- rubygems_version: 3.0.6
428
- signing_key:
429
+ rubygems_version: 3.1.4
430
+ signing_key:
429
431
  specification_version: 4
430
432
  summary: JSON-LD reader/writer for Ruby.
431
433
  test_files:
@@ -455,6 +457,7 @@ test_files:
455
457
  - spec/suite_flatten_spec.rb
456
458
  - spec/compact_spec.rb
457
459
  - spec/suite_http_spec.rb
460
+ - spec/streaming_reader_spec.rb
458
461
  - spec/writer_spec.rb
459
462
  - spec/test-files/test-3-compacted.json
460
463
  - spec/test-files/test-2-rdf.ttl