alfi2 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +98 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +71 -0
- data/Rakefile +5 -0
- data/alfi.gemspec +36 -0
- data/bin/alfi +5 -0
- data/extras/images/logov2.png +0 -0
- data/extras/images/terminal01.gif +0 -0
- data/extras/images/wide-logo.png +0 -0
- data/lib/alfi.rb +11 -0
- data/lib/alfi/cli.rb +112 -0
- data/lib/alfi/providers.rb +6 -0
- data/lib/alfi/providers/base.rb +31 -0
- data/lib/alfi/providers/bintray.rb +61 -0
- data/lib/alfi/providers/maven.rb +34 -0
- data/lib/alfi/providers/offline.rb +27 -0
- data/lib/alfi/search.rb +36 -0
- data/lib/alfi/version.rb +3 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e98b5ecd2e26c3bf217f3ec6ee0883b2ed0340a0
|
4
|
+
data.tar.gz: fa2eceaaaa2dda51cf81fe38b4a356d8e4acf650
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 02474d7c7fc088f3b2d0d464d58f00e89ba367737ed3fc51a01e7d145e5b4adeac54a689b80134867855375e6774f66a1781600b7edf65be0329c13fac750605
|
7
|
+
data.tar.gz: 156919c7d7d7d71ef331498a121375e12e139485b6d1fa6ab84c171e161d23256e387c02482e28c50a95cddce74cd1536f11922377c3b945d9983d7200422915
|
data/.gitignore
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
# Created by https://www.gitignore.io
|
11
|
+
|
12
|
+
### RubyMine ###
|
13
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
14
|
+
|
15
|
+
*.iml
|
16
|
+
|
17
|
+
## Directory-based project format:
|
18
|
+
.idea/
|
19
|
+
# if you remove the above rule, at least ignore the following:
|
20
|
+
|
21
|
+
# User-specific stuff:
|
22
|
+
# .idea/workspace.xml
|
23
|
+
# .idea/tasks.xml
|
24
|
+
# .idea/dictionaries
|
25
|
+
|
26
|
+
# Sensitive or high-churn files:
|
27
|
+
# .idea/dataSources.ids
|
28
|
+
# .idea/dataSources.xml
|
29
|
+
# .idea/sqlDataSources.xml
|
30
|
+
# .idea/dynamic.xml
|
31
|
+
# .idea/uiDesigner.xml
|
32
|
+
|
33
|
+
# Gradle:
|
34
|
+
# .idea/gradle.xml
|
35
|
+
# .idea/libraries
|
36
|
+
|
37
|
+
# Mongo Explorer plugin:
|
38
|
+
# .idea/mongoSettings.xml
|
39
|
+
|
40
|
+
## File-based project format:
|
41
|
+
*.ipr
|
42
|
+
*.iws
|
43
|
+
|
44
|
+
## Plugin-specific files:
|
45
|
+
|
46
|
+
# IntelliJ
|
47
|
+
/out/
|
48
|
+
|
49
|
+
# mpeltonen/sbt-idea plugin
|
50
|
+
.idea_modules/
|
51
|
+
|
52
|
+
# JIRA plugin
|
53
|
+
atlassian-ide-plugin.xml
|
54
|
+
|
55
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
56
|
+
com_crashlytics_export_strings.xml
|
57
|
+
crashlytics.properties
|
58
|
+
crashlytics-build.properties
|
59
|
+
|
60
|
+
|
61
|
+
### Ruby ###
|
62
|
+
*.gem
|
63
|
+
*.rbc
|
64
|
+
/.config
|
65
|
+
/coverage/
|
66
|
+
/InstalledFiles
|
67
|
+
/pkg/
|
68
|
+
/spec/reports/
|
69
|
+
/test/tmp/
|
70
|
+
/test/version_tmp/
|
71
|
+
/tmp/
|
72
|
+
|
73
|
+
## Specific to RubyMotion:
|
74
|
+
.dat*
|
75
|
+
.repl_history
|
76
|
+
build/
|
77
|
+
|
78
|
+
## Documentation cache and generated files:
|
79
|
+
/.yardoc/
|
80
|
+
/_yardoc/
|
81
|
+
/doc/
|
82
|
+
/rdoc/
|
83
|
+
|
84
|
+
## Environment normalisation:
|
85
|
+
/.bundle/
|
86
|
+
/vendor/bundle
|
87
|
+
/lib/bundler/man/
|
88
|
+
|
89
|
+
# for a library or gem, you might want to ignore these files since the code is
|
90
|
+
# intended to run in multiple environments; otherwise, check them in:
|
91
|
+
# Gemfile.lock
|
92
|
+
# .ruby-version
|
93
|
+
# .ruby-gemset
|
94
|
+
|
95
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
96
|
+
.rvmrc
|
97
|
+
.ruby-version
|
98
|
+
.ruby-gemset
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 César Ferreira
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# alfi 2
|
2
|
+
|
3
|
+
![](http://ruby-gem-downloads-badge.herokuapp.com/alfi2?type=total)
|
4
|
+
[![Build Status](https://travis-ci.org/afzalive/alfi.svg?branch=master)](https://travis-ci.org/afzalive/alfi)
|
5
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/52ccd1e232684026b943c2be7059afcd)](https://www.codacy.com/app/AfzalivE/alfi?utm_source=github.com&utm_medium=referral&utm_content=AfzalivE/alfi&utm_campaign=Badge_Grade)
|
6
|
+
[![Gem Version](http://img.shields.io/gem/v/alfi2.svg?style=flat)](http://badge.fury.io/rb/alfi2)
|
7
|
+
|
8
|
+
**A**ndroid **L**ibrary **Fi**nder 2
|
9
|
+
|
10
|
+
Search through thousands of android libraries that can help you scale your projects elegantly
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Search for `something`
|
15
|
+
|
16
|
+
```bash
|
17
|
+
alfi picasso
|
18
|
+
```
|
19
|
+
|
20
|
+
<p align="center">
|
21
|
+
<img src="https://raw.github.com/cesarferreira/alfi/master/extras/images/terminal01.gif" />
|
22
|
+
</p>
|
23
|
+
|
24
|
+
|
25
|
+
Search for `something` by repository
|
26
|
+
|
27
|
+
```bash
|
28
|
+
alfi picasso --repository maven
|
29
|
+
```
|
30
|
+
|
31
|
+
This will search picasso only on maven, you can also define multiple repositories like:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
alfi picasso -r mavencentral -r jcenter
|
35
|
+
```
|
36
|
+
|
37
|
+
This will search picasso on mavenCentral and jCenter
|
38
|
+
|
39
|
+
Search for `something` and print with a custom prefix
|
40
|
+
|
41
|
+
```bash
|
42
|
+
alfi picasso -p compile
|
43
|
+
```
|
44
|
+
|
45
|
+
Search for `something` and print with single quotes
|
46
|
+
|
47
|
+
```bash
|
48
|
+
alfi picasso -s
|
49
|
+
```
|
50
|
+
|
51
|
+
**Final step:** Copy the library you want to your `build.gradle` and sync it
|
52
|
+
|
53
|
+
## Installation
|
54
|
+
|
55
|
+
Install it via terminal:
|
56
|
+
|
57
|
+
$ gem install alfi2
|
58
|
+
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it ( https://github.com/afzalive/alfi/fork )
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create a new Pull Request
|
67
|
+
|
68
|
+
|
69
|
+
## Thanks
|
70
|
+
To [@cesarferreira](https://github.com/cesarferreira) for creating this project
|
71
|
+
To [@joaquimadraz](https://github.com/joaquimadraz) for the ruby pro-tips
|
data/Rakefile
ADDED
data/alfi.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'alfi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'alfi2'
|
8
|
+
spec.version = Alfi::VERSION
|
9
|
+
spec.authors = ['cesar ferreira', 'Afzal Najam']
|
10
|
+
spec.email = ['afzalnaj+dev@gmail.com']
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
#spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.summary = 'Android Library Finder'
|
17
|
+
spec.description = 'Android Library Finder'
|
18
|
+
spec.homepage = "https://github.com/afzalive/alfi"
|
19
|
+
spec.license = 'MIT'
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = 'bin'
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.required_ruby_version = '>= 2.0.0'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
29
|
+
spec.add_development_dependency 'webmock', '~> 3.3.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
31
|
+
spec.add_development_dependency 'vcr', '~> 2.9'
|
32
|
+
spec.add_development_dependency 'pry', '~> 0.10.1'
|
33
|
+
spec.add_dependency 'bundler', '~> 1.7'
|
34
|
+
spec.add_dependency 'json', '~> 2.0.2'
|
35
|
+
spec.add_dependency 'colorize', '~> 0.7'
|
36
|
+
end
|
data/bin/alfi
ADDED
Binary file
|
Binary file
|
Binary file
|
data/lib/alfi.rb
ADDED
data/lib/alfi/cli.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
include OptionParser::Arguable
|
3
|
+
|
4
|
+
$prefix = "implementation"
|
5
|
+
$single_quotes = false
|
6
|
+
|
7
|
+
class Alfi::Cli
|
8
|
+
BINTRAY_OPTIONS_FILE_NAME = File.expand_path('~/.alfi_bintray.json')
|
9
|
+
|
10
|
+
def exit_with(message)
|
11
|
+
puts message
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(arguments)
|
16
|
+
@search_type = []
|
17
|
+
create_options_parser
|
18
|
+
search_param = @all_defined_arguments.include?(arguments.first) ? nil : arguments.shift
|
19
|
+
@bintray_username = nil
|
20
|
+
@bintray_key = nil
|
21
|
+
@opt_parser.parse!(arguments)
|
22
|
+
|
23
|
+
parse_bintray_auth
|
24
|
+
|
25
|
+
exit_with("Missing query parameter\n".red + @opt_parser.help) unless search_param
|
26
|
+
|
27
|
+
Alfi::Search.new.call(search_param, @search_type)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_options_parser
|
31
|
+
@all_defined_arguments = [
|
32
|
+
'-u',
|
33
|
+
'--user',
|
34
|
+
'-k',
|
35
|
+
'--key',
|
36
|
+
'-r',
|
37
|
+
'--repository',
|
38
|
+
'-h',
|
39
|
+
'--help',
|
40
|
+
'-v',
|
41
|
+
'--version',
|
42
|
+
'-p',
|
43
|
+
'--prefix',
|
44
|
+
'-s',
|
45
|
+
'--single-quotes'
|
46
|
+
]
|
47
|
+
@opt_parser = OptionParser.new do |opts|
|
48
|
+
opts.banner = "Usage: alfi SEARCH_QUERY [OPTIONS]"
|
49
|
+
opts.separator ''
|
50
|
+
opts.separator 'Options'
|
51
|
+
|
52
|
+
opts.on('-u BINTRAY_USER_NAME', '--user BINTRAY_USER_NAME', 'your bintray user name') do |bintray_username|
|
53
|
+
@bintray_username = bintray_username
|
54
|
+
end
|
55
|
+
opts.on('-k BINTRAY_KEY', '--key BINTRAY_KEY', 'your bintray api key') do |bintray_key|
|
56
|
+
@bintray_key = bintray_key
|
57
|
+
end
|
58
|
+
opts.on('-h', '--help', 'Displays help') do
|
59
|
+
puts opts.help
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
opts.on('-v', '--version', 'Displays version') do
|
63
|
+
puts Alfi::VERSION
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
opts.on('-p PREFIX', '--prefix PREFIX', 'Use custom prefix instead of "implementation"') do |prefix|
|
67
|
+
$prefix = prefix
|
68
|
+
end
|
69
|
+
opts.on('-s', '--single-quotes', 'Use single quotes instead of double quotes') do
|
70
|
+
$single_quotes = true
|
71
|
+
end
|
72
|
+
opts.on('-r REPOSITORY_NAME', '--repository REPOSITORY_NAME', 'If should search on maven, jCenter or mavenCentral ') do |repository_name|
|
73
|
+
if repository_name != "maven" && repository_name != "jcenter" && repository_name != "mavencentral"
|
74
|
+
puts "Please choose one of the following maven, jcenter or mavencentral"
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
if repository_name.downcase == "maven"
|
79
|
+
@search_type << "m"
|
80
|
+
end
|
81
|
+
|
82
|
+
if repository_name.downcase == "mavencentral"
|
83
|
+
@search_type << "maven"
|
84
|
+
end
|
85
|
+
|
86
|
+
if repository_name.downcase == "jcenter"
|
87
|
+
@search_type << "jcenter"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
opts.separator "\nNow you are using alfi credentials for Bintray".yellow
|
92
|
+
opts.separator "But you also could enter your authentication data if you want. "\
|
93
|
+
"It will be saved once you provided it\n".green unless @bintray_username
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_bintray_auth
|
98
|
+
$bintray_auth = if @bintray_username && @bintray_key
|
99
|
+
# write new auth data
|
100
|
+
new_data = { user_name: @bintray_username, api_key: @bintray_key }
|
101
|
+
File.open(BINTRAY_OPTIONS_FILE_NAME, 'w+') do |f|
|
102
|
+
f.puts new_data.to_json
|
103
|
+
end
|
104
|
+
new_data
|
105
|
+
else
|
106
|
+
# read old auth data
|
107
|
+
return unless File.exist?(BINTRAY_OPTIONS_FILE_NAME)
|
108
|
+
auth_data = JSON.parse(File.read(BINTRAY_OPTIONS_FILE_NAME) || '{}', symbolize_names: true)
|
109
|
+
auth_data if auth_data[:user_name] && auth_data[:api_key]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Alfi::Providers::Base
|
2
|
+
def initialize(query, search_type)
|
3
|
+
@query = query
|
4
|
+
@uri = URI.parse(query_url(query))
|
5
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
6
|
+
@request = Net::HTTP::Get.new(@uri.request_uri)
|
7
|
+
@search_type = search_type
|
8
|
+
@quote_symbol = $single_quotes ? "'" : "\""
|
9
|
+
request_extensions if self.class.method_defined?(:request_extensions)
|
10
|
+
end
|
11
|
+
|
12
|
+
def query_url
|
13
|
+
fail NotImplementedError
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
fail NotImplementedError
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_to_list(helper_string)
|
21
|
+
$result_list << helper_string
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_suggestions(suggestions)
|
25
|
+
$suggestions += Array(suggestions)
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_repo_to_list(package)
|
29
|
+
$result_list << " #{$prefix} #{@quote_symbol}#{package}#{@quote_symbol}".green
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Alfi::Providers::Bintray < Alfi::Providers::Base
|
2
|
+
PROVIDERS_TEXTS = {
|
3
|
+
'maven' => 'mavenCentral()',
|
4
|
+
'jcenter' => 'jcenter()'
|
5
|
+
}
|
6
|
+
ALFI_BINTRAY_CREDS = [
|
7
|
+
{
|
8
|
+
user_name: 'alfi',
|
9
|
+
api_key: '5bfa2bedc8d2f5abb8a3fdff49a8599d6ebe7bef'
|
10
|
+
},
|
11
|
+
{
|
12
|
+
user_name: 'alfi2',
|
13
|
+
api_key: '98ebb0e5c0fb45c03a1d747da5532b294e01f77e'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
user_name: 'alfi3',
|
17
|
+
api_key: 'd506539a493ede165e6497269bea4b0f822fdb6a'
|
18
|
+
},
|
19
|
+
{
|
20
|
+
user_name: 'alfi4',
|
21
|
+
api_key: '3da11d361aa52d5d46ee5fd320838f7a5592d9e1'
|
22
|
+
}
|
23
|
+
]
|
24
|
+
|
25
|
+
def query_url(query)
|
26
|
+
"https://api.bintray.com/search/packages?name=#{query}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def request_extensions
|
30
|
+
unless $bintray_auth
|
31
|
+
$bintray_auth = ALFI_BINTRAY_CREDS.sample
|
32
|
+
end
|
33
|
+
@http.use_ssl = true
|
34
|
+
@request.basic_auth $bintray_auth[:user_name], $bintray_auth[:api_key]
|
35
|
+
end
|
36
|
+
|
37
|
+
def call
|
38
|
+
if @search_type.empty? || @search_type.include?('jcenter') || @search_type.include?('maven')
|
39
|
+
begin
|
40
|
+
response = @http.request(@request)
|
41
|
+
rescue SocketError
|
42
|
+
puts "Internet Connection not available".red
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
|
46
|
+
return if response.code != '200'
|
47
|
+
response_json = JSON.parse(response.body || '{}')
|
48
|
+
|
49
|
+
add_to_list " # #{'-'*20}Bintray#{'-'*20}" if response_json.size > 0
|
50
|
+
|
51
|
+
response_json.group_by { |package| package['repo'] }.each do |provider, repositories|
|
52
|
+
if @search_type.empty? || @search_type.include?(provider)
|
53
|
+
add_to_list " # #{PROVIDERS_TEXTS[provider]}"
|
54
|
+
repositories.each do |repo|
|
55
|
+
add_repo_to_list "#{repo['system_ids'][0]}:#{repo['latest_version']}" if repo['system_ids'].size > 0
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Alfi::Providers::Maven < Alfi::Providers::Base
|
2
|
+
def query_url(query)
|
3
|
+
"http://search.maven.org/solrsearch/select?q=#{query}&rows=350&wt=json"
|
4
|
+
end
|
5
|
+
|
6
|
+
def call
|
7
|
+
if @search_type.empty? || @search_type.include?('m')
|
8
|
+
begin
|
9
|
+
response = @http.request(@request)
|
10
|
+
rescue SocketError
|
11
|
+
puts "Internet Connection not available".red
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
if response.code == '200'
|
16
|
+
result = JSON.parse(response.body)
|
17
|
+
|
18
|
+
num_results = result['response']['numFound']
|
19
|
+
|
20
|
+
if num_results == 0
|
21
|
+
suggestions = (result['spellcheck']['suggestions'].last || {})['suggestion']
|
22
|
+
add_suggestions(suggestions) if suggestions
|
23
|
+
else
|
24
|
+
add_to_list " # #{'-'*20}Maven.org#{'-'*20}"
|
25
|
+
add_to_list ' # mavenCentral()'
|
26
|
+
end
|
27
|
+
result['response']['docs'].each { |doc| add_repo_to_list "#{doc['id']}:#{doc['latestVersion']}" }
|
28
|
+
else
|
29
|
+
puts "Error: #{response.code}\n#{response}".red
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# require 'alfi/providers/base'
|
2
|
+
class Alfi::Providers::Offline < Alfi::Providers::Base
|
3
|
+
def initialize(query, search_type)
|
4
|
+
@query = query
|
5
|
+
end
|
6
|
+
|
7
|
+
def call
|
8
|
+
google_libs = [
|
9
|
+
'com.android.support:appcompat-v7',
|
10
|
+
'com.android.support:cardview-v7',
|
11
|
+
'com.android.support:gridlayout-v7',
|
12
|
+
'com.android.support:leanback-v17',
|
13
|
+
'com.android.support:mediarouter-v7',
|
14
|
+
'com.android.support:palette-v7',
|
15
|
+
'com.android.support:support-annotations',
|
16
|
+
'com.android.support:support-v4',
|
17
|
+
'com.android.support:support-v13',
|
18
|
+
'com.google.android.gms:play-services-wearable',
|
19
|
+
'com.google.android.gms:play-services',
|
20
|
+
'com.android.support:recyclerview-v7'
|
21
|
+
]
|
22
|
+
results = google_libs.map { |lib| "#{lib}:+" if lib.include?(@query) }.compact
|
23
|
+
return unless results.size > 0
|
24
|
+
add_to_list ' # Google'
|
25
|
+
results.each { |library| add_repo_to_list(library) }
|
26
|
+
end
|
27
|
+
end
|
data/lib/alfi/search.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
class Alfi::Search
|
2
|
+
def initialize
|
3
|
+
$result_list = []
|
4
|
+
$suggestions = []
|
5
|
+
end
|
6
|
+
|
7
|
+
def exit_with(message)
|
8
|
+
puts message
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(search_param, search_type)
|
13
|
+
return puts 'The search needs 3+ characters'.red if search_param.size < 3
|
14
|
+
puts "Searching...\n"
|
15
|
+
|
16
|
+
Alfi::Providers.all.each { |cc| cc.new(search_param, search_type).call }
|
17
|
+
|
18
|
+
exit_with('No results'.red) if $result_list.empty? && $suggestions.empty?
|
19
|
+
num_results = total_results_count
|
20
|
+
|
21
|
+
if num_results > 0
|
22
|
+
puts "\ndependencies {\n"
|
23
|
+
$result_list.each { |result| puts result }
|
24
|
+
puts "}\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
puts "\nFound: #{num_results} result#{num_results > 1?'s':''} for '#{search_param.yellow}'"
|
28
|
+
|
29
|
+
return if $suggestions.empty?
|
30
|
+
puts "Did you mean: #{$suggestions.join(', ').yellow}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def total_results_count
|
34
|
+
return $result_list.count { |r| r.strip[0] != '#' }
|
35
|
+
end
|
36
|
+
end
|
data/lib/alfi/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alfi2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cesar ferreira
|
8
|
+
- Afzal Najam
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '12.0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '12.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: webmock
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.3.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.3.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.2'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.2'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: vcr
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.9'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.9'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: pry
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.10.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.10.1
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: bundler
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '1.7'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.7'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: json
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.0.2
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 2.0.2
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: colorize
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.7'
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.7'
|
126
|
+
description: Android Library Finder
|
127
|
+
email:
|
128
|
+
- afzalnaj+dev@gmail.com
|
129
|
+
executables:
|
130
|
+
- alfi
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- ".travis.yml"
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- alfi.gemspec
|
142
|
+
- bin/alfi
|
143
|
+
- extras/images/logov2.png
|
144
|
+
- extras/images/terminal01.gif
|
145
|
+
- extras/images/wide-logo.png
|
146
|
+
- lib/alfi.rb
|
147
|
+
- lib/alfi/cli.rb
|
148
|
+
- lib/alfi/providers.rb
|
149
|
+
- lib/alfi/providers/base.rb
|
150
|
+
- lib/alfi/providers/bintray.rb
|
151
|
+
- lib/alfi/providers/maven.rb
|
152
|
+
- lib/alfi/providers/offline.rb
|
153
|
+
- lib/alfi/search.rb
|
154
|
+
- lib/alfi/version.rb
|
155
|
+
homepage: https://github.com/afzalive/alfi
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
metadata: {}
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 2.0.0
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 2.6.13
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: Android Library Finder
|
179
|
+
test_files: []
|