What is TmpFile
A ruby gem to temporarily store data in a file with an appropriate extension
Why TmpFile was born
At Topspin we provide ArtistLink, a platform for musician to upload and share their songs. When a song contains cover art in the ID3 tag, we extract it to an image and process it to create a nice page background. We use TmpFile to temporarily extract the cover art data from the song into a file store its processed version.
Requirements
TmpFile has been tested on Ruby 1.8.7, 1.9.2, 1.9.3 and 2.0.0. No external libraries are required.
How to use from other programs
- Include
tmp_file
in the Gemfile of your bundled project andbundle install
To store data in a temporary file and yield the file handle, run:
TmpFile.open(data, mime_type) do |tmp_file| # do something with tmp_file end
For more details, check the specs.
How to contribute
Make sure tests pass with rake spec
, then submit a Pull Request.
A list of nice TODOs is provided.