module EacRubyUtils::Fs::Temp
Utilities for temporary files.
Public Class Methods
directory(*tempfile_args)
click to toggle source
Shortcut to +EacRubyUtils::Fs::Temp::Directory.new(*tempfile_args)+.
@return [Pathname]
# File lib/eac_ruby_utils/fs/temp.rb, line 17 def directory(*tempfile_args) ::EacRubyUtils::Fs::Temp::Directory.new(*tempfile_args) end
file(*tempfile_args)
click to toggle source
Shortcut to +EacRubyUtils::Fs::Temp::File.new(*tempfile_args)+.
@return [Pathname]
# File lib/eac_ruby_utils/fs/temp.rb, line 24 def file(*tempfile_args) ::EacRubyUtils::Fs::Temp::File.new(*tempfile_args) end
on_directory(*tempfile_args) { |temp_dir| ... }
click to toggle source
Run a block while a temporary directory pathname is provided. The directory is deleted when the block is finished.
# File lib/eac_ruby_utils/fs/temp.rb, line 30 def on_directory(*tempfile_args) temp_dir = directory(*tempfile_args) begin yield(temp_dir) ensure temp_dir.remove end end
on_file(*tempfile_args) { |temp_file| ... }
click to toggle source
Run a block while a temporary file pathname is providade. The file is deleted when block is finished.
# File lib/eac_ruby_utils/fs/temp.rb, line 41 def on_file(*tempfile_args) temp_file = file(*tempfile_args) begin yield(temp_file) ensure temp_file.remove end end