ghuls-lib 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ghuls/lib.rb +36 -49
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 299e01ecedca7f648fcd46e367f08fc6debdacea
4
- data.tar.gz: 0035f3c9b4247553ef559da16d251f637a130224
3
+ metadata.gz: 38b8374eeb0e56a4de7f931d07bf7788d0caa95a
4
+ data.tar.gz: 5e7306abf6f9fec7146ef4b40f621d49aa087264
5
5
  SHA512:
6
- metadata.gz: 41c8c3bfe9b9bf38efcf38a5dc7c1e40ed0e1e131a0ba23582b2b082e04e4f21329dfaddc6ed271a90167991419718aeb3ce2b6ae067c4cb7a77e18756bb4294
7
- data.tar.gz: 830a185c4f1d08ff03937b2a92e7b69eb3e275206eace94bf11b5accaa743aea78b52d6ff459ece0e7a2aa326400afd768ffad8ef0eea89a6f4d57e572236827
6
+ metadata.gz: 1160f5808594ab75403b4484d22ffa4ab86a0044f5677ff61574194361a36b73070e61d82b498fc1675f9ce96d275bb3f61c574c320d23a0eca0ee78ee5e9496
7
+ data.tar.gz: ee595de199d0d087e585a13d2780f9a2454f05827d142c3e4f7aa4927705cb14dff261b1d11d29f459b193b4dba3133148ebfb6289cbc3a6533d955549cb90ca
data/lib/ghuls/lib.rb CHANGED
@@ -50,7 +50,7 @@ module GHULS
50
50
  end
51
51
 
52
52
  # Returns the repos in the user's organizations that they have actually
53
- # contributed to.
53
+ # contributed to, organized by forks, privates, publics, and mirrors.
54
54
  # @param username [String] See #get_user_and_check
55
55
  # @param github [Octokit::Client] See #get_user_and_check
56
56
  # @return [Array] All the repository full names that the user has
@@ -65,18 +65,17 @@ module GHULS
65
65
  end
66
66
  true_repos = []
67
67
  repos.each do |r|
68
- next if r[:fork]
69
68
  contributors = github.contributors(r[:full_name])
70
69
  next if contributors.empty?
71
70
  contributors.each do |c|
72
71
  if c[:login] =~ /^#{username}$/i
73
- true_repos.push(r[:full_name])
72
+ true_repos.push(r)
74
73
  else
75
74
  next
76
75
  end
77
76
  end
78
77
  end
79
- true_repos
78
+ get_organized_repos(true_repos)
80
79
  end
81
80
 
82
81
  # Gets the user's repositories organized by whether they are forks,
@@ -85,29 +84,7 @@ module GHULS
85
84
  # @param github [Octokit::Client] See #get_user_and_check
86
85
  # @return [Hash] All the repositories under the user's account.
87
86
  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
- }
87
+ get_organized_repos(github.repositories(username))
111
88
  end
112
89
 
113
90
  # Gets the number of forkers, stargazers, and watchers.
@@ -256,28 +233,6 @@ module GHULS
256
233
  lang_percents
257
234
  end
258
235
 
259
- # Performs the main analysis of the user's organizations.
260
- # @param username [String] See #get_user_and_check
261
- # @param github [Octokit::Client] See #get_user_and_check
262
- # @return [Hash] See #get_org_langs
263
- # @return [Nil] If the user does not have any languages.
264
- def self.analyze_orgs(username, github)
265
- langs = get_org_langs(username, github)
266
- return nil if langs.empty?
267
- return langs
268
- end
269
-
270
- # Performs the main analysis of the user.
271
- # @param username [String] See #get_user_and_check
272
- # @param github [Octokit::Client] See #get_user_and_check
273
- # @return [Hash] See #analyze_orgs
274
- # @return [Nil] See #analyze_orgs
275
- def self.analyze_user(username, github)
276
- langs = get_user_langs(username, github)
277
- return nil if langs.empty?
278
- return langs
279
- end
280
-
281
236
  using StringUtility
282
237
  # Gets a random GitHub user that actually has data to analyze.
283
238
  # Must always get a user that exists and has repositories, so it will
@@ -298,5 +253,37 @@ module GHULS
298
253
  end
299
254
  user
300
255
  end
256
+
257
+ private
258
+
259
+ # Gets the organized repository hash for the main repository hash given
260
+ # by Octokit::Client#repositories
261
+ # @param repos [Hash] The repository hash given by Octokit
262
+ # @return [Hash] An organizeed hash divided into public, forked, mirrored,
263
+ # and private repos.
264
+ def self.get_organized_repos(repos)
265
+ forks = []
266
+ publics = []
267
+ mirrors = []
268
+ privates = []
269
+ repos.each do |r|
270
+ forks.push(r[:full_name]) if r[:fork]
271
+
272
+ if r[:private]
273
+ privates.push(r[:full_name])
274
+ else
275
+ publics.push(r[:full_name])
276
+ end
277
+
278
+ mirrors.push(r[:full_name]) unless r[:mirror_url].nil?
279
+ end
280
+
281
+ {
282
+ public: publics,
283
+ forks: forks,
284
+ mirrors: mirrors,
285
+ privates: privates
286
+ }
287
+ end
301
288
  end
302
289
  end
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: 2.0.2
4
+ version: 2.1.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-16 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit