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
@@ -8,8 +8,8 @@ module Github #:nodoc
|
|
8
8
|
super(
|
9
9
|
generate_message(
|
10
10
|
:problem => "Attempted to send request with nil arguments for #{errors.keys.join(', ')}.",
|
11
|
-
:summary => 'Each request expects certain number of arguments.',
|
12
|
-
:resolution => 'Double check that the provided arguments are set to some value.'
|
11
|
+
:summary => 'Each request expects certain number of required arguments.',
|
12
|
+
:resolution => 'Double check that the provided arguments are set to some value that is neither nil nor empty string.'
|
13
13
|
)
|
14
14
|
)
|
15
15
|
end
|
data/lib/github_api/gists.rb
CHANGED
@@ -32,12 +32,10 @@ module Github
|
|
32
32
|
# github = Github.new :oauth_token => '...'
|
33
33
|
# github.gists.list
|
34
34
|
#
|
35
|
-
def list(
|
36
|
-
|
35
|
+
def list(*args)
|
36
|
+
params = arguments(args).params
|
37
37
|
|
38
|
-
user = params.delete('user')
|
39
|
-
|
40
|
-
response = if user
|
38
|
+
response = if (user = params.delete('user'))
|
41
39
|
get_request("/users/#{user}/gists", params)
|
42
40
|
elsif oauth_token
|
43
41
|
get_request("/gists", params)
|
@@ -55,10 +53,9 @@ module Github
|
|
55
53
|
# github = Github.new :oauth_token => '...'
|
56
54
|
# github.gists.starred
|
57
55
|
#
|
58
|
-
def starred(
|
59
|
-
|
60
|
-
|
61
|
-
response = get_request("/gists/starred", params)
|
56
|
+
def starred(*args)
|
57
|
+
arguments(args)
|
58
|
+
response = get_request("/gists/starred", arguments.params)
|
62
59
|
return response unless block_given?
|
63
60
|
response.each { |el| yield el }
|
64
61
|
end
|
@@ -69,11 +66,10 @@ module Github
|
|
69
66
|
# github = Github.new
|
70
67
|
# github.gists.get 'gist-id'
|
71
68
|
#
|
72
|
-
def get(
|
73
|
-
|
74
|
-
assert_presence_of gist_id
|
69
|
+
def get(*args)
|
70
|
+
arguments(args, :required => [:gist_id])
|
75
71
|
|
76
|
-
get_request("/gists/#{gist_id}", params)
|
72
|
+
get_request("/gists/#{gist_id}", arguments.params)
|
77
73
|
end
|
78
74
|
alias :find :get
|
79
75
|
|
@@ -98,11 +94,12 @@ module Github
|
|
98
94
|
# }
|
99
95
|
# }
|
100
96
|
#
|
101
|
-
def create(
|
102
|
-
|
103
|
-
|
97
|
+
def create(*args)
|
98
|
+
arguments(args) do
|
99
|
+
assert_required REQUIRED_GIST_INPUTS
|
100
|
+
end
|
104
101
|
|
105
|
-
post_request("/gists", params)
|
102
|
+
post_request("/gists", arguments.params)
|
106
103
|
end
|
107
104
|
|
108
105
|
# Edit a gist
|
@@ -133,11 +130,10 @@ module Github
|
|
133
130
|
# 'delete_the_file.txt' => nil
|
134
131
|
# }
|
135
132
|
#
|
136
|
-
def edit(
|
137
|
-
|
138
|
-
normalize! params
|
133
|
+
def edit(*args)
|
134
|
+
arguments(args, :required => [:gist_id])
|
139
135
|
|
140
|
-
patch_request("/gists/#{gist_id}", params)
|
136
|
+
patch_request("/gists/#{gist_id}", arguments.params)
|
141
137
|
end
|
142
138
|
|
143
139
|
# Star a gist
|
@@ -146,11 +142,10 @@ module Github
|
|
146
142
|
# github = Github.new
|
147
143
|
# github.gists.star 'gist-id'
|
148
144
|
#
|
149
|
-
def star(
|
150
|
-
|
151
|
-
normalize! params
|
145
|
+
def star(*args)
|
146
|
+
arguments(args, :required => [:gist_id])
|
152
147
|
|
153
|
-
put_request("/gists/#{gist_id}/star", params)
|
148
|
+
put_request("/gists/#{gist_id}/star", arguments.params)
|
154
149
|
end
|
155
150
|
|
156
151
|
# Unstar a gist
|
@@ -159,11 +154,10 @@ module Github
|
|
159
154
|
# github = Github.new
|
160
155
|
# github.gists.unstar 'gist-id'
|
161
156
|
#
|
162
|
-
def unstar(
|
163
|
-
|
164
|
-
normalize! params
|
157
|
+
def unstar(*args)
|
158
|
+
arguments(args, :required => [:gist_id])
|
165
159
|
|
166
|
-
delete_request("/gists/#{gist_id}/star", params)
|
160
|
+
delete_request("/gists/#{gist_id}/star", arguments.params)
|
167
161
|
end
|
168
162
|
|
169
163
|
# Check if a gist is starred
|
@@ -172,11 +166,9 @@ module Github
|
|
172
166
|
# github = Github.new
|
173
167
|
# github.gists.starred? 'gist-id'
|
174
168
|
#
|
175
|
-
def starred?(
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
get_request("/gists/#{gist_id}/star", params)
|
169
|
+
def starred?(*args)
|
170
|
+
arguments(args, :required => [:gist_id])
|
171
|
+
get_request("/gists/#{gist_id}/star", arguments.params)
|
180
172
|
true
|
181
173
|
rescue Github::Error::NotFound
|
182
174
|
false
|
@@ -188,11 +180,10 @@ module Github
|
|
188
180
|
# github = Github.new
|
189
181
|
# github.gists.fork 'gist-id'
|
190
182
|
#
|
191
|
-
def fork(
|
192
|
-
|
193
|
-
normalize! params
|
183
|
+
def fork(*args)
|
184
|
+
arguments(args, :required => [:gist_id])
|
194
185
|
|
195
|
-
post_request("/gists/#{gist_id}/fork", params)
|
186
|
+
post_request("/gists/#{gist_id}/fork", arguments.params)
|
196
187
|
end
|
197
188
|
|
198
189
|
# Delete a gist
|
@@ -201,11 +192,10 @@ module Github
|
|
201
192
|
# github = Github.new
|
202
193
|
# github.gists.delete 'gist-id'
|
203
194
|
#
|
204
|
-
def delete(
|
205
|
-
|
206
|
-
normalize! params
|
195
|
+
def delete(*args)
|
196
|
+
arguments(args, :required => [:gist_id])
|
207
197
|
|
208
|
-
delete_request("/gists/#{gist_id}", params)
|
198
|
+
delete_request("/gists/#{gist_id}", arguments.params)
|
209
199
|
end
|
210
200
|
|
211
201
|
end # Gists
|
@@ -19,11 +19,10 @@ module Github
|
|
19
19
|
# github = Github.new
|
20
20
|
# github.gists.comments.list 'gist-id'
|
21
21
|
#
|
22
|
-
def list(
|
23
|
-
|
24
|
-
assert_presence_of gist_id
|
22
|
+
def list(*args)
|
23
|
+
arguments(args, :required => [:gist_id])
|
25
24
|
|
26
|
-
response = get_request("/gists/#{gist_id}/comments", params)
|
25
|
+
response = get_request("/gists/#{gist_id}/comments", arguments.params)
|
27
26
|
return response unless block_given?
|
28
27
|
response.each { |el| yield el }
|
29
28
|
end
|
@@ -35,11 +34,10 @@ module Github
|
|
35
34
|
# github = Github.new
|
36
35
|
# github.gists.comments.get 'gist-id', 'comment-id'
|
37
36
|
#
|
38
|
-
def get(
|
39
|
-
|
40
|
-
assert_presence_of comment_id
|
37
|
+
def get(*args)
|
38
|
+
arguments(args, :required => [:gist_id, :comment_id])
|
41
39
|
|
42
|
-
get_request("/gists/#{gist_id}/comments/#{comment_id}", params)
|
40
|
+
get_request("/gists/#{gist_id}/comments/#{comment_id}", arguments.params)
|
43
41
|
end
|
44
42
|
alias :find :get
|
45
43
|
|
@@ -49,12 +47,13 @@ module Github
|
|
49
47
|
# github = Github.new
|
50
48
|
# github.gists.comments.create 'gist-id'
|
51
49
|
#
|
52
|
-
def create(
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
def create(*args)
|
51
|
+
arguments(args, :required => [:gist_id]) do
|
52
|
+
sift VALID_GIST_COMMENT_OPTIONS
|
53
|
+
assert_required REQUIRED_GIST_COMMENT_OPTIONS
|
54
|
+
end
|
56
55
|
|
57
|
-
post_request("/gists/#{gist_id}/comments", params)
|
56
|
+
post_request("/gists/#{gist_id}/comments", arguments.params)
|
58
57
|
end
|
59
58
|
|
60
59
|
# Edit a comment
|
@@ -63,13 +62,13 @@ module Github
|
|
63
62
|
# github = Github.new
|
64
63
|
# github.gists.comments.edit 'gist-id', 'comment-id'
|
65
64
|
#
|
66
|
-
def edit(
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
def edit(*args)
|
66
|
+
arguments(args, :required => [:gist_id, :comment_id]) do
|
67
|
+
sift VALID_GIST_COMMENT_OPTIONS
|
68
|
+
assert_required REQUIRED_GIST_COMMENT_OPTIONS
|
69
|
+
end
|
71
70
|
|
72
|
-
patch_request("/gists/#{gist_id}/comments/#{comment_id}", params)
|
71
|
+
patch_request("/gists/#{gist_id}/comments/#{comment_id}", arguments.params)
|
73
72
|
end
|
74
73
|
|
75
74
|
# Delete a comment
|
@@ -78,11 +77,10 @@ module Github
|
|
78
77
|
# github = Github.new
|
79
78
|
# github.gists.comments.delete 'gist-id', 'comment-id'
|
80
79
|
#
|
81
|
-
def delete(
|
82
|
-
|
83
|
-
assert_presence_of comment_id
|
80
|
+
def delete(*args)
|
81
|
+
arguments(args, :required => [:gist_id, :comment_id])
|
84
82
|
|
85
|
-
delete_request("/gists/#{gist_id}/comments/#{comment_id}", params)
|
83
|
+
delete_request("/gists/#{gist_id}/comments/#{comment_id}", arguments.params)
|
86
84
|
end
|
87
85
|
|
88
86
|
end # Gists::Comments
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
+
|
5
|
+
# Since blobs can be any arbitrary binary data, the input and responses for
|
6
|
+
# the blob api takes an encoding parameter that can be either utf-8 or base64.
|
7
|
+
# If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it.
|
4
8
|
class GitData::Blobs < API
|
5
|
-
# Since blobs can be any arbitrary binary data, the input and responses for
|
6
|
-
# the blob api takes an encoding parameter that can be either utf-8 or base64.
|
7
|
-
# If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it.
|
8
9
|
|
9
10
|
VALID_BLOB_PARAM_NAMES = %w[ content encoding ].freeze
|
10
11
|
|
@@ -14,12 +15,10 @@ module Github
|
|
14
15
|
# github = Github.new
|
15
16
|
# github.git_data.blobs.get 'user-name', 'repo-name', 'sha'
|
16
17
|
#
|
17
|
-
def get(
|
18
|
-
|
19
|
-
assert_presence_of user, repo, sha
|
20
|
-
normalize! params
|
18
|
+
def get(*args)
|
19
|
+
arguments(args, :required => [:user, :repo, :sha])
|
21
20
|
|
22
|
-
get_request("/repos/#{user}/#{repo}/git/blobs/#{sha}", params)
|
21
|
+
get_request("/repos/#{user}/#{repo}/git/blobs/#{sha}", arguments.params)
|
23
22
|
end
|
24
23
|
alias :find :get
|
25
24
|
|
@@ -34,15 +33,13 @@ module Github
|
|
34
33
|
# "content" => "Content of the blob",
|
35
34
|
# "encoding" => "utf-8"
|
36
35
|
#
|
37
|
-
def create(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
filter! VALID_BLOB_PARAM_NAMES, params
|
43
|
-
assert_required_keys(VALID_BLOB_PARAM_NAMES, params)
|
36
|
+
def create(*args)
|
37
|
+
arguments(args, :required => [:user, :repo]) do
|
38
|
+
sift VALID_BLOB_PARAM_NAMES
|
39
|
+
assert_required VALID_BLOB_PARAM_NAMES
|
40
|
+
end
|
44
41
|
|
45
|
-
post_request("/repos/#{user}/#{repo}/git/blobs", params)
|
42
|
+
post_request("/repos/#{user}/#{repo}/git/blobs", arguments.params)
|
46
43
|
end
|
47
44
|
|
48
45
|
end # GitData::Blobs
|
@@ -26,10 +26,12 @@ module Github
|
|
26
26
|
# github = Github.new
|
27
27
|
# github.git_data.commits.get 'user-name', 'repo-name', 'sha'
|
28
28
|
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
# commits = Github::Commits.new user: 'user-name', repo: 'repo-name'
|
30
|
+
# commits.get sha: '...'
|
31
|
+
#
|
32
|
+
def get(*args)
|
33
|
+
arguments(args, :required => [:user, :repo, :sha])
|
34
|
+
params = arguments.params
|
33
35
|
|
34
36
|
get_request("/repos/#{user}/#{repo}/git/commits/#{sha}", params)
|
35
37
|
end
|
@@ -67,12 +69,12 @@ module Github
|
|
67
69
|
# ],
|
68
70
|
# "tree": "827efc6d56897b048c772eb4087f854f46256132"]
|
69
71
|
#
|
70
|
-
def create(
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
def create(*args)
|
73
|
+
arguments(args, :required => [:user, :repo]) do
|
74
|
+
sift VALID_COMMIT_PARAM_NAMES
|
75
|
+
assert_required REQUIRED_COMMIT_PARAMS
|
76
|
+
end
|
77
|
+
params = arguments.params
|
76
78
|
|
77
79
|
post_request("/repos/#{user}/#{repo}/git/commits", params)
|
78
80
|
end
|
@@ -5,6 +5,8 @@ module Github
|
|
5
5
|
|
6
6
|
VALID_REF_PARAM_NAMES = %w[ ref sha force ].freeze
|
7
7
|
|
8
|
+
REQUIRED_REF_PARAMS = %w[ ref sha ].freeze
|
9
|
+
|
8
10
|
VALID_REF_PARAM_VALUES = {
|
9
11
|
'ref' => %r{^refs\/\w+(\/\w+)*} # test fully qualified reference
|
10
12
|
}
|
@@ -22,13 +24,11 @@ module Github
|
|
22
24
|
#
|
23
25
|
# github.git_data.references.list 'user-name', 'repo-name', ref:'tags'
|
24
26
|
#
|
25
|
-
def list(
|
26
|
-
|
27
|
-
|
28
|
-
normalize! params
|
27
|
+
def list(*args)
|
28
|
+
arguments(args, :required => [:user, :repo])
|
29
|
+
params = arguments.params
|
29
30
|
|
30
|
-
response = if params
|
31
|
-
ref = params.delete('ref')
|
31
|
+
response = if (ref = params.delete('ref'))
|
32
32
|
validate_reference ref
|
33
33
|
get_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
|
34
34
|
else
|
@@ -50,17 +50,15 @@ module Github
|
|
50
50
|
# github = Github.new
|
51
51
|
# github.git_data.references.get 'user-name', 'repo-name', 'heads/branch'
|
52
52
|
#
|
53
|
-
def get(
|
54
|
-
|
55
|
-
assert_presence_of user, repo, ref
|
53
|
+
def get(*args)
|
54
|
+
arguments(args, :required => [:user, :repo, :ref])
|
56
55
|
validate_reference ref
|
57
|
-
|
56
|
+
params = arguments.params
|
58
57
|
|
59
58
|
get_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
|
60
59
|
end
|
61
60
|
alias :find :get
|
62
61
|
|
63
|
-
|
64
62
|
# Create a reference
|
65
63
|
#
|
66
64
|
# = Inputs
|
@@ -73,13 +71,13 @@ module Github
|
|
73
71
|
# "ref" => "refs/heads/master",
|
74
72
|
# "sha" => "827efc6d56897b048c772eb4087f854f46256132"
|
75
73
|
#
|
76
|
-
def create(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
def create(*args)
|
75
|
+
arguments(args, :required => [:user, :repo]) do
|
76
|
+
sift VALID_REF_PARAM_NAMES
|
77
|
+
assert_required REQUIRED_REF_PARAMS
|
78
|
+
end
|
79
|
+
params = arguments.params
|
81
80
|
validate_reference params['ref']
|
82
|
-
assert_required_keys(%w[ ref sha ], params)
|
83
81
|
|
84
82
|
post_request("/repos/#{user}/#{repo}/git/refs", params)
|
85
83
|
end
|
@@ -96,13 +94,12 @@ module Github
|
|
96
94
|
# "sha" => "827efc6d56897b048c772eb4087f854f46256132",
|
97
95
|
# "force" => true
|
98
96
|
#
|
99
|
-
def update(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
assert_required_keys(%w[ sha ], params)
|
97
|
+
def update(*args)
|
98
|
+
arguments(args, :required => [:user, :repo, :ref]) do
|
99
|
+
sift VALID_REF_PARAM_NAMES
|
100
|
+
assert_required %w[ sha ]
|
101
|
+
end
|
102
|
+
params = arguments.params
|
106
103
|
|
107
104
|
patch_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
|
108
105
|
end
|
@@ -114,10 +111,9 @@ module Github
|
|
114
111
|
# github.git_data.references.delete 'user-name', 'repo-name',
|
115
112
|
# "ref" => "refs/heads/master",
|
116
113
|
#
|
117
|
-
def delete(
|
118
|
-
|
119
|
-
|
120
|
-
normalize! params
|
114
|
+
def delete(*args)
|
115
|
+
arguments(args, :required => [:user, :repo, :ref])
|
116
|
+
params = arguments.params
|
121
117
|
|
122
118
|
delete_request("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
|
123
119
|
end
|
@@ -28,10 +28,9 @@ module Github
|
|
28
28
|
# github = Github.new
|
29
29
|
# github.git_data.tags.get 'user-name', 'repo-name', 'sha'
|
30
30
|
#
|
31
|
-
def get(
|
32
|
-
|
33
|
-
|
34
|
-
normalize! params
|
31
|
+
def get(*args)
|
32
|
+
arguments(args, :required => [:user, :repo, :sha])
|
33
|
+
params = arguments.params
|
35
34
|
|
36
35
|
get_request("/repos/#{user}/#{repo}/git/tags/#{sha}", params)
|
37
36
|
end
|
@@ -65,13 +64,12 @@ module Github
|
|
65
64
|
# "date" => "2011-06-17T14:53:3"
|
66
65
|
# }
|
67
66
|
#
|
68
|
-
def create(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
assert_valid_values(VALID_TAG_PARAM_VALUES, params)
|
67
|
+
def create(*args)
|
68
|
+
arguments(args, :required => [:user, :repo]) do
|
69
|
+
sift VALID_TAG_PARAM_NAMES
|
70
|
+
assert_values VALID_TAG_PARAM_VALUES
|
71
|
+
end
|
72
|
+
params = arguments.params
|
75
73
|
|
76
74
|
post_request("/repos/#{user}/#{repo}/git/tags", params)
|
77
75
|
end
|