Class: Hubba::Github
- Inherits:
-
Object
show all
- Defined in:
- lib/hubba/github.rb
Defined Under Namespace
Classes: Orgs, Repos, Resource
Constant Summary
collapse
- BASE_URL =
'https://api.github.com'
Instance Method Summary
collapse
Constructor Details
#initialize(token: nil, user: nil, password: nil) ⇒ Github
Returns a new instance of Github.
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/hubba/github.rb', line 33
def initialize( token: nil,
user: nil,
password: nil )
@token = nil
@user = nil
@password = nil
if token @token = token
elsif user && password @user = user
@password = password
elsif Hubba.config.token @token = Hubba.config.token
elsif Hubba.config.user && Hubba.config.password @user = Hubba.config.user
@password = Hubba.config.password
else end
end
|
Instance Method Details
#org(name) ⇒ Object
80
81
82
|
# File 'lib/hubba/github.rb', line 80
def org( name )
Resource.new( get "/orgs/#{name}" )
end
|
#org_repos(name) ⇒ Object
84
85
86
|
# File 'lib/hubba/github.rb', line 84
def org_repos( name )
Repos.new( get "/orgs/#{name}/repos?per_page=100" )
end
|
#repo(full_name) ⇒ Object
full_name (handle) e.g. henrythemes/jekyll-starter-theme
90
91
92
|
# File 'lib/hubba/github.rb', line 90
def repo( full_name ) Resource.new( get "/repos/#{full_name}" )
end
|
#repo_commits(full_name) ⇒ Object
105
106
107
|
# File 'lib/hubba/github.rb', line 105
def repo_commits( full_name )
Resource.new( get "/repos/#{full_name}/commits" )
end
|
#repo_languages(full_name) ⇒ Object
94
95
96
|
# File 'lib/hubba/github.rb', line 94
def repo_languages( full_name )
Resource.new( get "/repos/#{full_name}/languages" )
end
|
#repo_topics(full_name) ⇒ Object
98
99
100
101
102
|
# File 'lib/hubba/github.rb', line 98
def repo_topics( full_name )
Resource.new( get( "/repos/#{full_name}/topics", preview: 'mercy' ) )
end
|
#repo_traffic_clones(full_name) ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/hubba/github.rb', line 110
def repo_traffic_clones( full_name )
Resource.new( get "/repos/#{full_name}/traffic/clones" )
end
|
#repo_traffic_popular_paths(full_name) ⇒ Object
129
130
131
132
133
|
# File 'lib/hubba/github.rb', line 129
def repo_traffic_popular_paths( full_name )
Resource.new( get "/repos/#{full_name}/traffic/popular/paths" )
end
|
#repo_traffic_popular_referrers(full_name) ⇒ Object
135
136
137
138
139
|
# File 'lib/hubba/github.rb', line 135
def repo_traffic_popular_referrers( full_name )
Resource.new( get "/repos/#{full_name}/traffic/popular/referrers" )
end
|
#repo_traffic_views(full_name) ⇒ Object
119
120
121
122
123
124
125
126
|
# File 'lib/hubba/github.rb', line 119
def repo_traffic_views( full_name )
Resource.new( get "/repos/#{full_name}/traffic/views" )
end
|
#user(name) ⇒ Object
57
58
59
|
# File 'lib/hubba/github.rb', line 57
def user( name )
Resource.new( get "/users/#{name}" )
end
|
#user_orgs(name) ⇒ Object
note: pagination
requests that return multiple items will be paginated to 30 items by default.
You can specify further pages with the ?page parameter.
For some resources, you can also set a custom page size up to 100
with the ?per_page=100 parameter
74
75
76
|
# File 'lib/hubba/github.rb', line 74
def user_orgs( name )
Orgs.new( get "/users/#{name}/orgs?per_page=100" )
end
|
#user_repos(name) ⇒ Object
62
63
64
|
# File 'lib/hubba/github.rb', line 62
def user_repos( name )
Repos.new( get "/users/#{name}/repos" ) end
|