diff -ur tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/README tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README --- tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/README 2003-10-10 18:09:04.000000000 +0200 +++ tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README 2003-10-17 22:48:37.000000000 +0200 @@ -1,11 +1,12 @@ Usage: ruby tar2rubyscript.rb application.tar [application.rb [licence.txt]] or - ruby tar2rubyscript.rb application/ [application.rb [licence.txt]] + ruby tar2rubyscript.rb application[/] [application.rb [licence.txt]] -The second variant needs the external program ´tar´ for creating the -archive internally. The first one doesn´t. +If "application.rb" is not provided or equals to "-", it will +be derived from "application.tar" or "application/". -If "application.rb" is not provided, it will be determined from -"application.tar" or "application/". +If a license is provided, it will be put at the beginning of +The Application. -For more information, see http://www.erikveen.dds.nl/tar2rubyscript/ . +For more information, see +http://www.erikveen.dds.nl/tar2rubyscript/ . diff -ur tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb --- tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-10 19:40:46.000000000 +0200 +++ tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-17 22:52:06.000000000 +0200 @@ -3,7 +3,7 @@ rbfile = ARGV.shift licensefile = ARGV.shift -tarfile.gsub!(/[\/\\]$/, "") +tarfile.dup.gsub!(/[\/\\]$/, "") if tarfile.nil? puts "Usage: ruby tar2rubyscript.rb application.tar [application.rb [license.txt]]" @@ -26,7 +26,6 @@ exit end - script = nil archive = nil @@ -53,15 +52,27 @@ Dir.chdir("..") - IO.popen("tar ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")} + begin + tar = "tar" + IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")} + rescue + tar = newlocation("tar.exe") + IO.popen("#{tar} ch #{tarfile.sub(/.*[\/\\]/, "")}", "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")} + end Dir.chdir(orgdir) end if not licensefile.nil? - lic = nil ; File.open(licensefile) {|f| lic = f.read} + lic = nil ; File.open(licensefile) {|f| lic = f.readlines} - script = "# License, not of this script, but of the application it contains:\n\n" + lic + "\n" + script + lic.collect! do |line| + line.gsub!(/[\r\n]/, "") + line = "# #{line}" unless line =~ /^[ \t]*#/ + line + end + + script = "# License, not of this script, but of the application it contains:\n#\n" + lic.join("\n") + "\n\n" + script end rbfile = tarfile.gsub(/\.tar$/, "") + ".rb" if (rbfile.nil? or File.basename(rbfile) == "-") @@ -71,4 +82,5 @@ f.write "\n" f.write "\n" f.write archive + f.write "\n" end diff -ur tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb --- tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-10 19:40:46.000000000 +0200 +++ tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-17 22:52:06.000000000 +0200 @@ -1,5 +1,5 @@ # License of this script, not of the application it contains: - +# # Copyright Erik Veenstra <tar2rubyscript@erikveen.dds.nl> # # This program is free software; you can redistribute it and/or @@ -16,8 +16,6 @@ # Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA. -# License of this script, not of the application it contains: - # Tar2RubyScript constants JustExtract = ARGV.include?("--tar2rubyscript-justextract") @@ -137,9 +135,9 @@ def initialize(header) fields = header.unpack(´A100 A8 A8 A8 A12 A12 A8 A1 A100 A8 A32 A32 A8 A8´) types = [´str´, ´oct´, ´oct´, ´oct´, ´oct´, ´time´, ´oct´, ´str´, ´str´, ´str´, ´str´, ´str´, ´oct´, ´oct´] - converted = [] begin + converted = [] while field = fields.shift type = types.shift @@ -181,16 +179,15 @@ def initialize @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift @olddir = Dir.pwd - @tmpdir = "/tmp" - @tmpdir = "c:/tmp" if FileTest.exists?("c:/") - @tempdir = "#{@tmpdir}/tar2rubyscript.d.#{Process.pid}" - @tempfile = "#{@tmpdir}/tar2rubyscript.f.#{Process.pid}" + temp = ENV["TEMP"] + temp = "/tmp" if temp.nil? + @tempdir = "#{temp}/tar2rubyscript.d.#{Process.pid}" + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" @newdir=@tempdir end def eval - Dir.mkdir(@tmpdir) if not FileTest.exists?(@tmpdir) Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir) newlocation do @@ -202,14 +199,14 @@ # Eventually look for a subdirectory. - entries = Dir.entries(@tempdir) + entries = Dir.entries(".") entries.delete(".") entries.delete("..") if entries.length == 1 - entry = @tempdir + "/" + entries.shift + entry = entries.shift.dup if FileTest.directory?(entry) - @newdir = entry + @newdir = "#{@tempdir}/#{entry}" end end end @@ -296,9 +293,9 @@ class Extract def initialize @archive = File.new($0, "rb").read.gsub(/\r/, "").split(/\n\n/)[-1].split("\n").collect{|s| s[2..-1]}.join("\n").unpack("m").shift - @tmpdir = "/tmp" - @tmpdir = "c:/tmp" if FileTest.exists?("c:/") - @tempfile = "#{@tmpdir}/tar2rubyscript.f.#{Process.pid}" + temp = ENV["TEMP"] + temp = "/tmp" if temp.nil? + @tempfile = "#{temp}/tar2rubyscript.f.#{Process.pid}" end def extract @@ -306,8 +303,6 @@ # Create the temp environment. - Dir.mkdir(@tmpdir) if not FileTest.exists?(@tmpdir) - File.open(@tempfile, "wb") {|f| f.write @archive} File.open(@tempfile, "rb") {|f| Reader.new(f).extract} Binary files tar2rubyscript-0.3.2.tar.gz/tar2rubyscript/tar.exe and tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar.exe differ