Class: Alfi::Providers::Bintray
- Inherits:
-
Base
- Object
- Base
- Alfi::Providers::Bintray
show all
- Defined in:
- lib/alfi/providers/bintray.rb
Constant Summary
collapse
- PROVIDERS_TEXTS =
{
'maven' => 'mavenCentral()',
'jcenter' => 'jcenter()'
}
- ALFI_BINTRAY_CREDS =
[
{
user_name: 'alfi',
api_key: '5bfa2bedc8d2f5abb8a3fdff49a8599d6ebe7bef'
},
{
user_name: 'alfi2',
api_key: '98ebb0e5c0fb45c03a1d747da5532b294e01f77e'
},
{
user_name: 'alfi3',
api_key: 'd506539a493ede165e6497269bea4b0f822fdb6a'
},
{
user_name: 'alfi4',
api_key: '3da11d361aa52d5d46ee5fd320838f7a5592d9e1'
}
]
Instance Method Summary
collapse
Methods inherited from Base
#add_repo_to_list, #add_suggestions, #add_to_list, #initialize
Instance Method Details
#call ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# 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) ⇒ Object
25
26
27
|
# File 'lib/alfi/providers/bintray.rb', line 25
def query_url(query)
"https://api.bintray.com/search/packages?name=#{query}"
end
|
#request_extensions ⇒ Object
29
30
31
32
33
34
35
|
# 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
|