summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/unpack_command.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/commands/unpack_command.rb26
1 files changed, 14 insertions, 12 deletions
@@ -12,7 +12,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
:version => Gem::Requirement.default,
:target => Dir.pwd
- add_option('--target', 'target directory for unpacking') do |value, options|
options[:target] = value
end
@@ -35,18 +35,20 @@ class Gem::Commands::UnpackCommand < Gem::Command
# TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
# this, so that it works for uninstall as well. (And check other commands
# at the same time.)
def execute
- gemname = get_one_gem_name
- path = get_path(gemname, options[:version])
-
- if path then
- basename = File.basename(path).sub(/\.gem$/, '')
- target_dir = File.expand_path File.join(options[:target], basename)
- FileUtils.mkdir_p target_dir
- Gem::Installer.new(path, :unpack => true).unpack target_dir
- say "Unpacked gem: '#{target_dir}'"
- else
- alert_error "Gem '#{gemname}' not installed."
end
end