class Alfi::Providers::Bintray

Constants

ALFI_BINTRAY_CREDS
PROVIDERS_TEXTS

Public Instance Methods

call() click to toggle source
# File lib/alfi/providers/bintray.rb, line 37
def call
  if @search_type.empty? || @search_type.include?('jcenter') || @search_type.include?('maven')
    begin
      response = @http.request(@request)
    rescue SocketError
      puts "Internet Connection not available".red
      exit 1
    end

    return if response.code != '200'
    response_json = JSON.parse(response.body || '{}')

    add_to_list "  # #{'-'*20}Bintray#{'-'*20}" if response_json.size > 0

    response_json.group_by { |package| package['repo'] }.each do |provider, repositories|
      if @search_type.empty? || @search_type.include?(provider)
        add_to_list "  # #{PROVIDERS_TEXTS[provider]}"
        repositories.each do |repo|
          add_repo_to_list "#{repo['system_ids'][0]}:#{repo['latest_version']}" if repo['system_ids'].size > 0
        end
      end
    end
  end
end
query_url(query) click to toggle source
# File lib/alfi/providers/bintray.rb, line 25
def query_url(query)
  "https://api.bintray.com/search/packages?name=#{query}"
end
request_extensions() click to toggle source
# File lib/alfi/providers/bintray.rb, line 29
def request_extensions
  unless $bintray_auth
    $bintray_auth = ALFI_BINTRAY_CREDS.sample
  end
  @http.use_ssl = true
  @request.basic_auth $bintray_auth[:user_name], $bintray_auth[:api_key]
end