json-ld 1.1.6.1 → 1.1.7

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: 7fee10018378978dc0a87102e4c783208b1613cf
4
- data.tar.gz: 9cde4a421857ee6a66cd9e0978ec168046d2675b
3
+ metadata.gz: b6c779ef87a832a22299e041f6247302d291701d
4
+ data.tar.gz: 1dea55d7a1187607566c39865ed76ca4dbc8131a
5
5
  SHA512:
6
- metadata.gz: a85611f4cd46ca52b6a75bdb2cddb6185e603848c3bea5caf1719936f9f96d32ee05fbd5bf4c55c1b41fdebef51d9fad450797a64f8bc73a37b47097a2ee341f
7
- data.tar.gz: df6233a9715ce191085f38a4b21f158dc0fdc36efca5db1fd3eee9049925d5117101ed96717c93cfab1544d058ce99f2df284a9b37d903d62e387c958d944e08
6
+ metadata.gz: 2e8560d7338e1d891bf5dc2d0959d1a767b5fa1e73a89be5533f5b064dbc135187a755f0f736683945e2ea52fe89fece40bed2f24e5dd075cd10790634c4a7a8
7
+ data.tar.gz: 987d781688176b608e3f0d70f18e50936376096857176293f14b995d061982ec5c9bc1e64e75fdbca7e797d5a3069ffe6002658e5c623205b605d796430a770f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.6.1
1
+ 1.1.7
@@ -493,7 +493,7 @@ module JSON::LD
493
493
  remote_document = RemoteDocument.new(parsed_url.to_s, response.body)
494
494
 
495
495
  # If the input has been retrieved, the response has an HTTP Link Header [RFC5988] using the http://www.w3.org/ns/json-ld#context link relation and a content type of application/json or any media type with a +json suffix as defined in [RFC6839] except application/ld+json, update the active context using the Context Processing algorithm, passing the context referenced in the HTTP Link Header as local context. The HTTP Link Header is ignored for documents served as application/ld+json If multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context link relation are found, the promise is rejected with a JsonLdError whose code is set to multiple context link headers and processing is terminated.
496
- unless content_type.start_with?("application/ld+json")
496
+ unless content_type.to_s.start_with?("application/ld+json")
497
497
  links = response["link"].to_s.
498
498
  split(",").
499
499
  map(&:strip).
@@ -190,6 +190,14 @@ module JSON::LD
190
190
  yield(self) if block_given?
191
191
  end
192
192
 
193
+ ##
194
+ # Initial context, without mappings, vocab or default language
195
+ #
196
+ # @return [Boolean]
197
+ def empty?
198
+ @term_definitions.empty? && self.vocab.nil? && self.default_language.nil?
199
+ end
200
+
193
201
  # @param [String] value must be an absolute IRI
194
202
  def base=(value)
195
203
  if value
@@ -247,6 +255,8 @@ module JSON::LD
247
255
  # @see http://json-ld.org/spec/latest/json-ld-api/index.html#context-processing-algorithm
248
256
  def parse(local_context, remote_contexts = [])
249
257
  result = self.dup
258
+ result.provided_context = local_context if self.empty?
259
+
250
260
  local_context = [local_context] unless local_context.is_a?(Array)
251
261
 
252
262
  local_context.each do |context|
@@ -265,7 +275,7 @@ module JSON::LD
265
275
  ctx = JSON.load(context)
266
276
  raise JSON::LD::JsonLdError::InvalidRemoteContext, "Context missing @context key" if @options[:validate] && ctx['@context'].nil?
267
277
  result = parse(ctx["@context"] ? ctx["@context"].dup : {})
268
- result.provided_context = ctx["@context"]
278
+ result.provided_context = ctx["@context"] if [context] == local_context
269
279
  result
270
280
  rescue JSON::ParserError => e
271
281
  debug("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
@@ -283,9 +293,6 @@ module JSON::LD
283
293
 
284
294
  context_no_base = self.dup
285
295
  context_no_base.base = nil
286
- unless @options[:processingMode] == "json-ld-1.0"
287
- context_no_base.provided_context = context.to_s
288
- end
289
296
  context_no_base.context_base = context.to_s
290
297
 
291
298
  begin
@@ -310,7 +317,7 @@ module JSON::LD
310
317
 
311
318
  # 3.2.6) Set context to the result of recursively calling this algorithm, passing context no base for active context, context for local context, and remote contexts.
312
319
  context = context_no_base.parse(context, remote_contexts.dup)
313
- context.provided_context = context_no_base.provided_context
320
+ context.provided_context = result.provided_context
314
321
  context.base ||= result.base
315
322
  result = context
316
323
  debug("parse") {"=> provided_context: #{context.inspect}"}
@@ -80,6 +80,20 @@ describe JSON::LD::Context do
80
80
  "avatar" => "http://xmlns.com/foaf/0.1/avatar"
81
81
  }, @debug)
82
82
  end
83
+
84
+ context "remote with local mappings" do
85
+ let(:ctx) {["http://example.com/context", {"integer" => "xsd:integer"}]}
86
+ it "retrieves and parses a remote context document" do
87
+ expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
88
+ ec = subject.parse(ctx)
89
+ end
90
+
91
+ it "does not use passed context as provided_context" do
92
+ expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context").and_yield(remote_doc)
93
+ ec = subject.parse(ctx)
94
+ expect(ec.provided_context).to produce(ctx, @debug)
95
+ end
96
+ end
83
97
  end
84
98
 
85
99
  context "Array" do
@@ -557,7 +571,7 @@ describe JSON::LD::Context do
557
571
  {
558
572
  "extra key" => {
559
573
  :input => {"foo" => {"@id" => "http://example.com/foo", "@baz" => "foobar"}},
560
- :result => {"@context" => {"foo" => "http://example.com/foo"}}
574
+ :result => {"@context" => {"foo" => {"@id" => "http://example.com/foo", "@baz" => "foobar"}}}
561
575
  }
562
576
  }.each do |title, params|
563
577
  it title do
@@ -10,6 +10,7 @@ describe JSON::LD do
10
10
  describe m.name do
11
11
  m.entries.each do |t|
12
12
  specify "#{t.property('input')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
13
+ pending "context corner-case" if t.input_loc.end_with?('flatten-0044-in.jsonld')
13
14
  t.run self
14
15
  end
15
16
  end
@@ -64,6 +64,10 @@ module Fixtures
64
64
  end
65
65
 
66
66
  define_method("#{m}_loc".to_sym) {property(m) && "#{SUITE}tests/#{property(m)}"}
67
+
68
+ define_method("#{m}_json".to_sym) do
69
+ JSON.parse(self.send(m)) if property(m)
70
+ end
67
71
  end
68
72
 
69
73
  def testType
@@ -100,7 +104,7 @@ module Fixtures
100
104
  when "jld:ExpandTest"
101
105
  JSON::LD::API.expand(input_loc, options.merge(:debug => debug))
102
106
  when "jld:CompactTest"
103
- JSON::LD::API.compact(input_loc, context_loc, options.merge(:debug => debug))
107
+ JSON::LD::API.compact(input_loc, context_json['@context'], options.merge(:debug => debug))
104
108
  when "jld:FlattenTest"
105
109
  JSON::LD::API.flatten(input_loc, context_loc, options.merge(:debug => debug))
106
110
  when "jld:FrameTest"
@@ -148,7 +152,7 @@ module Fixtures
148
152
  when "jld:ExpandTest"
149
153
  JSON::LD::API.expand(t.input_loc, options.merge(:debug => debug))
150
154
  when "jld:CompactTest"
151
- JSON::LD::API.compact(t.input_loc, t.context_loc, options.merge(:debug => debug))
155
+ JSON::LD::API.compact(t.input_loc, t.context_json['@context'], options.merge(:debug => debug))
152
156
  when "jld:FlattenTest"
153
157
  JSON::LD::API.flatten(t.input_loc, t.context_loc, options.merge(:debug => debug))
154
158
  when "jld:FrameTest"
@@ -263,7 +267,7 @@ module Fixtures
263
267
 
264
268
  remote_document = JSON::LD::API::RemoteDocument.new(parsed_url.to_s, response.body)
265
269
 
266
- unless content_type.start_with?("application/ld+json")
270
+ unless content_type.to_s.start_with?("application/ld+json")
267
271
  links = response["link"].to_s.
268
272
  split(",").
269
273
  map(&:strip).
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.6.1
4
+ version: 1.1.7
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-09-26 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -30,20 +30,6 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.1.4
33
- - !ruby/object:Gem::Dependency
34
- name: equivalent-xml
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '0.4'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0.4'
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: open-uri-cached
49
35
  requirement: !ruby/object:Gem::Requirement