github_api 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- metadata +4 -140
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -228
- data/Rakefile +0 -52
- data/features/github_api.feature +0 -50
- data/features/step_definitions/github_api_steps.rb +0 -11
- data/features/support/env.rb +0 -13
- data/lib/github_api.rb +0 -73
- data/lib/github_api/api.rb +0 -175
- data/lib/github_api/api/utils.rb +0 -9
- data/lib/github_api/authorization.rb +0 -73
- data/lib/github_api/authorizations.rb +0 -119
- data/lib/github_api/cache_control.rb +0 -19
- data/lib/github_api/client.rb +0 -55
- data/lib/github_api/compatibility.rb +0 -23
- data/lib/github_api/configuration.rb +0 -96
- data/lib/github_api/connection.rb +0 -81
- data/lib/github_api/core_ext/array.rb +0 -14
- data/lib/github_api/core_ext/hash.rb +0 -42
- data/lib/github_api/error.rb +0 -35
- data/lib/github_api/events.rb +0 -202
- data/lib/github_api/gists.rb +0 -200
- data/lib/github_api/gists/comments.rb +0 -86
- data/lib/github_api/git_data.rb +0 -26
- data/lib/github_api/git_data/blobs.rb +0 -51
- data/lib/github_api/git_data/commits.rb +0 -78
- data/lib/github_api/git_data/references.rb +0 -113
- data/lib/github_api/git_data/tags.rb +0 -78
- data/lib/github_api/git_data/trees.rb +0 -89
- data/lib/github_api/issues.rb +0 -215
- data/lib/github_api/issues/comments.rb +0 -110
- data/lib/github_api/issues/events.rb +0 -50
- data/lib/github_api/issues/labels.rb +0 -191
- data/lib/github_api/issues/milestones.rb +0 -119
- data/lib/github_api/mime_type.rb +0 -55
- data/lib/github_api/orgs.rb +0 -95
- data/lib/github_api/orgs/members.rb +0 -120
- data/lib/github_api/orgs/teams.rb +0 -245
- data/lib/github_api/pull_requests.rb +0 -224
- data/lib/github_api/pull_requests/comments.rb +0 -144
- data/lib/github_api/repos.rb +0 -286
- data/lib/github_api/repos/collaborators.rb +0 -81
- data/lib/github_api/repos/commits.rb +0 -180
- data/lib/github_api/repos/downloads.rb +0 -155
- data/lib/github_api/repos/forks.rb +0 -48
- data/lib/github_api/repos/hooks.rb +0 -173
- data/lib/github_api/repos/keys.rb +0 -104
- data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
- data/lib/github_api/repos/watching.rb +0 -94
- data/lib/github_api/request.rb +0 -84
- data/lib/github_api/request/basic_auth.rb +0 -31
- data/lib/github_api/request/caching.rb +0 -33
- data/lib/github_api/request/oauth2.rb +0 -33
- data/lib/github_api/response.rb +0 -28
- data/lib/github_api/response/helpers.rb +0 -14
- data/lib/github_api/response/jsonize.rb +0 -26
- data/lib/github_api/response/mashify.rb +0 -24
- data/lib/github_api/response/raise_error.rb +0 -33
- data/lib/github_api/result.rb +0 -42
- data/lib/github_api/users.rb +0 -84
- data/lib/github_api/users/emails.rb +0 -49
- data/lib/github_api/users/followers.rb +0 -98
- data/lib/github_api/users/keys.rb +0 -84
- data/lib/github_api/version.rb +0 -12
- data/spec/README.rdoc +0 -22
- data/spec/coverage_adapter.rb +0 -14
- data/spec/fixtures/auths/authorization.json +0 -14
- data/spec/fixtures/auths/authorizations.json +0 -16
- data/spec/fixtures/events/events.json +0 -29
- data/spec/fixtures/issues/issue.json +0 -56
- data/spec/fixtures/issues/issues.json +0 -58
- data/spec/fixtures/orgs/members.json +0 -9
- data/spec/fixtures/orgs/org.json +0 -18
- data/spec/fixtures/orgs/orgs.json +0 -8
- data/spec/fixtures/orgs/team.json +0 -8
- data/spec/fixtures/orgs/team_repos.json +0 -29
- data/spec/fixtures/orgs/teams.json +0 -7
- data/spec/fixtures/repos/branches.json +0 -9
- data/spec/fixtures/repos/collaborators.json +0 -8
- data/spec/fixtures/repos/commit.json +0 -53
- data/spec/fixtures/repos/commit_comment.json +0 -16
- data/spec/fixtures/repos/commit_comments.json +0 -18
- data/spec/fixtures/repos/commits.json +0 -27
- data/spec/fixtures/repos/contributors.json +0 -8
- data/spec/fixtures/repos/download.json +0 -10
- data/spec/fixtures/repos/download_s3.json +0 -21
- data/spec/fixtures/repos/downloads.json +0 -12
- data/spec/fixtures/repos/fork.json +0 -27
- data/spec/fixtures/repos/forks.json +0 -29
- data/spec/fixtures/repos/hook.json +0 -15
- data/spec/fixtures/repos/hooks.json +0 -10
- data/spec/fixtures/repos/key.json +0 -6
- data/spec/fixtures/repos/keys.json +0 -8
- data/spec/fixtures/repos/languages.json +0 -4
- data/spec/fixtures/repos/repo.json +0 -90
- data/spec/fixtures/repos/repo_comments.json +0 -18
- data/spec/fixtures/repos/repos.json +0 -29
- data/spec/fixtures/repos/tags.json +0 -11
- data/spec/fixtures/repos/teams.json +0 -7
- data/spec/fixtures/repos/watched.json +0 -29
- data/spec/fixtures/repos/watchers.json +0 -8
- data/spec/fixtures/users/user.json +0 -32
- data/spec/github/api_spec.rb +0 -25
- data/spec/github/authorization_spec.rb +0 -176
- data/spec/github/authorizations_spec.rb +0 -242
- data/spec/github/client_spec.rb +0 -50
- data/spec/github/core_ext/hash_spec.rb +0 -44
- data/spec/github/events_spec.rb +0 -491
- data/spec/github/gists/comments_spec.rb +0 -5
- data/spec/github/gists_spec.rb +0 -5
- data/spec/github/git_data/blobs_spec.rb +0 -5
- data/spec/github/git_data/commits_spec.rb +0 -5
- data/spec/github/git_data/references_spec.rb +0 -5
- data/spec/github/git_data/tags_spec.rb +0 -5
- data/spec/github/git_data/trees_spec.rb +0 -5
- data/spec/github/git_data_spec.rb +0 -5
- data/spec/github/issues/comments_spec.rb +0 -5
- data/spec/github/issues/events_spec.rb +0 -5
- data/spec/github/issues/labels_spec.rb +0 -5
- data/spec/github/issues/milestones_spec.rb +0 -5
- data/spec/github/issues_spec.rb +0 -287
- data/spec/github/mime_type_spec.rb +0 -70
- data/spec/github/orgs/members_spec.rb +0 -275
- data/spec/github/orgs/teams_spec.rb +0 -563
- data/spec/github/orgs_spec.rb +0 -160
- data/spec/github/repos/collaborators_spec.rb +0 -169
- data/spec/github/repos/commits_spec.rb +0 -424
- data/spec/github/repos/downloads_spec.rb +0 -236
- data/spec/github/repos/forks_spec.rb +0 -103
- data/spec/github/repos/hooks_spec.rb +0 -307
- data/spec/github/repos/keys_spec.rb +0 -216
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
- data/spec/github/repos/watching_spec.rb +0 -222
- data/spec/github/repos_spec.rb +0 -571
- data/spec/github/result_spec.rb +0 -43
- data/spec/github/users_spec.rb +0 -140
- data/spec/github_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -86
@@ -1,144 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Github
|
4
|
-
class PullRequests
|
5
|
-
module Comments
|
6
|
-
|
7
|
-
VALID_REQUEST_COM_PARAM_NAMES = %w[
|
8
|
-
body
|
9
|
-
commit_id
|
10
|
-
path
|
11
|
-
position
|
12
|
-
in_reply_to
|
13
|
-
mime_type
|
14
|
-
resource
|
15
|
-
].freeze
|
16
|
-
|
17
|
-
# List comments on a pull request
|
18
|
-
#
|
19
|
-
# = Examples
|
20
|
-
# @github = Github.new
|
21
|
-
# @github.pull_requests.request_comments 'user-name', 'repo-name', 'request-id'
|
22
|
-
#
|
23
|
-
def request_comments(user_name, repo_name, request_id, params={})
|
24
|
-
_update_user_repo_params(user_name, repo_name)
|
25
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
26
|
-
_validate_presence_of request_id
|
27
|
-
|
28
|
-
_normalize_params_keys(params)
|
29
|
-
_merge_mime_type(:pull_comment, params)
|
30
|
-
|
31
|
-
response = get("/repos/#{user}/#{repo}/pulls/#{request_id}/comments", params)
|
32
|
-
return response unless block_given?
|
33
|
-
response.each { |el| yield el }
|
34
|
-
end
|
35
|
-
|
36
|
-
# Get a single comment for pull requests
|
37
|
-
# = Examples
|
38
|
-
# @github = Github.new
|
39
|
-
# @github.pull_requests.request_comment 'user-name', 'repo-name', 'comment-id'
|
40
|
-
#
|
41
|
-
def request_comment(user_name, repo_name, comment_id, params={})
|
42
|
-
_update_user_repo_params(user_name, repo_name)
|
43
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
44
|
-
_validate_presence_of comment_id
|
45
|
-
|
46
|
-
_normalize_params_keys(params)
|
47
|
-
_merge_mime_type(:pull_comment, params)
|
48
|
-
|
49
|
-
get("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Create a pull request comment
|
53
|
-
#
|
54
|
-
# = Inputs
|
55
|
-
# * <tt>:body</tt> - Required string
|
56
|
-
# * <tt>:commit_id</tt> - Required string - sha of the commit to comment on.
|
57
|
-
# * <tt>:path</tt> - Required string - Relative path of the file to comment on.
|
58
|
-
# * <tt>:position</tt> - Required number - Line index in the diff to comment on
|
59
|
-
#
|
60
|
-
# = Examples
|
61
|
-
# @github = Github.new
|
62
|
-
# @github.pull_requests.create_request_comment 'user-name', 'repo-name', 'request-id', "body" => "Nice change",
|
63
|
-
# "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
64
|
-
# "path" => "file1.txt",
|
65
|
-
# "position" => 4
|
66
|
-
#
|
67
|
-
# = Alternative Inputs
|
68
|
-
# Instead of passing commit_id, path, and position you can reply to
|
69
|
-
# an existing Pull Request Comment like this
|
70
|
-
# * <tt>:body</tt> - Required string
|
71
|
-
# * <tt>:in_reply_to</tt> - Required number - comment id to reply to.
|
72
|
-
#
|
73
|
-
# = Examples
|
74
|
-
# @github = Github.new
|
75
|
-
# @github.pull_requests.create_request_comment 'user-name', 'repo-name', 'request-id', "body" => "Nice change",
|
76
|
-
# "in_reply_to" => 4
|
77
|
-
#
|
78
|
-
def create_request_comment(user_name, repo_name, request_id, params={})
|
79
|
-
_update_user_repo_params(user_name, repo_name)
|
80
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
81
|
-
_validate_presence_of request_id
|
82
|
-
|
83
|
-
_normalize_params_keys(params)
|
84
|
-
_merge_mime_type(:pull_comment, params)
|
85
|
-
_filter_params_keys(VALID_REQUEST_COM_PARAM_NAMES, params)
|
86
|
-
_validate_reply_to(params)
|
87
|
-
|
88
|
-
post("/repos/#{user}/#{repo}/pulls/#{request_id}/comments", params)
|
89
|
-
end
|
90
|
-
|
91
|
-
# Edit a pull request comment
|
92
|
-
#
|
93
|
-
# = Inputs
|
94
|
-
# * <tt>:body</tt> - Required string
|
95
|
-
#
|
96
|
-
# = Examples
|
97
|
-
# @github = Github.new
|
98
|
-
# @github.pull_requests.edit_request_comment 'user-name', 'repo-name', 'comment-id', "body" => "Nice change",
|
99
|
-
#
|
100
|
-
def edit_request_comment(user_name, repo_name, comment_id, params={})
|
101
|
-
_update_user_repo_params(user_name, repo_name)
|
102
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
103
|
-
_validate_presence_of comment_id
|
104
|
-
|
105
|
-
_normalize_params_keys(params)
|
106
|
-
_merge_mime_type(:pull_comment, params)
|
107
|
-
_filter_params_keys(VALID_REQUEST_COM_PARAM_NAMES, params)
|
108
|
-
|
109
|
-
patch("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Delete a pull request comment
|
113
|
-
#
|
114
|
-
# = Examples
|
115
|
-
# @github = Github.new
|
116
|
-
# @github.pull_requests.delete_request_comment 'user-name', 'repo-name',
|
117
|
-
# 'comment-id'
|
118
|
-
#
|
119
|
-
def delete_request_comment(user_name, repo_name, comment_id, params={})
|
120
|
-
_update_user_repo_params(user_name, repo_name)
|
121
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
122
|
-
_validate_presence_of comment_id
|
123
|
-
|
124
|
-
_normalize_params_keys(params)
|
125
|
-
_merge_mime_type(:pull_comment, params)
|
126
|
-
|
127
|
-
delete("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
128
|
-
end
|
129
|
-
|
130
|
-
private
|
131
|
-
|
132
|
-
# To let user know that the params supplied are wrong before request is made
|
133
|
-
def _validate_reply_to(params)
|
134
|
-
if params['in_reply_to'] && !_validate_inputs(%w[ body in_reply_to ], params)
|
135
|
-
raise ArgumentError, "Required params are: #{%w[ body in_reply_to].join(',')}"
|
136
|
-
|
137
|
-
elsif !_validate_inputs(VALID_REQUEST_COM_PARAM_NAMES - %w[ in_reply_to ], params)
|
138
|
-
raise ArgumentError, "Required params are: #{VALID_REQUEST_COM_PARAM_NAMES.join(', ')}"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end # Comments
|
143
|
-
end # PullRequests
|
144
|
-
end # Github
|
data/lib/github_api/repos.rb
DELETED
@@ -1,286 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Github
|
4
|
-
class Repos < API
|
5
|
-
extend AutoloadHelper
|
6
|
-
|
7
|
-
# Load all the modules after initializing Repos to avoid superclass mismatch
|
8
|
-
autoload_all 'github_api/repos',
|
9
|
-
:Collaborators => 'collaborators',
|
10
|
-
:Commits => 'commits',
|
11
|
-
:Downloads => 'downloads',
|
12
|
-
:Forks => 'forks',
|
13
|
-
:Hooks => 'hooks',
|
14
|
-
:Keys => 'keys',
|
15
|
-
:Watching => 'watching',
|
16
|
-
:PubSubHubbub => 'pub_sub_hubbub'
|
17
|
-
|
18
|
-
include Github::Repos::Collaborators
|
19
|
-
include Github::Repos::Commits
|
20
|
-
include Github::Repos::Downloads
|
21
|
-
include Github::Repos::Forks
|
22
|
-
include Github::Repos::Hooks
|
23
|
-
include Github::Repos::Keys
|
24
|
-
include Github::Repos::Watching
|
25
|
-
include Github::Repos::PubSubHubbub
|
26
|
-
|
27
|
-
DEFAULT_REPO_OPTIONS = {
|
28
|
-
"homepage" => "https://github.com",
|
29
|
-
"public" => true,
|
30
|
-
"has_issues" => true,
|
31
|
-
"has_wiki" => true,
|
32
|
-
"has_downloads" => true
|
33
|
-
}.freeze
|
34
|
-
|
35
|
-
VALID_REPO_OPTIONS = %w[
|
36
|
-
name
|
37
|
-
description
|
38
|
-
homepage
|
39
|
-
public
|
40
|
-
has_issues
|
41
|
-
has_wiki
|
42
|
-
has_downloads
|
43
|
-
].freeze
|
44
|
-
|
45
|
-
VALID_REPO_TYPES = %w[ all public private member ].freeze
|
46
|
-
|
47
|
-
# Creates new Repositories API
|
48
|
-
def initialize(options = {})
|
49
|
-
super(options)
|
50
|
-
end
|
51
|
-
|
52
|
-
# List branches
|
53
|
-
#
|
54
|
-
# = Examples
|
55
|
-
#
|
56
|
-
# @github = Github.new
|
57
|
-
# @github.repos.branches 'user-name', 'repo-name'
|
58
|
-
#
|
59
|
-
# @repos = Github::Repos.new
|
60
|
-
# @repos.branches 'user-name', 'repo-name'
|
61
|
-
#
|
62
|
-
def branches(user_name=nil, repo_name=nil, params={})
|
63
|
-
_update_user_repo_params(user_name, repo_name)
|
64
|
-
_validate_user_repo_params(user, repo) unless (user? && repo?)
|
65
|
-
_normalize_params_keys(params)
|
66
|
-
|
67
|
-
response = get("/repos/#{user}/#{repo}/branches", params)
|
68
|
-
return response unless block_given?
|
69
|
-
response.each { |el| yield el }
|
70
|
-
end
|
71
|
-
alias :list_branches :branches
|
72
|
-
|
73
|
-
# Create a new repository for the autheticated user.
|
74
|
-
#
|
75
|
-
# = Parameters
|
76
|
-
# <tt>:name</tt> - Required string
|
77
|
-
# <tt>:description</tt> - Optional string
|
78
|
-
# <tt>:homepage</tt> - Optional string
|
79
|
-
# <tt>:public</tt> - Optional boolean - true to create public repo, false to create a private one
|
80
|
-
# <tt>:has_issues</tt> - Optional boolean - <tt>true</tt> to enable issues for this repository, <tt>false</tt> to disable them
|
81
|
-
# <tt>:has_wiki</tt> - Optional boolean - <tt>true</tt> to enable the wiki for this repository, <tt>false</tt> to disable it. Default is <tt>true</tt>
|
82
|
-
# <tt>:has_downloads</tt> Optional boolean - <tt>true</tt> to enable downloads for this repository
|
83
|
-
#
|
84
|
-
# = Examples
|
85
|
-
# @github = Github.new
|
86
|
-
# @github.repos.create_repo "name" => 'repo-name'
|
87
|
-
# "description": "This is your first repo",
|
88
|
-
# "homepage": "https://github.com",
|
89
|
-
# "public": true,
|
90
|
-
# "has_issues": true,
|
91
|
-
# "has_wiki": true,
|
92
|
-
# "has_downloads": true
|
93
|
-
#
|
94
|
-
# Create a new repository in this organisation. The authenticated user
|
95
|
-
# must be a member of this organisation
|
96
|
-
#
|
97
|
-
# Examples:
|
98
|
-
# @github = Github.new :oauth_token => '...'
|
99
|
-
# @github.repos.create_repo :name => 'repo-name', :org => 'organisation-name'
|
100
|
-
#
|
101
|
-
def create_repo(*args)
|
102
|
-
params = args.last.is_a?(Hash) ? args.pop : {}
|
103
|
-
_normalize_params_keys(params)
|
104
|
-
_filter_params_keys(VALID_REPO_OPTIONS + %w[ org ], params)
|
105
|
-
|
106
|
-
raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
|
107
|
-
|
108
|
-
# Requires authenticated user
|
109
|
-
if (org = params.delete("org"))
|
110
|
-
post("/orgs/#{org}/repos", DEFAULT_REPO_OPTIONS.merge(params))
|
111
|
-
else
|
112
|
-
post("/user/repos", DEFAULT_REPO_OPTIONS.merge(params))
|
113
|
-
end
|
114
|
-
end
|
115
|
-
alias :create_repository :create_repo
|
116
|
-
|
117
|
-
# List contributors
|
118
|
-
#
|
119
|
-
# = Parameters
|
120
|
-
# <tt>:anon</tt> - Optional flag. Set to 1 or true to include anonymous contributors.
|
121
|
-
#
|
122
|
-
# = Examples
|
123
|
-
#
|
124
|
-
# @github = Github.new
|
125
|
-
# @github.repos.contributors 'user-name','repo-name'
|
126
|
-
# @github.repos.contributors 'user-name','repo-name' { |cont| ... }
|
127
|
-
#
|
128
|
-
def contributors(user_name=nil, repo_name=nil, params={})
|
129
|
-
_update_user_repo_params(user_name, repo_name)
|
130
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
131
|
-
_normalize_params_keys(params)
|
132
|
-
_filter_params_keys(['anon'], params)
|
133
|
-
|
134
|
-
response = get("/repos/#{user}/#{repo}/contributors", params)
|
135
|
-
return response unless block_given?
|
136
|
-
response.each { |el| yield el }
|
137
|
-
end
|
138
|
-
alias :list_contributors :contributors
|
139
|
-
alias :contribs :contributors
|
140
|
-
|
141
|
-
# Edit a repository
|
142
|
-
#
|
143
|
-
# = Parameters
|
144
|
-
# * <tt>:name</tt> Required string
|
145
|
-
# * <tt>:description</tt> Optional string
|
146
|
-
# * <tt>:homepage</tt> Optional string
|
147
|
-
# * <tt>:public</tt> Optional boolean - true to create public repo, false to create a private one
|
148
|
-
# * <tt>:has_issues</tt> Optional boolean - <tt>true</tt> to enable issues for this repository, <tt>false</tt> to disable them
|
149
|
-
# * <tt>:has_wiki</tt> Optional boolean - <tt>true</tt> to enable the wiki for this repository, <tt>false</tt> to disable it. Default is <tt>true</tt>
|
150
|
-
# * <tt>:has_downloads</tt> Optional boolean - <tt>true</tt> to enable downloads for this repository
|
151
|
-
#
|
152
|
-
# = Examples
|
153
|
-
#
|
154
|
-
# @github = Github.new
|
155
|
-
# @github.repos.edit_repo('user-name', 'repo-name', { :name => 'hello-world', :description => 'This is your first repo', :homepage => "https://github.com", :public => true, :has_issues => true })
|
156
|
-
#
|
157
|
-
def edit_repo(user_name=nil, repo_name=nil, params={})
|
158
|
-
_update_user_repo_params(user_name, repo_name)
|
159
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
160
|
-
|
161
|
-
_normalize_params_keys(params)
|
162
|
-
_filter_params_keys(VALID_REPO_OPTIONS, params)
|
163
|
-
|
164
|
-
raise ArgumentError, "Required params are: #{%w[ :name ] }" unless _validate_inputs(%w[ name ], params)
|
165
|
-
|
166
|
-
patch("/repos/#{user}/#{repo}", DEFAULT_REPO_OPTIONS.merge(params))
|
167
|
-
end
|
168
|
-
alias :edit_repository :edit_repo
|
169
|
-
|
170
|
-
# Get a repository
|
171
|
-
#
|
172
|
-
# = Examples
|
173
|
-
# @github = Github.new
|
174
|
-
# @github.repos.get_repo('user-name', 'repo-name')
|
175
|
-
#
|
176
|
-
def get_repo(user_name=nil, repo_name=nil, params={})
|
177
|
-
_update_user_repo_params(user_name, repo_name)
|
178
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
179
|
-
_normalize_params_keys(params)
|
180
|
-
|
181
|
-
get("/repos/#{user}/#{repo}", params)
|
182
|
-
end
|
183
|
-
alias :get_repository :get_repo
|
184
|
-
|
185
|
-
|
186
|
-
# List languages
|
187
|
-
#
|
188
|
-
# = Examples
|
189
|
-
# @github = Github.new
|
190
|
-
# @github.repos.languages('user-name', 'repo-name')
|
191
|
-
# @github.repos.languages('user-name', 'repo-name') { |lang| ... }
|
192
|
-
#
|
193
|
-
def languages(user_name=nil, repo_name=nil, params={})
|
194
|
-
_update_user_repo_params(user_name, repo_name)
|
195
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
196
|
-
_normalize_params_keys(params)
|
197
|
-
|
198
|
-
response = get("/repos/#{user}/#{repo}/languages", params)
|
199
|
-
return response unless block_given?
|
200
|
-
response.each { |el| yield el }
|
201
|
-
end
|
202
|
-
alias :list_languages :languages
|
203
|
-
|
204
|
-
# List repositories for the authenticated user
|
205
|
-
#
|
206
|
-
# = Examples
|
207
|
-
# @github = Github.new :oauth_token => '...'
|
208
|
-
# @github.repos.list_repos
|
209
|
-
# @github.repos.list_repos { |repo| ... }
|
210
|
-
#
|
211
|
-
# List public repositories for the specified user.
|
212
|
-
#
|
213
|
-
# = Examples
|
214
|
-
# github = Github.new
|
215
|
-
# github.repos.list_repos :user => 'user-name'
|
216
|
-
# github.repos.list_repos :user => 'user-name', { |repo| ... }
|
217
|
-
#
|
218
|
-
# List repositories for the specified organisation.
|
219
|
-
#
|
220
|
-
# = Examples
|
221
|
-
# @github = Github.new
|
222
|
-
# @github.repos.list_repos :org => 'org-name'
|
223
|
-
# @github.repos.list_repos :org => 'org-name', { |repo| ... }
|
224
|
-
#
|
225
|
-
def repos(*args)
|
226
|
-
params = args.last.is_a?(Hash) ? args.pop : {}
|
227
|
-
_normalize_params_keys(params)
|
228
|
-
# _merge_user_into_params!(params) unless params.has_key?('user')
|
229
|
-
_filter_params_keys(%w[ org user type ], params)
|
230
|
-
|
231
|
-
response = if (user_name = params.delete("user"))
|
232
|
-
get("/users/#{user_name}/repos")
|
233
|
-
elsif (org_name = params.delete("org"))
|
234
|
-
get("/orgs/#{org_name}/repos", params)
|
235
|
-
else
|
236
|
-
# For authenticated user
|
237
|
-
get("/user/repos", params)
|
238
|
-
end
|
239
|
-
return response unless block_given?
|
240
|
-
response.each { |el| yield el }
|
241
|
-
end
|
242
|
-
alias :list_repos :repos
|
243
|
-
alias :list_repositories :repos
|
244
|
-
|
245
|
-
# List tags
|
246
|
-
#
|
247
|
-
# = Examples
|
248
|
-
# @github = Github.new
|
249
|
-
# @github.repos.tags('user-name', 'repo-name')
|
250
|
-
# @github.repos.tags('user-name', 'repo-name') { |tag| ... }
|
251
|
-
#
|
252
|
-
def tags(user_name=nil, repo_name=nil, params={})
|
253
|
-
_update_user_repo_params(user_name, repo_name)
|
254
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
255
|
-
_normalize_params_keys(params)
|
256
|
-
|
257
|
-
response = get("/repos/#{user}/#{repo}/tags", params)
|
258
|
-
return response unless block_given?
|
259
|
-
response.each { |el| yield el }
|
260
|
-
end
|
261
|
-
alias :list_tags :tags
|
262
|
-
alias :repo_tags :tags
|
263
|
-
alias :repository_tags :tags
|
264
|
-
|
265
|
-
# List teams
|
266
|
-
#
|
267
|
-
# == Examples
|
268
|
-
# @github = Github.new
|
269
|
-
# @github.repos.teams('user-name', 'repo-name')
|
270
|
-
# @github.repos.teams('user-name', 'repo-name') { |team| ... }
|
271
|
-
#
|
272
|
-
def teams(user_name=nil, repo_name=nil, params={})
|
273
|
-
_update_user_repo_params(user_name, repo_name)
|
274
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
275
|
-
_normalize_params_keys(params)
|
276
|
-
|
277
|
-
response = get("/repos/#{user}/#{repo}/teams", params)
|
278
|
-
return response unless block_given?
|
279
|
-
response.each { |el| yield el }
|
280
|
-
end
|
281
|
-
alias :list_teams :teams
|
282
|
-
alias :repo_teams :teams
|
283
|
-
alias :repository_teams :teams
|
284
|
-
|
285
|
-
end # Repos
|
286
|
-
end # Github
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Github
|
4
|
-
class Repos
|
5
|
-
module Collaborators
|
6
|
-
|
7
|
-
# Add collaborator
|
8
|
-
#
|
9
|
-
# Examples:
|
10
|
-
# @github = Github.new
|
11
|
-
# @github.collaborators.add_collaborator 'user', 'repo', 'collaborator'
|
12
|
-
#
|
13
|
-
# @repos = Github::Repos.new
|
14
|
-
# @repos.add_collaborator 'user', 'repo', 'collaborator'
|
15
|
-
#
|
16
|
-
def add_collaborator(user_name, repo_name, collaborator, params={})
|
17
|
-
_update_user_repo_params(user_name, repo_name)
|
18
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
19
|
-
_validate_presence_of collaborator
|
20
|
-
_normalize_params_keys(params)
|
21
|
-
|
22
|
-
put("/repos/#{user}/#{repo}/collaborators/#{collaborator}", params)
|
23
|
-
end
|
24
|
-
alias :add_collab :add_collaborator
|
25
|
-
|
26
|
-
# Checks if user is a collaborator for a given repository
|
27
|
-
#
|
28
|
-
# Examples:
|
29
|
-
# @github = Github.new
|
30
|
-
# @github.collaborators.collaborator?('user', 'repo', 'collaborator')
|
31
|
-
#
|
32
|
-
def collaborator?(user_name, repo_name, collaborator, params={})
|
33
|
-
_update_user_repo_params(user_name, repo_name)
|
34
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
35
|
-
_validate_presence_of collaborator
|
36
|
-
_normalize_params_keys(params)
|
37
|
-
|
38
|
-
get("/repos/#{user}/#{repo}/collaborators/#{collaborator}", params)
|
39
|
-
true
|
40
|
-
rescue Github::ResourceNotFound
|
41
|
-
false
|
42
|
-
end
|
43
|
-
|
44
|
-
# List collaborators
|
45
|
-
#
|
46
|
-
# Examples:
|
47
|
-
# @github = Github.new
|
48
|
-
# @github.repos.collaborators 'user-name', 'repo-name'
|
49
|
-
# @github.repos.collaborators 'user-name', 'repo-name' { |cbr| .. }
|
50
|
-
#
|
51
|
-
def collaborators(user_name=nil, repo_name=nil, params={})
|
52
|
-
_update_user_repo_params(user_name, repo_name)
|
53
|
-
_validate_user_repo_params(user, repo) unless (user? && repo?)
|
54
|
-
_normalize_params_keys(params)
|
55
|
-
|
56
|
-
response = get("/repos/#{user}/#{repo}/collaborators", params)
|
57
|
-
return response unless block_given?
|
58
|
-
response.each { |el| yield el }
|
59
|
-
end
|
60
|
-
alias :list_collaborators :collaborators
|
61
|
-
alias :collabs :collaborators
|
62
|
-
|
63
|
-
# Removes collaborator
|
64
|
-
#
|
65
|
-
# Examples:
|
66
|
-
# @github = Github.new
|
67
|
-
# @github.repos.remove_collaborator 'user', 'repo', 'collaborator'
|
68
|
-
#
|
69
|
-
def remove_collaborator(user_name, repo_name, collaborator, params={})
|
70
|
-
_update_user_repo_params(user_name, repo_name)
|
71
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
72
|
-
_validate_presence_of collaborator
|
73
|
-
_normalize_params_keys(params)
|
74
|
-
|
75
|
-
delete("/repos/#{user}/#{repo}/collaborators/#{collaborator}", params)
|
76
|
-
end
|
77
|
-
alias :remove_collab :remove_collaborator
|
78
|
-
|
79
|
-
end # Collaborators
|
80
|
-
end # Repos
|
81
|
-
end # Github
|