Class: Autorake::Builder::TmpFiles
- Inherits:
-
Object
- Object
- Autorake::Builder::TmpFiles
- Defined in:
- lib/autorake/compile.rb
Instance Attribute Summary collapse
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Class Method Summary collapse
Instance Method Summary collapse
- #bin ⇒ Object
- #cleanup ⇒ Object
- #cpp ⇒ Object
-
#initialize(source) ⇒ TmpFiles
constructor
A new instance of TmpFiles.
- #obj ⇒ Object
Constructor Details
#initialize(source) ⇒ TmpFiles
Returns a new instance of TmpFiles.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/autorake/compile.rb', line 73 def initialize source @plain = "autorake-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 |
Instance Attribute Details
#src ⇒ Object (readonly)
Returns the value of attribute src.
71 72 73 |
# File 'lib/autorake/compile.rb', line 71 def src @src end |
Class Method Details
.open(source, keep = nil) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/autorake/compile.rb', line 62 def open source, keep = nil i = new source yield i ensure i.cleanup unless keep end |
Instance Method Details
#bin ⇒ Object
88 |
# File 'lib/autorake/compile.rb', line 88 def bin ; @bin = "#@plain" ; end |
#cleanup ⇒ Object
90 91 92 93 94 95 |
# File 'lib/autorake/compile.rb', line 90 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 ⇒ Object
86 |
# File 'lib/autorake/compile.rb', line 86 def cpp ; @cpp = "#@plain.cpp" ; end |
#obj ⇒ Object
87 |
# File 'lib/autorake/compile.rb', line 87 def obj ; @obj = "#@plain.o" ; end |