diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
commit | 25a9b62d45ddd60a231272567c7dda9337da9b62 (patch) | |
tree | e72ba4c9c01cba5fb510eb1eafaba76d998baf4c /lib/rubygems/gemcutter_utilities.rb | |
parent | 86bb0af7ea3b50f72e6845a6f5f64cb1b23fd279 (diff) | |
download | ruby-25a9b62d45ddd60a231272567c7dda9337da9b62.tar.gz |
Import rubygems 1.6.0 (released version @ 58d8a0b9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/gemcutter_utilities.rb')
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index 1681356805..a77a4911f2 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -7,6 +7,26 @@ require 'rubygems/remote_fetcher' module Gem::GemcutterUtilities + OptionParser.accept Symbol do |value| + value.to_sym + end + + ## + # Add the --key option + + def add_key_option + add_option '-k', '--key KEYNAME', Symbol, 'Use the given API key' do |value,options| + options[:key] = value + end + end + + def api_key + if options[:key] then + verify_api_key options[:key] + else + Gem.configuration.rubygems_api_key + end + end def sign_in return if Gem.configuration.rubygems_api_key @@ -33,6 +53,8 @@ module Gem::GemcutterUtilities host = ENV['RUBYGEMS_HOST'] if ENV['RUBYGEMS_HOST'] uri = URI.parse "#{host}/#{path}" + say "Pushing gem to #{host}..." + request_method = Net::HTTP.const_get method.to_s.capitalize Gem::RemoteFetcher.fetcher.request(uri, request_method, &block) @@ -52,4 +74,13 @@ module Gem::GemcutterUtilities end end + def verify_api_key(key) + if Gem.configuration.api_keys.key? key then + Gem.configuration.api_keys[key] + else + alert_error "No such API key. You can add it with gem keys --add #{key}" + terminate_interaction 1 + end + end + end |