diff options
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r-- | lib/rubygems/commands/build_command.rb | 41 | ||||
-rw-r--r-- | lib/rubygems/commands/push_command.rb | 2 |
2 files changed, 30 insertions, 13 deletions
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb index e59471e976..761b80ee94 100644 --- a/lib/rubygems/commands/build_command.rb +++ b/lib/rubygems/commands/build_command.rb @@ -18,6 +18,10 @@ class Gem::Commands::BuildCommand < Gem::Command add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options| options[:output] = value end + + add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options| + options[:build_path] = value + end end def arguments # :nodoc: @@ -60,25 +64,36 @@ Gems can be saved to a specified filename with the output option: end if File.exist? gemspec - Dir.chdir(File.dirname(gemspec)) do - spec = Gem::Specification.load File.basename(gemspec) - - if spec - Gem::Package.build( - spec, - options[:force], - options[:strict], - options[:output] - ) - else - alert_error "Error loading gemspec. Aborting." - terminate_interaction 1 + spec = Gem::Specification.load(gemspec) + + if options[:build_path] + Dir.chdir(File.dirname(gemspec)) do + spec = Gem::Specification.load File.basename(gemspec) + build_package(spec) end + else + build_package(spec) end + else alert_error "Gemspec file not found: #{gemspec}" terminate_interaction 1 end end + private + + def build_package(spec) + if spec + Gem::Package.build( + spec, + options[:force], + options[:strict], + options[:output] + ) + else + alert_error "Error loading gemspec. Aborting." + terminate_interaction 1 + end + end end diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index 3ea4703a3e..55ee3ae73f 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -15,6 +15,8 @@ https://rubygems.org) and adds it to the index. The gem can be removed from the index and deleted from the server using the yank command. For further discussion see the help for the yank command. + +The push command will use ~/.gem/credentials to authenticate to a server, but you can use the RubyGems environment variable GEM_HOST_API_KEY to set the api key to authenticate. EOF end |