Sha256: 53fd93caf10aa1683a6ea64de3ac3aabaf4a129ae5444ebbd36067ca51a766af

Contents?: true

Size: 501 Bytes

Versions: 1

Compression:

Stored size: 501 Bytes

Contents

#--
# Copyright 2009 Suraj N. Kurapati
# See the LICENSE file for details.
#++

require 'tempfile'
require 'fileutils'

class TempDir
  attr_reader :path

  def initialize basename = nil, dirname = nil
    args = [basename || File.basename($0), dirname].compact
    file = Tempfile.new(*args)

    @path = file.path

    # replace the file with a directory
    file.close!
    FileUtils.mkdir_p @path

    # clean up on exit
    at_exit { close }
  end

  def close
    FileUtils.rm_rf @path
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inochi-1.0.0 lib/inochi/util/tempdir.rb