Sha256: 473d521b946f9c79d79ea436e7f2e1508cfd2b96a442682598e6ffb51e3bdfef

Contents?: true

Size: 883 Bytes

Versions: 6

Compression:

Stored size: 883 Bytes

Contents

module Octokit
  module Authentication
    def authentication
      if login && password
        {:login => login, :password => password}
      else
        {}
      end
    end

    def authenticated?
      !authentication.empty?
    end

    def oauthed?
      !oauth_token.nil?
    end

    def unauthed_rate_limited?
      client_id && client_secret
    end

    def unauthed_rate_limit_params
      {
        :client_id => client_id,
        :client_secret => client_secret
      }
    end

    def login_and_password_from_netrc(rc = false)
      return unless rc

      info = case rc
              when TrueClass
                Netrc.read
              when String
                Netrc.read rc
              end
      netrc_host = URI.parse(api_endpoint).host
      creds = info[netrc_host]
      self.login = creds.shift
      self.password = creds.shift
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
octokit-1.25.0 lib/octokit/authentication.rb
octokit-1.24.0 lib/octokit/authentication.rb
octokit-1.23.0 lib/octokit/authentication.rb
octokit-1.22.0 lib/octokit/authentication.rb
octokit-1.21.0 lib/octokit/authentication.rb
octokit-1.20.0 lib/octokit/authentication.rb