summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/unpack_command.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/commands/unpack_command.rb20
1 files changed, 16 insertions, 4 deletions
@@ -2,11 +2,20 @@
require 'rubygems/command'
require 'rubygems/installer'
require 'rubygems/version_option'
require 'rubygems/remote_fetcher'
class Gem::Commands::UnpackCommand < Gem::Command
include Gem::VersionOption
def initialize
require 'fileutils'
@@ -24,6 +33,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
options[:spec] = true
end
add_version_option
end
@@ -63,6 +73,8 @@ command help for an example.
# at the same time.)
def execute
get_all_gem_names.each do |name|
dependency = Gem::Dependency.new name, options[:version]
path = get_path dependency
@@ -73,7 +85,7 @@ command help for an example.
end
if @options[:spec] then
- spec, metadata = get_metadata path
if metadata.nil? then
alert_error "--spec is unsupported on '#{name}' (old format gem)"
@@ -89,7 +101,7 @@ command help for an example.
basename = File.basename path, '.gem'
target_dir = File.expand_path basename, options[:target]
- package = Gem::Package.new path
package.extract_files target_dir
say "Unpacked gem: '#{target_dir}'"
@@ -158,8 +170,8 @@ command help for an example.
#--
# TODO move to Gem::Package as #raw_spec or something
- def get_metadata path
- format = Gem::Package.new path
spec = format.spec
metadata = nil