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.
@@ -35,7 +35,7 @@ describe JSON::LD::API do
35
35
  }.each do |title, (js, ttl)|
36
36
  it title do
37
37
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
38
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
38
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
39
39
  end
40
40
  end
41
41
  end
@@ -52,7 +52,7 @@ describe JSON::LD::API do
52
52
  }.each do |title, (js, ttl)|
53
53
  it title do
54
54
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
55
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
55
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
56
56
  end
57
57
  end
58
58
 
@@ -82,7 +82,7 @@ describe JSON::LD::API do
82
82
  }.each do |title, (js, ttl)|
83
83
  it title do
84
84
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
85
- expect(parse(js, :base => "http://example.org/")).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
85
+ expect(parse(js, base: "http://example.org/")).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
86
86
  end
87
87
  end
88
88
  end
@@ -111,7 +111,7 @@ describe JSON::LD::API do
111
111
  }.each do |title, (js, ttl)|
112
112
  it title do
113
113
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
114
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
114
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
115
115
  end
116
116
  end
117
117
  end
@@ -145,7 +145,7 @@ describe JSON::LD::API do
145
145
  }.each do |title, (js, ttl)|
146
146
  it title do
147
147
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
148
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
148
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
149
149
  end
150
150
  end
151
151
  end
@@ -194,7 +194,7 @@ describe JSON::LD::API do
194
194
  }.each do |title, (js, ttl)|
195
195
  it title do
196
196
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
197
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
197
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
198
198
  end
199
199
  end
200
200
  end
@@ -216,7 +216,7 @@ describe JSON::LD::API do
216
216
  }.each_pair do |title, (js, ttl)|
217
217
  it title do
218
218
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
219
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
219
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
220
220
  end
221
221
  end
222
222
  end
@@ -238,7 +238,7 @@ describe JSON::LD::API do
238
238
  }.each do |title, (js, ttl)|
239
239
  it title do
240
240
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
241
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
241
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
242
242
  end
243
243
  end
244
244
  end
@@ -277,7 +277,7 @@ describe JSON::LD::API do
277
277
  }.each do |title, (js, ttl)|
278
278
  it title do
279
279
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
280
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
280
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
281
281
  end
282
282
  end
283
283
  end
@@ -299,7 +299,7 @@ describe JSON::LD::API do
299
299
  }.each do |title, (js, ttl)|
300
300
  it title do
301
301
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
302
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
302
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
303
303
  end
304
304
  end
305
305
  end
@@ -360,7 +360,7 @@ describe JSON::LD::API do
360
360
  }.each do |title, (js, ttl)|
361
361
  it title do
362
362
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
363
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
363
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
364
364
  end
365
365
  end
366
366
  end
@@ -483,7 +483,7 @@ describe JSON::LD::API do
483
483
  }.each do |title, (js, ttl)|
484
484
  it title do
485
485
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
486
- expect(parse(js)).to be_equivalent_graph(ttl, :base => "http://example/", :trace => @debug, :inputDocument => js)
486
+ expect(parse(js)).to be_equivalent_graph(ttl, base: "http://example/", trace: @debug, inputDocument: js)
487
487
  end
488
488
  end
489
489
 
@@ -536,7 +536,7 @@ describe JSON::LD::API do
536
536
  }.each do |title, (js, ttl)|
537
537
  it title do
538
538
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
539
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
539
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
540
540
  end
541
541
  end
542
542
  end
@@ -572,7 +572,7 @@ describe JSON::LD::API do
572
572
  }.each do |title, (js, ttl)|
573
573
  it title do
574
574
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
575
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
575
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
576
576
  end
577
577
  end
578
578
  end
@@ -583,12 +583,12 @@ describe JSON::LD::API do
583
583
  subject {%q({"@id": "http://example/subj", "_:foo": "bar"})}
584
584
 
585
585
  it "outputs statements with blank node predicates if :produceGeneralizedRdf is true" do
586
- graph = parse(subject, :produceGeneralizedRdf => true)
586
+ graph = parse(subject, produceGeneralizedRdf: true)
587
587
  expect(graph.count).to eq 1
588
588
  end
589
589
 
590
590
  it "rejects statements with blank node predicates if :produceGeneralizedRdf is false" do
591
- graph = parse(subject, :produceGeneralizedRdf => false)
591
+ graph = parse(subject, produceGeneralizedRdf: false)
592
592
  expect(graph.count).to eq 0
593
593
  end
594
594
  end
@@ -654,7 +654,7 @@ describe JSON::LD::API do
654
654
  }.each do |title, (js, ttl)|
655
655
  it title do
656
656
  ttl = "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . #{ttl}"
657
- expect(parse(js)).to be_equivalent_graph(ttl, :trace => @debug, :inputDocument => js)
657
+ expect(parse(js)).to be_equivalent_graph(ttl, trace: @debug, inputDocument: js)
658
658
  end
659
659
  end
660
660
  end
@@ -14,10 +14,10 @@ describe JSON::LD::Writer 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::Reader.for(arg)).to eq JSON::LD::Reader
@@ -36,7 +36,7 @@ describe JSON::LD::Writer do
36
36
 
37
37
  it "should use qname URIs with standard prefix" do
38
38
  input = %(<http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .)
39
- expect(serialize(input, :standard_prefixes => true)).to produce({
39
+ expect(serialize(input, standard_prefixes: true)).to produce({
40
40
  '@context' => {
41
41
  "foaf" => "http://xmlns.com/foaf/0.1/",
42
42
  },
@@ -52,10 +52,10 @@ describe JSON::LD::Writer do
52
52
  <https://senet.org/gm> <https://senet.org/ns#unofficialTitle> "Rhythm Tengoku"@en .
53
53
  <https://senet.org/gm> <https://senet.org/ns#urlkey> "rhythm-tengoku" .
54
54
  )
55
- expect(serialize(input, :prefixes => {
56
- :dc => "http://purl.org/dc/terms/",
57
- :frbr => "http://vocab.org/frbr/core#",
58
- :senet => "https://senet.org/ns#",
55
+ expect(serialize(input, prefixes: {
56
+ dc: "http://purl.org/dc/terms/",
57
+ frbr: "http://vocab.org/frbr/core#",
58
+ senet: "https://senet.org/ns#",
59
59
  })).to produce({
60
60
  '@context' => {
61
61
  "dc" => "http://purl.org/dc/terms/",
@@ -73,7 +73,7 @@ describe JSON::LD::Writer do
73
73
  it "should use CURIEs with empty prefix" do
74
74
  input = %(<http://xmlns.com/foaf/0.1/b> <http://xmlns.com/foaf/0.1/c> <http://xmlns.com/foaf/0.1/d> .)
75
75
  begin
76
- expect(serialize(input, :prefixes => { "" => RDF::FOAF})).
76
+ expect(serialize(input, prefixes: { "" => RDF::FOAF})).
77
77
  to produce({
78
78
  "@context" => {
79
79
  "" => "http://xmlns.com/foaf/0.1/"
@@ -90,7 +90,7 @@ describe JSON::LD::Writer do
90
90
 
91
91
  it "should not use terms if no suffix" do
92
92
  input = %(<http://xmlns.com/foaf/0.1/> <http://xmlns.com/foaf/0.1/> <http://xmlns.com/foaf/0.1/> .)
93
- expect(serialize(input, :standard_prefixes => true)).
93
+ expect(serialize(input, standard_prefixes: true)).
94
94
  not_to produce({
95
95
  "@context" => {"foaf" => "http://xmlns.com/foaf/0.1/"},
96
96
  '@id' => "foaf",
@@ -105,7 +105,7 @@ describe JSON::LD::Writer do
105
105
  db:Michael_Jackson dbo:artistOf <http://dbpedia.org/resource/%28I_Can%27t_Make_It%29_Another_Day> .
106
106
  )
107
107
 
108
- expect(serialize(input, :prefixes => {
108
+ expect(serialize(input, prefixes: {
109
109
  "db" => RDF::URI("http://dbpedia.org/resource/"),
110
110
  "dbo" => RDF::URI("http://dbpedia.org/ontology/")})).
111
111
  to produce({
@@ -131,7 +131,7 @@ describe JSON::LD::Writer do
131
131
  <http://example.com/test-cases/0001> a :TestCase .
132
132
  <http://example.com/test-cases/0002> a :TestCase .
133
133
  )
134
- expect(serialize(input, :prefixes => {"" => "http://www.w3.org/2006/03/test-description#"})).
134
+ expect(serialize(input, prefixes: {"" => "http://www.w3.org/2006/03/test-description#"})).
135
135
  to produce({
136
136
  '@context' => {
137
137
  "" => "http://www.w3.org/2006/03/test-description#",
@@ -158,10 +158,10 @@ describe JSON::LD::Writer do
158
158
  owl:onClass <http://data.wikia.com/terms#Element>;
159
159
  owl:onProperty <http://data.wikia.com/terms#characterIn> .
160
160
  )
161
- expect(serialize(input, :rename_bnodes => false, :prefixes => {
162
- :owl => "http://www.w3.org/2002/07/owl#",
163
- :rdfs => "http://www.w3.org/2000/01/rdf-schema#",
164
- :xsd => "http://www.w3.org/2001/XMLSchema#"
161
+ expect(serialize(input, rename_bnodes: false, prefixes: {
162
+ owl: "http://www.w3.org/2002/07/owl#",
163
+ rdfs: "http://www.w3.org/2000/01/rdf-schema#",
164
+ xsd: "http://www.w3.org/2001/XMLSchema#"
165
165
  })).
166
166
  to produce({
167
167
  '@context' => {
@@ -187,16 +187,39 @@ describe JSON::LD::Writer do
187
187
  }, @debug)
188
188
  end
189
189
  end
190
-
190
+
191
+ context "Writes fromRdf tests to isomorphic graph", skip: ENV['CI'] do
192
+ require 'suite_helper'
193
+ m = Fixtures::SuiteTest::Manifest.open("#{Fixtures::SuiteTest::SUITE}tests/fromRdf-manifest.jsonld")
194
+ describe m.name do
195
+ m.entries.each do |t|
196
+ next unless t.positiveTest? && !t.property('input').include?('0016')
197
+ t.debug = ["test: #{t.inspect}", "source: #{t.input}"]
198
+ specify "#{t.property('input')}: #{t.name}" do
199
+ repo = RDF::Repository.load(t.input_loc, format: :nquads)
200
+ jsonld = JSON::LD::Writer.buffer(debug: t.debug) do |writer|
201
+ writer << repo
202
+ end
203
+
204
+ # And then, re-generate jsonld as RDF
205
+
206
+ expect(parse(jsonld, format: :jsonld)).to be_equivalent_graph(repo, t)
207
+ end
208
+ end
209
+ end
210
+ end
211
+
191
212
  def parse(input, options = {})
192
- RDF::Graph.new << RDF::Turtle::Reader.new(input, options)
213
+ format = options.fetch(:format, :trig)
214
+ reader = RDF::Reader.for(format)
215
+ RDF::Repository.new << reader.new(input, options)
193
216
  end
194
217
 
195
218
  # Serialize ntstr to a string and compare against regexps
196
219
  def serialize(ntstr, options = {})
197
220
  g = ntstr.is_a?(String) ? parse(ntstr, options) : ntstr
198
221
  @debug = [] << g.dump(:ttl)
199
- result = JSON::LD::Writer.buffer(options.merge(:debug => @debug)) do |writer|
222
+ result = JSON::LD::Writer.buffer(options.merge(debug: @debug)) do |writer|
200
223
  writer << g
201
224
  end
202
225
  if $verbose
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: 1.1.7
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '1.1'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.1.4
22
+ version: 1.1.7
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,41 +29,63 @@ dependencies:
29
29
  version: '1.1'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.1.4
32
+ version: 1.1.7
33
33
  - !ruby/object:Gem::Dependency
34
- name: open-uri-cached
34
+ name: yard
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.0'
40
- - - ">="
39
+ version: '0.8'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.8'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rack-cache
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
41
52
  - !ruby/object:Gem::Version
42
- version: 0.0.5
53
+ version: '1.2'
43
54
  type: :development
44
55
  prerelease: false
45
56
  version_requirements: !ruby/object:Gem::Requirement
46
57
  requirements:
47
58
  - - "~>"
48
59
  - !ruby/object:Gem::Version
49
- version: '0.0'
50
- - - ">="
60
+ version: '1.2'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rest-client
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.7'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
51
73
  - !ruby/object:Gem::Version
52
- version: 0.0.5
74
+ version: '1.7'
53
75
  - !ruby/object:Gem::Dependency
54
- name: yard
76
+ name: rest-client-components
55
77
  requirement: !ruby/object:Gem::Requirement
56
78
  requirements:
57
79
  - - "~>"
58
80
  - !ruby/object:Gem::Version
59
- version: '0.8'
81
+ version: '1.3'
60
82
  type: :development
61
83
  prerelease: false
62
84
  version_requirements: !ruby/object:Gem::Requirement
63
85
  requirements:
64
86
  - - "~>"
65
87
  - !ruby/object:Gem::Version
66
- version: '0.8'
88
+ version: '1.3'
67
89
  - !ruby/object:Gem::Dependency
68
90
  name: rspec
69
91
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +209,7 @@ files:
187
209
  - lib/json/ld/from_rdf.rb
188
210
  - lib/json/ld/reader.rb
189
211
  - lib/json/ld/resource.rb
212
+ - lib/json/ld/streaming_writer.rb
190
213
  - lib/json/ld/to_rdf.rb
191
214
  - lib/json/ld/utils.rb
192
215
  - lib/json/ld/version.rb
@@ -203,6 +226,7 @@ files:
203
226
  - spec/reader_spec.rb
204
227
  - spec/resource_spec.rb
205
228
  - spec/spec_helper.rb
229
+ - spec/streaming_writer_spec.rb
206
230
  - spec/suite_compact_spec.rb
207
231
  - spec/suite_error_spec.rb
208
232
  - spec/suite_expand_spec.rb
@@ -291,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
315
  version: '0'
292
316
  requirements: []
293
317
  rubyforge_project: json-ld
294
- rubygems_version: 2.2.2
318
+ rubygems_version: 2.4.5
295
319
  signing_key:
296
320
  specification_version: 4
297
321
  summary: JSON-LD reader/writer for Ruby.
@@ -308,6 +332,7 @@ test_files:
308
332
  - spec/reader_spec.rb
309
333
  - spec/resource_spec.rb
310
334
  - spec/spec_helper.rb
335
+ - spec/streaming_writer_spec.rb
311
336
  - spec/suite_compact_spec.rb
312
337
  - spec/suite_error_spec.rb
313
338
  - spec/suite_expand_spec.rb