0.0
No commit activity in last 3 years
No release in over 3 years
A variation of tempfile standard lib, that actually creates a File instance.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.2.0
~> 1.8.4
~> 0.9.0
~> 3.12
~> 2.8.0
~> 0.7
 Project Readme

open-temporary the “real file” temporary one.¶ ↑

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

github.com/rails/rails/pull/2068

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.

File.open # => 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.