Module: Async::RSpec::Buffer

Defined in:
lib/async/rspec/buffer.rb

Constant Summary collapse

TMP =
"/tmp"

Class Method Summary collapse

Class Method Details

.open(mode = 'w+', root: TMP) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/async/rspec/buffer.rb', line 28

def self.open(mode = 'w+', root: TMP)
  path = File.join(root, SecureRandom.hex(32))
  file = File.open(path, mode)
  
  File.unlink(path)
  
  return file unless block_given?
  
  begin
    yield file
  ensure
    file.close
  end
end