json-ld 1.99.2 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/json/ld.rb +0 -3
- data/lib/json/ld/api.rb +38 -21
- data/lib/json/ld/compact.rb +24 -24
- data/lib/json/ld/context.rb +80 -79
- data/lib/json/ld/expand.rb +30 -30
- data/lib/json/ld/flatten.rb +2 -2
- data/lib/json/ld/format.rb +126 -1
- data/lib/json/ld/frame.rb +3 -3
- data/lib/json/ld/from_rdf.rb +3 -3
- data/lib/json/ld/reader.rb +15 -5
- data/lib/json/ld/streaming_writer.rb +6 -6
- data/lib/json/ld/to_rdf.rb +75 -85
- data/lib/json/ld/utils.rb +1 -30
- data/lib/json/ld/writer.rb +86 -51
- data/spec/api_spec.rb +8 -8
- data/spec/compact_spec.rb +19 -19
- data/spec/context_spec.rb +76 -96
- data/spec/expand_spec.rb +30 -30
- data/spec/flatten_spec.rb +3 -4
- data/spec/format_spec.rb +43 -0
- data/spec/frame_spec.rb +7 -9
- data/spec/from_rdf_spec.rb +25 -24
- data/spec/reader_spec.rb +4 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/streaming_writer_spec.rb +18 -11
- data/spec/suite_helper.rb +29 -28
- data/spec/suite_to_rdf_spec.rb +0 -2
- data/spec/to_rdf_spec.rb +17 -18
- data/spec/writer_spec.rb +15 -11
- metadata +75 -35
- data/spec/matchers.rb +0 -67
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-ld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0.beta
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '3'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0.beta
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: multi_json
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,86 +132,122 @@ dependencies:
|
|
126
132
|
name: rdf-isomorphic
|
127
133
|
requirement: !ruby/object:Gem::Requirement
|
128
134
|
requirements:
|
129
|
-
- - "
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.0.0.beta
|
138
|
+
- - "<"
|
130
139
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
140
|
+
version: '3'
|
132
141
|
type: :development
|
133
142
|
prerelease: false
|
134
143
|
version_requirements: !ruby/object:Gem::Requirement
|
135
144
|
requirements:
|
136
|
-
- - "
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 2.0.0.beta
|
148
|
+
- - "<"
|
137
149
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
150
|
+
version: '3'
|
139
151
|
- !ruby/object:Gem::Dependency
|
140
152
|
name: rdf-spec
|
141
153
|
requirement: !ruby/object:Gem::Requirement
|
142
154
|
requirements:
|
143
|
-
- - "
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.0.0.beta
|
158
|
+
- - "<"
|
144
159
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
160
|
+
version: '3'
|
146
161
|
type: :development
|
147
162
|
prerelease: false
|
148
163
|
version_requirements: !ruby/object:Gem::Requirement
|
149
164
|
requirements:
|
150
|
-
- - "
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 2.0.0.beta
|
168
|
+
- - "<"
|
151
169
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
170
|
+
version: '3'
|
153
171
|
- !ruby/object:Gem::Dependency
|
154
172
|
name: rdf-trig
|
155
173
|
requirement: !ruby/object:Gem::Requirement
|
156
174
|
requirements:
|
157
|
-
- - "
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: 2.0.0.beta
|
178
|
+
- - "<"
|
158
179
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
180
|
+
version: '3'
|
160
181
|
type: :development
|
161
182
|
prerelease: false
|
162
183
|
version_requirements: !ruby/object:Gem::Requirement
|
163
184
|
requirements:
|
164
|
-
- - "
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 2.0.0.beta
|
188
|
+
- - "<"
|
165
189
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
190
|
+
version: '3'
|
167
191
|
- !ruby/object:Gem::Dependency
|
168
192
|
name: rdf-turtle
|
169
193
|
requirement: !ruby/object:Gem::Requirement
|
170
194
|
requirements:
|
171
|
-
- - "
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 2.0.0.beta
|
198
|
+
- - "<"
|
172
199
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
200
|
+
version: '3'
|
174
201
|
type: :development
|
175
202
|
prerelease: false
|
176
203
|
version_requirements: !ruby/object:Gem::Requirement
|
177
204
|
requirements:
|
178
|
-
- - "
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 2.0.0.beta
|
208
|
+
- - "<"
|
179
209
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
210
|
+
version: '3'
|
181
211
|
- !ruby/object:Gem::Dependency
|
182
212
|
name: rdf-vocab
|
183
213
|
requirement: !ruby/object:Gem::Requirement
|
184
214
|
requirements:
|
185
|
-
- - "
|
215
|
+
- - ">="
|
186
216
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
217
|
+
version: 2.0.0.beta
|
218
|
+
- - "<"
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '3'
|
188
221
|
type: :development
|
189
222
|
prerelease: false
|
190
223
|
version_requirements: !ruby/object:Gem::Requirement
|
191
224
|
requirements:
|
192
|
-
- - "
|
225
|
+
- - ">="
|
193
226
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
227
|
+
version: 2.0.0.beta
|
228
|
+
- - "<"
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '3'
|
195
231
|
- !ruby/object:Gem::Dependency
|
196
232
|
name: rdf-xsd
|
197
233
|
requirement: !ruby/object:Gem::Requirement
|
198
234
|
requirements:
|
199
|
-
- - "
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: 2.0.0.beta
|
238
|
+
- - "<"
|
200
239
|
- !ruby/object:Gem::Version
|
201
|
-
version: '
|
240
|
+
version: '3'
|
202
241
|
type: :development
|
203
242
|
prerelease: false
|
204
243
|
version_requirements: !ruby/object:Gem::Requirement
|
205
244
|
requirements:
|
206
|
-
- - "
|
245
|
+
- - ">="
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
version: 2.0.0.beta
|
248
|
+
- - "<"
|
207
249
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
250
|
+
version: '3'
|
209
251
|
- !ruby/object:Gem::Dependency
|
210
252
|
name: rspec
|
211
253
|
requirement: !ruby/object:Gem::Requirement
|
@@ -286,7 +328,6 @@ files:
|
|
286
328
|
- spec/format_spec.rb
|
287
329
|
- spec/frame_spec.rb
|
288
330
|
- spec/from_rdf_spec.rb
|
289
|
-
- spec/matchers.rb
|
290
331
|
- spec/reader_spec.rb
|
291
332
|
- spec/resource_spec.rb
|
292
333
|
- spec/spec_helper.rb
|
@@ -374,12 +415,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
374
415
|
version: '2.0'
|
375
416
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
376
417
|
requirements:
|
377
|
-
- - "
|
418
|
+
- - ">"
|
378
419
|
- !ruby/object:Gem::Version
|
379
|
-
version:
|
420
|
+
version: 1.3.1
|
380
421
|
requirements: []
|
381
422
|
rubyforge_project: json-ld
|
382
|
-
rubygems_version: 2.
|
423
|
+
rubygems_version: 2.5.1
|
383
424
|
signing_key:
|
384
425
|
specification_version: 4
|
385
426
|
summary: JSON-LD reader/writer for Ruby.
|
@@ -392,7 +433,6 @@ test_files:
|
|
392
433
|
- spec/format_spec.rb
|
393
434
|
- spec/frame_spec.rb
|
394
435
|
- spec/from_rdf_spec.rb
|
395
|
-
- spec/matchers.rb
|
396
436
|
- spec/reader_spec.rb
|
397
437
|
- spec/resource_spec.rb
|
398
438
|
- spec/spec_helper.rb
|
data/spec/matchers.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'rdf/isomorphic'
|
2
|
-
require 'rspec/matchers'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
Info = Struct.new(:about, :information, :trace, :inputDocument, :outputDocument, :expectedResults)
|
6
|
-
|
7
|
-
def normalize(graph)
|
8
|
-
case graph
|
9
|
-
when RDF::Enumerable then graph
|
10
|
-
when IO, StringIO
|
11
|
-
RDF::Graph.new.load(graph, base: @info.about)
|
12
|
-
else
|
13
|
-
# Figure out which parser to use
|
14
|
-
g = RDF::Repository.new
|
15
|
-
reader_class = detect_format(graph)
|
16
|
-
reader_class.new(graph, base: @info.about).each {|s| g << s}
|
17
|
-
g
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec::Matchers.define :be_equivalent_graph do |expected, info|
|
22
|
-
match do |actual|
|
23
|
-
@info = if info.respond_to?(:input)
|
24
|
-
info
|
25
|
-
elsif info.is_a?(Hash)
|
26
|
-
identifier = info[:identifier] || info[:about]
|
27
|
-
trace = info[:trace]
|
28
|
-
trace = trace.join("\n") if trace.is_a?(Array)
|
29
|
-
Info.new(identifier, info[:information] || "", trace, info[:inputDocument])
|
30
|
-
else
|
31
|
-
Info.new(expected.is_a?(RDF::Graph) ? expected.context : info, info.to_s)
|
32
|
-
end
|
33
|
-
@expected = normalize(expected)
|
34
|
-
@actual = normalize(actual)
|
35
|
-
@actual.isomorphic_with?(@expected)
|
36
|
-
end
|
37
|
-
|
38
|
-
failure_message do |actual|
|
39
|
-
info = @info.respond_to?(:information) ? @info.information : @info.inspect
|
40
|
-
if @expected.is_a?(RDF::Enumerable) && @actual.size != @expected.size
|
41
|
-
"Graph entry count differs:\nexpected: #{@expected.size}\nactual: #{@actual.size}"
|
42
|
-
elsif @expected.is_a?(Array) && @actual.size != @expected.length
|
43
|
-
"Graph entry count differs:\nexpected: #{@expected.length}\nactual: #{@actual.size}"
|
44
|
-
else
|
45
|
-
"Graph differs"
|
46
|
-
end +
|
47
|
-
"\n#{info + "\n" unless info.empty?}" +
|
48
|
-
"Unsorted Expected:\n#{@expected.dump(:nquads, standard_prefixes: true)}" +
|
49
|
-
"Unsorted Results:\n#{@actual.dump(:nquads, standard_prefixes: true)}" +
|
50
|
-
(@info.inputDocument ? "Input file: #{@info.inputDocument}\n" : "") +
|
51
|
-
(@info.outputDocument ? "Output file: #{@info.outputDocument}\n" : "") +
|
52
|
-
(@info.trace ? "\nDebug:\n#{@info.trace}" : "")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
RSpec::Matchers.define :produce do |expected, info|
|
57
|
-
match do |actual|
|
58
|
-
expect(actual).to eq expected
|
59
|
-
end
|
60
|
-
|
61
|
-
failure_message do |actual|
|
62
|
-
"Expected: #{expected.is_a?(String) ? expected : expected.to_json(JSON_STATE) rescue 'malformed json'}\n" +
|
63
|
-
"Actual : #{actual.is_a?(String) ? actual : actual.to_json(JSON_STATE) rescue 'malformed json'}\n" +
|
64
|
-
#(expected.is_a?(Hash) && actual.is_a?(Hash) ? "Diff: #{expected.diff(actual).to_json(JSON_STATE) rescue 'malformed json'}\n" : "") +
|
65
|
-
"Processing results:\n#{info.join("\n")}"
|
66
|
-
end
|
67
|
-
end
|