class Object

Constants

TempfileFixture

Fixture class for Tempfiles.

@example Load a fixture file as a tempfile

Tempfile.Fixture('/path/to/data.txt').copy do |tempfile|
  # do something with the tempfile
end

# the tempfile should be gone

@example Don't unlink the tempfile

tempfile = Tempfile::Fixture.new('/path/to/data.txt').copy!
tempfile # => the tempfile

Public Class Methods

Fixture(path, binary: false, &block) click to toggle source

noinspection RubyClassMethodNamingConvention

# File lib/tempfile/fixture.rb, line 69
def self.Fixture(path, binary: false, &block)
  raise ArgumentError, 'no block given' unless block_given?
  raise ArgumentError, 'no path given' unless path && path.length.positive?
  encoding = binary ? 'ascii-8bit' : 'utf-8'

  TempfileFixture.new(path, tempfile_options: { encoding: encoding })
                 .copy(&block)
end