/
traffic.rb
64 lines (60 loc) · 2.46 KB
/
traffic.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true
module Octokit
class Client
# Methods for the Traffic API
#
# @see https://developer.github.com/v3/repos/traffic/
module Traffic
# Get the top 10 referrers over the last 14 days
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @return [Array<Sawyer::Resource>] List of referrers and stats
# @see https://developer.github.com/v3/repos/traffic/#list-referrers
# @example
# @client.top_referrers('octokit/octokit.rb')
def top_referrers(repo, options = {})
get "#{Repository.path repo}/traffic/popular/referrers", options
end
# Get the top 10 popular contents over the last 14 days
#
# @param repo [Integer, String, Repository, Hash] A GitHub repository
# @return [Array<Sawyer::Resource>] List of popular contents
# @see https://developer.github.com/v3/repos/traffic/#list-paths
# @example
# @client.top_paths('octokit/octokit.rb')
def top_paths(repo, options = {})
get "#{Repository.path repo}/traffic/popular/paths", options
end
# Get the total number of views and breakdown per day or week for the
# last 14 days
#
# @param repo [Integer, String, Repository, Hash] A GitHub Repository
# @option options [String] :per ('day') Views per. <tt>day</tt> or
# <tt>week</tt>
# @return [Sawyer::Resource] Breakdown of view stats
# @see https://developer.github.com/v3/repos/traffic/#views
# @example Views per day
# @client.views('octokit/octokit.rb')
# @example Views per week
# @client.views('octokit/octokit.rb', per: 'week')
def views(repo, options = {})
get "#{Repository.path repo}/traffic/views", options
end
# Get the total number of clones and breakdown per day or week for the
# last 14 days
#
# @param repo [Integer, String, Repository, Hash] A GitHub Repository
# @option options [String] :per ('day') Views per. <tt>day</tt> or
# <tt>week</tt>
# @return [Sawyer::Resource] Breakdown of clone stats
# @see https://developer.github.com/v3/repos/traffic/#clones
# @example Clones per day
# @client.clones('octokit/octokit.rb')
# @example Clones per week
# @client.clones('octokit/octokit.rb', per: 'week')
def clones(repo, options = {})
get "#{Repository.path repo}/traffic/clones", options
end
end
end
end