json-ld 3.1.9 → 3.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/json/ld/compact.rb +1 -0
- data/lib/json/ld/context.rb +16 -12
- data/lib/json/ld/expand.rb +11 -11
- data/lib/json/ld/html/nokogiri.rb +3 -4
- data/spec/compact_spec.rb +70 -0
- data/spec/context_spec.rb +8 -1
- data/spec/frame_spec.rb +93 -3
- data/spec/spec_helper.rb +8 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0324a9e3b617b6dabe52c3f36c81e4b7fc4b78eaab9450510f45a760933064ba
|
4
|
+
data.tar.gz: 7cf759dd5940a052969477e50c50bb0dc31d7cac38a5ccc8e1bdc046e3994a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d427823af59053d28e4999984f698cde37229fb9a3336a22f06517bcc65fbf80527a535b50dd28eaeca1e5d67e38d0d140dbace8854b9a62944f8ba149ea61c
|
7
|
+
data.tar.gz: 83ba9860d9b7fe72924c9469a26bd5337a051003396b02fdcf5ae9e4b2bbd13940c37d7b4d95c16b427248fda64fa799551c3dcf5c767436e804ea89fba03b4f
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ JSON::LD parses and serializes [JSON-LD][] into [RDF][] and implements expansion
|
|
14
14
|
JSON::LD can now be used to create a _context_ from an RDFS/OWL definition, and optionally include a JSON-LD representation of the ontology itself. This is currently accessed through the `script/gen_context` script.
|
15
15
|
|
16
16
|
* If the [jsonlint][] gem is installed, it will be used when validating an input document.
|
17
|
-
* If available, uses [Nokogiri][]
|
17
|
+
* If available, uses [Nokogiri][] for parsing HTML, falls back to REXML otherwise.
|
18
18
|
* Provisional support for [JSON-LD-star][JSON-LD-star].
|
19
19
|
|
20
20
|
[Implementation Report](https://ruby-rdf.github.io/json-ld/etc/earl.html)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.10
|
data/lib/json/ld/compact.rb
CHANGED
@@ -297,6 +297,7 @@ module JSON::LD
|
|
297
297
|
if index_key == '@index'
|
298
298
|
map_key = expanded_item['@index']
|
299
299
|
else
|
300
|
+
index_key = context.expand_iri(index_key, vocab: true)
|
300
301
|
container_key = context.compact_iri(index_key, vocab: true)
|
301
302
|
map_key, *others = Array(compacted_item[container_key])
|
302
303
|
if map_key.is_a?(String)
|
data/lib/json/ld/context.rb
CHANGED
@@ -253,6 +253,7 @@ module JSON::LD
|
|
253
253
|
|
254
254
|
local_context = as_array(local_context)
|
255
255
|
|
256
|
+
log_depth do
|
256
257
|
local_context.each do |context|
|
257
258
|
case context
|
258
259
|
when nil,false
|
@@ -266,22 +267,22 @@ module JSON::LD
|
|
266
267
|
"Attempt to clear a context with protected terms"
|
267
268
|
end
|
268
269
|
when Context
|
269
|
-
|
270
|
+
log_debug("parse") {"context: #{context.inspect}"}
|
270
271
|
result = result.merge(context)
|
271
272
|
when IO, StringIO
|
272
|
-
|
273
|
+
log_debug("parse") {"io: #{context}"}
|
273
274
|
# Load context document, if it is an open file
|
274
275
|
begin
|
275
276
|
ctx = JSON.load(context)
|
276
277
|
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Context missing @context key" if @options[:validate] && ctx['@context'].nil?
|
277
278
|
result = result.parse(ctx["@context"] ? ctx["@context"] : {})
|
278
279
|
rescue JSON::ParserError => e
|
279
|
-
|
280
|
+
log_info("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
|
280
281
|
raise JSON::LD::JsonLdError::InvalidRemoteContext, "Failed to parse remote context at #{context}: #{e.message}" if @options[:validate]
|
281
282
|
self
|
282
283
|
end
|
283
284
|
when String, RDF::URI
|
284
|
-
|
285
|
+
log_debug("parse") {"remote: #{context}, base: #{result.context_base || result.base}"}
|
285
286
|
|
286
287
|
# 3.2.1) Set context to the result of resolving value against the base IRI which is established as specified in section 5.1 Establishing a Base URI of [RFC3986]. Only the basic algorithm in section 5.2 of [RFC3986] is used; neither Syntax-Based Normalization nor Scheme-Based Normalization are performed. Characters additionally allowed in IRI references are treated in the same way that unreserved characters are treated in URI references, per section 6.5 of [RFC3987].
|
287
288
|
context = RDF::URI(result.context_base || base).join(context)
|
@@ -296,11 +297,11 @@ module JSON::LD
|
|
296
297
|
|
297
298
|
cached_context = if PRELOADED[context_canon.to_s]
|
298
299
|
# If we have a cached context, merge it into the current context (result) and use as the new context
|
299
|
-
|
300
|
+
log_debug("parse") {"=> cached_context: #{context_canon.to_s.inspect}"}
|
300
301
|
|
301
302
|
# If this is a Proc, then replace the entry with the result of running the Proc
|
302
303
|
if PRELOADED[context_canon.to_s].respond_to?(:call)
|
303
|
-
|
304
|
+
log_debug("parse") {"=> (call)"}
|
304
305
|
PRELOADED[context_canon.to_s] = PRELOADED[context_canon.to_s].call
|
305
306
|
end
|
306
307
|
PRELOADED[context_canon.to_s]
|
@@ -320,16 +321,17 @@ module JSON::LD
|
|
320
321
|
ctx = Context.new(unfrozen: true, **options).dup
|
321
322
|
ctx.context_base = context.to_s
|
322
323
|
ctx = ctx.parse(remote_doc.document['@context'], remote_contexts: remote_contexts.dup)
|
324
|
+
ctx.context_base = context.to_s # In case it was altered
|
323
325
|
ctx.instance_variable_set(:@base, nil)
|
324
326
|
ctx
|
325
327
|
end
|
326
328
|
rescue JsonLdError::LoadingDocumentFailed => e
|
327
|
-
|
329
|
+
log_info("parse") {"Failed to retrieve @context from remote document at #{context_canon.inspect}: #{e.message}"}
|
328
330
|
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
|
329
331
|
rescue JsonLdError
|
330
332
|
raise
|
331
333
|
rescue StandardError => e
|
332
|
-
|
334
|
+
log_info("parse") {"Failed to retrieve @context from remote document at #{context_canon.inspect}: #{e.message}"}
|
333
335
|
raise JsonLdError::LoadingRemoteContextFailed, "#{context}: #{e.message}", e.backtrace
|
334
336
|
end
|
335
337
|
end
|
@@ -406,6 +408,7 @@ module JSON::LD
|
|
406
408
|
raise JsonLdError::InvalidLocalContext, "must be a URL, JSON object or array of same: #{context.inspect}"
|
407
409
|
end
|
408
410
|
end
|
411
|
+
end
|
409
412
|
result
|
410
413
|
end
|
411
414
|
|
@@ -475,7 +478,7 @@ module JSON::LD
|
|
475
478
|
remote_contexts: [],
|
476
479
|
validate_scoped: true)
|
477
480
|
# Expand a string value, unless it matches a keyword
|
478
|
-
|
481
|
+
log_debug("create_term_definition") {"term = #{term.inspect}"}
|
479
482
|
|
480
483
|
# If defined contains the key term, then the associated value must be true, indicating that the term definition has already been created, so return. Otherwise, a cyclical term definition has been detected, which is an error.
|
481
484
|
case defined[term]
|
@@ -646,7 +649,7 @@ module JSON::LD
|
|
646
649
|
# Otherwise, term is an absolute IRI. Set the IRI mapping for definition to term
|
647
650
|
term
|
648
651
|
end
|
649
|
-
|
652
|
+
log_debug("") {"=> #{definition.id}"}
|
650
653
|
elsif term.include?('/')
|
651
654
|
# If term is a relative IRI
|
652
655
|
definition.id = expand_iri(term, vocab: true)
|
@@ -659,7 +662,7 @@ module JSON::LD
|
|
659
662
|
# Otherwise, active context must have a vocabulary mapping, otherwise an invalid value has been detected, which is an error. Set the IRI mapping for definition to the result of concatenating the value associated with the vocabulary mapping and term.
|
660
663
|
raise JsonLdError::InvalidIRIMapping, "relative term definition without vocab: #{term} on term #{term.inspect}" unless vocab
|
661
664
|
definition.id = vocab + term
|
662
|
-
|
665
|
+
log_debug("") {"=> #{definition.id}"}
|
663
666
|
end
|
664
667
|
|
665
668
|
@iri_to_term[definition.id] = term if simple_term && definition.id
|
@@ -699,6 +702,7 @@ module JSON::LD
|
|
699
702
|
when nil then [nil]
|
700
703
|
else value['@context']
|
701
704
|
end
|
705
|
+
log_debug("") {"context: #{definition.context.inspect}"}
|
702
706
|
rescue JsonLdError => e
|
703
707
|
raise JsonLdError::InvalidScopedContext, "Term definition for #{term.inspect} contains illegal value for @context: #{e.message}"
|
704
708
|
end
|
@@ -1884,7 +1888,7 @@ module JSON::LD
|
|
1884
1888
|
@base_and_parents ||= begin
|
1885
1889
|
u = base
|
1886
1890
|
iri_set = u.to_s.end_with?('/') ? [u.to_s] : []
|
1887
|
-
iri_set << u.to_s while (u = u.parent)
|
1891
|
+
iri_set << u.to_s while (u != './' && u = u.parent)
|
1888
1892
|
iri_set
|
1889
1893
|
end
|
1890
1894
|
b = base.to_s
|
data/lib/json/ld/expand.rb
CHANGED
@@ -107,7 +107,7 @@ module JSON::LD
|
|
107
107
|
Array(input[tk]).sort.each do |term|
|
108
108
|
term_context = type_scoped_context.term_definitions[term].context if type_scoped_context.term_definitions[term]
|
109
109
|
unless term_context.nil?
|
110
|
-
log_debug("expand", depth: log_depth.to_i) {"term_context: #{term_context.inspect}"}
|
110
|
+
log_debug("expand", depth: log_depth.to_i) {"term_context[#{term}]: #{term_context.inspect}"}
|
111
111
|
context = context.parse(term_context, base: @options[:base], propagate: false)
|
112
112
|
end
|
113
113
|
end
|
@@ -258,10 +258,10 @@ module JSON::LD
|
|
258
258
|
expanded_property.to_s.start_with?("_:") &&
|
259
259
|
context.processingMode('json-ld-1.1')
|
260
260
|
|
261
|
-
|
261
|
+
log_debug("expand property", depth: log_depth.to_i) {"ap: #{active_property.inspect}, expanded: #{expanded_property.inspect}, value: #{value.inspect}"}
|
262
262
|
|
263
263
|
if expanded_property.nil?
|
264
|
-
|
264
|
+
log_debug(" => ", depth: log_depth.to_i) {"skip nil property"}
|
265
265
|
next
|
266
266
|
end
|
267
267
|
|
@@ -341,7 +341,7 @@ module JSON::LD
|
|
341
341
|
Array(output_object['@included']) + included_result
|
342
342
|
when '@type'
|
343
343
|
# If expanded property is @type and value is neither a string nor an array of strings, an invalid type value error has been detected and processing is aborted. Otherwise, set expanded value to the result of using the IRI Expansion algorithm, passing active context, true for vocab, and true for document relative to expand the value or each of its items.
|
344
|
-
|
344
|
+
log_debug("@type", depth: log_depth.to_i) {"value: #{value.inspect}"}
|
345
345
|
e_type = case value
|
346
346
|
when Array
|
347
347
|
value.map do |v|
|
@@ -516,7 +516,7 @@ module JSON::LD
|
|
516
516
|
|
517
517
|
# If expanded value contains an @reverse member, i.e., properties that are reversed twice, execute for each of its property and item the following steps:
|
518
518
|
if value.key?('@reverse')
|
519
|
-
|
519
|
+
log_debug("@reverse", depth: log_depth.to_i) {"double reverse: #{value.inspect}"}
|
520
520
|
value['@reverse'].each do |property, item|
|
521
521
|
# If result does not have a property member, create one and set its value to an empty array.
|
522
522
|
# Append item to the value of the property member of result.
|
@@ -566,7 +566,7 @@ module JSON::LD
|
|
566
566
|
end
|
567
567
|
|
568
568
|
# Unless expanded value is null, set the expanded property member of result to expanded value.
|
569
|
-
|
569
|
+
log_debug("expand #{expanded_property}", depth: log_depth.to_i) { expanded_value.inspect}
|
570
570
|
output_object[expanded_property] = expanded_value unless expanded_value.nil? && expanded_property == '@value' && input_type != '@json'
|
571
571
|
next
|
572
572
|
end
|
@@ -688,21 +688,21 @@ module JSON::LD
|
|
688
688
|
|
689
689
|
# If expanded value is null, ignore key by continuing to the next key from element.
|
690
690
|
if expanded_value.nil?
|
691
|
-
|
691
|
+
log_debug(" => skip nil value", depth: log_depth.to_i)
|
692
692
|
next
|
693
693
|
end
|
694
|
-
|
694
|
+
log_debug(depth: log_depth.to_i) {" => #{expanded_value.inspect}"}
|
695
695
|
|
696
696
|
# If the container mapping associated to key in active context is @list and expanded value is not already a list object, convert expanded value to a list object by first setting it to an array containing only expanded value if it is not already an array, and then by setting it to a JSON object containing the key-value pair @list-expanded value.
|
697
697
|
if container.first == '@list' && container.length == 1 && !list?(expanded_value)
|
698
|
-
|
698
|
+
log_debug(" => ", depth: log_depth.to_i) { "convert #{expanded_value.inspect} to list"}
|
699
699
|
expanded_value = {'@list' => as_array(expanded_value)}
|
700
700
|
end
|
701
|
-
|
701
|
+
log_debug(depth: log_depth.to_i) {" => #{expanded_value.inspect}"}
|
702
702
|
|
703
703
|
# convert expanded value to @graph if container specifies it
|
704
704
|
if container.first == '@graph' && container.length == 1
|
705
|
-
|
705
|
+
log_debug(" => ", depth: log_depth.to_i) { "convert #{expanded_value.inspect} to list"}
|
706
706
|
expanded_value = as_array(expanded_value).map do |v|
|
707
707
|
{'@graph' => as_array(v)}
|
708
708
|
end
|
@@ -136,11 +136,10 @@ module JSON::LD
|
|
136
136
|
input
|
137
137
|
else
|
138
138
|
begin
|
139
|
-
require 'nokogumbo' unless defined?(::Nokogumbo)
|
140
139
|
input = input.read if input.respond_to?(:read)
|
141
|
-
::Nokogiri::HTML5(input.
|
142
|
-
rescue LoadError
|
143
|
-
::Nokogiri::HTML.parse(input, 'utf-8')
|
140
|
+
::Nokogiri::HTML5(input.force_encoding('utf-8'), max_parse_errors: 1000)
|
141
|
+
rescue LoadError, NoMethodError
|
142
|
+
::Nokogiri::HTML.parse(input, base_uri.to_s, 'utf-8')
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
data/spec/compact_spec.rb
CHANGED
@@ -954,6 +954,76 @@ describe JSON::LD::API do
|
|
954
954
|
}),
|
955
955
|
processingMode: 'json-ld-1.1'
|
956
956
|
},
|
957
|
+
"issue-514": {
|
958
|
+
input: %({
|
959
|
+
"http://example.org/ns/prop": [{
|
960
|
+
"@id": "http://example.org/ns/bar",
|
961
|
+
"http://example.org/ns/name": "bar"
|
962
|
+
}, {
|
963
|
+
"@id": "http://example.org/ns/foo",
|
964
|
+
"http://example.org/ns/name": "foo"
|
965
|
+
}]
|
966
|
+
}),
|
967
|
+
context: %({
|
968
|
+
"@context": {
|
969
|
+
"ex": "http://example.org/ns/",
|
970
|
+
"prop": {
|
971
|
+
"@id": "ex:prop",
|
972
|
+
"@container": "@index",
|
973
|
+
"@index": "ex:name"
|
974
|
+
}
|
975
|
+
}
|
976
|
+
}),
|
977
|
+
output: %({
|
978
|
+
"@context": {
|
979
|
+
"ex": "http://example.org/ns/",
|
980
|
+
"prop": {
|
981
|
+
"@id": "ex:prop",
|
982
|
+
"@container": "@index",
|
983
|
+
"@index": "ex:name"
|
984
|
+
}
|
985
|
+
},
|
986
|
+
"prop": {
|
987
|
+
"foo": { "@id": "ex:foo"},
|
988
|
+
"bar": { "@id": "ex:bar"}
|
989
|
+
}
|
990
|
+
})
|
991
|
+
},
|
992
|
+
"issue-514b": {
|
993
|
+
input: %({
|
994
|
+
"http://example.org/ns/prop": [{
|
995
|
+
"@id": "http://example.org/ns/bar",
|
996
|
+
"http://example.org/ns/name": "bar"
|
997
|
+
}, {
|
998
|
+
"@id": "http://example.org/ns/foo",
|
999
|
+
"http://example.org/ns/name": "foo"
|
1000
|
+
}]
|
1001
|
+
}),
|
1002
|
+
context: %({
|
1003
|
+
"@context": {
|
1004
|
+
"ex": "http://example.org/ns/",
|
1005
|
+
"prop": {
|
1006
|
+
"@id": "ex:prop",
|
1007
|
+
"@container": "@index",
|
1008
|
+
"@index": "http://example.org/ns/name"
|
1009
|
+
}
|
1010
|
+
}
|
1011
|
+
}),
|
1012
|
+
output: %({
|
1013
|
+
"@context": {
|
1014
|
+
"ex": "http://example.org/ns/",
|
1015
|
+
"prop": {
|
1016
|
+
"@id": "ex:prop",
|
1017
|
+
"@container": "@index",
|
1018
|
+
"@index": "http://example.org/ns/name"
|
1019
|
+
}
|
1020
|
+
},
|
1021
|
+
"prop": {
|
1022
|
+
"foo": { "@id": "ex:foo"},
|
1023
|
+
"bar": { "@id": "ex:bar"}
|
1024
|
+
}
|
1025
|
+
})
|
1026
|
+
},
|
957
1027
|
}.each_pair do |title, params|
|
958
1028
|
it(title) {run_compact(params)}
|
959
1029
|
end
|
data/spec/context_spec.rb
CHANGED
@@ -181,7 +181,14 @@ describe JSON::LD::Context do
|
|
181
181
|
before {JSON::LD::Context.instance_variable_set(:@cache, nil)}
|
182
182
|
it "retrieves and parses a remote context document" do
|
183
183
|
expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
|
184
|
-
subject.parse(ctx)
|
184
|
+
ec = subject.parse(ctx)
|
185
|
+
expect(ec.send(:mappings)).to produce({
|
186
|
+
"xsd" => "http://www.w3.org/2001/XMLSchema#",
|
187
|
+
"name" => "http://xmlns.com/foaf/0.1/name",
|
188
|
+
"homepage" => "http://xmlns.com/foaf/0.1/homepage",
|
189
|
+
"avatar" => "http://xmlns.com/foaf/0.1/avatar",
|
190
|
+
"integer" => "http://www.w3.org/2001/XMLSchema#integer"
|
191
|
+
}, logger)
|
185
192
|
end
|
186
193
|
end
|
187
194
|
|
data/spec/frame_spec.rb
CHANGED
@@ -992,6 +992,95 @@ describe JSON::LD::API do
|
|
992
992
|
end
|
993
993
|
end
|
994
994
|
|
995
|
+
context "omitGraph option" do
|
996
|
+
{
|
997
|
+
"Defaults to false in 1.0": {
|
998
|
+
input: %([{
|
999
|
+
"http://example.org/prop": [{"@value": "value"}],
|
1000
|
+
"http://example.org/foo": [{"@value": "bar"}]
|
1001
|
+
}]),
|
1002
|
+
frame: %({
|
1003
|
+
"@context": {
|
1004
|
+
"@vocab": "http://example.org/"
|
1005
|
+
}
|
1006
|
+
}),
|
1007
|
+
output: %({
|
1008
|
+
"@context": {
|
1009
|
+
"@vocab": "http://example.org/"
|
1010
|
+
},
|
1011
|
+
"@graph": [{
|
1012
|
+
"foo": "bar",
|
1013
|
+
"prop": "value"
|
1014
|
+
}]
|
1015
|
+
}),
|
1016
|
+
processingMode: "json-ld-1.0"
|
1017
|
+
},
|
1018
|
+
"Set with option in 1.0": {
|
1019
|
+
input: %([{
|
1020
|
+
"http://example.org/prop": [{"@value": "value"}],
|
1021
|
+
"http://example.org/foo": [{"@value": "bar"}]
|
1022
|
+
}]),
|
1023
|
+
frame: %({
|
1024
|
+
"@context": {
|
1025
|
+
"@vocab": "http://example.org/"
|
1026
|
+
}
|
1027
|
+
}),
|
1028
|
+
output: %({
|
1029
|
+
"@context": {
|
1030
|
+
"@vocab": "http://example.org/"
|
1031
|
+
},
|
1032
|
+
"foo": "bar",
|
1033
|
+
"prop": "value"
|
1034
|
+
}),
|
1035
|
+
processingMode: "json-ld-1.0",
|
1036
|
+
omitGraph: true
|
1037
|
+
},
|
1038
|
+
"Defaults to true in 1.1": {
|
1039
|
+
input: %([{
|
1040
|
+
"http://example.org/prop": [{"@value": "value"}],
|
1041
|
+
"http://example.org/foo": [{"@value": "bar"}]
|
1042
|
+
}]),
|
1043
|
+
frame: %({
|
1044
|
+
"@context": {
|
1045
|
+
"@vocab": "http://example.org/"
|
1046
|
+
}
|
1047
|
+
}),
|
1048
|
+
output: %({
|
1049
|
+
"@context": {
|
1050
|
+
"@vocab": "http://example.org/"
|
1051
|
+
},
|
1052
|
+
"foo": "bar",
|
1053
|
+
"prop": "value"
|
1054
|
+
}),
|
1055
|
+
processingMode: "json-ld-1.1"
|
1056
|
+
},
|
1057
|
+
"Set with option in 1.1": {
|
1058
|
+
input: %([{
|
1059
|
+
"http://example.org/prop": [{"@value": "value"}],
|
1060
|
+
"http://example.org/foo": [{"@value": "bar"}]
|
1061
|
+
}]),
|
1062
|
+
frame: %({
|
1063
|
+
"@context": {
|
1064
|
+
"@vocab": "http://example.org/"
|
1065
|
+
}
|
1066
|
+
}),
|
1067
|
+
output: %({
|
1068
|
+
"@context": {
|
1069
|
+
"@vocab": "http://example.org/"
|
1070
|
+
},
|
1071
|
+
"@graph": [{
|
1072
|
+
"foo": "bar",
|
1073
|
+
"prop": "value"
|
1074
|
+
}]
|
1075
|
+
}),
|
1076
|
+
processingMode: "json-ld-1.1",
|
1077
|
+
omitGraph: false
|
1078
|
+
},
|
1079
|
+
}.each do |title, params|
|
1080
|
+
it(title) {do_frame(params.merge(pruneBlankNodeIdentifiers: true))}
|
1081
|
+
end
|
1082
|
+
end
|
1083
|
+
|
995
1084
|
context "@included" do
|
996
1085
|
{
|
997
1086
|
"Basic Included array": {
|
@@ -2359,15 +2448,16 @@ describe JSON::LD::API do
|
|
2359
2448
|
|
2360
2449
|
def do_frame(params)
|
2361
2450
|
begin
|
2362
|
-
input, frame, output
|
2451
|
+
input, frame, output = params[:input], params[:frame], params[:output]
|
2452
|
+
params = {processingMode: 'json-ld-1.0'}.merge(params)
|
2363
2453
|
input = ::JSON.parse(input) if input.is_a?(String)
|
2364
2454
|
frame = ::JSON.parse(frame) if frame.is_a?(String)
|
2365
2455
|
output = ::JSON.parse(output) if output.is_a?(String)
|
2366
2456
|
jld = nil
|
2367
2457
|
if params[:write]
|
2368
|
-
expect{jld = JSON::LD::API.frame(input, frame, logger: logger,
|
2458
|
+
expect{jld = JSON::LD::API.frame(input, frame, logger: logger, **params)}.to write(params[:write]).to(:error)
|
2369
2459
|
else
|
2370
|
-
expect{jld = JSON::LD::API.frame(input, frame, logger: logger,
|
2460
|
+
expect{jld = JSON::LD::API.frame(input, frame, logger: logger, **params)}.not_to write.to(:error)
|
2371
2461
|
end
|
2372
2462
|
expect(jld).to produce_jsonld(output, logger)
|
2373
2463
|
|
data/spec/spec_helper.rb
CHANGED
@@ -15,10 +15,16 @@ require_relative 'matchers'
|
|
15
15
|
require 'yaml'
|
16
16
|
begin
|
17
17
|
require 'simplecov'
|
18
|
-
require '
|
18
|
+
require 'simplecov-lcov'
|
19
|
+
SimpleCov::Formatter::LcovFormatter.config do |config|
|
20
|
+
#Coveralls is coverage by default/lcov. Send info results
|
21
|
+
config.report_with_single_file = true
|
22
|
+
config.single_report_path = 'coverage/lcov.info'
|
23
|
+
end
|
24
|
+
|
19
25
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
20
26
|
SimpleCov::Formatter::HTMLFormatter,
|
21
|
-
|
27
|
+
SimpleCov::Formatter::LcovFormatter
|
22
28
|
])
|
23
29
|
SimpleCov.start do
|
24
30
|
add_filter "/spec/"
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -427,7 +427,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
427
427
|
- !ruby/object:Gem::Version
|
428
428
|
version: '0'
|
429
429
|
requirements: []
|
430
|
-
rubygems_version: 3.2.
|
430
|
+
rubygems_version: 3.2.22
|
431
431
|
signing_key:
|
432
432
|
specification_version: 4
|
433
433
|
summary: JSON-LD reader/writer for Ruby.
|