Class: Stickler::Repository::BasicAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/stickler/repository/basic_authenticator.rb

Overview

Generate the authentication for basic auth request

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (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

#credentialsObject



18
19
20
# File 'lib/stickler/repository/basic_authenticator.rb', line 18

def credentials
  "Basic #{@cred}"
end