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.
Files changed (138) hide show
  1. metadata +4 -140
  2. data/LICENSE.txt +0 -20
  3. data/README.rdoc +0 -228
  4. data/Rakefile +0 -52
  5. data/features/github_api.feature +0 -50
  6. data/features/step_definitions/github_api_steps.rb +0 -11
  7. data/features/support/env.rb +0 -13
  8. data/lib/github_api.rb +0 -73
  9. data/lib/github_api/api.rb +0 -175
  10. data/lib/github_api/api/utils.rb +0 -9
  11. data/lib/github_api/authorization.rb +0 -73
  12. data/lib/github_api/authorizations.rb +0 -119
  13. data/lib/github_api/cache_control.rb +0 -19
  14. data/lib/github_api/client.rb +0 -55
  15. data/lib/github_api/compatibility.rb +0 -23
  16. data/lib/github_api/configuration.rb +0 -96
  17. data/lib/github_api/connection.rb +0 -81
  18. data/lib/github_api/core_ext/array.rb +0 -14
  19. data/lib/github_api/core_ext/hash.rb +0 -42
  20. data/lib/github_api/error.rb +0 -35
  21. data/lib/github_api/events.rb +0 -202
  22. data/lib/github_api/gists.rb +0 -200
  23. data/lib/github_api/gists/comments.rb +0 -86
  24. data/lib/github_api/git_data.rb +0 -26
  25. data/lib/github_api/git_data/blobs.rb +0 -51
  26. data/lib/github_api/git_data/commits.rb +0 -78
  27. data/lib/github_api/git_data/references.rb +0 -113
  28. data/lib/github_api/git_data/tags.rb +0 -78
  29. data/lib/github_api/git_data/trees.rb +0 -89
  30. data/lib/github_api/issues.rb +0 -215
  31. data/lib/github_api/issues/comments.rb +0 -110
  32. data/lib/github_api/issues/events.rb +0 -50
  33. data/lib/github_api/issues/labels.rb +0 -191
  34. data/lib/github_api/issues/milestones.rb +0 -119
  35. data/lib/github_api/mime_type.rb +0 -55
  36. data/lib/github_api/orgs.rb +0 -95
  37. data/lib/github_api/orgs/members.rb +0 -120
  38. data/lib/github_api/orgs/teams.rb +0 -245
  39. data/lib/github_api/pull_requests.rb +0 -224
  40. data/lib/github_api/pull_requests/comments.rb +0 -144
  41. data/lib/github_api/repos.rb +0 -286
  42. data/lib/github_api/repos/collaborators.rb +0 -81
  43. data/lib/github_api/repos/commits.rb +0 -180
  44. data/lib/github_api/repos/downloads.rb +0 -155
  45. data/lib/github_api/repos/forks.rb +0 -48
  46. data/lib/github_api/repos/hooks.rb +0 -173
  47. data/lib/github_api/repos/keys.rb +0 -104
  48. data/lib/github_api/repos/pub_sub_hubbub.rb +0 -102
  49. data/lib/github_api/repos/watching.rb +0 -94
  50. data/lib/github_api/request.rb +0 -84
  51. data/lib/github_api/request/basic_auth.rb +0 -31
  52. data/lib/github_api/request/caching.rb +0 -33
  53. data/lib/github_api/request/oauth2.rb +0 -33
  54. data/lib/github_api/response.rb +0 -28
  55. data/lib/github_api/response/helpers.rb +0 -14
  56. data/lib/github_api/response/jsonize.rb +0 -26
  57. data/lib/github_api/response/mashify.rb +0 -24
  58. data/lib/github_api/response/raise_error.rb +0 -33
  59. data/lib/github_api/result.rb +0 -42
  60. data/lib/github_api/users.rb +0 -84
  61. data/lib/github_api/users/emails.rb +0 -49
  62. data/lib/github_api/users/followers.rb +0 -98
  63. data/lib/github_api/users/keys.rb +0 -84
  64. data/lib/github_api/version.rb +0 -12
  65. data/spec/README.rdoc +0 -22
  66. data/spec/coverage_adapter.rb +0 -14
  67. data/spec/fixtures/auths/authorization.json +0 -14
  68. data/spec/fixtures/auths/authorizations.json +0 -16
  69. data/spec/fixtures/events/events.json +0 -29
  70. data/spec/fixtures/issues/issue.json +0 -56
  71. data/spec/fixtures/issues/issues.json +0 -58
  72. data/spec/fixtures/orgs/members.json +0 -9
  73. data/spec/fixtures/orgs/org.json +0 -18
  74. data/spec/fixtures/orgs/orgs.json +0 -8
  75. data/spec/fixtures/orgs/team.json +0 -8
  76. data/spec/fixtures/orgs/team_repos.json +0 -29
  77. data/spec/fixtures/orgs/teams.json +0 -7
  78. data/spec/fixtures/repos/branches.json +0 -9
  79. data/spec/fixtures/repos/collaborators.json +0 -8
  80. data/spec/fixtures/repos/commit.json +0 -53
  81. data/spec/fixtures/repos/commit_comment.json +0 -16
  82. data/spec/fixtures/repos/commit_comments.json +0 -18
  83. data/spec/fixtures/repos/commits.json +0 -27
  84. data/spec/fixtures/repos/contributors.json +0 -8
  85. data/spec/fixtures/repos/download.json +0 -10
  86. data/spec/fixtures/repos/download_s3.json +0 -21
  87. data/spec/fixtures/repos/downloads.json +0 -12
  88. data/spec/fixtures/repos/fork.json +0 -27
  89. data/spec/fixtures/repos/forks.json +0 -29
  90. data/spec/fixtures/repos/hook.json +0 -15
  91. data/spec/fixtures/repos/hooks.json +0 -10
  92. data/spec/fixtures/repos/key.json +0 -6
  93. data/spec/fixtures/repos/keys.json +0 -8
  94. data/spec/fixtures/repos/languages.json +0 -4
  95. data/spec/fixtures/repos/repo.json +0 -90
  96. data/spec/fixtures/repos/repo_comments.json +0 -18
  97. data/spec/fixtures/repos/repos.json +0 -29
  98. data/spec/fixtures/repos/tags.json +0 -11
  99. data/spec/fixtures/repos/teams.json +0 -7
  100. data/spec/fixtures/repos/watched.json +0 -29
  101. data/spec/fixtures/repos/watchers.json +0 -8
  102. data/spec/fixtures/users/user.json +0 -32
  103. data/spec/github/api_spec.rb +0 -25
  104. data/spec/github/authorization_spec.rb +0 -176
  105. data/spec/github/authorizations_spec.rb +0 -242
  106. data/spec/github/client_spec.rb +0 -50
  107. data/spec/github/core_ext/hash_spec.rb +0 -44
  108. data/spec/github/events_spec.rb +0 -491
  109. data/spec/github/gists/comments_spec.rb +0 -5
  110. data/spec/github/gists_spec.rb +0 -5
  111. data/spec/github/git_data/blobs_spec.rb +0 -5
  112. data/spec/github/git_data/commits_spec.rb +0 -5
  113. data/spec/github/git_data/references_spec.rb +0 -5
  114. data/spec/github/git_data/tags_spec.rb +0 -5
  115. data/spec/github/git_data/trees_spec.rb +0 -5
  116. data/spec/github/git_data_spec.rb +0 -5
  117. data/spec/github/issues/comments_spec.rb +0 -5
  118. data/spec/github/issues/events_spec.rb +0 -5
  119. data/spec/github/issues/labels_spec.rb +0 -5
  120. data/spec/github/issues/milestones_spec.rb +0 -5
  121. data/spec/github/issues_spec.rb +0 -287
  122. data/spec/github/mime_type_spec.rb +0 -70
  123. data/spec/github/orgs/members_spec.rb +0 -275
  124. data/spec/github/orgs/teams_spec.rb +0 -563
  125. data/spec/github/orgs_spec.rb +0 -160
  126. data/spec/github/repos/collaborators_spec.rb +0 -169
  127. data/spec/github/repos/commits_spec.rb +0 -424
  128. data/spec/github/repos/downloads_spec.rb +0 -236
  129. data/spec/github/repos/forks_spec.rb +0 -103
  130. data/spec/github/repos/hooks_spec.rb +0 -307
  131. data/spec/github/repos/keys_spec.rb +0 -216
  132. data/spec/github/repos/pub_sub_hubbub_spec.rb +0 -83
  133. data/spec/github/repos/watching_spec.rb +0 -222
  134. data/spec/github/repos_spec.rb +0 -571
  135. data/spec/github/result_spec.rb +0 -43
  136. data/spec/github/users_spec.rb +0 -140
  137. data/spec/github_spec.rb +0 -109
  138. data/spec/spec_helper.rb +0 -86
@@ -1,78 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class GitData
5
- # This tags api only deals with tag objects - so only annotated tags, not lightweight tags.
6
- module Tags
7
-
8
- VALID_TAG_PARAM_NAMES = %w[
9
- tag
10
- message
11
- object
12
- type
13
- name
14
- email
15
- date
16
- ]
17
-
18
- VALID_TAG_PARAM_VALUES = {
19
- 'type' => %w[ blob tree commit ]
20
- }
21
-
22
- # Get a tag
23
- #
24
- # = Examples
25
- # @github = Github.new
26
- # @github.git_data.tag 'user-name', 'repo-name', 'sha'
27
- #
28
- def tag(user_name, repo_name, sha, params={})
29
- _update_user_repo_params(user_name, repo_name)
30
- _validate_user_repo_params(user, repo) unless user? && repo?
31
- _validate_presence_of sha
32
- _normalize_params_keys(params)
33
-
34
- get("/repos/#{user}/#{repo}/git/tags/#{sha}", params)
35
- end
36
-
37
- # Create a tag object
38
- # Note that creating a tag object does not create the reference that
39
- # makes a tag in Git. If you want to create an annotated tag in Git,
40
- # you have to do this call to create the tag object, and then create
41
- # the <tt>refs/tags/[tag]</tt> reference. If you want to create a lightweight tag, you simply have to create the reference - this call would be unnecessary.
42
- #
43
- # = Parameters
44
- # * <tt>:tag</tt> - String of the tag
45
- # * <tt>:message</tt> - String of the tag message
46
- # * <tt>:object</tt> - String of the SHA of the git object this is tagging
47
- # * <tt>:type</tt> - String of the type of the object we're tagging. Normally this is a <tt>commit</tt> but it can also be a <tt>tree</tt> or a <tt>blob</tt>
48
- # * tagger.name:: String of the name of the author of the tag
49
- # * tagger.email:: String of the email of the author of the tag
50
- # * tagger.date:: Timestamp of when this object was tagged
51
- #
52
- # = Examples
53
- # @github = Github.new
54
- # @github.git_data.create_tag 'user-name', 'repo-name',
55
- # "tag" => "v0.0.1",
56
- # "message" => "initial version\n",
57
- # "type": "commit",
58
- # "object": "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c",
59
- # "tagger" => {
60
- # "name" => "Scott Chacon",
61
- # "email" => "schacon@gmail.com",
62
- # "date" => "2011-06-17T14:53:3"
63
- # }
64
- #
65
- def create_tag(user_name, repo_name, params={})
66
- _update_user_repo_params(user_name, repo_name)
67
- _validate_user_repo_params(user, repo) unless user? && repo?
68
- _normalize_params_keys(params)
69
-
70
- _filter_params_keys(VALID_TAG_PARAM_NAMES, params)
71
- _validate_params_values(VALID_TAG_PARAM_VALUES, params)
72
-
73
- post("/repos/#{user}/#{repo}/git/tags", params)
74
- end
75
-
76
- end # Tags
77
- end # GitData
78
- end # Github
@@ -1,89 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class GitData
5
- module Trees
6
-
7
- VALID_TREE_PARAM_NAMES = %w[
8
- base_tree
9
- tree
10
- path
11
- mode
12
- type
13
- sha
14
- content
15
- ].freeze
16
-
17
- VALID_TREE_PARAM_VALUES = {
18
- 'mode' => %w[ 100644 100755 040000 160000 120000 ],
19
- 'type' => %w[ blob tree commit ]
20
- }
21
-
22
- # Get a tree
23
- #
24
- # = Examples
25
- # @github = Github.new
26
- # @github.git_data.tree 'user-name', 'repo-name', 'sha'
27
- # @github.git_data.tree 'user-name', 'repo-name', 'sha' do |file|
28
- # file.path
29
- # end
30
- #
31
- def tree(user_name, repo_name, sha, params={})
32
- _update_user_repo_params(user_name, repo_name)
33
- _validate_user_repo_params(user, repo) unless user? && repo?
34
- _validate_presence_of sha
35
- _normalize_params_keys(params)
36
-
37
- response = if params['recursive']
38
- params['recursive'] = 1
39
- get("/repos/#{user}/#{repo}/git/trees/#{sha}", params)
40
- else
41
- get("/repos/#{user}/#{repo}/git/trees/#{sha.to_s}", params)
42
- end
43
- return response unless block_given?
44
- response.tree.each { |el| yield el }
45
- end
46
-
47
- # Create a tree
48
- #
49
- # The tree creation API will take nested entries as well.
50
- # If both a tree and a nested path modifying that tree are specified,
51
- # it will overwrite the contents of that tree with the new path contents
52
- # and write a new tree out.
53
- #
54
- # = Parameters
55
- # * <tt>:base_tree</tt> - optional string of the SHA1 of the tree you want to update with new data
56
- # * <tt>:tree</tt> - array of hash objects(of <tt>:path</tt>, <tt>:mode</tt>, <tt>:type</tt> and <tt>sha</tt>)
57
- # * tree.path:: String of the file referenced in the tree
58
- # * tree.mode:: String of the file mode - one of <tt>100644</tt> for file(blob), <tt>100755</tt> for executable (blob), <tt>040000</tt> for subdirectory (tree), <tt>160000</tt> for submodule (commit) or <tt>120000</tt> for a blob that specifies the path of a symlink
59
- # * tree.type:: String of <tt>blob</tt>, <tt>tree</tt>, <tt>commit</tt>
60
- # * tree.sha:: String of SHA1 checksum ID of the object in the tree
61
- # * tree.content:: String of content you want this file to have - GitHub will write this blob out and use the SHA for this entry. Use either this or <tt>tree.sha</tt>
62
- #
63
- # = Examples
64
- # @github = Github.new
65
- # @github.git_data.create_tree 'user-name', 'repo-name',
66
- # "tree" => [
67
- # {
68
- # "path" => "file.rb",
69
- # "mode" => "100644",
70
- # "type" => "blob",
71
- # "sha" => "44b4fc6d56897b048c772eb4087f854f46256132"
72
- # },
73
- # ...
74
- # ]
75
- #
76
- def create_tree(user_name=nil, repo_name=nil, params={})
77
- _update_user_repo_params(user_name, repo_name)
78
- _validate_user_repo_params(user, repo) unless user? && repo?
79
- _normalize_params_keys(params)
80
-
81
- _filter_params_keys(VALID_TREE_PARAM_NAMES, params['tree'])
82
- _validate_params_values(VALID_TREE_PARAM_VALUES, params['tree'])
83
-
84
- post("/repos/#{user}/#{repo}/git/trees", params)
85
- end
86
-
87
- end # Trees
88
- end # GitData
89
- end # Github
@@ -1,215 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Issues < API
5
- extend AutoloadHelper
6
-
7
- autoload_all 'github_api/issues',
8
- :Comments => 'comments',
9
- :Events => 'events',
10
- :Labels => 'labels',
11
- :Milestones => 'milestones'
12
-
13
- include Github::Issues::Comments
14
- include Github::Issues::Events
15
- include Github::Issues::Labels
16
- include Github::Issues::Milestones
17
-
18
- VALID_ISSUE_PARAM_NAMES = %w[
19
- filter
20
- state
21
- labels
22
- sort
23
- direction
24
- since
25
- milestone
26
- assignee
27
- mentioned
28
- title
29
- body
30
- resource
31
- mime_type
32
- ].freeze
33
-
34
- VALID_ISSUE_PARAM_VALUES = {
35
- 'filter' => %w[ assigned created mentioned subscribed ],
36
- 'state' => %w[ open closed ],
37
- 'sort' => %w[ created updated comments ],
38
- 'direction' => %w[ desc asc ],
39
- 'since' => %r{\d{4}-\d{2}-\d{5}:\d{2}:\d{3}}
40
- }
41
-
42
- # Creates new Issues API
43
- def initialize(options = {})
44
- super(options)
45
- end
46
-
47
- # List your issues
48
- #
49
- # = Parameters
50
- # <tt>:filter</tt>
51
- # * <tt>assigned</tt>: Issues assigned to you (default)
52
- # * <tt>created</tt>: Issues assigned to you (default)
53
- # * <tt>mentioned</tt>: Issues assigned to you (default)
54
- # * <tt>subscribed</tt>: Issues assigned to you (default)
55
- # <tt>:state</tt> - <tt>open</tt>, <tt>closed</tt>, default: <tt>open</tt>
56
- # <tt>:labels</tt> - String list of comma separated Label names. Example: bug,ui,@high
57
- # <tt>:sort</tt> - <tt>created</tt>, <tt>updated</tt>, <tt>comments</tt>, default: <tt>created</tt>
58
- # <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
59
- # <tt>:since</tt> - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
60
- #
61
- # = Examples
62
- # @github = Github.new :oauth_token => '...'
63
- # @github.issues.issues :since => '2011-04-12312:12:121',
64
- # :filter => 'created',
65
- # :state => 'open',
66
- # :labels => "bug,ui,bla",
67
- # :sort => 'comments',
68
- # :direction => 'asc'
69
- #
70
- def issues(params={})
71
- _normalize_params_keys(params)
72
- _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
73
- _merge_mime_type(:issue, params)
74
- _validate_params_values(VALID_ISSUE_PARAM_VALUES, params)
75
-
76
- response = get("/issues", params)
77
- return response unless block_given?
78
- response.each { |el| yield el }
79
- end
80
- alias :list_issues :issues
81
-
82
- # List issues for a repository
83
- #
84
- # = Parameters
85
- # <tt>:milestone</tt>
86
- # * Integer Milestone number
87
- # * <tt>none</tt> for Issues with no Milestone.
88
- # * <tt>*</tt> for Issues with any Milestone
89
- # <tt>:state</tt> - <tt>open</tt>, <tt>closed</tt>, default: <tt>open</tt>
90
- # <tt>:assignee</tt>
91
- # * String User login
92
- # * <tt>none</tt> for Issues with no assigned User.
93
- # * <tt>*</tt> for Issues with any assigned User.
94
- # <tt>:mentioned</tt> String User login
95
- # <tt>:labels</tt> - String list of comma separated Label names. Example: bug,ui,@high
96
- # <tt>:sort</tt> - <tt>created</tt>, <tt>updated</tt>, <tt>comments</tt>, default: <tt>created</tt>
97
- # <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
98
- # <tt>:since</tt> - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
99
- # <tt></tt>, default: <tt>due_date</tt>
100
- # <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
101
- #
102
- # = Examples
103
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
104
- # @github.issues.repo_issues :milestone => 1,
105
- # :state => 'open',
106
- # :assignee => '*',
107
- # :mentioned => 'octocat',
108
- # :labels => "bug,ui,bla",
109
- # :sort => 'comments',
110
- # :direction => 'asc'
111
- #
112
- def repo_issues(user_name=nil, repo_name=nil, params={})
113
- _update_user_repo_params(user_name, repo_name)
114
- _validate_user_repo_params(user, repo) unless user? && repo?
115
-
116
- _normalize_params_keys(params)
117
- _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
118
- _merge_mime_type(:issue, params)
119
- _validate_params_values(VALID_ISSUE_PARAM_VALUES, params)
120
-
121
- response = get("/repos/#{user}/#{repo}/issues", params)
122
- return response unless block_given?
123
- response.each { |el| yield el }
124
- end
125
- alias :repository_issues :repo_issues
126
- alias :list_repo_issues :repo_issues
127
- alias :list_repository_issues :repo_issues
128
-
129
- # Get a single issue
130
- #
131
- # = Examples
132
- # @github = Github.new
133
- # @github.issues.get_issue 'user-name', 'repo-name', 'issue-id'
134
- #
135
- def issue(user_name, repo_name, issue_id, params={})
136
- _update_user_repo_params(user_name, repo_name)
137
- _validate_user_repo_params(user, repo) unless user? && repo?
138
- _validate_presence_of issue_id
139
-
140
- _normalize_params_keys(params)
141
- _merge_mime_type(:issue, params)
142
-
143
- get("/repos/#{user}/#{repo}/issues/#{issue_id}")
144
- end
145
- alias :get_issue :issue
146
-
147
- # Create an issue
148
- #
149
- # = Inputs
150
- # <tt>:title</tt> - Required string
151
- # <tt>:body</tt> - Optional string
152
- # <tt>:assignee</tt> - Optional string - Login for the user that this issue should be assigned to.
153
- # <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
154
- # <tt>:labels</tt> - Optional array of strings - Labels to associate with this issue
155
- # = Examples
156
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
157
- # @github.issues.create_issue
158
- # "title" => "Found a bug",
159
- # "body" => "I'm having a problem with this.",
160
- # "assignee" => "octocat",
161
- # "milestone" => 1,
162
- # "labels" => [
163
- # "Label1",
164
- # "Label2"
165
- # ]
166
- #
167
- def create_issue(user_name=nil, repo_name=nil, params={})
168
- _update_user_repo_params(user_name, repo_name)
169
- _validate_user_repo_params(user, repo) unless user? && repo?
170
-
171
- _normalize_params_keys(params)
172
- _merge_mime_type(:issue, params)
173
- _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
174
-
175
- raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
176
-
177
- post("/repos/#{user}/#{repo}/issues", params)
178
- end
179
-
180
- # Edit an issue
181
- #
182
- # = Inputs
183
- # <tt>:title</tt> - Optional string
184
- # <tt>:body</tt> - Optional string
185
- # <tt>:assignee</tt> - Optional string - Login for the user that this issue should be assigned to.
186
- # <tt>:state</tt> - Optional string - State of the issue:<tt>open</tt> or <tt>closed</tt>
187
- # <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
188
- # <tt>:labels</tt> - Optional array of strings - Labels to associate with this issue. Pass one or more Labels to replace the set of Labels on this Issue. Send an empty array ([]) to clear all Labels from the Issue.
189
- #
190
- # = Examples
191
- # @github = Github.new
192
- # @github.issues.create_issue 'user-name', 'repo-name', 'issue-id'
193
- # "title" => "Found a bug",
194
- # "body" => "I'm having a problem with this.",
195
- # "assignee" => "octocat",
196
- # "milestone" => 1,
197
- # "labels" => [
198
- # "Label1",
199
- # "Label2"
200
- # ]
201
- #
202
- def edit_issue(user_name, repo_name, issue_id, params={})
203
- _update_user_repo_params(user_name, repo_name)
204
- _validate_user_repo_params(user, repo) unless user? && repo?
205
- _validate_presence_of issue_id
206
-
207
- _normalize_params_keys(params)
208
- _merge_mime_type(:issue, params)
209
- _filter_params_keys(VALID_MILESTONE_INPUTS, params)
210
-
211
- patch("/repos/#{user}/#{repo}/issues/#{issue_id}", params)
212
- end
213
-
214
- end # Issues
215
- end # Github
@@ -1,110 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Github
4
- class Issues
5
- module Comments
6
-
7
- VALID_ISSUE_COMMENT_PARAM_NAME = %w[
8
- body
9
- resource
10
- mime_type
11
- ].freeze
12
-
13
- # List comments on an issue
14
- #
15
- # = Examples
16
- # @github = Github.new
17
- # @github.issues.issue_comments 'user-name', 'repo-name', 'issue-id'
18
- #
19
- def issue_comments(user_name, repo_name, issue_id, params={})
20
- _update_user_repo_params(user_name, repo_name)
21
- _validate_user_repo_params(user, repo) unless user? && repo?
22
- _validate_presence_of issue_id
23
-
24
- _normalize_params_keys(params)
25
- _merge_mime_type(:issue_comment, params)
26
-
27
- get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
28
- end
29
-
30
- # Get a single comment
31
- #
32
- # = Examples
33
- # @github = Github.new
34
- # @github.issues.issue_comment 'user-name', 'repo-name', 'comment-id'
35
- #
36
- def issue_comment(user_name, repo_name, comment_id, params={})
37
- _update_user_repo_params(user_name, repo_name)
38
- _validate_user_repo_params(user, repo) unless user? && repo?
39
- _validate_presence_of comment_id
40
-
41
- _normalize_params_keys(params)
42
- _merge_mime_type(:issue_comment, params)
43
-
44
- get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
45
- end
46
-
47
- # Create a comment
48
- #
49
- # = Inputs
50
- # <tt>:body</tt> Required string
51
- #
52
- # = Examples
53
- # @github = Github.new
54
- # @github.issues.create_issue_comment 'user-name', 'repo-name', 'issue-id',
55
- # "body" => 'a new comment'
56
- #
57
- def create_issue_comment(user_name, repo_name, issue_id, params={})
58
- _update_user_repo_params(user_name, repo_name)
59
- _validate_user_repo_params(user, repo) unless user? && repo?
60
- _validate_presence_of issue_id
61
-
62
- _normalize_params_keys(params)
63
- _merge_mime_type(:issue_comment, params)
64
- _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
65
-
66
- post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
67
- end
68
-
69
- # Edit a comment
70
- #
71
- # = Inputs
72
- # <tt>:body</tt> Required string
73
- #
74
- # = Examples
75
- # @github = Github.new
76
- # @github.issues.edit_issue_comment 'user-name', 'repo-name', 'comment-id',
77
- # "body" => 'a new comment'
78
- #
79
- def edit_issue_comment(user_name, repo_name, comment_id, params={})
80
- _update_user_repo_params(user_name, repo_name)
81
- _validate_user_repo_params(user, repo) unless user? && repo?
82
- _validate_presence_of comment_id
83
-
84
- _normalize_params_keys(params)
85
- _merge_mime_type(:issue_comment, params)
86
- _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
87
-
88
- patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
89
- end
90
-
91
- # Delete a comment
92
- #
93
- # = Examples
94
- # @github = Github.new
95
- # @github.issues.delete_issue_comment 'user-name', 'repo-name', 'comment-id'
96
- #
97
- def delete_issue_comment(user_name, repo_name, comment_id, params={})
98
- _update_user_repo_params(user_name, repo_name)
99
- _validate_user_repo_params(user, repo) unless user? && repo?
100
- _validate_presence_of comment_id
101
-
102
- _normalize_params_keys(params)
103
- _merge_mime_type(:issue_comment, params)
104
-
105
- delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
106
- end
107
-
108
- end # Comments
109
- end # Issues
110
- end # Github