Class: MiniDeploy::TemporaryFile

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_deploy/temporary_file.rb

Instance Method Summary collapse

Constructor Details

#initializeTemporaryFile

Returns a new instance of TemporaryFile.



5
6
7
# File 'lib/mini_deploy/temporary_file.rb', line 5

def initialize
  @tempfile = Tempfile.new('mwd')
end

Instance Method Details

#closeObject



14
15
16
# File 'lib/mini_deploy/temporary_file.rb', line 14

def close
  @tempfile.close
end

#current_pathObject



29
30
31
# File 'lib/mini_deploy/temporary_file.rb', line 29

def current_path
  @tempfile.path
end

#destroyObject



18
19
20
# File 'lib/mini_deploy/temporary_file.rb', line 18

def destroy
  @tempfile.unlink
end

#doneObject



22
23
24
25
26
27
# File 'lib/mini_deploy/temporary_file.rb', line 22

def done
  close
  destroy
rescue StandardError => e
  # ignore
end

#write(data) ⇒ Object



9
10
11
12
# File 'lib/mini_deploy/temporary_file.rb', line 9

def write(data)
  @tempfile.write data
  @tempfile.rewind
end