Skip to content

Commit 83a5022

Browse files
committed
Add whitespace to canonical triple term representation.
1 parent c119c20 commit 83a5022

4 files changed

Lines changed: 36 additions & 34 deletions

File tree

lib/rdf/ntriples/writer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def format_statement(statement, **options)
230230
# @param [Hash{Symbol => Object}] options ({})
231231
# @return [String]
232232
def format_tripleTerm(statement, **options)
233-
"<<(%s %s %s)>>" % statement.to_a.map { |value| format_term(value, **options) }
233+
"<<( %s %s %s )>>" % statement.to_a.map { |value| format_term(value, **options) }
234234
end
235235

236236
##

lib/rdf/reader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def initialize(input = $stdin,
333333
# Returns the base URI determined by this reader.
334334
#
335335
# @example
336-
# reader.prefixes[:dc] #=> RDF::URI('http://purl.org/dc/terms/')
336+
# reader.base_uri #=> RDF::URI('http://example.com/')
337337
#
338338
# @return [RDF::URI]
339339
# @since 0.3.0

spec/nquads_spec.rb

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -180,51 +180,59 @@
180180
end
181181
end
182182

183-
# FIXME: quoted triples are deprecated
184-
context "quoted triples" do
185-
statements = {
183+
context "triple terms" do
184+
ill_statements = {
186185
"subject-iii": '<<<http://example/s1> <http://example/p1> <http://example/o1>>> <http://example/p> <http://example/o> <http://example/g> .',
187186
"subject-iib": '<<<http://example/s1> <http://example/p1> _:o1>> <http://example/p> <http://example/o> <http://example/g> .',
188187
"subject-iil": '<<<http://example/s1> <http://example/p1> "o1">> <http://example/p> <http://example/o> <http://example/g> .',
189188
"subject-bii": '<<_:s1 <http://example/p1> <http://example/o1>>> <http://example/p> <http://example/o> <http://example/g> .',
190189
"subject-bib": '<<_:s1 <http://example/p1> _:o1>> <http://example/p> <http://example/o> <http://example/g> .',
191190
"subject-bil": '<<_:s1 <http://example/p1> "o">> <http://example/p> <http://example/o> <http://example/g> .',
192191
"subject-ws": '<< <http://example/s1> <http://example/p1> <http://example/o1> >> <http://example/p> <http://example/o> <http://example/g> .',
193-
"object-iii": '<http://example/s> <http://example/p> <<<http://example/s1> <http://example/p1> <http://example/o1>>> <http://example/g> .',
194-
"object-iib": '<http://example/s> <http://example/p> <<<http://example/s1> <http://example/p1> _:o1>> <http://example/g> .',
195-
"object-iil": '<http://example/s> <http://example/p> <<<http://example/s1> <http://example/p1> "o1">> <http://example/g> .',
196-
"object-ws": '<http://example/s> <http://example/p> << <http://example/s1> <http://example/p1> <http://example/o1> >> <http://example/g> .',
192+
"recursive-subject": '<<(<<(<http://example/s2> <http://example/p2> <http://example/o2>)>> <http://example/p1> <http://example/o1>)>> <http://example/p> <http://example/o> <http://example/g> .',
193+
}
194+
195+
statements = {
196+
"object-iii": '<http://example/s> <http://example/p> <<(<http://example/s1> <http://example/p1> <http://example/o1>)>> <http://example/g> .',
197+
"object-iib": '<http://example/s> <http://example/p> <<(<http://example/s1> <http://example/p1> _:o1)>> <http://example/g> .',
198+
"object-iil": '<http://example/s> <http://example/p> <<(<http://example/s1> <http://example/p1> "o1")>> <http://example/g> .',
199+
"object-ws": '<http://example/s> <http://example/p> <<( <http://example/s1> <http://example/p1> <http://example/o1> )>> <http://example/g> .',
197200
}
198201

199202
context "without rdfstar option" do
200203
it "Raises an error" do
201204
expect do
202-
expect {RDF::Graph.new << described_class.new(statements.values.first)}.to raise_error(RDF::ReaderError)
205+
expect {RDF::Repository.new << RDF::NQuads::Reader.new(statements.values.first)}.to raise_error(RDF::ReaderError)
203206
end.to write(:something).to(:error)
204207
end
205208
end
206209

207-
statements.each do |name, st|
208-
context name do
209-
let(:graph) do
210-
g = RDF::Graph.new
211-
expect do
212-
g << RDF::NQuads::Reader.new(st, rdfstar: true)
213-
end.to write('[DEPRECATION]').to(:error)
214-
g
210+
context "with rdfstar option" do
211+
ill_statements.each do |name, st|
212+
context name do
213+
it "Raises an error" do
214+
expect do
215+
expect {RDF::Repository.new << RDF::NQuads::Reader.new(statements.values.first)}.to raise_error(RDF::ReaderError)
216+
end.to write(:something).to(:error)
217+
end
215218
end
219+
end
216220

217-
it "creates two statements" do
218-
expect(graph.count).to eql(1)
219-
end
221+
statements.each do |name, st|
222+
context name do
223+
let(:graph) do
224+
RDF::Repository.new {|r| r << RDF::NQuads::Reader.new(st, rdfstar: true)}
225+
end
226+
227+
it "creates a statement" do
228+
expect(graph.count).to eql(1)
229+
end
220230

221-
it "has a statement whose subject or object is a statement" do
222-
referencing = graph.statements.first
223-
expect(referencing).to be_a_statement
224-
if referencing.subject.statement?
225-
expect(referencing.subject).to be_a_statement
226-
else
231+
it "statements which are object of another statement are triple terms" do
232+
referencing = graph.statements.first
233+
expect(referencing).to be_a_statement
227234
expect(referencing.object).to be_a_statement
235+
expect(referencing.object).to be_tripleTerm
228236
end
229237
end
230238
end

spec/ntriples_spec.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,13 @@
479479
context name do
480480
let(:graph) {parse(st, rdfstar: true)}
481481

482-
it "creates two unquoted statements" do
482+
it "creates an unquoted statement" do
483483
expect(graph.count).to eql(1)
484484
graph.statements.each do |stmt|
485485
expect(stmt).not_to be_quoted
486486
end
487487
end
488488

489-
it "has a statement whose object is a statement" do
490-
referencing = graph.statements.first
491-
expect(referencing).to be_a_statement
492-
expect(referencing.object).to be_a_statement
493-
end
494-
495489
it "statements which are object of another statement are triple terms" do
496490
referencing = graph.statements.first
497491
expect(referencing).to be_a_statement

0 commit comments

Comments
 (0)