Sha256: ce8350060b1039ee147ce9b3c2dfc1715d761cc1d84bb70e5daa24458f98e8b3

Contents?: true

Size: 493 Bytes

Versions: 12

Compression:

Stored size: 493 Bytes

Contents

require 'tmpdir'
module Astrails
  module Safe
    module TmpFile
      @KEEP_FILES = []
      TMPDIR = Dir.mktmpdir

      def self.cleanup
        FileUtils.remove_entry_secure TMPDIR
      end

      def self.create(name)
        # create temp directory

        file = Tempfile.new(name, TMPDIR)

        yield file

        file.close
        @KEEP_FILES << file # so that it will not get gcollected and removed from filesystem until the end
        file.path
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
astrails-safe-0.0.9 lib/astrails/safe/tmp_file.rb
astrails-safe-0.1.0 lib/astrails/safe/tmp_file.rb
astrails-safe-0.1.1 lib/astrails/safe/tmp_file.rb
astrails-safe-0.1.2 lib/astrails/safe/tmp_file.rb
astrails-safe-0.1.3 lib/astrails/safe/tmp_file.rb
astrails-safe-0.1.4 lib/astrails/safe/tmp_file.rb
astrails-safe-0.1.6 lib/astrails/safe/tmp_file.rb
colin-safe-0.1.6 lib/astrails/safe/tmp_file.rb
colin-safe-0.1.7 lib/astrails/safe/tmp_file.rb
colin-safe-0.1.8 lib/astrails/safe/tmp_file.rb
markmansour-safe-0.1.7 lib/astrails/safe/tmp_file.rb
ralph-safe-0.1.7 lib/astrails/safe/tmp_file.rb