Sha256: fd85080dbafc7ebb2f9d3a5c979f4d0781dbc8fb09a24d8bc532a00181a9233b
Contents?: true
Size: 938 Bytes
Versions: 54
Compression:
Stored size: 938 Bytes
Contents
# frozen_string_literal: true require "net/http" require "uri" require "openssl" module Gemsmith module Authenticators # An authenticator for retrieving RubyGems authorization. class RubyGems def self.url "https://rubygems.org/api/v1/api_key" end def initialize login, password @login = login @password = password @uri = URI.parse self.class.url @client = configure_client end def authorization request = Net::HTTP::Get.new uri.request_uri request.basic_auth login, password response = client.request request String response.body end private attr_reader :login, :password, :uri, :client 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 end end end
Version data entries
54 entries across 54 versions & 1 rubygems