summaryrefslogtreecommitdiff
path: root/tool/gem-unpack.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/gem-unpack.rb')
-rwxr-xr-xtool/gem-unpack.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/tool/gem-unpack.rb b/tool/gem-unpack.rb
new file mode 100755
index 0000000000..5f15751d9c
--- /dev/null
+++ b/tool/gem-unpack.rb
@@ -0,0 +1,16 @@
+require 'rubygems'
+require 'rubygems/package'
+
+def Gem.unpack(file, dir = nil)
+ pkg = Gem::Package.new(file)
+ pkg.security_policy = Gem::Security::LowSecurity
+ spec = pkg.spec
+ target = spec.full_name
+ target = File.join(dir, target) if dir
+ pkg.extract_files target
+ spec_file = File.join(target, "#{spec.name}.gemspec")
+ open(spec_file, 'wb') do |f|
+ f.print spec.to_ruby
+ end
+ puts "Unpacked #{file}"
+end