ghuls-lib 1.2.0 → 1.2.1
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.
- checksums.yaml +4 -4
- data/lib/ghuls/lib.rb +15 -20
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 610530e600dae4056abf96b5a94c286df2852d0f
         | 
| 4 | 
            +
              data.tar.gz: 63ec7b6e63018a392d4323594434f8366df62b14
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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  | 
| 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]  | 
| 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 | 
            -
                  { | 
| 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 [ | 
| 166 | 
            +
                # @return [Nil] If the user does not have any languages.
         | 
| 164 167 | 
             
                def self.analyze_orgs(username, github)
         | 
| 165 | 
            -
                   | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 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 [ | 
| 177 | 
            +
                # @return [Nil] See #analyze_orgs
         | 
| 179 178 | 
             
                def self.analyze_user(username, github)
         | 
| 180 | 
            -
                   | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 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 [ | 
| 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
         |