# File lib/rubygems/gemcutter_utilities.rb, line 26 26: def rubygems_api_request(method, path, &block) 27: host = ENV['RUBYGEMS_HOST'] || 'https://rubygems.org' 28: uri = URI.parse "#{host}/#{path}" 29: 30: request_method = Net::HTTP.const_get method.to_s.capitalize 31: 32: Gem::RemoteFetcher.fetcher.request(uri, request_method, &block) 33: end
# File lib/rubygems/gemcutter_utilities.rb, line 6 6: def sign_in 7: return if Gem.configuration.rubygems_api_key 8: 9: say "Enter your RubyGems.org credentials." 10: say "Don't have an account yet? Create one at http://rubygems.org/sign_up" 11: 12: email = ask " Email: " 13: password = ask_for_password "Password: " 14: say "\n" 15: 16: response = rubygems_api_request :get, "api/v1/api_key" do |request| 17: request.basic_auth email, password 18: end 19: 20: with_response response do |resp| 21: say "Signed in." 22: Gem.configuration.rubygems_api_key = resp.body 23: end 24: end
# File lib/rubygems/gemcutter_utilities.rb, line 35 35: def with_response(resp) 36: case resp 37: when Net::HTTPSuccess then 38: if block_given? then 39: yield resp 40: else 41: say resp.body 42: end 43: else 44: say resp.body 45: terminate_interaction 1 46: end 47: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.