Module: Entangler::Helper

Defined in:
lib/entangler/executor/helpers.rb

Class Method Summary collapse

Class Method Details

.with_temp_file(name: 'tmp_file', contents: nil) {|t| ... } ⇒ Object

Yields:

  • (t)


5
6
7
8
9
10
11
12
13
# File 'lib/entangler/executor/helpers.rb', line 5

def self.with_temp_file(name: 'tmp_file', contents: nil)
  require 'tempfile'

  t = Tempfile.new(name)
  t.puts(contents) unless contents.nil?
  t.close
  yield t
  t.unlink
end