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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb9297e31b76d1e901ae278f349ed412086831f5
4
- data.tar.gz: e07e7aeb8bb57349e5f819da903fb55524c46b43
3
+ metadata.gz: 1a24e95bd68b625c54093b4d41f19f264147cf28
4
+ data.tar.gz: db126bfc8830837da1cd36329451443ff610a624
5
5
  SHA512:
6
- metadata.gz: 7baea9184fa7cea017a37cb7ec2aa2a4a4b18e153b6a771a8b5297bfe518ca669a66e9a84dc5e37dd04e1b135653ff9195f4b6fb56d48af1a835f1290f8862dd
7
- data.tar.gz: fba430dad035dd6465e07ee94c952bf79c33be220baa642a57e07c8d21cd7aa3431e824c5487c3f3b43f4a23f7b30f55c62d059e4b6fb5c2ff1ac8828932b86e
6
+ metadata.gz: 0ecf9190facd71bb800cdce96eb8069da3359afe1816ab381bc21735828f0ca8c19d066850ca30339c405b0408955438d53b29e290efde9fdbe1be72430ae43a
7
+ data.tar.gz: 3b6bf6517ba347b8b73679c213c2c625b0957990cf9c1a2ecc220a85b4ec0340c3299d79fa8c10453a194bf9a2a5195ac8cf5e001cd96324241d899d07e99fba
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.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' then parser_options[:debug] = ::JSON::LD::debug = true
125
- when '--compact' then options[:compact] = true
126
- when '--context' then options[:context] = arg
127
- when '--evaluate' then input = arg
128
- when '--expand' then options[:expand] = true
129
- when '--format' then options[:output_format] = arg.to_sym
130
- when '--flatten' then options[:flatten] = arg
131
- when '--frame' then options[:frame] = arg
132
- when '--input-format' then options[:input_format] = arg.to_sym
133
- when '--output' then options[:output] = File.open(arg, "w")
134
- when '--parse-only' then options[:parse_only] = true
135
- when '--quiet' then options[:quiet] = true
136
- when '--stream' then parser_options[:stream] = true
137
- when '--uri' then parser_options[:base] = arg
138
- when '--validate' then parser_options[:validate] = true
139
- when '--help' then usage
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
 
@@ -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
@@ -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.new(value)
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
@@ -93,7 +93,7 @@ module JSON::LD
93
93
 
94
94
  ##
95
95
  # Return a hash of this object, suitable for use by for ETag
96
- # @return [Fixnum]
96
+ # @return [Integer]
97
97
  def hash
98
98
  self.deresolve.hash
99
99
  end
@@ -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 Integer, Float, Fixnum
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
@@ -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(Fixnum)}
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
@@ -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.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-27 00:00:00.000000000 Z
11
+ date: 2016-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf