summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Nichols <nichoj@gentoo.org>2006-08-20 01:48:27 +0000
committerJoshua Nichols <nichoj@gentoo.org>2006-08-20 01:48:27 +0000
commitf1c4131d99fdae7450bcd5b150a2ee778f40ba45 (patch)
tree8e8c7aa022dc2e0eb74435001083c891601146f3 /projects
parentAdded forum stuff. Added documentation stuff. (diff)
downloadnichoj-f1c4131d99fdae7450bcd5b150a2ee778f40ba45.tar.gz
nichoj-f1c4131d99fdae7450bcd5b150a2ee778f40ba45.tar.bz2
nichoj-f1c4131d99fdae7450bcd5b150a2ee778f40ba45.zip
Added jarparser
svn path=/; revision=54
Diffstat (limited to 'projects')
-rwxr-xr-xprojects/gentoolkit-nichoj/trunk/jarparser.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/projects/gentoolkit-nichoj/trunk/jarparser.rb b/projects/gentoolkit-nichoj/trunk/jarparser.rb
new file mode 100755
index 0000000..9cb472f
--- /dev/null
+++ b/projects/gentoolkit-nichoj/trunk/jarparser.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/ruby -w
+require 'zip/zipfilesystem'
+require 'getoptlong'
+
+opts = GetoptLong.new(
+ [ "--manifest", "-m", GetoptLong::NO_ARGUMENT ],
+ [ "--manifestparameter", "-p", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--classes", "-c", GetoptLong::NO_ARGUMENT ],
+ [ "--resources", "-r", GetoptLong::NO_ARGUMENT ]
+)
+
+domanifest = false
+manifestparameter = nil
+opts.each do |opt, arg|
+ case opt
+ when '--manifest'
+ domanifest = true
+ when '--manifestparameter'
+ manifestparameter = arg
+ end
+end
+
+if ARGV.length != 1
+ puts "Expecting one arguement, the location of a jar"
+ exit 1
+end
+
+zipfilename=ARGV[0]
+Zip::ZipFile.open(zipfilename) do |zipfile|
+ if domanifest
+ if manifestparameter.nil?
+ puts zipfile.file.read("META-INF/MANIFEST.MF")
+ else
+ zipfile.file.open("META-INF/MANIFEST.MF") do |io|
+ while line = io.gets
+ line =~ /(.*):\s(.*)$/
+ parameter = $1
+ value = $2
+ if parameter == manifestparameter
+ puts value
+ end
+ end
+ end
+ end
+ end
+end