ghuls-lib 1.2.0 → 1.2.1

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 +15 -20
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91d1a894139f17e933e802fd1d27f59e1a0b82a4
4
- data.tar.gz: c56fc6748fe1d35005202c4491d5dd176ed19381
3
+ metadata.gz: 610530e600dae4056abf96b5a94c286df2852d0f
4
+ data.tar.gz: 63ec7b6e63018a392d4323594434f8366df62b14
5
5
  SHA512:
6
- metadata.gz: bd4a495f647029cc917e9e22728730a573a4e8b2ecc7e20753bca93db80d08678a2cd67336f6be5d6b2efdfc5fd56f12d175a6991d671151ed86a7bebe7a8f8e
7
- data.tar.gz: 44f297bff0cacaf26e4ff4ddbbfd4bea4a34f525b089d3a93a38e4f5a9251cc5538bf8d7867c2ae0cdcae1d0b110d6245101c6ce04ace05cf261c106bd460234
6
+ metadata.gz: 6f416f5e54a83b37d113a7aa470727412043e012b9c238de28d62759347c65dd9dec0e9ad3499f39b538736fa0b65df74b0ea429dc8b0d6ad296667583582b8d
7
+ data.tar.gz: 59fd44b2b7007031a2d2e5c8585e1b243441a4ba43231711b0f9ce79d814ef372dcf2d0c2afbe76180b487609190664b8ed47db81b6c35513c7c80d154855616
data/lib/ghuls/lib.rb CHANGED
@@ -32,10 +32,10 @@ module GHULS
32
32
  full.at(full.index(single) + 1)
33
33
  end
34
34
 
35
- # Gets the username and checks if it exists in the process.
35
+ # Gets the user and checks if it exists in the process.
36
36
  # @param user [Any] The user ID or name.
37
37
  # @param github [Octokit::Client] The instance of Octokit::Client.
38
- # @return [Hash] Data formatted as { username: username, avatar: url }
38
+ # @return [Hash] Their username and avatar URL.
39
39
  # @return [Boolean] False if it does not exist.
40
40
  def self.get_user_and_check(user, github)
41
41
  begin
@@ -43,7 +43,10 @@ module GHULS
43
43
  rescue Octokit::NotFound
44
44
  return false
45
45
  end
46
- { username: user_full[:login], avatar: user_full[:avatar_url] }
46
+ {
47
+ username: user_full[:login],
48
+ avatar: user_full[:avatar_url]
49
+ }
47
50
  end
48
51
 
49
52
  # Returns the repos in the user's organizations that they have actually
@@ -160,30 +163,22 @@ module GHULS
160
163
  # @param username [String] See #get_user_and_check
161
164
  # @param github [Octokit::Client] See #get_user_and_check
162
165
  # @return [Hash] See #get_language_percentages
163
- # @return [Boolean] False if get_user_and_check returns false.
166
+ # @return [Nil] If the user does not have any languages.
164
167
  def self.analyze_orgs(username, github)
165
- if get_user_and_check(username, github) != false
166
- langs = get_org_langs(username, github)
167
- return false if langs.empty?
168
- get_language_percentages(langs)
169
- else
170
- false
171
- end
168
+ langs = get_org_langs(username, github)
169
+ return nil if langs.empty?
170
+ get_language_percentages(langs)
172
171
  end
173
172
 
174
173
  # Performs the main analysis of the user.
175
174
  # @param username [String] See #get_user_and_check
176
175
  # @param github [Octokit::Client] See #get_user_and_check
177
176
  # @return [Hash] See #analyze_orgs
178
- # @return [Boolean] See #analyze_orgs
177
+ # @return [Nil] See #analyze_orgs
179
178
  def self.analyze_user(username, github)
180
- if get_user_and_check(username, github) != false
181
- langs = get_user_langs(username, github)
182
- return false if langs.empty?
183
- get_language_percentages(langs)
184
- else
185
- false
186
- end
179
+ langs = get_user_langs(username, github)
180
+ return nil if langs.empty?
181
+ get_language_percentages(langs)
187
182
  end
188
183
 
189
184
  using StringUtility
@@ -194,7 +189,7 @@ module GHULS
194
189
  # it. However, none of the documented GitHub APIs show that we can get the
195
190
  # total number of GitHub users.
196
191
  # @param github [Octokit::Client] See #get_user_and_check
197
- # @return [String] A random username.
192
+ # @return [Hash] See #get_user_and_check.
198
193
  def self.get_random_user(github)
199
194
  source = open('https://github.com/search?utf8=%E2%9C%93&q=repos%3A%3E-1' \
200
195
  '&type=Users&ref=searchresults').read
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghuls-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Foster