Class: Stickler::Repository::BasicAuthenticator
- Inherits:
-
Object
- Object
- Stickler::Repository::BasicAuthenticator
- Defined in:
- lib/stickler/repository/basic_authenticator.rb
Overview
Generate the authentication for basic auth request
Class Method Summary collapse
Instance Method Summary collapse
- #credentials ⇒ Object
-
#initialize(uri) ⇒ BasicAuthenticator
constructor
A new instance of BasicAuthenticator.
Constructor Details
#initialize(uri) ⇒ BasicAuthenticator
Returns a new instance of BasicAuthenticator.
12 13 14 15 16 |
# File 'lib/stickler/repository/basic_authenticator.rb', line 12 def initialize( uri ) @user = uri.user @password = uri.password @cred = ["#{@user}:#{@password}"].pack('m').tr("\n", '') end |
Class Method Details
.handles?(uri) ⇒ Boolean
8 9 10 |
# File 'lib/stickler/repository/basic_authenticator.rb', line 8 def self.handles?( uri ) %w[ http https ].include?( uri.scheme ) and uri.user and uri.password end |
Instance Method Details
#credentials ⇒ Object
18 19 20 |
# File 'lib/stickler/repository/basic_authenticator.rb', line 18 def credentials "Basic #{@cred}" end |