Skip to content

Commit

Permalink
first pass to fix issue #13 -- pass through IO-type objects that can'…
Browse files Browse the repository at this point in the history
…t be IO#read properly (because they are too large?)
  • Loading branch information
Chris Beer committed Mar 21, 2012
1 parent 963aac9 commit cff91ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rubydora/datastream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def content
rescue RestClient::ResourceNotFound
end

content = @content.read and @content.rewind if @content.kind_of? IO
if @content.kind_of? IO
content = @content.read and @content.rewind rescue nil
end

content ||= @content
end
alias_method :read, :content
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/datastream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@

end

it "should pass-through IO-type content if reading the content fails" do
@mock_io = File.open('rubydora.gemspec')
@mock_io.should_receive(:read).and_raise('Rubydora #13-style read-error.')

@datastream.content = @mock_io

@datastream.content.should == @mock_io

end


end

Expand Down

0 comments on commit cff91ce

Please sign in to comment.