Easily convert a File object to a Tempfile object.
Add this line to your application's Gemfile:
gem 'file_to_tempfile'
And then execute:
$ bundle install
require 'file_to_tempfile'
file = File.open '.gitignore'
tempfile = FileToTempfile.convert(file)
Bug reports and pull requests are welcome on GitHub at https://github.com/ZaikoXander/file_to_tempfile.
The gem is available as open source under the terms of the MIT License.