summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/unpack_command.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 08:39:12 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-20 08:39:12 +0000
commit8289771e326006cc4e15a667e3eff3a72cfb3327 (patch)
treef6d367888b42848fd6a660fad57fa2020e38c097 /lib/rubygems/commands/unpack_command.rb
parent40d8543fbdec5485a638a2cb1008089d106b978d (diff)
Import RubyGems 1.0.0, r1575
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands/unpack_command.rb')
-rw-r--r--lib/rubygems/commands/unpack_command.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/rubygems/commands/unpack_command.rb b/lib/rubygems/commands/unpack_command.rb
index ece24745a2..23ebabc21a 100644
--- a/lib/rubygems/commands/unpack_command.rb
+++ b/lib/rubygems/commands/unpack_command.rb
@@ -9,7 +9,13 @@ class Gem::Commands::UnpackCommand < Gem::Command
def initialize
super 'unpack', 'Unpack an installed gem to the current directory',
- :version => Gem::Requirement.default
+ :version => Gem::Requirement.default,
+ :target => Dir.pwd
+
+ add_option('--target', 'target directory for unpacking') do |value, options|
+ options[:target] = value
+ end
+
add_version_option
end
@@ -32,10 +38,11 @@ class Gem::Commands::UnpackCommand < Gem::Command
def execute
gemname = get_one_gem_name
path = get_path(gemname, options[:version])
- if path
- target_dir = File.basename(path).sub(/\.gem$/, '')
+ 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(File.expand_path(target_dir))
+ Gem::Installer.new(path).unpack target_dir
say "Unpacked gem: '#{target_dir}'"
else
alert_error "Gem '#{gemname}' not installed."