Sha256: 34f09a04ac2b6ff424fa04ce5e6c421c150812f9db1e78cfbba7d2ce22df983f

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require 'httparty'
require 'json'

require_relative 'api/access'
require_relative 'api/accounts'
require_relative 'api/changes'
require_relative 'api/groups'
require_relative 'api/projects'
require_relative 'api/request'
require_relative 'api/branches'


module Gerry
  ##
  # Client for gerrit request api
  #
  # - for anonymout user
  #  client = Gerry::Client.new('http://gerrit.example.com')
  # - for user/password
  #  client = Gerry::Client.new('http://gerrit.example.com', 'username', 'password')
  #  
  #   
  
  class Client
    include HTTParty
    headers 'Accept' => 'application/json'

    include Api::Access
    include Api::Accounts
    include Api::Changes
    include Api::Groups
    include Api::Projects
    include Api::Branches
    include Api::Request

    def set_auth_type(auth_type)
      warn 'set_auth_type is deprecated. digest auth is no longer supported'
    end

    def initialize(url, username = nil, password = nil)
      self.class.base_uri(url)

      if username && password
        @username = username
        @password = password
      else
        require 'netrc'
        @username, @password = Netrc.read[URI.parse(url).host]
      end
      if @username && @password
        self.class.basic_auth(@username, @password)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gerry-0.1.6 lib/gerry/client.rb