github_api 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +50 -5
- data/features/cassettes/git_data/commits/get.yml +69 -0
- data/features/git_data/commmits.feature +14 -0
- data/lib/github_api.rb +1 -0
- data/lib/github_api/activity/events.rb +42 -33
- data/lib/github_api/activity/notifications.rb +22 -22
- data/lib/github_api/activity/starring.rb +16 -21
- data/lib/github_api/activity/watching.rb +16 -19
- data/lib/github_api/api.rb +51 -8
- data/lib/github_api/arguments.rb +155 -0
- data/lib/github_api/authorizations.rb +19 -20
- data/lib/github_api/configuration.rb +5 -0
- data/lib/github_api/emojis.rb +3 -3
- data/lib/github_api/error/validations.rb +2 -2
- data/lib/github_api/gists.rb +32 -42
- data/lib/github_api/gists/comments.rb +21 -23
- data/lib/github_api/git_data/blobs.rb +13 -16
- data/lib/github_api/git_data/commits.rb +12 -10
- data/lib/github_api/git_data/references.rb +24 -28
- data/lib/github_api/git_data/tags.rb +9 -11
- data/lib/github_api/git_data/trees.rb +10 -13
- data/lib/github_api/gitignore.rb +4 -6
- data/lib/github_api/issues.rb +24 -32
- data/lib/github_api/issues/assignees.rb +11 -8
- data/lib/github_api/issues/comments.rb +21 -26
- data/lib/github_api/issues/events.rb +7 -9
- data/lib/github_api/issues/labels.rb +39 -53
- data/lib/github_api/issues/milestones.rb +26 -33
- data/lib/github_api/markdown.rb +5 -6
- data/lib/github_api/meta.rb +3 -3
- data/lib/github_api/orgs.rb +10 -11
- data/lib/github_api/orgs/members.rb +18 -20
- data/lib/github_api/orgs/teams.rb +54 -58
- data/lib/github_api/pull_requests.rb +40 -54
- data/lib/github_api/pull_requests/comments.rb +19 -26
- data/lib/github_api/repos.rb +146 -101
- data/lib/github_api/repos/collaborators.rb +29 -30
- data/lib/github_api/repos/comments.rb +20 -25
- data/lib/github_api/repos/commits.rb +12 -14
- data/lib/github_api/repos/contents.rb +22 -14
- data/lib/github_api/repos/downloads.rb +19 -23
- data/lib/github_api/repos/forks.rb +6 -11
- data/lib/github_api/repos/hooks.rb +25 -34
- data/lib/github_api/repos/keys.rb +25 -27
- data/lib/github_api/repos/merging.rb +7 -6
- data/lib/github_api/repos/pub_sub_hubbub.rb +14 -18
- data/lib/github_api/repos/statuses.rb +13 -14
- data/lib/github_api/say.rb +1 -3
- data/lib/github_api/search.rb +12 -21
- data/lib/github_api/users.rb +10 -9
- data/lib/github_api/users/emails.rb +11 -9
- data/lib/github_api/users/followers.rb +25 -23
- data/lib/github_api/users/keys.rb +27 -29
- data/lib/github_api/version.rb +1 -1
- data/spec/github/activity/events/org_spec.rb +6 -6
- data/spec/github/activity/events/performed_spec.rb +1 -1
- data/spec/github/activity/events/received_spec.rb +1 -1
- data/spec/github/activity/events/user_org_spec.rb +4 -2
- data/spec/github/activity/notifications/create_spec.rb +1 -1
- data/spec/github/activity/notifications/delete_spec.rb +1 -1
- data/spec/github/activity/notifications/get_spec.rb +1 -1
- data/spec/github/activity/notifications/subscribed_spec.rb +1 -1
- data/spec/github/activity/starring/list_spec.rb +2 -0
- data/spec/github/activity/starring/starring_spec.rb +1 -1
- data/spec/github/activity/watching/list_spec.rb +2 -0
- data/spec/github/activity/watching/watching_spec.rb +1 -3
- data/spec/github/api/set_spec.rb +18 -4
- data/spec/github/api/with_spec.rb +28 -0
- data/spec/github/api_spec.rb +11 -33
- data/spec/github/arguments/parse_spec.rb +68 -0
- data/spec/github/authorizations/delete_spec.rb +1 -1
- data/spec/github/authorizations/get_spec.rb +1 -1
- data/spec/github/error/validations_spec.rb +3 -3
- data/spec/github/gists/comments/list_spec.rb +1 -1
- data/spec/github/gists/delete_spec.rb +1 -1
- data/spec/github/gists/fork_spec.rb +1 -1
- data/spec/github/gists/get_spec.rb +1 -1
- data/spec/github/gists/is_starred_spec.rb +2 -0
- data/spec/github/gists/star_spec.rb +1 -1
- data/spec/github/gists/unstar_spec.rb +1 -1
- data/spec/github/git_data/blobs/create_spec.rb +2 -0
- data/spec/github/git_data/blobs/get_spec.rb +1 -1
- data/spec/github/git_data/commits/create_spec.rb +2 -0
- data/spec/github/git_data/commits/get_spec.rb +3 -3
- data/spec/github/git_data/references/create_spec.rb +1 -1
- data/spec/github/git_data/references/delete_spec.rb +3 -1
- data/spec/github/git_data/tags/create_spec.rb +2 -0
- data/spec/github/gitignore/get_spec.rb +1 -1
- data/spec/github/issues/events/get_spec.rb +3 -1
- data/spec/github/issues/events/list_spec.rb +3 -1
- data/spec/github/issues/labels/add_spec.rb +6 -6
- data/spec/github/issues/labels/list_spec.rb +3 -1
- data/spec/github/issues/labels/replace_spec.rb +6 -7
- data/spec/github/issues/milestones/get_spec.rb +2 -0
- data/spec/github/normalizer_spec.rb +18 -6
- data/spec/github/orgs/members/conceal_spec.rb +6 -4
- data/spec/github/orgs/members/delete_spec.rb +2 -0
- data/spec/github/orgs/members/list_spec.rb +1 -1
- data/spec/github/orgs/members/member_spec.rb +3 -1
- data/spec/github/orgs/members/publicize_spec.rb +2 -0
- data/spec/github/orgs/teams/add_member_spec.rb +2 -0
- data/spec/github/orgs/teams/create_spec.rb +1 -1
- data/spec/github/orgs/teams/delete_spec.rb +1 -1
- data/spec/github/orgs/teams/edit_spec.rb +1 -1
- data/spec/github/orgs/teams/get_spec.rb +1 -1
- data/spec/github/orgs/teams/list_spec.rb +1 -1
- data/spec/github/orgs/teams/team_member_spec.rb +3 -1
- data/spec/github/parameter_filter_spec.rb +19 -58
- data/spec/github/pull_requests/comments/create_spec.rb +3 -1
- data/spec/github/pull_requests/comments/delete_spec.rb +1 -1
- data/spec/github/pull_requests/comments/edit_spec.rb +2 -0
- data/spec/github/pull_requests/comments/get_spec.rb +3 -1
- data/spec/github/pull_requests/comments/list_spec.rb +3 -1
- data/spec/github/pull_requests/commits_spec.rb +3 -3
- data/spec/github/pull_requests/create_spec.rb +4 -0
- data/spec/github/pull_requests/files_spec.rb +4 -0
- data/spec/github/pull_requests/get_spec.rb +3 -3
- data/spec/github/pull_requests/list_spec.rb +3 -3
- data/spec/github/pull_requests/merge_spec.rb +2 -0
- data/spec/github/pull_requests/merged_spec.rb +3 -1
- data/spec/github/pull_requests/update_spec.rb +4 -0
- data/spec/github/repos/collaborators/add_spec.rb +3 -1
- data/spec/github/repos/collaborators/get_spec.rb +1 -3
- data/spec/github/repos/collaborators/list_spec.rb +5 -1
- data/spec/github/repos/collaborators/remove_spec.rb +3 -1
- data/spec/github/repos/comments/create_spec.rb +4 -0
- data/spec/github/repos/comments/delete_spec.rb +2 -2
- data/spec/github/repos/comments/get_spec.rb +6 -2
- data/spec/github/repos/commits/compare_spec.rb +3 -3
- data/spec/github/repos/commits/get_spec.rb +3 -3
- data/spec/github/repos/commits/list_spec.rb +3 -3
- data/spec/github/repos/contents/archive_spec.rb +12 -0
- data/spec/github/repos/contents/get_spec.rb +5 -0
- data/spec/github/repos/contributors_spec.rb +7 -2
- data/spec/github/repos/downloads/create_spec.rb +4 -0
- data/spec/github/repos/downloads/delete_spec.rb +5 -1
- data/spec/github/repos/downloads/get_spec.rb +3 -1
- data/spec/github/repos/downloads/list_spec.rb +3 -1
- data/spec/github/repos/forks/create_spec.rb +2 -0
- data/spec/github/repos/forks/list_spec.rb +3 -1
- data/spec/github/repos/hooks/edit_spec.rb +1 -1
- data/spec/github/repos/keys/delete_spec.rb +1 -1
- data/spec/github/repos/keys/edit_spec.rb +2 -0
- data/spec/github/repos/keys/get_spec.rb +3 -1
- data/spec/github/repos/keys/list_spec.rb +4 -2
- data/spec/github/repos/list_spec.rb +6 -1
- data/spec/github/repos/pub_sub_hubbub/subscribe_service_spec.rb +27 -0
- data/spec/github/repos/pub_sub_hubbub/subscribe_spec.rb +51 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_service_spec.rb +21 -0
- data/spec/github/repos/pub_sub_hubbub/unsubscribe_spec.rb +58 -0
- data/spec/github/repos/statuses/create_spec.rb +2 -0
- data/spec/github/search_spec.rb +25 -10
- data/spec/github/users/followers/follow_spec.rb +1 -1
- data/spec/github/users/followers/is_following_spec.rb +1 -1
- data/spec/github/users/followers/unfollow_spec.rb +1 -1
- data/spec/github/users/keys/delete_spec.rb +1 -1
- data/spec/github/users/keys/get_spec.rb +1 -1
- data/spec/github/users/keys/update_spec.rb +1 -1
- data/spec/github/users/update_spec.rb +1 -1
- data/spec/integration/arguments_spec.rb +76 -0
- data/spec/{github → integration}/authorizations_spec.rb +0 -0
- metadata +44 -35
- data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -78
@@ -3,6 +3,23 @@
|
|
3
3
|
module Github
|
4
4
|
class Repos::Collaborators < API
|
5
5
|
|
6
|
+
# List collaborators
|
7
|
+
#
|
8
|
+
# Examples:
|
9
|
+
# github = Github.new
|
10
|
+
# github.repos.collaborators.list 'user-name', 'repo-name'
|
11
|
+
# github.repos.collaborators.list 'user-name', 'repo-name' { |cbr| .. }
|
12
|
+
#
|
13
|
+
def list(*args)
|
14
|
+
arguments(args, :required => [:user, :repo])
|
15
|
+
params = arguments.params
|
16
|
+
|
17
|
+
response = get_request("/repos/#{user}/#{repo}/collaborators", params)
|
18
|
+
return response unless block_given?
|
19
|
+
response.each { |el| yield el }
|
20
|
+
end
|
21
|
+
alias :all :list
|
22
|
+
|
6
23
|
# Add collaborator
|
7
24
|
#
|
8
25
|
# Examples:
|
@@ -12,10 +29,9 @@ module Github
|
|
12
29
|
# collaborators = Github::Repos::Collaborators.new
|
13
30
|
# collaborators.add 'user', 'repo', 'collaborator'
|
14
31
|
#
|
15
|
-
def add(
|
16
|
-
|
17
|
-
|
18
|
-
normalize! params
|
32
|
+
def add(*args)
|
33
|
+
arguments(args, :required => [:user, :repo, :collaborator])
|
34
|
+
params = arguments.params
|
19
35
|
|
20
36
|
put_request("/repos/#{user}/#{repo}/collaborators/#{collaborator}", params)
|
21
37
|
end
|
@@ -27,10 +43,12 @@ module Github
|
|
27
43
|
# github = Github.new
|
28
44
|
# github.repos.collaborators.collaborator?('user', 'repo', 'collaborator')
|
29
45
|
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
46
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
47
|
+
# github.collaborators.collaborator? collaborator: 'collaborator'
|
48
|
+
#
|
49
|
+
def collaborator?(*args)
|
50
|
+
arguments(args, :required => [:user, :repo, :collaborator])
|
51
|
+
params = arguments.params
|
34
52
|
|
35
53
|
get_request("/repos/#{user}/#{repo}/collaborators/#{collaborator}", params)
|
36
54
|
true
|
@@ -38,34 +56,15 @@ module Github
|
|
38
56
|
false
|
39
57
|
end
|
40
58
|
|
41
|
-
# List collaborators
|
42
|
-
#
|
43
|
-
# Examples:
|
44
|
-
# github = Github.new
|
45
|
-
# github.repos.collaborators.list 'user-name', 'repo-name'
|
46
|
-
# github.repos.collaborators.list 'user-name', 'repo-name' { |cbr| .. }
|
47
|
-
#
|
48
|
-
def list(user_name, repo_name, params={})
|
49
|
-
set :user => user_name, :repo => repo_name
|
50
|
-
assert_presence_of user, repo
|
51
|
-
normalize! params
|
52
|
-
|
53
|
-
response = get_request("/repos/#{user}/#{repo}/collaborators", params)
|
54
|
-
return response unless block_given?
|
55
|
-
response.each { |el| yield el }
|
56
|
-
end
|
57
|
-
alias :all :list
|
58
|
-
|
59
59
|
# Removes collaborator
|
60
60
|
#
|
61
61
|
# Examples:
|
62
62
|
# github = Github.new
|
63
63
|
# github.repos.collaborators.remove 'user', 'repo', 'collaborator'
|
64
64
|
#
|
65
|
-
def remove(
|
66
|
-
|
67
|
-
|
68
|
-
normalize! params
|
65
|
+
def remove(*args)
|
66
|
+
arguments(args, :required => [:user, :repo, :collaborator])
|
67
|
+
params = arguments.params
|
69
68
|
|
70
69
|
delete_request("/repos/#{user}/#{repo}/collaborators/#{collaborator}", params)
|
71
70
|
end
|
@@ -25,10 +25,9 @@ module Github
|
|
25
25
|
# github.repos.comments.list 'user-name', 'repo-name',
|
26
26
|
# :sha => '6dcb09b5b57875f334f61aebed695e2e4193db5e'
|
27
27
|
#
|
28
|
-
def list(
|
29
|
-
|
30
|
-
|
31
|
-
normalize! params
|
28
|
+
def list(*args)
|
29
|
+
arguments(args, :required => [:user, :repo])
|
30
|
+
params = arguments.params
|
32
31
|
|
33
32
|
response = if (sha = params.delete('sha'))
|
34
33
|
get_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
|
@@ -46,10 +45,9 @@ module Github
|
|
46
45
|
# github = Github.new
|
47
46
|
# github.repos.comments.get 'user-name', 'repo-name', 'comment-id'
|
48
47
|
#
|
49
|
-
def get(
|
50
|
-
|
51
|
-
|
52
|
-
normalize! params
|
48
|
+
def get(*args)
|
49
|
+
arguments(args, :required => [:user, :repo, :comment_id])
|
50
|
+
params = arguments.params
|
53
51
|
|
54
52
|
get_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
55
53
|
end
|
@@ -73,14 +71,12 @@ module Github
|
|
73
71
|
# "path" => "file1.txt",
|
74
72
|
# "position" => 4
|
75
73
|
#
|
76
|
-
def create(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
assert_required_keys(REQUIRED_COMMENT_OPTIONS, params)
|
74
|
+
def create(*args)
|
75
|
+
arguments(args, :required => [:user, :repo, :sha]) do
|
76
|
+
sift VALID_COMMENT_OPTIONS
|
77
|
+
assert_required REQUIRED_COMMENT_OPTIONS
|
78
|
+
end
|
79
|
+
params = arguments.params
|
84
80
|
|
85
81
|
post_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
|
86
82
|
end
|
@@ -95,11 +91,11 @@ module Github
|
|
95
91
|
# github.repos.comments.update 'user-name', 'repo-name',
|
96
92
|
# 'comment-id', "body" => "Nice change"
|
97
93
|
#
|
98
|
-
def update(
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
94
|
+
def update(*args)
|
95
|
+
arguments(args, :required => [:user, :repo, :comment_id]) do
|
96
|
+
assert_required REQUIRED_COMMENT_OPTIONS
|
97
|
+
end
|
98
|
+
params = arguments.params
|
103
99
|
|
104
100
|
patch_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
105
101
|
end
|
@@ -110,10 +106,9 @@ module Github
|
|
110
106
|
# github = Github.new
|
111
107
|
# github.repos.comments.delete 'user-name', 'repo-name', 'comment-id'
|
112
108
|
#
|
113
|
-
def delete(
|
114
|
-
|
115
|
-
|
116
|
-
normalize! params
|
109
|
+
def delete(*args)
|
110
|
+
arguments(args, :required => [:user, :repo, :comment_id])
|
111
|
+
params = arguments.params
|
117
112
|
|
118
113
|
delete_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
119
114
|
end
|
@@ -23,11 +23,11 @@ module Github
|
|
23
23
|
# github.repos.commits.list 'user-name', 'repo-name', :sha => '...'
|
24
24
|
# github.repos.commits.list 'user-name', 'repo-name', :sha => '...' { |commit| ... }
|
25
25
|
#
|
26
|
-
def list(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def list(*args)
|
27
|
+
arguments(args, :required => [:user, :repo]) do
|
28
|
+
sift VALID_COMMITS_OPTIONS
|
29
|
+
end
|
30
|
+
params = arguments.params
|
31
31
|
|
32
32
|
response = get_request("/repos/#{user}/#{repo}/commits", params)
|
33
33
|
return response unless block_given?
|
@@ -41,10 +41,9 @@ module Github
|
|
41
41
|
# github = Github.new
|
42
42
|
# github.repos.commits.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
|
43
43
|
#
|
44
|
-
def get(
|
45
|
-
|
46
|
-
|
47
|
-
normalize! params
|
44
|
+
def get(*args)
|
45
|
+
arguments(args, :required => [:user, :repo, :sha])
|
46
|
+
params = arguments.params
|
48
47
|
|
49
48
|
get_request("/repos/#{user}/#{repo}/commits/#{sha}", params)
|
50
49
|
end
|
@@ -60,12 +59,11 @@ module Github
|
|
60
59
|
# 'v0.4.8',
|
61
60
|
# 'master'
|
62
61
|
#
|
63
|
-
def compare(
|
64
|
-
|
65
|
-
|
66
|
-
normalize! params
|
62
|
+
def compare(*args)
|
63
|
+
arguments(args, :required => [:user, :repo, :base, :head])
|
64
|
+
params = arguments.params
|
67
65
|
|
68
|
-
get_request("/repos/#{
|
66
|
+
get_request("/repos/#{user}/#{repo}/compare/#{base}...#{head}", params)
|
69
67
|
end
|
70
68
|
|
71
69
|
end # Repos::Commits
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
+
|
5
|
+
# These API methods let you retrieve the contents of files within a repository
|
6
|
+
# as Base64 encoded content.
|
4
7
|
class Repos::Contents < API
|
5
|
-
# These API methods let you retrieve the contents of files within a repository as Base64 encoded content
|
6
8
|
|
7
9
|
# Get the README
|
8
10
|
#
|
@@ -12,11 +14,14 @@ module Github
|
|
12
14
|
# github = Github.new
|
13
15
|
# github.repos.contents.readme 'user-name', 'repo-name'
|
14
16
|
#
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
# content = Github::Repos;:Contents.new user: 'user-name', 'repo-name'
|
18
|
+
# content.readme
|
19
|
+
#
|
20
|
+
def readme(*args)
|
21
|
+
arguments(args, :required => [:user, :repo])
|
22
|
+
params = arguments.params
|
18
23
|
|
19
|
-
get_request("/repos/#{
|
24
|
+
get_request("/repos/#{user}/#{repo}/readme", params)
|
20
25
|
end
|
21
26
|
|
22
27
|
# Get contents
|
@@ -30,11 +35,14 @@ module Github
|
|
30
35
|
# github = Github.new
|
31
36
|
# github.repos.contents.get 'user-name', 'repo-name', 'path'
|
32
37
|
#
|
33
|
-
|
34
|
-
|
35
|
-
|
38
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
39
|
+
# github.repos.contents.get path: 'README.md'
|
40
|
+
#
|
41
|
+
def get(*args)
|
42
|
+
arguments(args, :required => [:user, :repo, :path])
|
43
|
+
params = arguments.params
|
36
44
|
|
37
|
-
get_request("/repos/#{
|
45
|
+
get_request("/repos/#{user}/#{repo}/contents/#{path}", params)
|
38
46
|
end
|
39
47
|
alias :find :get
|
40
48
|
|
@@ -57,13 +65,13 @@ module Github
|
|
57
65
|
# "archive_format" => "tarball",
|
58
66
|
# "ref" => "master"
|
59
67
|
#
|
60
|
-
def archive(
|
61
|
-
|
62
|
-
|
68
|
+
def archive(*args)
|
69
|
+
arguments(args, :required => [:user, :repo])
|
70
|
+
params = arguments.params
|
63
71
|
archive_format = params.delete('archive_format') || 'zipball'
|
64
|
-
ref
|
72
|
+
ref = params.delete('ref') || 'master'
|
65
73
|
|
66
|
-
get_request("/repos/#{
|
74
|
+
get_request("/repos/#{user}/#{repo}/#{archive_format}/#{ref}", params)
|
67
75
|
end
|
68
76
|
|
69
77
|
end # Repos::Contents
|
@@ -5,7 +5,7 @@ require 'github_api/s3_uploader'
|
|
5
5
|
module Github
|
6
6
|
class Repos::Downloads < API
|
7
7
|
|
8
|
-
REQUIRED_PARAMS = %w[ name size ]
|
8
|
+
REQUIRED_PARAMS = %w[ name size ].freeze
|
9
9
|
|
10
10
|
VALID_DOWNLOAD_PARAM_NAMES = %w[
|
11
11
|
name
|
@@ -21,12 +21,10 @@ module Github
|
|
21
21
|
# github.repos.downloads.list 'user-name', 'repo-name'
|
22
22
|
# github.repos.downloads.list 'user-name', 'repo-name' { |downl| ... }
|
23
23
|
#
|
24
|
-
def list(
|
25
|
-
|
26
|
-
assert_presence_of user, repo
|
27
|
-
normalize! params
|
24
|
+
def list(*args)
|
25
|
+
arguments(args, :required => [:user, :repo])
|
28
26
|
|
29
|
-
response = get_request("/repos/#{user}/#{repo}/downloads", params)
|
27
|
+
response = get_request("/repos/#{user}/#{repo}/downloads", arguments.params)
|
30
28
|
return response unless block_given?
|
31
29
|
response.each { |el| yield el }
|
32
30
|
end
|
@@ -38,10 +36,9 @@ module Github
|
|
38
36
|
# github = Github.new
|
39
37
|
# github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
|
40
38
|
#
|
41
|
-
def get(
|
42
|
-
|
43
|
-
|
44
|
-
normalize! params
|
39
|
+
def get(*args)
|
40
|
+
arguments(args, :required => [:user, :repo, :download_id])
|
41
|
+
params = arguments.params
|
45
42
|
|
46
43
|
get_request("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
|
47
44
|
end
|
@@ -53,13 +50,13 @@ module Github
|
|
53
50
|
# github = Github.new
|
54
51
|
# github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
|
55
52
|
#
|
56
|
-
def delete(
|
57
|
-
|
58
|
-
|
59
|
-
normalize! params
|
53
|
+
def delete(*args)
|
54
|
+
arguments(args, :required => [:user, :repo, :download_id])
|
55
|
+
params = arguments.params
|
60
56
|
|
61
57
|
delete_request("/repos/#{user}/#{repo}/downloads/#{download_id}", params)
|
62
58
|
end
|
59
|
+
alias :remove :delete
|
63
60
|
|
64
61
|
# Creating a new download is a two step process.
|
65
62
|
# You must first create a new download resource using this method.
|
@@ -79,13 +76,12 @@ module Github
|
|
79
76
|
# "description" => "Latest release",
|
80
77
|
# "content_type" => "text/plain"
|
81
78
|
#
|
82
|
-
def create(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
assert_required_keys(REQUIRED_PARAMS, params)
|
79
|
+
def create(*args)
|
80
|
+
arguments(args, :required => [:user, :repo]) do
|
81
|
+
sift VALID_DOWNLOAD_PARAM_NAMES
|
82
|
+
assert_required REQUIRED_PARAMS
|
83
|
+
end
|
84
|
+
params = arguments.params
|
89
85
|
|
90
86
|
post_request("/repos/#{user}/#{repo}/downloads", params)
|
91
87
|
end
|
@@ -103,8 +99,8 @@ module Github
|
|
103
99
|
#
|
104
100
|
# github.repos.downloads.upload resource, '/users/octokit/image.jpg'
|
105
101
|
#
|
106
|
-
def upload(
|
107
|
-
|
102
|
+
def upload(*args)
|
103
|
+
arguments(args, :required => [:resource, :filename])
|
108
104
|
|
109
105
|
response = Github::S3Uploader.new(resource, filename).send
|
110
106
|
response.body
|
@@ -13,12 +13,10 @@ module Github
|
|
13
13
|
# github.repos.forks.list 'user-name', 'repo-name'
|
14
14
|
# github.repos.forks.list 'user-name', 'repo-name' { |fork| ... }
|
15
15
|
#
|
16
|
-
def list(
|
17
|
-
|
18
|
-
assert_presence_of user, repo
|
19
|
-
normalize! params
|
16
|
+
def list(*args)
|
17
|
+
arguments(args, :required => [:user, :repo])
|
20
18
|
|
21
|
-
response = get_request("/repos/#{user}/#{repo}/forks", params)
|
19
|
+
response = get_request("/repos/#{user}/#{repo}/forks", arguments.params)
|
22
20
|
return response unless block_given?
|
23
21
|
response.each { |el| yield el }
|
24
22
|
end
|
@@ -34,13 +32,10 @@ module Github
|
|
34
32
|
# github.repos.forks.create 'user-name', 'repo-name',
|
35
33
|
# "org" => "github"
|
36
34
|
#
|
37
|
-
def create(
|
38
|
-
|
39
|
-
assert_presence_of user, repo
|
40
|
-
normalize! params
|
41
|
-
filter! %w[ org ], params
|
35
|
+
def create(*args)
|
36
|
+
arguments(args, :required => [:user, :repo])
|
42
37
|
|
43
|
-
post_request("/repos/#{user}/#{repo}/forks", params)
|
38
|
+
post_request("/repos/#{user}/#{repo}/forks", arguments.params)
|
44
39
|
end
|
45
40
|
|
46
41
|
end # Repos::Forks
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
+
|
4
5
|
# The Repository Hooks API manages the post-receive web and
|
5
6
|
# service hooks for a repository.
|
6
7
|
class Repos::Hooks < API
|
@@ -42,12 +43,10 @@ module Github
|
|
42
43
|
# github.repos.hooks.list 'user-name', 'repo-name'
|
43
44
|
# github.repos.hooks.list 'user-name', 'repo-name' { |hook| ... }
|
44
45
|
#
|
45
|
-
def list(
|
46
|
-
|
47
|
-
assert_presence_of user, repo
|
48
|
-
normalize! params
|
46
|
+
def list(*args)
|
47
|
+
arguments(args, :required => [:user, :repo])
|
49
48
|
|
50
|
-
response = get_request("/repos/#{user}/#{repo}/hooks", params)
|
49
|
+
response = get_request("/repos/#{user}/#{repo}/hooks", arguments.params)
|
51
50
|
return response unless block_given?
|
52
51
|
response.each { |el| yield el }
|
53
52
|
end
|
@@ -59,12 +58,10 @@ module Github
|
|
59
58
|
# github = Github.new
|
60
59
|
# github.repos.hooks.get 'user-name', 'repo-name'
|
61
60
|
#
|
62
|
-
def get(
|
63
|
-
|
64
|
-
assert_presence_of user, repo, hook_id
|
65
|
-
normalize! params
|
61
|
+
def get(*args)
|
62
|
+
arguments(args, :required => [:user, :repo, :hook_id])
|
66
63
|
|
67
|
-
get_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
|
64
|
+
get_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", arguments.params)
|
68
65
|
end
|
69
66
|
alias :find :get
|
70
67
|
|
@@ -86,15 +83,13 @@ module Github
|
|
86
83
|
# }
|
87
84
|
# }
|
88
85
|
#
|
89
|
-
def create(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
filter! VALID_HOOK_PARAM_NAMES, params, :recursive => false
|
95
|
-
assert_required_keys(REQUIRED_PARAMS, params)
|
86
|
+
def create(*args)
|
87
|
+
arguments(args, :required => [:user, :repo]) do
|
88
|
+
sift VALID_HOOK_PARAM_NAMES, :recursive => false
|
89
|
+
assert_required REQUIRED_PARAMS
|
90
|
+
end
|
96
91
|
|
97
|
-
post_request("/repos/#{user}/#{repo}/hooks", params)
|
92
|
+
post_request("/repos/#{user}/#{repo}/hooks", arguments.params)
|
98
93
|
end
|
99
94
|
|
100
95
|
# Edit a hook
|
@@ -118,15 +113,13 @@ module Github
|
|
118
113
|
# "token" => "abc123"
|
119
114
|
# }
|
120
115
|
#
|
121
|
-
def edit(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
filter! VALID_HOOK_PARAM_NAMES, params, :recursive => false
|
127
|
-
assert_required_keys(REQUIRED_PARAMS, params)
|
116
|
+
def edit(*args)
|
117
|
+
arguments(args, :required => [:user, :repo, :hook_id]) do
|
118
|
+
sift VALID_HOOK_PARAM_NAMES, :recursive => false
|
119
|
+
assert_required REQUIRED_PARAMS
|
120
|
+
end
|
128
121
|
|
129
|
-
patch_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
|
122
|
+
patch_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", arguments.params)
|
130
123
|
end
|
131
124
|
|
132
125
|
# Test a hook
|
@@ -137,10 +130,9 @@ module Github
|
|
137
130
|
# github = Github.new
|
138
131
|
# github.repos.hooks.test 'user-name', 'repo-name', 'hook-id'
|
139
132
|
#
|
140
|
-
def test(
|
141
|
-
|
142
|
-
|
143
|
-
normalize! params
|
133
|
+
def test(*args)
|
134
|
+
arguments(args, :required => [:user, :repo, :hook_id])
|
135
|
+
params = arguments.params
|
144
136
|
|
145
137
|
post_request("/repos/#{user}/#{repo}/hooks/#{hook_id}/test", params)
|
146
138
|
end
|
@@ -151,10 +143,9 @@ module Github
|
|
151
143
|
# github = Github.new
|
152
144
|
# github.repos.hooks.delete 'user-name', 'repo-name', 'hook-id'
|
153
145
|
#
|
154
|
-
def delete(
|
155
|
-
|
156
|
-
|
157
|
-
normalize! params
|
146
|
+
def delete(*args)
|
147
|
+
arguments(args, :required => [:user, :repo, :hook_id])
|
148
|
+
params = arguments.params
|
158
149
|
|
159
150
|
delete_request("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
|
160
151
|
end
|