Sha256: 303e86028c8625e666ff98833f60dd40079f93c93703e19c0d3b25dc2621da49
Contents?: true
Size: 753 Bytes
Versions: 2
Compression:
Stored size: 753 Bytes
Contents
# frozen_string_literal: true require 'pathname' require 'tempfile' module EacRubyUtils module Fs # Utilities for temporary files. module Temp class << self # @return [Pathname] def file(*tempfile_args) file = Tempfile.new(*tempfile_args) r = ::Pathname.new(file.path) file.close file.unlink r end # Run a block while a temporary file pathname is providade. The file is deleted when block # is finished. def on_file(*tempfile_args) pathname = file(*tempfile_args) begin yield(pathname) ensure pathname.unlink if pathname.exist? end end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
eac_ruby_utils-0.30.0 | lib/eac_ruby_utils/fs/temp.rb |
ehbrs-tools-0.6.0 | vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/temp.rb |