json-ld 2.0.0.beta2 → 2.0.0.beta3

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: 5adc54c6221f35206e44c2d599acc5bdf40431c5
4
- data.tar.gz: 484e28238ca6b1615943d1b3040fa08cf9b077c1
3
+ metadata.gz: 1da92b315af019278538aaac7a28f81aa326b9d2
4
+ data.tar.gz: 6af02e670f5487b42020949408bc2e41a34acd15
5
5
  SHA512:
6
- metadata.gz: 9d268dcf9996b5cb83bf2a775c96c04a2cca8afd6901fdf7b40815b2a654edc3e032d528bc4bc59c712c11fa0d78c6aabc08ddd8010f42abc9c76f089ccf5aed
7
- data.tar.gz: a283566902b6d1896f2685c06de158d35da2a94317afaf942ebb6ee4714eb9d7d4eb1f65e2538fc381a278e457a0d99b21640bc7ab9e3a2fc90bb69799c13516
6
+ metadata.gz: 89bf9f2ac0f47311225074131ea1bb83a332f53b33b44a26c37c127b883208cad59e97f292275a4ffa76be4a5da6e1147990ae48f266d4251c1f596070db81ca
7
+ data.tar.gz: ef1940a0babfabeeee80890eceb153d57dd99d5322338c431f8c4db8c1f96fb2e79d9564af6afe6ab1c02cf837899812e00a82f7fd9f70e0d394bb680e38cc19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta2
1
+ 2.0.0.beta3
data/lib/json/ld/api.rb CHANGED
@@ -79,7 +79,7 @@ module JSON::LD
79
79
  # @option options [Boolean] :rename_bnodes (true)
80
80
  # Rename bnodes as part of expansion, or keep them the same.
81
81
  # @option options [Boolean] :unique_bnodes (false)
82
- # Use unique bnode identifiers, defaults to using the identifier which the node was originall initialized with (if any).
82
+ # Use unique bnode identifiers, defaults to using the identifier which the node was originally initialized with (if any).
83
83
  # @option options [Boolean] :simple_compact_iris (false)
84
84
  # When compacting IRIs, do not use terms with expanded term definitions
85
85
  # @option options [Symbol] :adapter used with MultiJson
@@ -133,7 +133,7 @@ module JSON::LD
133
133
  context ||= (@value['@context'] if @value.is_a?(Hash)) || context_ref
134
134
  @context = Context.new(@options)
135
135
  @context = @context.parse(context) if context
136
-
136
+
137
137
  if block_given?
138
138
  case block.arity
139
139
  when 0, -1 then instance_eval(&block)
@@ -265,11 +265,11 @@ module JSON::LD
265
265
  result = context.dup
266
266
  when IO, StringIO
267
267
  log_debug("parse") {"io: #{context}"}
268
- # Load context document, if it is a string
268
+ # Load context document, if it is an open file
269
269
  begin
270
270
  ctx = JSON.load(context)
271
271
  raise JSON::LD::JsonLdError::InvalidRemoteContext, "Context missing @context key" if @options[:validate] && ctx['@context'].nil?
272
- result = parse(ctx["@context"] ? ctx["@context"].dup : {})
272
+ result = result.dup.parse(ctx["@context"] ? ctx["@context"].dup : {})
273
273
  result.provided_context = ctx["@context"] if [context] == local_context
274
274
  result
275
275
  rescue JSON::ParserError => e
@@ -286,7 +286,7 @@ module JSON::LD
286
286
  raise JsonLdError::RecursiveContextInclusion, "#{context}" if remote_contexts.include?(context.to_s)
287
287
  remote_contexts << context.to_s
288
288
 
289
- context_no_base = self.dup
289
+ context_no_base = result.dup
290
290
  context_no_base.base = nil
291
291
  context_no_base.context_base = context.to_s
292
292
 
data/lib/json/ld/utils.rb CHANGED
@@ -70,7 +70,7 @@ module JSON::LD
70
70
  def as_resource(id, base = nil)
71
71
  @nodes ||= {} # Re-use BNodes
72
72
  if id[0,2] == '_:'
73
- (@nodes[id] ||= RDF::Node.new(id[2..-1]))
73
+ (@nodes[id] ||= RDF::Node.new(namer.get_sym(id)))
74
74
  elsif base
75
75
  base.join(id)
76
76
  else
@@ -130,7 +130,6 @@ module JSON::LD
130
130
  options[:base_uri] ||= options[:base] if options.has_key?(:base)
131
131
  options[:base] ||= options[:base_uri] if options.has_key?(:base_uri)
132
132
  super do
133
- log_statistics.clear # FIXME: shouldn't be necessary
134
133
  @repo = RDF::Repository.new
135
134
 
136
135
  if block_given?
data/spec/context_spec.rb CHANGED
@@ -109,6 +109,24 @@ describe JSON::LD::Context do
109
109
  "bar" => "http://example.com/foo"
110
110
  }, logger)
111
111
  end
112
+
113
+ it "merges definitions from remote contexts" do
114
+ expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/context", anything).and_yield(remote_doc)
115
+ rd2 = JSON::LD::API::RemoteDocument.new("http://example.com/c2", %q({
116
+ "@context": {
117
+ "title": {"@id": "http://purl.org/dc/terms/title"}
118
+ }
119
+ }))
120
+ expect(JSON::LD::API).to receive(:documentLoader).with("http://example.com/c2", anything).and_yield(rd2)
121
+ ec = subject.parse(%w(http://example.com/context http://example.com/c2))
122
+ expect(ec.send(:mappings)).to produce({
123
+ "xsd" => "http://www.w3.org/2001/XMLSchema#",
124
+ "name" => "http://xmlns.com/foaf/0.1/name",
125
+ "homepage" => "http://xmlns.com/foaf/0.1/homepage",
126
+ "avatar" => "http://xmlns.com/foaf/0.1/avatar",
127
+ "title" => "http://purl.org/dc/terms/title"
128
+ }, logger)
129
+ end
112
130
  end
113
131
 
114
132
  context "Hash" do
@@ -11,7 +11,6 @@ describe JSON::LD do
11
11
  specify "#{t.property('input')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
12
12
  skip "Native value fidelity" if %w(toRdf-0035-in.jsonld).include?(t.property('input'))
13
13
  pending "Generalized RDF" if %w(toRdf-0118-in.jsonld).include?(t.property('input'))
14
- pending "Blank nodes with reverse properties" if %w(toRdf-0119-in.jsonld).include?(t.property('input'))
15
14
  t.run self
16
15
  end
17
16
  end
data/spec/writer_spec.rb CHANGED
@@ -201,7 +201,6 @@ describe JSON::LD::Writer do
201
201
  logger.info "source: #{t.input}"
202
202
  t.logger = logger
203
203
  pending "Shared list BNode in different graphs" if t.property('input').include?("fromRdf-0021")
204
- pending "graph comparison issue" if t.property('input').include?("fromRdf-0008")
205
204
  repo = RDF::Repository.load(t.input_loc, format: :nquads)
206
205
  jsonld = JSON::LD::Writer.buffer(logger: t.logger) do |writer|
207
206
  writer << repo
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.0.0.beta2
4
+ version: 2.0.0.beta3
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-02-28 00:00:00.000000000 Z
11
+ date: 2016-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf