json-ld 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/jsonld +46 -17
- data/lib/json/ld/api.rb +9 -20
- data/lib/json/ld/context.rb +2 -2
- data/lib/json/ld/resource.rb +1 -1
- data/lib/json/ld/to_rdf.rb +1 -1
- data/spec/resource_spec.rb +1 -1
- data/spec/suite_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a24e95bd68b625c54093b4d41f19f264147cf28
|
4
|
+
data.tar.gz: db126bfc8830837da1cd36329451443ff610a624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ecf9190facd71bb800cdce96eb8069da3359afe1816ab381bc21735828f0ca8c19d066850ca30339c405b0408955438d53b29e290efde9fdbe1be72430ae43a
|
7
|
+
data.tar.gz: 3b6bf6517ba347b8b73679c213c2c625b0957990cf9c1a2ecc220a85b4ec0340c3299d79fa8c10453a194bf9a2a5195ac8cf5e001cd96324241d899d07e99fba
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.2
|
data/bin/jsonld
CHANGED
@@ -21,7 +21,6 @@ def run(input, options)
|
|
21
21
|
reader_class.new(input, options[:parser_options])
|
22
22
|
end
|
23
23
|
|
24
|
-
prefixes = {}
|
25
24
|
start = Time.new
|
26
25
|
if options[:expand]
|
27
26
|
options = options.merge(expandContext: options.delete(:context)) if options.has_key?(:context)
|
@@ -87,17 +86,27 @@ input = nil
|
|
87
86
|
OPT_ARGS = [
|
88
87
|
["--dbg", GetoptLong::NO_ARGUMENT, "Turn on verbose debugging"],
|
89
88
|
["--compact", GetoptLong::NO_ARGUMENT, "Compact document, using --context"],
|
89
|
+
["--compactArrays", GetoptLong::OPTIONAL_ARGUMENT, "Set compactArrays option"],
|
90
90
|
["--context", GetoptLong::REQUIRED_ARGUMENT,"Context to apply for expand, compact and converting from RDF"],
|
91
|
+
["--embed", GetoptLong::REQUIRED_ARGUMENT,"a flag specifying that objects should be directly embedded in the output, instead of being referred to by their IRI"],
|
91
92
|
["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as a JSON-LD document"],
|
92
93
|
["--expand", GetoptLong::NO_ARGUMENT, "Expand document, using an optional --context"],
|
94
|
+
["--expanded", GetoptLong::OPTIONAL_ARGUMENT, "Input is already expanded"],
|
95
|
+
["--explicit", GetoptLong::OPTIONAL_ARGUMENT, "a flag specifying that for properties to be included in the output, they must be explicitly declared in the framing context"],
|
93
96
|
["--flatten", GetoptLong::NO_ARGUMENT, "Flatten document, using an optional --context"],
|
94
97
|
["--format", GetoptLong::REQUIRED_ARGUMENT,"Specify output format when converting to RDF"],
|
95
98
|
["--frame", GetoptLong::REQUIRED_ARGUMENT,"Frame document, using the file or URL as a frame specification"],
|
96
99
|
["--input-format", GetoptLong::REQUIRED_ARGUMENT,"Format of the input document, when converting from RDF."],
|
100
|
+
["--omitDefault", GetoptLong::OPTIONAL_ARGUMENT,"a flag specifying that properties that are missing from the JSON-LD input should be omitted from the output"],
|
97
101
|
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT,"Output to the specified file path"],
|
98
102
|
["--parse-only", GetoptLong::NO_ARGUMENT, "Parse the document for well-formedness only"],
|
103
|
+
["--processingMode",GetoptLong::REQUIRED_ARGUMENT,"Set processing mode, defaults to json-ld-1.1"],
|
99
104
|
["--quiet", GetoptLong::NO_ARGUMENT, "Supress most output other than progress indicators"],
|
105
|
+
["--rename_bnodes", GetoptLong::OPTIONAL_ARGUMENT,"Rename bnodes as part of expansion, or keep them the same"],
|
106
|
+
["--requireAll", GetoptLong::OPTIONAL_ARGUMENT,"Rename bnodes as part of expansion, or keep them the same"],
|
107
|
+
["--simple_compact_iris",GetoptLong::OPTIONAL_ARGUMENT,"When compacting IRIs, do not use terms with expanded term definitions"],
|
100
108
|
["--stream", GetoptLong::NO_ARGUMENT, "Use Streaming reader/writer"],
|
109
|
+
["--unique_bnodes", GetoptLong::OPTIONAL_ARGUMENT,"Use unique bnode identifiers"],
|
101
110
|
["--uri", GetoptLong::REQUIRED_ARGUMENT,"URI to be used as the document base"],
|
102
111
|
["--validate", GetoptLong::NO_ARGUMENT, "Validate while processing"],
|
103
112
|
["--help", "-?", GetoptLong::NO_ARGUMENT, "This message"]
|
@@ -121,22 +130,42 @@ opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})
|
|
121
130
|
|
122
131
|
opts.each do |opt, arg|
|
123
132
|
case opt
|
124
|
-
when '--dbg'
|
125
|
-
when '--compact'
|
126
|
-
when
|
127
|
-
when '--
|
128
|
-
when '--
|
129
|
-
when '--
|
130
|
-
when
|
131
|
-
when
|
132
|
-
when '--
|
133
|
-
when '--
|
134
|
-
when '--
|
135
|
-
when '--
|
136
|
-
when
|
137
|
-
when '--
|
138
|
-
when '--
|
139
|
-
when '--
|
133
|
+
when '--dbg' then parser_options[:debug] = ::JSON::LD::debug = true
|
134
|
+
when '--compact' then options[:compact] = true
|
135
|
+
when "--compactArrays" then options[:compactArrays] = (arg || 'true') == 'true'
|
136
|
+
when '--context' then options[:context] = arg
|
137
|
+
when '--evaluate' then input = arg
|
138
|
+
when '--expand' then options[:expand] = true
|
139
|
+
when "--expanded" then options[:expanded] = (arg || 'true') == 'true'
|
140
|
+
when "--explicit" then options[:compactArrays] = (arg || 'true') == 'true'
|
141
|
+
when '--format' then options[:output_format] = arg.to_sym
|
142
|
+
when '--flatten' then options[:flatten] = arg
|
143
|
+
when '--frame' then options[:frame] = arg
|
144
|
+
when '--input-format' then options[:input_format] = arg.to_sym
|
145
|
+
when "--omitDefault" then options[:omitDefault] = (arg || 'true') == 'true'
|
146
|
+
when '--output' then options[:output] = File.open(arg, "w")
|
147
|
+
when '--parse-only' then options[:parse_only] = true
|
148
|
+
when '--processingMode' then options[:processingMode] = arg
|
149
|
+
when '--quiet' then options[:quiet] = true
|
150
|
+
when "--rename_bnodes" then options[:rename_bnodes] = (arg || 'true') == 'true'
|
151
|
+
when "--requireAll" then options[:requireAll] = (arg || 'true') == 'true'
|
152
|
+
when '--stream' then parser_options[:stream] = true
|
153
|
+
when "--unique_bnodes" then options[:unique_bnodes] = (arg || 'true') == 'true'
|
154
|
+
when '--uri' then parser_options[:base] = arg
|
155
|
+
when '--validate' then parser_options[:validate] = true
|
156
|
+
when '--help' then usage
|
157
|
+
when '--embed'
|
158
|
+
case arg
|
159
|
+
when '@always', '@never', '@link', '@last'
|
160
|
+
options[:embed] = arg
|
161
|
+
when 'true'
|
162
|
+
options[:embed] = true
|
163
|
+
when 'false'
|
164
|
+
options[:embed] = false
|
165
|
+
else
|
166
|
+
STDERR.puts "--embed option takes one of '@always', '@never', '@link', '@last', true, or false"
|
167
|
+
exit(1)
|
168
|
+
end
|
140
169
|
end
|
141
170
|
end
|
142
171
|
|
data/lib/json/ld/api.rb
CHANGED
@@ -60,8 +60,7 @@ module JSON::LD
|
|
60
60
|
# An external context to use additionally to the context embedded in input when expanding the input.
|
61
61
|
# @param [Hash{Symbol => Object}] options
|
62
62
|
# @option options [String, #to_s] :base
|
63
|
-
# The Base IRI to use when expanding the document. This overrides the value of `input` if it is a _IRI_. If not specified and `input` is not an _IRI_, the base IRI defaults to the current document IRI if in a browser context, or the empty string if there is no document context.
|
64
|
-
# If not specified, and a base IRI is found from `input`, options[:base] will be modified with this value.
|
63
|
+
# The Base IRI to use when expanding the document. This overrides the value of `input` if it is a _IRI_. If not specified and `input` is not an _IRI_, the base IRI defaults to the current document IRI if in a browser context, or the empty string if there is no document context. If not specified, and a base IRI is found from `input`, options[:base] will be modified with this value.
|
65
64
|
# @option options [Boolean] :compactArrays (true)
|
66
65
|
# If set to `true`, the JSON-LD processor replaces arrays with just one element with that element during compaction. If set to `false`, all arrays will remain arrays even if they have just one element.
|
67
66
|
# @option options [Proc] :documentLoader
|
@@ -148,8 +147,7 @@ module JSON::LD
|
|
148
147
|
private :initialize
|
149
148
|
|
150
149
|
##
|
151
|
-
# Expands the given input according to the steps in the Expansion Algorithm. The input must be copied, expanded and returned
|
152
|
-
# if there are no errors. If the expansion fails, an appropriate exception must be thrown.
|
150
|
+
# Expands the given input according to the steps in the Expansion Algorithm. The input must be copied, expanded and returned if there are no errors. If the expansion fails, an appropriate exception must be thrown.
|
153
151
|
#
|
154
152
|
# The resulting `Array` either returned or yielded
|
155
153
|
#
|
@@ -171,8 +169,7 @@ module JSON::LD
|
|
171
169
|
result = api.expand(api.value, nil, api.context, ordered: options.fetch(:ordered, true))
|
172
170
|
end
|
173
171
|
|
174
|
-
# If, after the algorithm outlined above is run, the resulting element is an
|
175
|
-
# JSON object with just a @graph property, element is set to the value of @graph's value.
|
172
|
+
# If, after the algorithm outlined above is run, the resulting element is an JSON object with just a @graph property, element is set to the value of @graph's value.
|
176
173
|
result = result['@graph'] if result.is_a?(Hash) && result.keys == %w(@graph)
|
177
174
|
|
178
175
|
# Finally, if element is a JSON object, it is wrapped into an array.
|
@@ -181,8 +178,7 @@ module JSON::LD
|
|
181
178
|
end
|
182
179
|
|
183
180
|
##
|
184
|
-
# Compacts the given input according to the steps in the Compaction Algorithm. The input must be copied, compacted and
|
185
|
-
# returned if there are no errors. If the compaction fails, an appropirate exception must be thrown.
|
181
|
+
# Compacts the given input according to the steps in the Compaction Algorithm. The input must be copied, compacted and returned if there are no errors. If the compaction fails, an appropirate exception must be thrown.
|
186
182
|
#
|
187
183
|
# If no context is provided, the input document is compacted using the top-level context of the document
|
188
184
|
#
|
@@ -284,9 +280,7 @@ module JSON::LD
|
|
284
280
|
end
|
285
281
|
|
286
282
|
##
|
287
|
-
# Frames the given input using the frame according to the steps in the Framing Algorithm. The input is used to build the
|
288
|
-
# framed output and is returned if there are no errors. If there are no matches for the frame, null must be returned.
|
289
|
-
# Exceptions must be thrown if there are errors.
|
283
|
+
# Frames the given input using the frame according to the steps in the Framing Algorithm. The input is used to build the framed output and is returned if there are no errors. If there are no matches for the frame, null must be returned. Exceptions must be thrown if there are errors.
|
290
284
|
#
|
291
285
|
# The resulting `Array` is either returned, or yielded if a block is given.
|
292
286
|
#
|
@@ -296,18 +290,13 @@ module JSON::LD
|
|
296
290
|
# The frame to use when re-arranging the data.
|
297
291
|
# @option options (see #initialize)
|
298
292
|
# @option options ['@last', '@always', '@never', '@link'] :embed ('@last')
|
299
|
-
# a flag specifying that objects should be directly embedded in the output,
|
300
|
-
# instead of being referred to by their IRI.
|
293
|
+
# a flag specifying that objects should be directly embedded in the output, instead of being referred to by their IRI.
|
301
294
|
# @option options [Boolean] :explicit (false)
|
302
|
-
# a flag specifying that for properties to be included in the output,
|
303
|
-
# they must be explicitly declared in the framing context.
|
295
|
+
# a flag specifying that for properties to be included in the output, they must be explicitly declared in the framing context.
|
304
296
|
# @option options [Boolean] :requireAll (true)
|
305
|
-
# A flag specifying that all properties present in the input frame must
|
306
|
-
# either have a default value or be present in the JSON-LD input for the
|
307
|
-
# frame to match.
|
297
|
+
# A flag specifying that all properties present in the input frame must either have a default value or be present in the JSON-LD input for the frame to match.
|
308
298
|
# @option options [Boolean] :omitDefault (false)
|
309
|
-
# a flag specifying that properties that are missing from the JSON-LD
|
310
|
-
# input should be omitted from the output.
|
299
|
+
# a flag specifying that properties that are missing from the JSON-LD input should be omitted from the output.
|
311
300
|
# @option options [Boolean] :expanded Input is already expanded
|
312
301
|
# @yield jsonld
|
313
302
|
# @yieldparam [Hash] jsonld
|
data/lib/json/ld/context.rb
CHANGED
@@ -1283,10 +1283,10 @@ module JSON::LD
|
|
1283
1283
|
#log_debug "uri(bnode)#{value}: #{$1}"
|
1284
1284
|
bnode(namer.get_sym($1))
|
1285
1285
|
else
|
1286
|
-
value = RDF::URI
|
1286
|
+
value = RDF::URI(value)
|
1287
1287
|
value.validate! if @options[:validate]
|
1288
1288
|
value.canonicalize! if @options[:canonicalize]
|
1289
|
-
value = RDF::URI.intern(value) if @options[:intern]
|
1289
|
+
value = RDF::URI.intern(value, {}) if @options[:intern]
|
1290
1290
|
value
|
1291
1291
|
end
|
1292
1292
|
end
|
data/lib/json/ld/resource.rb
CHANGED
data/lib/json/ld/to_rdf.rb
CHANGED
@@ -23,7 +23,7 @@ module JSON::LD
|
|
23
23
|
# If value is true or false, then set value its canonical lexical form as defined in the section Data Round Tripping. If datatype is null, set it to xsd:boolean.
|
24
24
|
value = value.to_s
|
25
25
|
datatype ||= RDF::XSD.boolean.to_s
|
26
|
-
when
|
26
|
+
when Numeric
|
27
27
|
# Otherwise, if value is a number, then set value to its canonical lexical form as defined in the section Data Round Tripping. If datatype is null, set it to either xsd:integer or xsd:double, depending on if the value contains a fractional and/or an exponential component.
|
28
28
|
lit = RDF::Literal.new(value, canonicalize: true)
|
29
29
|
value = lit.to_s
|
data/spec/resource_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe JSON::LD::Resource do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "#hash" do
|
43
|
-
specify {expect(subject.hash).to be_a(
|
43
|
+
specify {expect(subject.hash).to be_a(Integer)}
|
44
44
|
|
45
45
|
it "returns the hash of the attributes" do
|
46
46
|
expect(subject.hash).to eq subject.deresolve.hash
|
data/spec/suite_helper.rb
CHANGED
@@ -125,7 +125,7 @@ module Fixtures
|
|
125
125
|
end
|
126
126
|
if evaluationTest?
|
127
127
|
if testType == "jld:ToRDFTest"
|
128
|
-
expected = RDF::Repository.new << RDF::NQuads::Reader.new(expect)
|
128
|
+
expected = RDF::Repository.new << RDF::NQuads::Reader.new(expect, logger: [])
|
129
129
|
rspec_example.instance_eval {
|
130
130
|
expect(result).to be_equivalent_graph(expected, logger)
|
131
131
|
}
|
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: 2.1.
|
4
|
+
version: 2.1.2
|
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-12-
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|