diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/README --- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/README 2003-10-17 22:48:37.000000000 +0200 +++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/README 2003-10-19 19:17:19.000000000 +0200 @@ -1,6 +1,6 @@ -Usage: ruby tar2rubyscript.rb application.tar [application.rb [licence.txt]] +Usage: ruby init.rb application.tar [application.rb [licence.txt]] or - ruby tar2rubyscript.rb application[/] [application.rb [licence.txt]] + ruby init.rb application[/] [application.rb [licence.txt]] If "application.rb" is not provided or equals to "-", it will be derived from "application.tar" or "application/". diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb --- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2003-10-23 23:15:17.000000000 +0200 +++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/ev/oldandnewlocation.rb 2003-10-23 23:15:17.000000000 +0200 @@ -0,0 +1,39 @@ +def oldlocation(file="") + if ENV.include?("OLDDIR") + dir = ENV["OLDDIR"] + else + dir = "." + end + + if block_given? + pdir = Dir.pwd + + Dir.chdir(dir) + res = yield + Dir.chdir(pdir) + else + res = File.expand_path(file, dir) if not file.nil? + end + + res +end + +def newlocation(file="") + if ENV.include?("NEWDIR") + dir = ENV["NEWDIR"] + else + dir = "." + end + + if block_given? + pdir = Dir.pwd + + Dir.chdir(dir) + res = yield + Dir.chdir(pdir) + else + res = File.expand_path(file, dir) if not file.nil? + end + + res +end diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/init.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/init.rb --- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/init.rb 2003-10-23 23:15:17.000000000 +0200 +++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/init.rb 2003-10-19 19:16:01.000000000 +0200 @@ -0,0 +1,81 @@ +require "ev/oldandnewlocation" + +scriptfile = "tarrubyscript.rb" +tarfile = oldlocation(ARGV.shift) +rbfile = oldlocation(ARGV.shift) +licensefile = oldlocation(ARGV.shift) + +if tarfile.nil? + exit 1 +end + +tarfile.dup.gsub!(/[\/\\]$/, "") + +if not FileTest.exist?(tarfile) + puts "#{tarfile} doesn´t exist." + exit +end + +if not licensefile.nil? and not FileTest.file?(licensefile) + puts "#{licensefile} doesn´t exist." + exit +end + +script = nil +archive = nil + +File.open(scriptfile) {|f| script = f.read} + +if FileTest.file?(tarfile) + File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")} +end + +if FileTest.directory?(tarfile) + orgdir = Dir.pwd + + Dir.chdir(tarfile) + + if FileTest.file?("tar2rubyscript.bat") + puts "\".\\tar2rubyscript.bat\"" + system(".\\tar2rubyscript.bat") + end + + if FileTest.file?("tar2rubyscript.sh") + puts "\". ./tar2rubyscript.sh\"" + system("sh -c \". ./tar2rubyscript.sh\"") + end + + Dir.chdir("..") + + 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.readlines} + + 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) == "-") + +File.open(rbfile, "wb") do |f| + f.write script + f.write "\n" + f.write "\n" + f.write archive + f.write "\n" +end diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tar2rubyscript.rb --- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-17 22:52:06.000000000 +0200 +++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tar2rubyscript.rb 2003-10-23 23:15:17.000000000 +0200 @@ -1,86 +0,0 @@ -scriptfile = "tarrubyscript.rb" -tarfile = ARGV.shift -rbfile = ARGV.shift -licensefile = ARGV.shift - -tarfile.dup.gsub!(/[\/\\]$/, "") - -if tarfile.nil? - puts "Usage: ruby tar2rubyscript.rb application.tar [application.rb [license.txt]]" - puts " or" - puts " ruby tar2rubyscript.rb application/ [application.rb [license.txt]]" - puts "" - puts "The second option needs the external program ´tar´ for creating" - puts "the archive internally." - - exit 1 -end - -if not FileTest.exist?(tarfile) - puts "#{tarfile} doesn´t exist." - exit -end - -if not licensefile.nil? and not FileTest.file?(licensefile) - puts "#{licensefile} doesn´t exist." - exit -end - -script = nil -archive = nil - -File.open(scriptfile) {|f| script = f.read} - -if FileTest.file?(tarfile) - File.open(tarfile, "rb") {|f| archive = [f.read].pack("m").split("\n").collect{|s| "# " + s}.join("\n")} -end - -if FileTest.directory?(tarfile) - orgdir = Dir.pwd - - Dir.chdir(tarfile) - - if FileTest.file?("tar2rubyscript.bat") - puts "\".\\tar2rubyscript.bat\"" - system(".\\tar2rubyscript.bat") - end - - if FileTest.file?("tar2rubyscript.sh") - puts "\". ./tar2rubyscript.sh\"" - system("sh -c \". ./tar2rubyscript.sh\"") - end - - Dir.chdir("..") - - 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.readlines} - - 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) == "-") - -File.open(rbfile, "wb") do |f| - f.write script - f.write "\n" - f.write "\n" - f.write archive - f.write "\n" -end diff -ur tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tarrubyscript.rb --- tar2rubyscript-0.3.3.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-17 22:52:06.000000000 +0200 +++ tar2rubyscript-0.3.4.tar.gz/tar2rubyscript/tarrubyscript.rb 2003-10-22 18:52:06.000000000 +0200 @@ -187,7 +187,7 @@ @newdir=@tempdir end - def eval + def run Dir.mkdir(@tempdir) if not FileTest.exists?(@tempdir) newlocation do @@ -319,5 +319,5 @@ if JustExtract Extract.new.extract else - TempSpace.new.eval + TempSpace.new.run end