tests: speedup tests that require hitting mogstored
[ruby-mogilefs-client.git] / lib / mogilefs / put / tempfile.rb
blob8082f95854576d00fdcbf95e1535cc03e74f3620
1 # -*- encoding: binary -*-
2 # here are internal implementation details, do not rely on them in your code
3 require 'tempfile'
4 require 'mogilefs/http_file'
6 class MogileFS::Put::Tempfile < Tempfile
7   def initialize(*args)
8     @mogilefs_httpfile_args = args
9     super("mogilefs-client")
10     unlink
11   end
13   def commit
14     rewind
15     tmp = MogileFS::HTTPFile.new(*@mogilefs_httpfile_args)
16     tmp.big_io = to_io
17     tmp.commit
18   end
20   def close
21     commit
22     super
23   end
24 end