ghuls-lib 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ghuls/lib.rb +101 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb0b81d66ea6a9ef86fc09969c95c82a66d9f5a
|
4
|
+
data.tar.gz: 1a392a026bc1b4312d47126fd998a2e44c01d23a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eb932ac186900293782a7b1b1a4be66f7afde98fdf1d51d1b4f7b3a403403b73733d7fe33e9bd4094add6db3c0f3b19e14c1f95bf924218ade763ebf0d93280
|
7
|
+
data.tar.gz: 448be8cb8b3019b5b6c6cce71f47b7142080768fc5ad1af923fca121a86262b023e93ea748b0e31ff568fc76fbb34a5250a65a4898dc9aed59c6380fcf577195
|
data/lib/ghuls/lib.rb
CHANGED
@@ -79,6 +79,105 @@ module GHULS
|
|
79
79
|
true_repos
|
80
80
|
end
|
81
81
|
|
82
|
+
# Gets the user's repositories organized by whether they are forks,
|
83
|
+
# private, public, or mirrors.
|
84
|
+
# @param username [String] See #get_user_and_check
|
85
|
+
# @param github [Octokit::Client] See #get_user_and_check
|
86
|
+
# @return [Hash] All the repositories under the user's account.
|
87
|
+
def self.get_user_repos(username, github)
|
88
|
+
repos = github.repositories(username)
|
89
|
+
forks = []
|
90
|
+
publics = []
|
91
|
+
mirrors = []
|
92
|
+
privates = []
|
93
|
+
repos.each do |r|
|
94
|
+
forks.push(r[:full_name]) if r[:fork]
|
95
|
+
|
96
|
+
if r[:private]
|
97
|
+
privates.push(r[:full_name])
|
98
|
+
else
|
99
|
+
publics.push(r[:full_name])
|
100
|
+
end
|
101
|
+
|
102
|
+
mirrors.push(r[:full_name]) unless r[:mirror_url].nil?
|
103
|
+
end
|
104
|
+
|
105
|
+
{
|
106
|
+
public: publics,
|
107
|
+
forks: forks,
|
108
|
+
mirrors: mirrors,
|
109
|
+
privates: privates
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
# Gets the number of forkers, stargazers, and watchers.
|
114
|
+
# @param repository [String] The full repository name.
|
115
|
+
# @param github [Octkit::Client] See #get_user_and_check
|
116
|
+
# @return [Hash] The forks, stars, and watcher count.
|
117
|
+
def self.get_forks_stars_watchers(repository, github)
|
118
|
+
stargazers = github.stargazers(repository).length
|
119
|
+
forks = github.forks(repository).length
|
120
|
+
watchers = github.subscribers(repository).length
|
121
|
+
|
122
|
+
{
|
123
|
+
forks: forks,
|
124
|
+
stars: stargazers,
|
125
|
+
watchers: watchers
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
# Gets the number of followers and users followed by the user.
|
130
|
+
# @param username [String] See #get_user_and_check
|
131
|
+
# @param github [Octokit::Client] See #get_user_and_check
|
132
|
+
# @return [Hash] The number of following and followed users.
|
133
|
+
def self.get_followers_following(username, github)
|
134
|
+
following = github.following(username)
|
135
|
+
followers = github.followers(username)
|
136
|
+
|
137
|
+
{
|
138
|
+
following: following.length,
|
139
|
+
followers: followers.length
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
# Gets the number of closed/open issues and
|
144
|
+
# closed (without merge)/open/merged pull requests for a repository
|
145
|
+
# @param repository [String] See #get_forks_stars_watchers
|
146
|
+
# @param github [Octokit::Client] See #get_user_and_check
|
147
|
+
# @return [Hash] The number of issues and pulls.
|
148
|
+
def self.get_issues_pulls(repository, github)
|
149
|
+
issues = github.list_issues(repository, state: 'all')
|
150
|
+
pulls = github.pull_requests(repository, state: 'all')
|
151
|
+
issues_open = 0
|
152
|
+
issues_closed = 0
|
153
|
+
pulls_open = 0
|
154
|
+
pulls_closed = 0
|
155
|
+
pulls_merged = 0
|
156
|
+
issues.each do |i|
|
157
|
+
issues_open += 1 if i['state'] == 'open'
|
158
|
+
issues_closed += 1 if i['state'] == 'closed'
|
159
|
+
end
|
160
|
+
pulls.each do |p|
|
161
|
+
pulls_open += 1 if p['state'] == 'open'
|
162
|
+
if p['state'] == 'closed'
|
163
|
+
pulls_merged += 1 unless p['merged_at'].nil?
|
164
|
+
pulls_closed += 1 if p['merged_at'].nil?
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
{
|
169
|
+
issues: {
|
170
|
+
closed: issues_closed,
|
171
|
+
open: issues_open
|
172
|
+
},
|
173
|
+
pulls: {
|
174
|
+
closed: pulls_closed,
|
175
|
+
open: pulls_open,
|
176
|
+
merged: pulls_merged
|
177
|
+
}
|
178
|
+
}
|
179
|
+
end
|
180
|
+
|
82
181
|
# Gets the langauges and their bytes for the user.
|
83
182
|
# @param username [String] See #get_user_and_check
|
84
183
|
# @param github [Octokit::Client] See #get_user_and_check
|
@@ -94,8 +193,7 @@ module GHULS
|
|
94
193
|
if langs[l].nil?
|
95
194
|
langs[l] = b
|
96
195
|
else
|
97
|
-
|
98
|
-
langs[l] = existing + b
|
196
|
+
langs[l] += b
|
99
197
|
end
|
100
198
|
end
|
101
199
|
end
|
@@ -162,12 +260,11 @@ module GHULS
|
|
162
260
|
# Performs the main analysis of the user's organizations.
|
163
261
|
# @param username [String] See #get_user_and_check
|
164
262
|
# @param github [Octokit::Client] See #get_user_and_check
|
165
|
-
# @return [Hash] See #
|
263
|
+
# @return [Hash] See #get_org_langs
|
166
264
|
# @return [Nil] If the user does not have any languages.
|
167
265
|
def self.analyze_orgs(username, github)
|
168
266
|
langs = get_org_langs(username, github)
|
169
267
|
return nil if langs.empty?
|
170
|
-
get_language_percentages(langs)
|
171
268
|
end
|
172
269
|
|
173
270
|
# Performs the main analysis of the user.
|
@@ -178,7 +275,6 @@ module GHULS
|
|
178
275
|
def self.analyze_user(username, github)
|
179
276
|
langs = get_user_langs(username, github)
|
180
277
|
return nil if langs.empty?
|
181
|
-
get_language_percentages(langs)
|
182
278
|
end
|
183
279
|
|
184
280
|
using StringUtility
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghuls-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|