Skip to content
Browse files

Allow NTriples to use \r as line terminator.

  • Loading branch information...
1 parent a4581e8 commit 318d921c484396d55b0aa6f544bc41dd0ec7af62 @gkellogg gkellogg committed Nov 22, 2012
Showing with 7 additions and 8 deletions.
  1. +4 −3 lib/rdf/reader.rb
  2. +1 −3 spec/ntriples_spec.rb
  3. +2 −2 spec/readme_spec.rb
View
7 lib/rdf/reader.rb
@@ -483,9 +483,10 @@ def current_line
##
# @return [String]
def readline
- @line = @input.readline
- @line.chomp!
- @line.force_encoding(encoding) if @line.respond_to?(:force_encoding) # for Ruby 1.9+
+ @line = @line_rest || @input.readline
+ @line, @line_rest = @line.split("\r", 2)
+ @line = @line.to_s.chomp
+ @line.force_encoding(encoding) if @line.respond_to?(:force_encoding)
@line
end
View
4 spec/ntriples_spec.rb
@@ -346,9 +346,7 @@
end
it "should parse W3C's test data" do
- pending "lines separated by just \"\\r\" without a \"\\n\" are parsed incorrectly" do
- @reader.new(File.open(@testfile)).to_a.size.should == 30
- end
+ @reader.new(File.open(@testfile)).to_a.size.should == 30
end
it "should parse terms" do
View
4 spec/readme_spec.rb
@@ -7,12 +7,12 @@
@stdout, $stdout = $stdout, StringIO.new
@olddir, @tmpdir = Dir.pwd, File.join(File.dirname(__FILE__), '..', 'tmp')
FileUtils.mkdir_p(@tmpdir)
- Dir.chdir(@tmpdir)
+ Dir.chdir(@tmpdir) # FIXME: chdir causing warnings
end
after :each do
$stdout = @stdout
- Dir.chdir(@olddir)
+ Dir.chdir(@olddir) # FIXME: chdir causing warnings
end
context "the 'Writing RDF data using the N-Triples format' example" do

0 comments on commit 318d921

Please sign in to comment.
Something went wrong with that request. Please try again.