class Gemsmith::Authenticators::RubyGems

An authenticator for retrieving RubyGems authorization.

Attributes

client[R]
login[R]
password[R]
uri[R]

Public Class Methods

new(login, password) click to toggle source
# File lib/gemsmith/authenticators/ruby_gems.rb, line 15
def initialize login, password
  @login = login
  @password = password
  @uri = URI.parse self.class.url
  @client = configure_client
end
url() click to toggle source
# File lib/gemsmith/authenticators/ruby_gems.rb, line 11
def self.url
  "https://rubygems.org/api/v1/api_key"
end

Public Instance Methods

authorization() click to toggle source
# File lib/gemsmith/authenticators/ruby_gems.rb, line 22
def authorization
  request = Net::HTTP::Get.new uri.request_uri
  request.basic_auth login, password
  response = client.request request
  String response.body
end

Private Instance Methods

configure_client() click to toggle source
# File lib/gemsmith/authenticators/ruby_gems.rb, line 33
def configure_client
  Net::HTTP.new(uri.host, uri.port).tap do |client|
    client.use_ssl = true
    client.verify_mode = OpenSSL::SSL::VERIFY_PEER
  end
end