Use Tempfile's for the embryo source- and amx code.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sat, 26 Mar 2005 19:16:37 +0000 (19:16 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sat, 26 Mar 2005 19:16:37 +0000 (19:16 +0000)
ChangeLog
lib/redact/app.rb

index 2574181b11af48aedef784fd387065d5de02cb88..1615df6397d65a3ceda4c50d6a72f23b596caf9f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,11 @@
 --
 --
-$Id: ChangeLog 1 2005-03-26 01:32:38Z tilman $
+$Id: ChangeLog 2 2005-03-26 19:16:37Z tilman $
 ++
 
 ++
 
+2005-03-26 Tilman Sauerbeck (tilman at code-monkey de)
+        * lib/redact/app.rb: Use Tempfile's for the Embryo source- and
+          amx code
+
 2005-03-22 Tilman Sauerbeck (tilman at code-monkey de)
         * lib/redact/app.rb: The default extension for Edje files is
           'edj' now
 2005-03-22 Tilman Sauerbeck (tilman at code-monkey de)
         * lib/redact/app.rb: The default extension for Edje files is
           'edj' now
index de666280863078905bb9af53c69b31c1b9d34338..d2b192390297aba44ee86305363bba4d99109c8c 100644 (file)
@@ -1,5 +1,5 @@
 #--
 #--
-# $Id: app.rb 1 2005-03-26 01:32:38Z tilman $
+# $Id: app.rb 2 2005-03-26 19:16:37Z tilman $
 #
 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
 #
 #
 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
 #
@@ -25,6 +25,7 @@
 require "redact/redact.rb"
 require "redact/source.rb"
 require "ftools"
 require "redact/redact.rb"
 require "redact/source.rb"
 require "ftools"
+require "tempfile"
 require "pathname"
 require "ostruct"
 require "optparse"
 require "pathname"
 require "ostruct"
 require "optparse"
@@ -127,23 +128,21 @@ EOT
                        EDJE.collections.each_value do |col|
                                next unless col.has_embryo?
 
                        EDJE.collections.each_value do |col|
                                next unless col.has_embryo?
 
-                               File.open("/tmp/redact.sma", "w") do |tf|
-                                       tf.puts "#include <edje>"
-                                       dump_sma(tf, col)
-                                       tf.flush
+                               Tempfile.open("redact_col#{col.id}.sma") do |tf_in|
+                                       tf_in.puts "#include <edje>"
+                                       dump_sma(tf_in, col)
+                                       tf_in.flush
 
 
-                                       out = "/tmp/redact.amx"
-                                       File.rm_f(out)
+                                       Tempfile.open("redact_col#{col.id}.amx") do |tf_out|
+                                               incl = `edje-config --datadir`.strip
 
 
-                                       incl = `edje-config --datadir`.strip
-                                       c = "embryo_cc " +
-                                           "-i #{incl}/include " +
-                                           "-o #{out} #{tf.path}"
-                                       system(c)
+                                               c = "embryo_cc " +
+                                                   "-i #{incl}/include " +
+                                                   "-o #{tf_out.path} #{tf_in.path}"
+                                               system(c)
 
 
-                                       ret[col.id] = IO.read(out)
-                                       File.rm_f(out)
-                                       File.unlink(tf.path)
+                                               ret[col.id] = tf_out.read
+                                       end
                                end
                        end
 
                                end
                        end