Skip to content

Commit

Permalink
Enhanced RDF::Reader to automatically rewind the input stream once al…
Browse files Browse the repository at this point in the history
…l input has been consumed.

This helps make RDF::Reader more compatible with RDF::Enumerable, allowing subsequent operations on readers to work much as if readers were file-backed repositories.

However, since not all input streams are rewindable, this is currently defined as optional behavior; RDF.rb 0.3.0-compatible reader implementations SHOULD implement automatic rewinding where possible, but are not required to.
  • Loading branch information
artob committed Nov 18, 2010
1 parent cf2ca9e commit 41de696
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rdf/reader.rb
Expand Up @@ -252,6 +252,7 @@ def each_statement(&block)
begin
loop { block.call(read_statement) }
rescue EOFError => e
rewind rescue nil
end
end
enum_for(:each_statement)
Expand Down Expand Up @@ -285,6 +286,7 @@ def each_triple(&block)
begin
loop { block.call(*read_triple) }
rescue EOFError => e
rewind rescue nil
end
end
enum_for(:each_triple)
Expand Down

0 comments on commit 41de696

Please sign in to comment.