veye 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +16 -16
- data/README.md +66 -0
- data/bin/veye +140 -186
- data/lib/veye/base_executor.rb +24 -0
- data/lib/veye/github/delete.rb +35 -0
- data/lib/veye/github/import.rb +32 -0
- data/lib/veye/github/info.rb +30 -0
- data/lib/veye/github/list.rb +37 -0
- data/lib/veye/github/search.rb +34 -0
- data/lib/veye/github/sync.rb +33 -0
- data/lib/veye/github.rb +14 -0
- data/lib/veye/helpers/format_helpers.rb +4 -1
- data/lib/veye/helpers/repo_helpers.rb +5 -0
- data/lib/veye/package/follow.rb +37 -22
- data/lib/veye/package/info.rb +17 -27
- data/lib/veye/package/search.rb +29 -40
- data/lib/veye/project/check.rb +80 -74
- data/lib/veye/project/licence.rb +17 -31
- data/lib/veye/service.rb +16 -4
- data/lib/veye/user/me.rb +25 -45
- data/lib/veye/version.rb +1 -1
- data/lib/veye/views/base_csv.rb +26 -0
- data/lib/veye/views/base_json.rb +20 -0
- data/lib/veye/views/base_markdown.rb +17 -0
- data/lib/veye/views/base_pretty.rb +17 -0
- data/lib/veye/views/base_table.rb +34 -0
- data/lib/veye/views/github/info_csv.rb +30 -0
- data/lib/veye/views/github/info_json.rb +11 -0
- data/lib/veye/views/github/info_pretty.rb +35 -0
- data/lib/veye/views/github/info_table.rb +36 -0
- data/lib/veye/views/github/list_csv.rb +28 -0
- data/lib/veye/views/github/list_json.rb +16 -0
- data/lib/veye/views/github/list_pretty.rb +27 -0
- data/lib/veye/views/github/list_table.rb +28 -0
- data/lib/veye/views/github/search_csv.rb +36 -0
- data/lib/veye/views/github/search_json.rb +12 -0
- data/lib/veye/views/github/search_pretty.rb +31 -0
- data/lib/veye/views/github/search_table.rb +34 -0
- data/lib/veye/views/github.rb +19 -0
- data/lib/veye/{package → views/package}/info_csv.rb +7 -6
- data/lib/veye/views/package/info_json.rb +12 -0
- data/lib/veye/{package → views/package}/info_pretty.rb +8 -10
- data/lib/veye/views/package/info_table.rb +25 -0
- data/lib/veye/views/package/search_csv.rb +28 -0
- data/lib/veye/views/package/search_json.rb +11 -0
- data/lib/veye/views/package/search_pretty.rb +26 -0
- data/lib/veye/views/package/search_table.rb +25 -0
- data/lib/veye/views/package.rb +14 -0
- data/lib/veye/views/project/dependency_csv.rb +30 -0
- data/lib/veye/views/project/dependency_json.rb +11 -0
- data/lib/veye/views/project/dependency_markdown.rb +31 -0
- data/lib/veye/{project/project_dependency_pretty.rb → views/project/dependency_pretty.rb} +5 -7
- data/lib/veye/{project/project_dependency_table.rb → views/project/dependency_table.rb} +6 -15
- data/lib/veye/{project/project_csv.rb → views/project/info_csv.rb} +7 -7
- data/lib/veye/views/project/info_json.rb +12 -0
- data/lib/veye/{project/project_markdown.rb → views/project/info_markdown.rb} +8 -14
- data/lib/veye/{project/project_pretty.rb → views/project/info_pretty.rb} +3 -4
- data/lib/veye/views/project/info_table.rb +24 -0
- data/lib/veye/{project/project_licence_csv.rb → views/project/licence_csv.rb} +7 -5
- data/lib/veye/views/project/licence_json.rb +11 -0
- data/lib/veye/{project/project_licence_pretty.rb → views/project/licence_pretty.rb} +4 -6
- data/lib/veye/views/project/licence_table.rb +24 -0
- data/lib/veye/views/project.rb +22 -0
- data/lib/veye/views/user/favorite_csv.rb +32 -0
- data/lib/veye/views/user/favorite_json.rb +13 -0
- data/lib/veye/views/user/favorite_pretty.rb +23 -0
- data/lib/veye/views/user/favorite_table.rb +24 -0
- data/lib/veye/views/user/profile_csv.rb +23 -0
- data/lib/veye/views/user/profile_json.rb +12 -0
- data/lib/veye/{user → views/user}/profile_pretty.rb +6 -10
- data/lib/veye/views/user/profile_table.rb +30 -0
- data/lib/veye/views/user.rb +14 -0
- data/lib/veye.rb +3 -1
- metadata +90 -60
- data/lib/veye/package/info_json.rb +0 -14
- data/lib/veye/package/info_table.rb +0 -29
- data/lib/veye/package/search_csv.rb +0 -33
- data/lib/veye/package/search_json.rb +0 -19
- data/lib/veye/package/search_pretty.rb +0 -35
- data/lib/veye/package/search_table.rb +0 -40
- data/lib/veye/project/project_dependency_csv.rb +0 -30
- data/lib/veye/project/project_dependency_json.rb +0 -12
- data/lib/veye/project/project_dependency_markdown.rb +0 -47
- data/lib/veye/project/project_json.rb +0 -11
- data/lib/veye/project/project_licence_json.rb +0 -12
- data/lib/veye/project/project_licence_table.rb +0 -29
- data/lib/veye/project/project_table.rb +0 -30
- data/lib/veye/user/favorite_csv.rb +0 -28
- data/lib/veye/user/favorite_json.rb +0 -14
- data/lib/veye/user/favorite_pretty.rb +0 -25
- data/lib/veye/user/favorite_table.rb +0 -28
- data/lib/veye/user/profile_csv.rb +0 -21
- data/lib/veye/user/profile_json.rb +0 -14
- data/lib/veye/user/profile_table.rb +0 -34
data/lib/veye/project/licence.rb
CHANGED
|
@@ -1,51 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require_relative 'project_licence_csv.rb'
|
|
4
|
-
require_relative 'project_licence_json.rb'
|
|
5
|
-
require_relative 'project_licence_pretty.rb'
|
|
6
|
-
require_relative 'project_licence_table.rb'
|
|
1
|
+
require_relative '../views/project.rb'
|
|
2
|
+
require_relative '../base_executor.rb'
|
|
7
3
|
|
|
8
4
|
module Veye
|
|
9
5
|
module Project
|
|
10
|
-
class Licence
|
|
11
|
-
extend FormatHelpers
|
|
12
|
-
|
|
6
|
+
class Licence < BaseExecutor
|
|
13
7
|
@@output_formats = {
|
|
14
|
-
"csv" =>
|
|
15
|
-
"json" =>
|
|
16
|
-
"pretty" =>
|
|
17
|
-
"table" =>
|
|
8
|
+
"csv" => Project::LicenceCSV.new,
|
|
9
|
+
"json" => Project::LicenceJSON.new,
|
|
10
|
+
"pretty" => Project::LicencePretty.new,
|
|
11
|
+
"table" => Project::LicenceTable.new
|
|
18
12
|
}
|
|
19
13
|
|
|
20
|
-
def self.get_project(project_key, api_key)
|
|
21
|
-
|
|
14
|
+
def self.get_project(project_key, api_key, options)
|
|
15
|
+
results = nil
|
|
22
16
|
project_api = API::Resource.new(RESOURCE_PATH)
|
|
23
|
-
|
|
24
|
-
if project_key.nil? or project_key.empty?
|
|
17
|
+
|
|
18
|
+
if project_key.nil? or project_key.empty?
|
|
25
19
|
error_msg = sprintf("%s: %s",
|
|
26
20
|
"Error".foreground(:red),
|
|
27
|
-
"Not valid project_key: `#{project_key}`")
|
|
21
|
+
"Not valid project_key: `#{project_key}`")
|
|
28
22
|
exit_now! error_msg
|
|
29
23
|
end
|
|
30
|
-
|
|
24
|
+
|
|
31
25
|
project_url = "/#{project_key}/licenses"
|
|
32
26
|
qparams = {:params => {:api_key => api_key}}
|
|
33
27
|
project_api.resource[project_url].get(qparams) do |response, request, result|
|
|
34
|
-
|
|
28
|
+
results = API::JSONResponse.new(request, result, response)
|
|
35
29
|
end
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def self.format(results, format = 'pretty')
|
|
41
|
-
self.supported_format?(@@output_formats, format)
|
|
42
|
-
|
|
43
|
-
formatter = @@output_formats[format]
|
|
44
|
-
formatter.before
|
|
45
|
-
formatter.format results
|
|
46
|
-
formatter.after
|
|
31
|
+
catch_request_error(results, "Cant access a information for project `#{project_key}.")
|
|
32
|
+
show_results(@@output_formats, results.data, options)
|
|
33
|
+
results
|
|
47
34
|
end
|
|
48
|
-
|
|
49
35
|
end
|
|
50
36
|
end
|
|
51
37
|
end
|
data/lib/veye/service.rb
CHANGED
|
@@ -3,12 +3,24 @@ module Veye
|
|
|
3
3
|
RESOURCE_PATH = "/services"
|
|
4
4
|
def self.ping(n = 1)
|
|
5
5
|
public_api = API::Resource.new RESOURCE_PATH
|
|
6
|
-
|
|
6
|
+
api_response = "no idea"
|
|
7
7
|
public_api.resource['/ping'].get do |response, request, result, &block|
|
|
8
|
-
|
|
8
|
+
api_response = API::JSONResponse.new(request, result, response)
|
|
9
9
|
end
|
|
10
|
+
show_result(api_response)
|
|
11
|
+
return api_response
|
|
12
|
+
end
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
def self.show_result(result)
|
|
15
|
+
if result.success
|
|
16
|
+
puts "#{result.data['message']}".foreground(:green)
|
|
17
|
+
else
|
|
18
|
+
printf(
|
|
19
|
+
"VersionEye didnt recognized secret word.Answered %s, %s\n",
|
|
20
|
+
result.code.to_s.foreground(:red),
|
|
21
|
+
"#{result.message}".foreground(:yellow)
|
|
22
|
+
)
|
|
23
|
+
end
|
|
12
24
|
end
|
|
13
25
|
end
|
|
14
|
-
end
|
|
26
|
+
end
|
data/lib/veye/user/me.rb
CHANGED
|
@@ -1,78 +1,58 @@
|
|
|
1
|
-
require_relative '
|
|
2
|
-
require_relative '
|
|
3
|
-
require_relative 'profile_pretty.rb'
|
|
4
|
-
require_relative 'profile_table.rb'
|
|
1
|
+
require_relative '../views/user.rb'
|
|
2
|
+
require_relative '../base_executor.rb'
|
|
5
3
|
|
|
6
|
-
require_relative 'favorite_csv.rb'
|
|
7
|
-
require_relative 'favorite_json.rb'
|
|
8
|
-
require_relative 'favorite_pretty.rb'
|
|
9
|
-
require_relative 'favorite_table.rb'
|
|
10
4
|
|
|
11
5
|
module Veye
|
|
12
6
|
module User
|
|
13
|
-
class Me
|
|
14
|
-
extend FormatHelpers
|
|
7
|
+
class Me < BaseExecutor
|
|
15
8
|
|
|
16
9
|
@@profile_formats = {
|
|
17
|
-
'csv' => ProfileCSV.new,
|
|
18
|
-
'json' => ProfileJSON.new,
|
|
19
|
-
'pretty' => ProfilePretty.new,
|
|
20
|
-
'table' => ProfileTable.new
|
|
10
|
+
'csv' => User::ProfileCSV.new,
|
|
11
|
+
'json' => User::ProfileJSON.new,
|
|
12
|
+
'pretty' => User::ProfilePretty.new,
|
|
13
|
+
'table' => User::ProfileTable.new
|
|
21
14
|
}
|
|
22
15
|
|
|
23
16
|
@@favorite_formats = {
|
|
24
|
-
'csv' => FavoriteCSV.new,
|
|
25
|
-
'json' => FavoriteJSON.new,
|
|
26
|
-
'pretty' => FavoritePretty.new,
|
|
27
|
-
'table' => FavoriteTable.new
|
|
17
|
+
'csv' => User::FavoriteCSV.new,
|
|
18
|
+
'json' => User::FavoriteJSON.new,
|
|
19
|
+
'pretty' => User::FavoritePretty.new,
|
|
20
|
+
'table' => User::FavoriteTable.new
|
|
28
21
|
}
|
|
29
22
|
|
|
30
|
-
def self.get_profile(api_key)
|
|
23
|
+
def self.get_profile(api_key, options)
|
|
31
24
|
user_api = API::Resource.new(RESOURCE_PATH)
|
|
32
|
-
|
|
25
|
+
results = nil
|
|
33
26
|
qparams = {:params => {:api_key => api_key}}
|
|
34
27
|
|
|
35
28
|
user_api.resource.get(qparams) do |response, request, result|
|
|
36
|
-
|
|
29
|
+
results = API::JSONResponse.new(request, result, response)
|
|
37
30
|
end
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
catch_request_error(results, "Failed to read profile.")
|
|
33
|
+
show_results(@@profile_formats, results.data, options)
|
|
34
|
+
results
|
|
40
35
|
end
|
|
41
36
|
|
|
42
|
-
def self.get_favorites(api_key,
|
|
37
|
+
def self.get_favorites(api_key, options)
|
|
43
38
|
user_api = API::Resource.new(RESOURCE_PATH)
|
|
44
|
-
|
|
39
|
+
results = nil
|
|
40
|
+
page = options[:page] || 1
|
|
45
41
|
qparams = {
|
|
46
42
|
:params => {
|
|
47
43
|
:api_key => api_key,
|
|
48
|
-
:page => page
|
|
44
|
+
:page => page
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
user_api.resource['/favorites'].get(qparams) do |response, request, result|
|
|
53
|
-
|
|
49
|
+
results = API::JSONResponse.new(request, result, response)
|
|
54
50
|
end
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
catch_request_error(results, "Failed to read favorites.")
|
|
53
|
+
show_results(@@favorite_formats, results.data, options, results.data['paging'])
|
|
54
|
+
results
|
|
57
55
|
end
|
|
58
|
-
|
|
59
|
-
def self.format_profile(results, format = 'pretty')
|
|
60
|
-
self.supported_format?(@@profile_formats, format)
|
|
61
|
-
formatter = @@profile_formats[format]
|
|
62
|
-
formatter.before
|
|
63
|
-
formatter.format(results)
|
|
64
|
-
formatter.after
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def self.format_favorites(results, format = 'pretty')
|
|
68
|
-
self.supported_format?(@@favorite_formats, format)
|
|
69
|
-
formatter = @@favorite_formats[format]
|
|
70
|
-
|
|
71
|
-
formatter.before
|
|
72
|
-
formatter.format results
|
|
73
|
-
formatter.after
|
|
74
|
-
end
|
|
75
|
-
|
|
76
56
|
end
|
|
77
57
|
end
|
|
78
58
|
end
|
data/lib/veye/version.rb
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
class BaseCSV
|
|
3
|
+
def initialize(headers)
|
|
4
|
+
@columns = headers
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def before
|
|
8
|
+
puts @columns
|
|
9
|
+
end
|
|
10
|
+
def after(paging = nil, allow_pagination = false)
|
|
11
|
+
if allow_pagination && !paging.nil?
|
|
12
|
+
printf("# ------------------------------------------\n")
|
|
13
|
+
printf("current_page,per_page,total_pages,total_entries\n")
|
|
14
|
+
printf("%s,%s,%s,%s\n",
|
|
15
|
+
paging['current_page'],
|
|
16
|
+
paging['per_page'],
|
|
17
|
+
paging['total_pages'],
|
|
18
|
+
paging['total_entries'])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def format(results)
|
|
23
|
+
raise NotImplementedError
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class BaseJSON
|
|
2
|
+
|
|
3
|
+
def initialize
|
|
4
|
+
@results = {}
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def before; end
|
|
8
|
+
|
|
9
|
+
def after(paging = nil, allow_pagination = false)
|
|
10
|
+
if allow_pagination && !paging.nil?
|
|
11
|
+
@results[:paging] = paging
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
puts @results.to_json
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def format(results)
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'render-as-markdown'
|
|
2
|
+
|
|
3
|
+
class BaseMarkdown
|
|
4
|
+
def initialize(title, headings)
|
|
5
|
+
@title = title
|
|
6
|
+
@columns = headings
|
|
7
|
+
@markdown = "# #{@title}\n\n"
|
|
8
|
+
@table = RenderAsMarkdown::Table.new @columns
|
|
9
|
+
end
|
|
10
|
+
def before; end
|
|
11
|
+
|
|
12
|
+
def after(paging = nil, allow_pagination = false)
|
|
13
|
+
@markdown << @table.render
|
|
14
|
+
@markdown << "\n\n"
|
|
15
|
+
puts @markdown
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'rainbow'
|
|
2
|
+
|
|
3
|
+
class BasePretty
|
|
4
|
+
def before; end
|
|
5
|
+
def after(paging = nil, allow_pagination = false)
|
|
6
|
+
if allow_pagination and paging
|
|
7
|
+
printf("\n#-- %s\n", "Pagination information".bright)
|
|
8
|
+
printf("\t%-15s: %s\n", "Current page", paging['current_page'])
|
|
9
|
+
printf("\t%-15s: %s\n", "Per page", paging['per_page'])
|
|
10
|
+
printf("\t%-15s: %s\n", "Total pages", paging['total_pages'])
|
|
11
|
+
printf("\t%-15s: %s\n", "Total entries", paging['total_entries'])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
def format(results)
|
|
15
|
+
raise NotImplementedError
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'terminal-table'
|
|
2
|
+
|
|
3
|
+
class BaseTable
|
|
4
|
+
def initialize(title, headings)
|
|
5
|
+
@title = title
|
|
6
|
+
@headings = headings
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def before
|
|
10
|
+
@table = Terminal::Table.new :title => @title,
|
|
11
|
+
:headings => @headings
|
|
12
|
+
|
|
13
|
+
@table.align_column(0, :right)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def after(paging = nil, allow_pagination = false)
|
|
17
|
+
if allow_pagination && !paging.nil?
|
|
18
|
+
paging_header = ['p', 'current_page', 'per_page', 'total_pages', 'total_entries']
|
|
19
|
+
paging_data = ["p"]
|
|
20
|
+
paging.each_pair do |key, val|
|
|
21
|
+
paging_data << val
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
@table.add_separator
|
|
25
|
+
@table << paging_header
|
|
26
|
+
@table << paging_data
|
|
27
|
+
end
|
|
28
|
+
puts @table.to_s
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def format(result)
|
|
32
|
+
raise NotImplementedError
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require_relative '../base_csv.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class InfoCSV < BaseCSV
|
|
6
|
+
def initialize
|
|
7
|
+
headers = "name,language,owner_login,owner_type,private,fork,branches,imported_projects, description"
|
|
8
|
+
super(headers)
|
|
9
|
+
end
|
|
10
|
+
def format(results)
|
|
11
|
+
return nil if results.nil?
|
|
12
|
+
repo = results['repo']
|
|
13
|
+
imported_projects = results['imported_projects']
|
|
14
|
+
imported_project_names = imported_projects.map {|p| p['project_key']}
|
|
15
|
+
printf(
|
|
16
|
+
"%s,%s,%s,%s,%s,%s,%s,%s,%s\n",
|
|
17
|
+
repo['fullname'],
|
|
18
|
+
repo['language'],
|
|
19
|
+
repo['owner_login'],
|
|
20
|
+
repo['owner_type'],
|
|
21
|
+
repo['private'],
|
|
22
|
+
repo['fork'],
|
|
23
|
+
repo['branches'].join('|'),
|
|
24
|
+
imported_project_names.join('|'),
|
|
25
|
+
repo['description']
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_relative '../base_pretty.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class InfoPretty < BasePretty
|
|
6
|
+
|
|
7
|
+
def format(result)
|
|
8
|
+
return if result.nil?
|
|
9
|
+
repo = result['repo']
|
|
10
|
+
projects = result['imported_projects']
|
|
11
|
+
if projects
|
|
12
|
+
project_names = projects.map {|x| x['project_key']}
|
|
13
|
+
else
|
|
14
|
+
project_names = []
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
printf(
|
|
18
|
+
"\t%15s - %s\n",
|
|
19
|
+
"#{repo['fullname']}".foreground(:green),
|
|
20
|
+
"#{repo['language']}".bright
|
|
21
|
+
)
|
|
22
|
+
printf("\t%-15s: %s\n", "Description", repo['description'])
|
|
23
|
+
printf("\t%-15s: %s\n", "Owner login", repo['owner_login'])
|
|
24
|
+
printf("\t%-15s: %s\n", "Owner type", repo['owner_type'])
|
|
25
|
+
printf("\t%-15s: %s\n", "Private", repo['private'])
|
|
26
|
+
printf("\t%-15s: %s\n", "Fork", repo['fork'])
|
|
27
|
+
printf("\t%-15s: %s\n", "Branches", repo['branches'].to_a.join(', '))
|
|
28
|
+
printf("\t%-15s: %s\n", "Imported", project_names.join(', '))
|
|
29
|
+
printf("\t%-15s: %s\n", "Html url", repo['html_url'])
|
|
30
|
+
printf("\t%-15s: %s\n", "Git url", repo['git_url'])
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative '../base_table.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class InfoTable < BaseTable
|
|
6
|
+
def initialize
|
|
7
|
+
headings = %w(name language owner_login owner_type private fork branches imported_projects description)
|
|
8
|
+
super("Repository information", headings)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def format(result)
|
|
12
|
+
return if result.nil?
|
|
13
|
+
|
|
14
|
+
repo = result['repo']
|
|
15
|
+
projects = result['imported_projects']
|
|
16
|
+
if projects
|
|
17
|
+
project_names = projects.map {|x| x['project_key']}
|
|
18
|
+
else
|
|
19
|
+
project_names = []
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
row = [repo['fullname']]
|
|
23
|
+
row << repo['language']
|
|
24
|
+
row << repo['owner_login']
|
|
25
|
+
row << repo['owner_type']
|
|
26
|
+
row << repo['private']
|
|
27
|
+
row << repo['fork']
|
|
28
|
+
row << repo['branches'].to_a.join("\n")
|
|
29
|
+
row << project_names.join("\n")
|
|
30
|
+
row << repo['description']
|
|
31
|
+
|
|
32
|
+
@table << row
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require_relative '../base_csv.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class ListCSV < BaseCSV
|
|
6
|
+
def initialize
|
|
7
|
+
headers = "nr,fullname,language,owner_login,owner_type,private,fork,branches,description"
|
|
8
|
+
super(headers)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def format(results)
|
|
12
|
+
results['repos'].each_with_index do |result, index|
|
|
13
|
+
printf("%d,%s,%s,%s,%s,%s,%s,%s,%s\n",
|
|
14
|
+
index + 1,
|
|
15
|
+
result['fullname'],
|
|
16
|
+
result['language'],
|
|
17
|
+
result['owner_login'],
|
|
18
|
+
result['owner_type'],
|
|
19
|
+
result['private'],
|
|
20
|
+
result['fork'],
|
|
21
|
+
result['branches'].join('|'),
|
|
22
|
+
result['description']
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require_relative '../base_json.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class ListJSON < BaseJSON
|
|
6
|
+
def initialize
|
|
7
|
+
super()
|
|
8
|
+
end
|
|
9
|
+
def format(results)
|
|
10
|
+
results = results.shift if results.is_a? Array
|
|
11
|
+
@results[:repos] = results['repos']
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require_relative '../base_pretty.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class ListPretty < BasePretty
|
|
6
|
+
def format(results)
|
|
7
|
+
results['repos'].each_with_index {|result, index| print_row(result, index)}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def print_row(result, index)
|
|
11
|
+
printf(
|
|
12
|
+
"%3d - %s\n",
|
|
13
|
+
index + 1,
|
|
14
|
+
"#{result['name']}".foreground(:green).bright
|
|
15
|
+
)
|
|
16
|
+
printf("\t%-15s: %s\n", "Language", result['language'])
|
|
17
|
+
printf("\t%-15s: %s\n", "Owner name", result['owner_login'])
|
|
18
|
+
printf("\t%-15s: %s\n", "Owner type", result['owner_type'])
|
|
19
|
+
printf("\t%-15s: %s\n", "Private", result['private'])
|
|
20
|
+
printf("\t%-15s: %s\n", "Fork", result['fork'])
|
|
21
|
+
printf("\t%-15s: %s\n", "Branches", result['branches'].join(','))
|
|
22
|
+
printf("\t%-15s: %s\n", "Description", result['description'])
|
|
23
|
+
printf("\t%-15s: %s\n", "Imported", result['imported_projects'].join(','))
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require_relative '../base_table.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class ListTable < BaseTable
|
|
6
|
+
def initialize
|
|
7
|
+
headings = %w(index fullname language owner_login owner_type private fork branches imported)
|
|
8
|
+
super("Github repositories", headings)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def format(results)
|
|
12
|
+
results['repos'].each_with_index do |result, index|
|
|
13
|
+
row = [(index + 1)]
|
|
14
|
+
row << result['fullname']
|
|
15
|
+
row << result['language']
|
|
16
|
+
row << result['owner_login']
|
|
17
|
+
row << result['owner_type']
|
|
18
|
+
row << result['private']
|
|
19
|
+
row << result['fork']
|
|
20
|
+
row << result['branches'].join("\n")
|
|
21
|
+
row << result['imported_projects'].to_a.join("\n")
|
|
22
|
+
#row << result['description']
|
|
23
|
+
@table << row
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative '../base_csv.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class SearchCSV < BaseCSV
|
|
6
|
+
def initialize
|
|
7
|
+
columns = %w[nr,name,language,owner_name,owner_type,private,fork,watchers,forks,git_url]
|
|
8
|
+
super(columns)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def format(results)
|
|
12
|
+
return if results.nil?
|
|
13
|
+
|
|
14
|
+
results['results'].each_with_index do |result, index|
|
|
15
|
+
print_row(result, index)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def print_row(result, index)
|
|
20
|
+
printf("%d,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",
|
|
21
|
+
index + 1,
|
|
22
|
+
result['name'],
|
|
23
|
+
result['language'],
|
|
24
|
+
result['owner_name'],
|
|
25
|
+
result['owner_type'],
|
|
26
|
+
result['private'],
|
|
27
|
+
result['fork'],
|
|
28
|
+
result['watchers'],
|
|
29
|
+
result['forks'],
|
|
30
|
+
result['git_url']
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative '../base_pretty.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class SearchPretty < BasePretty
|
|
6
|
+
def format(results)
|
|
7
|
+
results['results'].each_with_index do |result, index|
|
|
8
|
+
print_row(result, index)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def print_row(result, index)
|
|
13
|
+
printf(
|
|
14
|
+
"%3d - %s\n",
|
|
15
|
+
index + 1,
|
|
16
|
+
"#{result["name"]}".foreground(:green).bright
|
|
17
|
+
)
|
|
18
|
+
printf("\t%-15s: %s\n", 'language', result['language'])
|
|
19
|
+
printf("\t%-15s: %s\n", 'owner_name', result['owner_name'])
|
|
20
|
+
printf("\t%-15s: %s\n", 'owner_type', result['owner_type'])
|
|
21
|
+
printf("\t%-15s: %s\n", 'private', result['private'])
|
|
22
|
+
printf("\t%-15s: %s\n", 'fork', result['fork'])
|
|
23
|
+
printf("\t%-15s: %s\n", 'watchers', result['watchers'])
|
|
24
|
+
printf("\t%-15s: %s\n", 'forks', result['forks'])
|
|
25
|
+
printf("\t%-15s: %s\n", 'git_url', result['git_url'])
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative '../base_table.rb'
|
|
2
|
+
|
|
3
|
+
module Veye
|
|
4
|
+
module Github
|
|
5
|
+
class SearchTable < BaseTable
|
|
6
|
+
def initialize
|
|
7
|
+
headings = %w(index name language owner_name owner_type private fork watchers forks github_url)
|
|
8
|
+
super("Search results", headings)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def format(results)
|
|
12
|
+
results['results'].each_with_index do |result, index|
|
|
13
|
+
print_row(result, index)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def print_row(result, index)
|
|
18
|
+
row = [(index + 1)]
|
|
19
|
+
row << result['name']
|
|
20
|
+
row << result['language']
|
|
21
|
+
row << result['owner_name']
|
|
22
|
+
row << result['owner_type']
|
|
23
|
+
row << result['private']
|
|
24
|
+
row << result['fork']
|
|
25
|
+
row << result['watchers']
|
|
26
|
+
row << result['forks']
|
|
27
|
+
row << result['git_url']
|
|
28
|
+
|
|
29
|
+
@table << row
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|