class Bundler::Dir

def self.mktmpdir(prefix_suffix=nil, *rest, **options)


end
Bundler::FileUtils.remove_entry dir
# remove the directory.
ensure
open("#{dir}/foo", "w") { ... }
# use the directory...
begin
dir = Bundler::Dir.mktmpdir

In this case, Bundler::Dir.mktmpdir doesn't remove the directory.
The path of the directory is returned.
If a block is not given,

}
open("#{dir}/foo", "w") { ... }
# use the directory...
Bundler::Dir.mktmpdir {|dir|

The value of the block is returned.
using Bundler::FileUtils.remove_entry before Bundler::Dir.mktmpdir returns.
The directory and its contents are removed
it is yielded with the path of the directory.
If a block is given,

Bundler::Dir.mktmpdir(nil, "/var/tmp") {|dir| dir is "/var/tmp/d..." }
Bundler::Dir.mktmpdir {|dir| dir is "#{Bundler::Dir.tmpdir}/d..." }

the optional second argument tmpdir if non-nil value is given.
The directory is created under Bundler::Dir.tmpdir or

Bundler::Dir.mktmpdir(["foo", "bar"]) {|dir| dir is ".../foo...bar" }
Bundler::Dir.mktmpdir("foo") {|dir| dir is ".../foo..." }
Bundler::Dir.mktmpdir {|dir| dir is ".../d..." }

- If it is an array, first element is used as the prefix and second element is used as a suffix.
- If it is a string, it is used as the prefix and no suffix is used.
- If it is not specified or nil, "d" is used as the prefix and no suffix is used.
the optional first argument, prefix_suffix.
The prefix and suffix of the name of the directory is specified by

Application should not change the permission to make the temporary directory accessible from other users.
The directory is created with 0700 permission.

Bundler::Dir.mktmpdir creates a temporary directory.
def self.mktmpdir(prefix_suffix=nil, *rest, **options)
  base = nil
  path = Tmpname.create(prefix_suffix || "d", *rest, **options) {|p, _, _, d|
    base = d
    mkdir(p, 0700)
  }
  if block_given?
    begin
      yield path.dup
    ensure
      unless base
        stat = File.stat(File.dirname(path))
        if stat.world_writable? and !stat.sticky?
          raise ArgumentError, "parent directory is world writable but not sticky"
        end
      end
      Bundler::FileUtils.remove_entry path
    end
  else
    path
  end
end