class Autorake::TmpFiles

Attributes

src[R]

Public Class Methods

new(source) click to toggle source
# File lib/autorake/compile.rb, line 119
def initialize source
  @plain = "tmp-0001"
  begin
    @src = "#@plain.c"
    File.open @src, File::WRONLY|File::CREAT|File::EXCL do |c|
      c.puts source
    end
  rescue Errno::EEXIST
    @plain.succ!
    retry
  end
end

Public Instance Methods

bin() click to toggle source
# File lib/autorake/compile.rb, line 134
def bin ; @bin = "#@plain"     ; end
cleanup() click to toggle source
# File lib/autorake/compile.rb, line 136
def cleanup
  File.delete @bin if @bin and File.exists? @bin
  File.delete @obj if @obj and File.exists? @obj
  File.delete @cpp if @cpp and File.exists? @cpp
  File.delete @src
end
cpp() click to toggle source
# File lib/autorake/compile.rb, line 132
def cpp ; @cpp = "#@plain.cpp" ; end
obj() click to toggle source
# File lib/autorake/compile.rb, line 133
def obj ; @obj = "#@plain.o"   ; end
open(source) { |i| ... } click to toggle source
# File lib/autorake/compile.rb, line 108
def open source
  i = new source
  yield i
ensure
  i.cleanup
end