Skip to content

Commit d8ba5f9

Browse files
committed
Finish 2.0.0.beta3
2 parents c4a77fe + c14c74c commit d8ba5f9

File tree

10 files changed

+37
-10
lines changed

10 files changed

+37
-10
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0.beta2
1+
2.0.0.beta3

example-files/pendragon-2.jsonld

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": [
3+
"http://bibdata.princeton.edu/dc/context.json",
4+
"http://bibdata.princeton.edu/mrel/context.json"
5+
],
6+
"@id": "http://bibdata.princeton.edu/bibliographic/4609321",
7+
"title": {
8+
"@value": "Biblia Latina",
9+
"@language": "lat"
10+
}
11+
}

lib/json/ld/api.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class API
7979
# @option options [Boolean] :rename_bnodes (true)
8080
# Rename bnodes as part of expansion, or keep them the same.
8181
# @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).
8383
# @option options [Boolean] :simple_compact_iris (false)
8484
# When compacting IRIs, do not use terms with expanded term definitions
8585
# @option options [Symbol] :adapter used with MultiJson
@@ -133,7 +133,7 @@ def initialize(input, context, options = {}, &block)
133133
context ||= (@value['@context'] if @value.is_a?(Hash)) || context_ref
134134
@context = Context.new(@options)
135135
@context = @context.parse(context) if context
136-
136+
137137
if block_given?
138138
case block.arity
139139
when 0, -1 then instance_eval(&block)

lib/json/ld/context.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ def parse(local_context, remote_contexts = [])
265265
result = context.dup
266266
when IO, StringIO
267267
log_debug("parse") {"io: #{context}"}
268-
# Load context document, if it is a string
268+
# Load context document, if it is an open file
269269
begin
270270
ctx = JSON.load(context)
271271
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 : {})
273273
result.provided_context = ctx["@context"] if [context] == local_context
274274
result
275275
rescue JSON::ParserError => e
@@ -286,7 +286,7 @@ def parse(local_context, remote_contexts = [])
286286
raise JsonLdError::RecursiveContextInclusion, "#{context}" if remote_contexts.include?(context.to_s)
287287
remote_contexts << context.to_s
288288

289-
context_no_base = self.dup
289+
context_no_base = result.dup
290290
context_no_base.base = nil
291291
context_no_base.context_base = context.to_s
292292

lib/json/ld/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def value?(value)
7070
def as_resource(id, base = nil)
7171
@nodes ||= {} # Re-use BNodes
7272
if id[0,2] == '_:'
73-
(@nodes[id] ||= RDF::Node.new(id[2..-1]))
73+
(@nodes[id] ||= RDF::Node.new(namer.get_sym(id)))
7474
elsif base
7575
base.join(id)
7676
else

lib/json/ld/writer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def initialize(output = $stdout, options = {}, &block)
130130
options[:base_uri] ||= options[:base] if options.has_key?(:base)
131131
options[:base] ||= options[:base_uri] if options.has_key?(:base_uri)
132132
super do
133-
log_statistics.clear # FIXME: shouldn't be necessary
134133
@repo = RDF::Repository.new
135134

136135
if block_given?

script/parse

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'rubygems'
33
require "bundler/setup"
44
$:.unshift(File.expand_path("../../lib", __FILE__))
5+
require 'rdf/turtle'
56
begin
67
require 'linkeddata'
78
rescue LoadError

spec/context_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ def containers
109109
"bar" => "http://example.com/foo"
110110
}, logger)
111111
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
112130
end
113131

114132
context "Hash" do

spec/suite_to_rdf_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
specify "#{t.property('input')}: #{t.name}#{' (negative test)' unless t.positiveTest?}" do
1212
skip "Native value fidelity" if %w(toRdf-0035-in.jsonld).include?(t.property('input'))
1313
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'))
1514
t.run self
1615
end
1716
end

spec/writer_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@
201201
logger.info "source: #{t.input}"
202202
t.logger = logger
203203
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")
205204
repo = RDF::Repository.load(t.input_loc, format: :nquads)
206205
jsonld = JSON::LD::Writer.buffer(logger: t.logger) do |writer|
207206
writer << repo

0 commit comments

Comments
 (0)