Sha256: db5e24e9630f085fdd30daac609eff2198a4e344fd66f2b429e914484df75b62

Contents?: true

Size: 480 Bytes

Versions: 7

Compression:

Stored size: 480 Bytes

Contents

require 'addressable/uri'

module Stickler::Repository
  #
  # Generate the authentication for basic auth request
  #
  class BasicAuthenticator
    def self.handles?( uri )
      %w[ http https ].include?( uri.scheme ) and uri.user and uri.password
    end

    def initialize( uri )
      @user     = uri.user
      @password = uri.password
      @cred     = ["#{@user}:#{@password}"].pack('m').tr("\n", '')
    end

    def credentials
      "Basic #{@cred}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stickler-2.4.2 lib/stickler/repository/basic_authenticator.rb
stickler-2.4.1 lib/stickler/repository/basic_authenticator.rb
stickler-2.4.0 lib/stickler/repository/basic_authenticator.rb
stickler-2.3.0 lib/stickler/repository/basic_authenticator.rb
stickler-2.2.4 lib/stickler/repository/basic_authenticator.rb
stickler-2.2.3 lib/stickler/repository/basic_authenticator.rb
stickler-2.2.2 lib/stickler/repository/basic_authenticator.rb