mogilefs-client.git  about / heads / tags
MogileFS client library for Ruby
blob ecec02ed448aa9d15a80738e0af816244f63f234 475 bytes (raw)
$ git show pu:lib/mogilefs/new_file/tempfile.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
# -*- encoding: binary -*-
# here are internal implementation details, do not rely on them in your code
require 'tempfile'
require 'mogilefs/http_file'

class MogileFS::NewFile::Tempfile < Tempfile
  def initialize(*args)
    @mogilefs_httpfile_args = args
    super("mogilefs-client")
    unlink
  end

  def commit
    rewind
    tmp = MogileFS::HTTPFile.new(*@mogilefs_httpfile_args)
    tmp.big_io = to_io
    tmp.commit
  end

  def close
    commit
    super
  end
end

git clone https://yhbt.net/mogilefs-client.git