github_api 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/README.rdoc +51 -20
  2. data/lib/github_api.rb +3 -1
  3. data/lib/github_api/api.rb +8 -2
  4. data/lib/github_api/authorization.rb +52 -0
  5. data/lib/github_api/cache_control.rb +19 -0
  6. data/lib/github_api/configuration.rb +8 -11
  7. data/lib/github_api/connection.rb +18 -36
  8. data/lib/github_api/gists/comments.rb +17 -5
  9. data/lib/github_api/issues.rb +9 -1
  10. data/lib/github_api/issues/comments.rb +15 -4
  11. data/lib/github_api/mime_type.rb +55 -0
  12. data/lib/github_api/pull_requests.rb +14 -0
  13. data/lib/github_api/pull_requests/comments.rb +10 -0
  14. data/lib/github_api/repos/collaborators.rb +41 -19
  15. data/lib/github_api/repos/commits.rb +108 -43
  16. data/lib/github_api/repos/forks.rb +32 -13
  17. data/lib/github_api/request.rb +12 -3
  18. data/lib/github_api/request/caching.rb +33 -0
  19. data/lib/github_api/version.rb +1 -1
  20. data/spec/fixtures/repos/collaborators.json +8 -0
  21. data/spec/fixtures/repos/commit.json +53 -0
  22. data/spec/fixtures/repos/commit_comment.json +16 -0
  23. data/spec/fixtures/repos/commit_comments.json +18 -0
  24. data/spec/fixtures/repos/commits.json +27 -0
  25. data/spec/fixtures/{repos_list.json → repos/fork.json} +0 -0
  26. data/spec/fixtures/repos/forks.json +29 -0
  27. data/spec/fixtures/repos/repo_comments.json +18 -0
  28. data/spec/github/authorization_spec.rb +71 -0
  29. data/spec/github/mime_type_spec.rb +70 -0
  30. data/spec/github/repos/collaborators_spec.rb +166 -3
  31. data/spec/github/repos/commits_spec.rb +421 -2
  32. data/spec/github/repos/forks_spec.rb +101 -3
  33. data/spec/github/repos/watching_spec.rb +6 -0
  34. data/spec/github_spec.rb +8 -4
  35. metadata +17 -9
  36. data/lib/github_api/api/extract_options.rb +0 -17
  37. data/lib/github_api/api/mime.rb +0 -5
  38. data/spec/fixtures/collaborators_list.json +0 -6
  39. data/spec/fixtures/commits_list.json +0 -25
  40. data/spec/fixtures/repos_branches_list.json +0 -7
@@ -4,7 +4,11 @@ module Github
4
4
  class Issues
5
5
  module Comments
6
6
 
7
- VALID_ISSUE_COMMENT_PARAM_NAME = %w[ body ]
7
+ VALID_ISSUE_COMMENT_PARAM_NAME = %w[
8
+ body
9
+ resource
10
+ mime_type
11
+ ].freeze
8
12
 
9
13
  # List comments on an issue
10
14
  #
@@ -16,7 +20,9 @@ module Github
16
20
  _update_user_repo_params(user_name, repo_name)
17
21
  _validate_user_repo_params(user, repo) unless user? && repo?
18
22
  _validate_presence_of issue_id
23
+
19
24
  _normalize_params_keys(params)
25
+ _merge_mime_type(:issue_comment, params)
20
26
 
21
27
  get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
22
28
  end
@@ -31,9 +37,11 @@ module Github
31
37
  _update_user_repo_params(user_name, repo_name)
32
38
  _validate_user_repo_params(user, repo) unless user? && repo?
33
39
  _validate_presence_of comment_id
40
+
34
41
  _normalize_params_keys(params)
42
+ _merge_mime_type(:issue_comment, params)
35
43
 
36
- get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
44
+ get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
37
45
  end
38
46
 
39
47
  # Create a comment
@@ -52,9 +60,10 @@ module Github
52
60
  _validate_presence_of issue_id
53
61
 
54
62
  _normalize_params_keys(params)
63
+ _merge_mime_type(:issue_comment, params)
55
64
  _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
56
65
 
57
- post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments")
66
+ post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
58
67
  end
59
68
 
60
69
  # Edit a comment
@@ -73,6 +82,7 @@ module Github
73
82
  _validate_presence_of comment_id
74
83
 
75
84
  _normalize_params_keys(params)
85
+ _merge_mime_type(:issue_comment, params)
76
86
  _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
77
87
 
78
88
  patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
@@ -90,8 +100,9 @@ module Github
90
100
  _validate_presence_of comment_id
91
101
 
92
102
  _normalize_params_keys(params)
103
+ _merge_mime_type(:issue_comment, params)
93
104
 
94
- delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
105
+ delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
95
106
  end
96
107
 
97
108
  end # Comments
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ module Github
4
+ module MimeType
5
+
6
+ attr_accessor :accepts
7
+
8
+ RESOURCE_LOOKUP = {
9
+ :json => 'json',
10
+ :issue => 'vnd.github-issue.',
11
+ :issue_comment => 'vnd.github-issuecomment.',
12
+ :commit_comment => 'vnd.github-commitcomment.',
13
+ :pull_request => 'vnd.github-pull.',
14
+ :pull_comment => 'vnd.github-pullcomment.',
15
+ :gist_comment => 'vnd.github-gistcomment.',
16
+ :blob => 'vnd.github-blob.'
17
+ }
18
+
19
+ MIME_LOOKUP = {
20
+ :json => 'json',
21
+ :blob => 'raw',
22
+ :raw => 'raw+json',
23
+ :text => 'text+json',
24
+ :html => 'html+json',
25
+ :full => 'full+json'
26
+ }
27
+
28
+ def parse(resource = nil, mime_type = :json)
29
+ resource = lookup_resource(resource) if resource
30
+ mime_type = lookup_mime(mime_type)
31
+ self.accepts = "application/#{resource || ''}#{mime_type}"
32
+ end
33
+
34
+ def lookup_resource(name)
35
+ RESOURCE_LOOKUP.fetch(name)
36
+ end
37
+
38
+ def lookup_mime(name)
39
+ MIME_LOOKUP.fetch(name)
40
+ end
41
+
42
+ def _normalize_name(name)
43
+ puts "NAME: #{name}"
44
+ case name
45
+ when String
46
+ name.strip.downcase.to_sym
47
+ when Symbol
48
+ name
49
+ else
50
+ raise ArgumentError, 'Provided MIME Type is not a valid or recognized entry'
51
+ end
52
+ end
53
+
54
+ end # MimeType
55
+ end # Github
@@ -17,6 +17,8 @@ module Github
17
17
  state
18
18
  issue
19
19
  commit_message
20
+ mime_type
21
+ resource
20
22
  ].freeze
21
23
 
22
24
  VALID_REQUEST_PARAM_VALUES = {
@@ -44,6 +46,7 @@ module Github
44
46
 
45
47
  _normalize_params_keys(params)
46
48
  _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
49
+ _merge_mime_type(:pull_request, params)
47
50
  _validate_params_values(VALID_REQUEST_PARAM_VALUES, params)
48
51
 
49
52
  response = get("/repos/#{user}/#{repo}/pulls", params)
@@ -64,7 +67,9 @@ module Github
64
67
  _update_user_repo_params(user_name, repo_name)
65
68
  _validate_user_repo_params(user, repo) unless user? && repo?
66
69
  _validate_presence_of request_id
70
+
67
71
  _normalize_params_keys(params)
72
+ _merge_mime_type(:pull_request, params)
68
73
 
69
74
  get("/repos/#{user}/#{repo}/pulls/#{request_id}", params)
70
75
  end
@@ -103,6 +108,7 @@ module Github
103
108
  _validate_user_repo_params(user, repo) unless user? && repo?
104
109
 
105
110
  _normalize_params_keys(params)
111
+ _merge_mime_type(:pull_request, params)
106
112
  _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
107
113
 
108
114
  post("/repos/#{user}/#{repo}/pulls", params)
@@ -129,6 +135,7 @@ module Github
129
135
 
130
136
  _normalize_params_keys(params)
131
137
  _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
138
+ _merge_mime_type(:pull_request, params)
132
139
  _validate_params_values(VALID_REQUEST_PARAM_VALUES, params)
133
140
 
134
141
  patch("/repos/#{user}/#{repo}/pulls/#{request_id}", params)
@@ -144,7 +151,9 @@ module Github
144
151
  _update_user_repo_params(user_name, repo_name)
145
152
  _validate_user_repo_params(user, repo) unless user? && repo?
146
153
  _validate_presence_of request_id
154
+
147
155
  _normalize_params_keys(params)
156
+ _merge_mime_type(:pull_request, params)
148
157
 
149
158
  response = get("/repos/#{user}/#{repo}/pulls/#{request_id}/commits", params)
150
159
  return response unless block_given?
@@ -161,7 +170,9 @@ module Github
161
170
  _update_user_repo_params(user_name, repo_name)
162
171
  _validate_user_repo_params(user, repo) unless user? && repo?
163
172
  _validate_presence_of request_id
173
+
164
174
  _normalize_params_keys(params)
175
+ _merge_mime_type(:pull_request, params)
165
176
 
166
177
  response = get("/repos/#{user}/#{repo}/pulls/#{request_id}/files", params)
167
178
  return response unless block_given?
@@ -178,7 +189,9 @@ module Github
178
189
  _update_user_repo_params(user_name, repo_name)
179
190
  _validate_user_repo_params(user, repo) unless user? && repo?
180
191
  _validate_presence_of request_id
192
+
181
193
  _normalize_params_keys(params)
194
+ _merge_mime_type(:pull_request, params)
182
195
 
183
196
  get("/repos/#{user}/#{repo}/pulls/#{request_id}/merge", params)
184
197
  true
@@ -201,6 +214,7 @@ module Github
201
214
  _validate_presence_of request_id
202
215
 
203
216
  _normalize_params_keys(params)
217
+ _merge_mime_type(:pull_request, params)
204
218
  _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
205
219
 
206
220
  put("/repos/#{user}/#{repo}/pulls/#{request_id}/merge", params)
@@ -10,6 +10,8 @@ module Github
10
10
  path
11
11
  position
12
12
  in_reply_to
13
+ mime_type
14
+ resource
13
15
  ].freeze
14
16
 
15
17
  # List comments on a pull request
@@ -22,7 +24,9 @@ module Github
22
24
  _update_user_repo_params(user_name, repo_name)
23
25
  _validate_user_repo_params(user, repo) unless user? && repo?
24
26
  _validate_presence_of request_id
27
+
25
28
  _normalize_params_keys(params)
29
+ _merge_mime_type(:pull_comment, params)
26
30
 
27
31
  response = get("/repos/#{user}/#{repo}/pulls/#{request_id}/comments", params)
28
32
  return response unless block_given?
@@ -38,7 +42,9 @@ module Github
38
42
  _update_user_repo_params(user_name, repo_name)
39
43
  _validate_user_repo_params(user, repo) unless user? && repo?
40
44
  _validate_presence_of comment_id
45
+
41
46
  _normalize_params_keys(params)
47
+ _merge_mime_type(:pull_comment, params)
42
48
 
43
49
  get("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
44
50
  end
@@ -75,6 +81,7 @@ module Github
75
81
  _validate_presence_of request_id
76
82
 
77
83
  _normalize_params_keys(params)
84
+ _merge_mime_type(:pull_comment, params)
78
85
  _filter_params_keys(VALID_REQUEST_COM_PARAM_NAMES, params)
79
86
  _validate_reply_to(params)
80
87
 
@@ -96,6 +103,7 @@ module Github
96
103
  _validate_presence_of comment_id
97
104
 
98
105
  _normalize_params_keys(params)
106
+ _merge_mime_type(:pull_comment, params)
99
107
  _filter_params_keys(VALID_REQUEST_COM_PARAM_NAMES, params)
100
108
 
101
109
  patch("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
@@ -112,7 +120,9 @@ module Github
112
120
  _update_user_repo_params(user_name, repo_name)
113
121
  _validate_user_repo_params(user, repo) unless user? && repo?
114
122
  _validate_presence_of comment_id
123
+
115
124
  _normalize_params_keys(params)
125
+ _merge_mime_type(:pull_comment, params)
116
126
 
117
127
  delete("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
118
128
  end
@@ -3,56 +3,78 @@
3
3
  module Github
4
4
  class Repos
5
5
  module Collaborators
6
-
6
+
7
7
  # Add collaborator
8
8
  #
9
9
  # Examples:
10
10
  # @github = Github.new
11
- # @github.collaborators.add_collaborator('user', 'repo', 'collaborator')
11
+ # @github.collaborators.add_collaborator 'user', 'repo', 'collaborator'
12
12
  #
13
13
  # @repos = Github::Repos.new
14
- # @repos.add_collaborator('user', 'repo', 'collaborator')
14
+ # @repos.add_collaborator 'user', 'repo', 'collaborator'
15
15
  #
16
- def add_collaborator(user, repo, collaborator)
17
- put("/repos/#{user}/#{repo}/collaborators/#{collaborator}")
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)
18
23
  end
19
-
20
-
24
+ alias :add_collab :add_collaborator
25
+
21
26
  # Checks if user is a collaborator for a given repository
22
27
  #
23
28
  # Examples:
24
29
  # @github = Github.new
25
30
  # @github.collaborators.collaborator?('user', 'repo', 'collaborator')
26
31
  #
27
- def collaborator?(user_name, repo_name, collaborator)
28
- get("/repos/#{user}/#{repo}/collaborators/#{collaborator}")
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
29
42
  end
30
43
 
31
44
  # List collaborators
32
45
  #
33
46
  # Examples:
34
47
  # @github = Github.new
35
- # @github.repos.collaborators('user-name', 'repo-name')
36
- # @github.repos.collaborators('user-name', 'repo-name') { |cbr| .. }
48
+ # @github.repos.collaborators 'user-name', 'repo-name'
49
+ # @github.repos.collaborators 'user-name', 'repo-name' { |cbr| .. }
37
50
  #
38
- def collaborators(user_name=nil, repo_name=nil)
39
- _update_user_repo_params(user_name, repo_name)
51
+ def collaborators(user_name=nil, repo_name=nil, params={})
52
+ _update_user_repo_params(user_name, repo_name)
40
53
  _validate_user_repo_params(user, repo) unless (user? && repo?)
41
-
42
- response = get("/repos/#{user}/#{repo}/collaborators")
54
+ _normalize_params_keys(params)
55
+
56
+ response = get("/repos/#{user}/#{repo}/collaborators", params)
43
57
  return response unless block_given?
44
58
  response.each { |el| yield el }
45
59
  end
46
-
60
+ alias :list_collaborators :collaborators
61
+ alias :collabs :collaborators
62
+
47
63
  # Removes collaborator
48
64
  #
49
65
  # Examples:
50
66
  # @github = Github.new
51
- # @github.collaborators.remove('user', 'repo', 'collaborator')
67
+ # @github.repos.remove_collaborator 'user', 'repo', 'collaborator'
52
68
  #
53
- def remove_collabolator(user, repo, collaborator)
54
- delete("/repos/#{user}/#{repo}/collaborators/#{user}")
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)
55
76
  end
77
+ alias :remove_collab :remove_collaborator
56
78
 
57
79
  end # Collaborators
58
80
  end # Repos
@@ -3,42 +3,76 @@
3
3
  module Github
4
4
  class Repos
5
5
  module Commits
6
-
7
- REQUIRED_COMMENT_PARAMS = %w[ body commit_id line path position ]
6
+
7
+ REQUIRED_COMMENT_PARAMS = %w[
8
+ body
9
+ commit_id
10
+ line
11
+ path
12
+ position
13
+ ].freeze
8
14
 
9
15
  # Creates a commit comment
10
16
  #
17
+ # = Inputs
18
+ # * <tt>:body</tt> - Required string.
19
+ # * <tt>:comment_id</tt> - Required string - Sha of the commit to comment on.
20
+ # * <tt>:line</tt> - Required number - Line number in the file to comment on.
21
+ # * <tt>:path</tt> - Required string - Relative path of the file to comment on.
22
+ # * <tt>:position</tt> - Required number - Line index in the diff to comment on.
23
+ #
11
24
  # = Examples
12
25
  # @github = Github.new
13
- # @github.repos.create_comment(...)
26
+ # @github.repos.create_comment 'user-name', 'repo-name', 'sha-key',
27
+ # "body" => "Nice change",
28
+ # "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
29
+ # "line" => 1,
30
+ # "path" => "file1.txt",
31
+ # "position" => 4
14
32
  #
15
- def create_comment(user_name=nil, repo_name=nil, params={})
16
- raise ArgumentError, "Expected following inputs to the method: #{REQUIRED_COMMENT_PARAMS.join(', ')}" unless _validate_inputs(REQUIRED_COMMENT_PARAMS, inputs)
33
+ def create_comment(user_name, repo_name, sha, params={})
34
+ _update_user_repo_params(user_name, repo_name)
35
+ _validate_user_repo_params(user, repo) unless user? && repo?
36
+ _validate_presence_of sha
37
+
38
+ _normalize_params_keys(params)
39
+ _filter_params_keys(REQUIRED_COMMENT_PARAMS, params)
17
40
 
18
- post("/repos/#{user}/#{repo}/commits/#{sha}/comments", inputs)
41
+ raise ArgumentError, "Expected following inputs to the method: #{REQUIRED_COMMENT_PARAMS.join(', ')}" unless _validate_inputs(REQUIRED_COMMENT_PARAMS, params)
42
+
43
+ post("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
19
44
  end
20
-
45
+ alias :create_commit_comment :create_comment
46
+
21
47
  # Deletes a commit comment
22
48
  #
23
49
  # = Examples
24
50
  # @github = Github.new
25
- # @github.repos.delete_comment(...)
51
+ # @github.repos.delete_comment 'user-name', 'repo-name', 'comment-id'
26
52
  #
27
- def delete_comment(user, repo, comment_id)
28
- delete("/repos/#{user}/#{repo}/comments/#{comment_id}")
53
+ def delete_comment(user_name, repo_name, comment_id, params={})
54
+ _update_user_repo_params(user_name, repo_name)
55
+ _validate_user_repo_params(user, repo) unless user? && repo?
56
+ _validate_presence_of comment_id
57
+ _normalize_params_keys(params)
58
+
59
+ delete("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
29
60
  end
61
+ alias :delete_commit_comment :delete_comment
30
62
 
31
63
  # List commits on a repository
32
64
  #
33
65
  # = Parameters
34
- # :sha Optional string. Sha or branch to start listing commits from.
35
- # :path Optional string. Only commits containing this file path will be returned
66
+ # * <tt>:sha</tt> Optional string. Sha or branch to start listing commits from.
67
+ # * <tt>:path</tt> Optional string. Only commits containing this file path will be returned
68
+ #
36
69
  # = Examples
37
70
  # @github = Github.new
38
- # @github.repos.commits('user-name', 'repo-name', { :sha => ... })
71
+ # @github.repos.commits 'user-name', 'repo-name', :sha => '...'
72
+ # @github.repos.commits 'user-name', 'repo-name', :sha => '...' { |commit| ... }
39
73
  #
40
74
  def commits(user_name=nil, repo_name=nil, params={})
41
- _update_user_repo_params(user_name, repo_name)
75
+ _update_user_repo_params(user_name, repo_name)
42
76
  _validate_user_repo_params(user, repo) unless user? && repo?
43
77
  _normalize_params_keys(params)
44
78
  _filter_params_keys(%w[ sha path], params)
@@ -47,69 +81,100 @@ module Github
47
81
  return response unless block_given?
48
82
  response.each { |el| yield el }
49
83
  end
84
+ alias :list_commits :commits
85
+ alias :list_repo_commits :commits
86
+ alias :list_repository_commits :commits
50
87
 
51
88
  # List commit comments for a repository
52
- #
89
+ #
53
90
  # = Examples
54
91
  # @github = Github.new
55
- # @github.repos.list_repo_comments('user-name', 'repo-name')
92
+ # @github.repos.repo_comments 'user-name', 'repo-name'
93
+ # @github.repos.repo_comments 'user-name', 'repo-name' { |com| ... }
56
94
  #
57
- def list_repo_comments(user_name=nil, repo_name=nil)
58
- _update_user_repo_params(user_name, repo_name)
95
+ def repo_comments(user_name=nil, repo_name=nil, params={})
96
+ _update_user_repo_params(user_name, repo_name)
59
97
  _validate_user_repo_params(user, repo) unless user? && repo?
98
+ _normalize_params_keys(params)
60
99
 
61
100
  response = get("/repos/#{user}/#{repo}/comments")
62
101
  return response unless block_given?
63
102
  response.each { |el| yield el }
64
103
  end
65
-
104
+ alias :list_repo_comments :repo_comments
105
+ alias :list_repository_comments :repo_comments
106
+
66
107
  # List comments for a single commit
67
108
  #
68
109
  # = Examples
69
110
  # @github = Github.new
70
- # @github.repos.list_commit_comments('user-name', 'repo-name', '6dcb09b5b57875f334f61aebed695e2e4193db5e')
111
+ # @github.repos.commit_comments 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed695e2e4193db5e'
71
112
  #
72
- def list_commit_comments(user, repo, sha)
73
- get("/repos/#{user}/#{repo}/commits/#{sha}/comments")
113
+ def commit_comments(user_name, repo_name, sha, params={})
114
+ _update_user_repo_params(user_name, repo_name)
115
+ _validate_user_repo_params(user, repo) unless user? && repo?
116
+ _validate_presence_of sha
117
+ _normalize_params_keys(params)
118
+
119
+ response = get("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
120
+ return response unless block_given?
121
+ response.each { |el| yield el }
74
122
  end
75
-
123
+ alias :list_commit_comments :commit_comments
124
+
76
125
  # Gets a single commit
77
- #
78
- # Examples:
126
+ #
127
+ # = Examples
79
128
  # @github = Github.new
80
- # @github.repos.get_commit('user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
129
+ # @github.repos.commit 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
81
130
  #
82
- def get_commit(user, repo, sha)
83
- get("/repos/#{user}/#{repo}/commits/#{sha}")
131
+ def commit(user_name, repo_name, sha, params={})
132
+ _update_user_repo_params(user_name, repo_name)
133
+ _validate_user_repo_params(user, repo) unless user? && repo?
134
+ _validate_presence_of sha
135
+ _normalize_params_keys(params)
136
+
137
+ get("/repos/#{user}/#{repo}/commits/#{sha}", params)
84
138
  end
139
+ alias :get_commit :commit
85
140
 
86
141
  # Gets a single commit comment
87
- #
142
+ #
88
143
  # = Examples
89
144
  # @github = Github.new
90
- # @github.repos.get_comment 'user-name', 'repo-name', 'comment-id'
145
+ # @github.repos.commit_comment 'user-name', 'repo-name', 'comment-id'
91
146
  #
92
- def get_comment(user, repo, comment_id)
93
- get("/repos/#{user}/#{repo}/comments/#{comment_id}")
94
- end
147
+ def commit_comment(user_name, repo_name, comment_id, params={})
148
+ _update_user_repo_params(user_name, repo_name)
149
+ _validate_user_repo_params(user, repo) unless user? && repo?
150
+ _validate_presence_of comment_id
151
+ _normalize_params_keys(params)
95
152
 
96
- # Gets a single commit
97
- #
98
- def get_commit(user, repo, sha)
99
- get("/repos/#{user}/#{repo}/commits/#{sha}")
153
+ get("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
100
154
  end
101
-
155
+ alias :get_commit_comment :commit_comment
156
+
102
157
  # Update a commit comment
103
158
  #
159
+ # = Inputs
160
+ # * <tt>:body</tt> - Required string.
161
+ #
104
162
  # = Examples
105
163
  # @github = Github.new
106
- # @github.repos.update_comment(...)
164
+ # @github.repos.update_comment 'user-name', 'repo-name', 'comment-id',
165
+ # "body" => "Nice change"
107
166
  #
108
- def update_comment(user, repo, comment_id)
109
- raise ArgumentError, "expected following inputs to the method: 'body'" unless _validate_inputs(["body"], inputs)
110
- patch("/repos/#{user}/#{repo}/comments/#{comment_id}")
167
+ def update_comment(user_name, repo_name, comment_id, params={})
168
+ _update_user_repo_params(user_name, repo_name)
169
+ _validate_user_repo_params(user, repo) unless user? && repo?
170
+ _validate_presence_of comment_id
171
+
172
+ _normalize_params_keys(params)
173
+ raise ArgumentError, "expected following inputs to the method: 'body'" unless _validate_inputs(["body"], params)
174
+
175
+ patch("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
111
176
  end
112
-
177
+
113
178
  end # Commits
114
179
  end # Repos
115
180
  end # Github