lib/octokit/client/stats.rb in octokit-1.25.0 vs lib/octokit/client/stats.rb in octokit-2.0.0.pre

- old
+ new

@@ -1,13 +1,17 @@ module Octokit class Client + + # Methods for the Repository Statistics API + # + # @see http://developer.github.com/v3/repos/statistics/ module Stats # Get contributors list with additions, deletions, and commit counts # # @param repo [String, Hash, Repository] A GitHub repository - # @return [Array<Hashie::Mash>] Array of contributor stats + # @return [Array<Sawyer::Resource>] Array of contributor stats # @see http://developer.github.com/v3/repos/statistics/#get-contributors-list-with-additions-deletions-and-commit-counts # @example Get contributor stats for octokit # @client.contributors_stats('pengwynn/octokit') def contributors_stats(repo) get_stats(repo, "contributors") @@ -15,11 +19,11 @@ alias :contributor_stats :contributors_stats # Get the last year of commit activity data # # @param repo [String, Hash, Repository] A GitHub repository - # @return [Array<Hashie::Mash>] The last year of commit activity grouped by + # @return [Array<Sawyer::Resource>] The last year of commit activity grouped by # week. The days array is a group of commits per day, starting on Sunday. # @see http://developer.github.com/v3/repos/statistics/#get-the-last-year-of-commit-activity-data # @example Get commit activity for octokit # @client.commit_activity_stats('pengwynn/octokit') def commit_activity_stats(repo) @@ -27,11 +31,11 @@ end # Get the number of additions and deletions per week # # @param repo [String, Hash, Repository] A GitHub repository - # @return [Array<Hashie::Mash>] Weekly aggregate of the number of additions + # @return [Array<Sawyer::Resource>] Weekly aggregate of the number of additions # and deletions pushed to a repository. # @see http://developer.github.com/v3/repos/statistics/#get-the-number-of-additions-and-deletions-per-week # @example Get code frequency stats for octokit # @client.code_frequency_stats('pengwynn/octokit') def code_frequency_stats(repo) @@ -39,11 +43,11 @@ end # Get the weekly commit count for the repo owner and everyone else # # @param repo [String, Hash, Repository] A GitHub repository - # @return [Hashie::Mash] Total commit counts for the owner and total commit + # @return [Sawyer::Resource] Total commit counts for the owner and total commit # counts in all. all is everyone combined, including the owner in the last # 52 weeks. If you’d like to get the commit counts for non-owners, you can # subtract all from owner. # @see http://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repo-owner-and-everyone-else # @example Get weekly commit counts for octokit @@ -69,12 +73,14 @@ # @private Get stats for a repository # # @param repo [String, Hash, Repository] A GitHub repository # @param metric [String] The metrics you are looking for - # @return [Array<Hashie::Mash>] Magical unicorn stats + # @return [Array<Sawyer::Resource>] Magical unicorn stats def get_stats(repo, metric) - get("repos/#{Repository.new repo}/stats/#{metric}") + data = get("repos/#{Repository.new repo}/stats/#{metric}") + + last_response.status == 202 ? nil : data end end end end