Class: Stickler::Repository::RubygemsAuthenticator
- Inherits:
-
Object
- Object
- Stickler::Repository::RubygemsAuthenticator
- Defined in:
- lib/stickler/repository/rubygems_authenticator.rb
Overview
When talking to rubygems itself, the rubygems_api key is required. This authenticator is injected automatically if the host you are talking to matches the rubygems host
Class Method Summary collapse
Instance Method Summary collapse
- #add_credentials_to(request) ⇒ Object
- #can_handle?(request) ⇒ Boolean
- #credentials ⇒ Object
- #rubygems_uri ⇒ Object
Class Method Details
.rubygems_uri ⇒ Object
10 11 12 |
# File 'lib/stickler/repository/rubygems_authenticator.rb', line 10 def self.rubygems_uri @rubygems_uri ||= Addressable::URI.parse( "https://rubygems.org" ) end |
Instance Method Details
#add_credentials_to(request) ⇒ Object
28 29 30 |
# File 'lib/stickler/repository/rubygems_authenticator.rb', line 28 def add_credentials_to(request) request.header['Authorization'] = credentials end |
#can_handle?(request) ⇒ Boolean
22 23 24 25 26 |
# File 'lib/stickler/repository/rubygems_authenticator.rb', line 22 def can_handle?( request ) request_uri = Addressable::URI.parse(request.uri) return (request_uri.host == rubygems_uri.host ) && (request_uri.scheme == rubygems_uri.scheme) end |
#credentials ⇒ Object
14 15 16 |
# File 'lib/stickler/repository/rubygems_authenticator.rb', line 14 def credentials Gem.configuration.rubygems_api_key end |
#rubygems_uri ⇒ Object
18 19 20 |
# File 'lib/stickler/repository/rubygems_authenticator.rb', line 18 def rubygems_uri self.class.rubygems_uri end |