Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A variant of Tempfile that makes File instead.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 ext open_temporary.c: fix fd leak
Octocat-spinner-32 lib indent
Octocat-spinner-32 spec indent
Octocat-spinner-32 .document remove trailing spaces.
Octocat-spinner-32 .gitignore remove trailing spaces.
Octocat-spinner-32 .rspec bundle exec jeweler --create-repo --rspec --bundler --yard open-tempo…
Octocat-spinner-32 Gemfile License terms update
Octocat-spinner-32 Gemfile.lock vim Gemfile && bundle install --path vendor/bundle
Octocat-spinner-32 LICENSE.txt License terms update
Octocat-spinner-32 README.rdoc README update
Octocat-spinner-32 Rakefile License terms update
Octocat-spinner-32 VERSION bundle exec rake version:bump:patch
Octocat-spinner-32 open-temporary.gemspec Regenerate gemspec for version 1.0.1

open-temporary the “real file” temporary one.

OK, so you dropped into a tempfile pitfall. Like Rails.

Why not just fix the situation so that you can safely dup?

How to use it?

You first add

gem "open-temporary"

to your Gemfile, then from your .rb file,

require 'open-temporary'

And that's it. Now you have the “open” method extended, just like the open-uri standard library. # => gives you a temporary file

This time the null (zero-arity) argument indicates this is a temporary file. You get a REAL instance of File, no proxy, no tweak. It can be dup'ed, it can be used with process forks, and still, you can just leave it, and the GC reclaims the whole resources.

Great! So why this isn't a standard?

Because it has absolutely zero portability. The magic behind the scene is that we just let your operating system to reclaim what's necessary. That way, the behaviour detail is much much OS specific. Especially, this kind of API is not doable on a Windows environment. Might not also on Java (not sure). So this can never be a part of gospel ruby.

Something went wrong with that request. Please try again.