github_api 0.4.11 → 0.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.md +76 -72
  2. data/features/cassettes/gists/starred.yml +48 -0
  3. data/features/cassettes/pagination/repos/commits/list.yml +193 -0
  4. data/features/cassettes/pagination/repos/commits/next.yml +183 -0
  5. data/features/cassettes/pagination/repos/diff/next.yml +45 -0
  6. data/features/cassettes/pagination/repos/list.yml +176 -0
  7. data/features/cassettes/pagination/repos/list/next.yml +222 -0
  8. data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
  9. data/features/cassettes/repos/list.yml +92 -0
  10. data/features/error_codes.feature +1 -1
  11. data/features/gists.feature +12 -3
  12. data/features/gists/comments.feature +3 -3
  13. data/features/github_api.feature +13 -2
  14. data/features/pagination.feature +40 -39
  15. data/features/repos.feature +2 -2
  16. data/features/step_definitions/common_steps.rb +12 -0
  17. data/features/step_definitions/github_api_steps.rb +12 -1
  18. data/lib/github_api.rb +1 -1
  19. data/lib/github_api/api.rb +4 -2
  20. data/lib/github_api/api_factory.rb +11 -5
  21. data/lib/github_api/authorizations.rb +23 -32
  22. data/lib/github_api/client.rb +1 -0
  23. data/lib/github_api/events.rb +38 -38
  24. data/lib/github_api/filter.rb +1 -1
  25. data/lib/github_api/gists.rb +47 -42
  26. data/lib/github_api/gists/comments.rb +77 -84
  27. data/lib/github_api/git_data.rb +25 -6
  28. data/lib/github_api/git_data/blobs.rb +48 -45
  29. data/lib/github_api/git_data/commits.rb +76 -73
  30. data/lib/github_api/git_data/references.rb +137 -118
  31. data/lib/github_api/git_data/tags.rb +74 -70
  32. data/lib/github_api/git_data/trees.rb +88 -85
  33. data/lib/github_api/issues.rb +43 -31
  34. data/lib/github_api/issues/comments.rb +116 -119
  35. data/lib/github_api/issues/events.rb +20 -19
  36. data/lib/github_api/issues/labels.rb +200 -197
  37. data/lib/github_api/issues/milestones.rb +137 -134
  38. data/lib/github_api/orgs.rb +27 -23
  39. data/lib/github_api/orgs/members.rb +105 -108
  40. data/lib/github_api/orgs/teams.rb +236 -237
  41. data/lib/github_api/paged_request.rb +1 -1
  42. data/lib/github_api/pull_requests.rb +40 -42
  43. data/lib/github_api/pull_requests/comments.rb +140 -143
  44. data/lib/github_api/repos.rb +101 -67
  45. data/lib/github_api/repos/collaborators.rb +64 -68
  46. data/lib/github_api/repos/commits.rb +50 -39
  47. data/lib/github_api/repos/downloads.rb +107 -110
  48. data/lib/github_api/repos/forks.rb +38 -39
  49. data/lib/github_api/repos/hooks.rb +161 -167
  50. data/lib/github_api/repos/keys.rb +86 -86
  51. data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
  52. data/lib/github_api/repos/watching.rb +80 -82
  53. data/lib/github_api/request.rb +5 -9
  54. data/lib/github_api/users.rb +26 -16
  55. data/lib/github_api/users/emails.rb +47 -47
  56. data/lib/github_api/users/followers.rb +85 -86
  57. data/lib/github_api/users/keys.rb +73 -75
  58. data/lib/github_api/validations.rb +25 -0
  59. data/lib/github_api/validations/format.rb +23 -0
  60. data/lib/github_api/validations/presence.rb +25 -0
  61. data/lib/github_api/validations/required.rb +21 -0
  62. data/lib/github_api/validations/token.rb +41 -0
  63. data/lib/github_api/version.rb +3 -3
  64. data/spec/fixtures/repos/commit_comparison.json +112 -0
  65. data/spec/github/api_factory_spec.rb +17 -1
  66. data/spec/github/authorizations_spec.rb +36 -34
  67. data/spec/github/gists/comments_spec.rb +39 -45
  68. data/spec/github/gists_spec.rb +50 -53
  69. data/spec/github/git_data/blobs_spec.rb +27 -20
  70. data/spec/github/git_data/commits_spec.rb +20 -19
  71. data/spec/github/git_data/references_spec.rb +83 -46
  72. data/spec/github/git_data/tags_spec.rb +16 -15
  73. data/spec/github/git_data/trees_spec.rb +20 -19
  74. data/spec/github/git_data_spec.rb +10 -1
  75. data/spec/github/issues/comments_spec.rb +78 -68
  76. data/spec/github/issues/events_spec.rb +42 -34
  77. data/spec/github/issues/labels_spec.rb +89 -101
  78. data/spec/github/issues/milestones_spec.rb +76 -54
  79. data/spec/github/issues_spec.rb +53 -57
  80. data/spec/github/orgs/members_spec.rb +64 -49
  81. data/spec/github/orgs/teams_spec.rb +112 -101
  82. data/spec/github/orgs_spec.rb +41 -31
  83. data/spec/github/paged_request_spec.rb +6 -5
  84. data/spec/github/pull_requests/comments_spec.rb +39 -44
  85. data/spec/github/pull_requests_spec.rb +32 -48
  86. data/spec/github/repos/collaborators_spec.rb +40 -29
  87. data/spec/github/repos/commits_spec.rb +108 -64
  88. data/spec/github/repos/downloads_spec.rb +46 -45
  89. data/spec/github/repos/forks_spec.rb +23 -24
  90. data/spec/github/repos/hooks_spec.rb +69 -71
  91. data/spec/github/repos/keys_spec.rb +39 -34
  92. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
  93. data/spec/github/repos/watching_spec.rb +31 -33
  94. data/spec/github/repos_spec.rb +74 -83
  95. data/spec/github/request_spec.rb +31 -2
  96. data/spec/github/users/emails_spec.rb +19 -17
  97. data/spec/github/users/followers_spec.rb +30 -28
  98. data/spec/github/users/keys_spec.rb +37 -33
  99. data/spec/github/users_spec.rb +124 -125
  100. data/spec/github/validations/format_spec.rb +42 -0
  101. data/spec/github/validations/presence_spec.rb +18 -0
  102. data/spec/github/validations/required_spec.rb +28 -0
  103. data/spec/github/validations/token_spec.rb +19 -0
  104. data/spec/github/validations_spec.rb +23 -0
  105. metadata +33 -10
  106. data/features/cassettes/pagination/repos.yml +0 -177
  107. data/features/cassettes/pagination/repos/next.yml +0 -177
  108. data/lib/github_api/validation.rb +0 -53
  109. data/spec/github/validation_spec.rb +0 -62
@@ -10,11 +10,6 @@ module Github
10
10
  :Labels => 'labels',
11
11
  :Milestones => 'milestones'
12
12
 
13
- include Github::Issues::Comments
14
- include Github::Issues::Events
15
- include Github::Issues::Labels
16
- include Github::Issues::Milestones
17
-
18
13
  VALID_ISSUE_PARAM_NAMES = %w[
19
14
  filter
20
15
  state
@@ -44,6 +39,26 @@ module Github
44
39
  super(options)
45
40
  end
46
41
 
42
+ # Access to Issues::Comments API
43
+ def comments
44
+ @comments ||= ApiFactory.new 'Issues::Comments'
45
+ end
46
+
47
+ # Access to Issues::Events API
48
+ def events
49
+ @events ||= ApiFactory.new 'Issues::Events'
50
+ end
51
+
52
+ # Access to Issues::Comments API
53
+ def labels
54
+ @labels ||= ApiFactory.new 'Issues::Labels'
55
+ end
56
+
57
+ # Access to Issues::Comments API
58
+ def milestones
59
+ @milestones ||= ApiFactory.new 'Issues::Milestones'
60
+ end
61
+
47
62
  # List your issues
48
63
  #
49
64
  # = Parameters
@@ -59,25 +74,25 @@ module Github
59
74
  # <tt>:since</tt> - Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
60
75
  #
61
76
  # = Examples
62
- # @github = Github.new :oauth_token => '...'
63
- # @github.issues.issues :since => '2011-04-12312:12:121',
77
+ # github = Github.new :oauth_token => '...'
78
+ # github.issues.list :since => '2011-04-12312:12:121',
64
79
  # :filter => 'created',
65
80
  # :state => 'open',
66
81
  # :labels => "bug,ui,bla",
67
82
  # :sort => 'comments',
68
83
  # :direction => 'asc'
69
84
  #
70
- def issues(params={})
85
+ def list(params={})
71
86
  _normalize_params_keys(params)
72
87
  _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
73
88
  # _merge_mime_type(:issue, params)
74
89
  _validate_params_values(VALID_ISSUE_PARAM_VALUES, params)
75
90
 
76
- response = get("/issues", params)
91
+ response = get_request("/issues", params)
77
92
  return response unless block_given?
78
93
  response.each { |el| yield el }
79
94
  end
80
- alias :list_issues :issues
95
+ alias :all :list
81
96
 
82
97
  # List issues for a repository
83
98
  #
@@ -100,8 +115,8 @@ module Github
100
115
  # <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
101
116
  #
102
117
  # = Examples
103
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
104
- # @github.issues.repo_issues :milestone => 1,
118
+ # github = Github.new :user => 'user-name', :repo => 'repo-name'
119
+ # github.issues.list_repo :milestone => 1,
105
120
  # :state => 'open',
106
121
  # :assignee => '*',
107
122
  # :mentioned => 'octocat',
@@ -109,7 +124,7 @@ module Github
109
124
  # :sort => 'comments',
110
125
  # :direction => 'asc'
111
126
  #
112
- def repo_issues(user_name=nil, repo_name=nil, params={})
127
+ def list_repo(user_name=nil, repo_name=nil, params={})
113
128
  _update_user_repo_params(user_name, repo_name)
114
129
  _validate_user_repo_params(user, repo) unless user? && repo?
115
130
 
@@ -118,21 +133,19 @@ module Github
118
133
  # _merge_mime_type(:issue, params)
119
134
  _validate_params_values(VALID_ISSUE_PARAM_VALUES, params)
120
135
 
121
- response = get("/repos/#{user}/#{repo}/issues", params)
136
+ response = get_request("/repos/#{user}/#{repo}/issues", params)
122
137
  return response unless block_given?
123
138
  response.each { |el| yield el }
124
139
  end
125
- alias :repository_issues :repo_issues
126
- alias :list_repo_issues :repo_issues
127
- alias :list_repository_issues :repo_issues
140
+ alias :list_repository :list_repo
128
141
 
129
142
  # Get a single issue
130
143
  #
131
144
  # = Examples
132
- # @github = Github.new
133
- # @github.issues.get_issue 'user-name', 'repo-name', 'issue-id'
145
+ # github = Github.new
146
+ # github.issues.find 'user-name', 'repo-name', 'issue-id'
134
147
  #
135
- def issue(user_name, repo_name, issue_id, params={})
148
+ def find(user_name, repo_name, issue_id, params={})
136
149
  _update_user_repo_params(user_name, repo_name)
137
150
  _validate_user_repo_params(user, repo) unless user? && repo?
138
151
  _validate_presence_of issue_id
@@ -140,9 +153,8 @@ module Github
140
153
  _normalize_params_keys(params)
141
154
  # _merge_mime_type(:issue, params)
142
155
 
143
- get("/repos/#{user}/#{repo}/issues/#{issue_id}", params)
156
+ get_request("/repos/#{user}/#{repo}/issues/#{issue_id}", params)
144
157
  end
145
- alias :get_issue :issue
146
158
 
147
159
  # Create an issue
148
160
  #
@@ -153,8 +165,8 @@ module Github
153
165
  # <tt>:milestone</tt> - Optional number - Milestone to associate this issue with
154
166
  # <tt>:labels</tt> - Optional array of strings - Labels to associate with this issue
155
167
  # = Examples
156
- # @github = Github.new :user => 'user-name', :repo => 'repo-name'
157
- # @github.issues.create_issue
168
+ # github = Github.new :user => 'user-name', :repo => 'repo-name'
169
+ # github.issues.create
158
170
  # "title" => "Found a bug",
159
171
  # "body" => "I'm having a problem with this.",
160
172
  # "assignee" => "octocat",
@@ -164,7 +176,7 @@ module Github
164
176
  # "Label2"
165
177
  # ]
166
178
  #
167
- def create_issue(user_name=nil, repo_name=nil, params={})
179
+ def create(user_name, repo_name, params={})
168
180
  _update_user_repo_params(user_name, repo_name)
169
181
  _validate_user_repo_params(user, repo) unless user? && repo?
170
182
 
@@ -173,7 +185,7 @@ module Github
173
185
  _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
174
186
  _validate_inputs(%w[ title ], params)
175
187
 
176
- post("/repos/#{user}/#{repo}/issues", params)
188
+ post_request("/repos/#{user}/#{repo}/issues", params)
177
189
  end
178
190
 
179
191
  # Edit an issue
@@ -187,8 +199,8 @@ module Github
187
199
  # <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.
188
200
  #
189
201
  # = Examples
190
- # @github = Github.new
191
- # @github.issues.create_issue 'user-name', 'repo-name', 'issue-id'
202
+ # github = Github.new
203
+ # github.issues.edit 'user-name', 'repo-name', 'issue-id'
192
204
  # "title" => "Found a bug",
193
205
  # "body" => "I'm having a problem with this.",
194
206
  # "assignee" => "octocat",
@@ -198,16 +210,16 @@ module Github
198
210
  # "Label2"
199
211
  # ]
200
212
  #
201
- def edit_issue(user_name, repo_name, issue_id, params={})
213
+ def edit(user_name, repo_name, issue_id, params={})
202
214
  _update_user_repo_params(user_name, repo_name)
203
215
  _validate_user_repo_params(user, repo) unless user? && repo?
204
216
  _validate_presence_of issue_id
205
217
 
206
218
  _normalize_params_keys(params)
207
219
  # _merge_mime_type(:issue, params)
208
- _filter_params_keys(VALID_MILESTONE_INPUTS, params)
220
+ _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
209
221
 
210
- patch("/repos/#{user}/#{repo}/issues/#{issue_id}", params)
222
+ patch_request("/repos/#{user}/#{repo}/issues/#{issue_id}", params)
211
223
  end
212
224
 
213
225
  end # Issues
@@ -1,123 +1,120 @@
1
1
  # encoding: utf-8
2
2
 
3
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.comments 'user-name', 'repo-name', 'issue-id'
18
- # @github.issues.comments 'user-name', 'repo-name', 'issue-id' { |com| ... }
19
- #
20
- def comments(user_name, repo_name, issue_id, params={})
21
- _update_user_repo_params(user_name, repo_name)
22
- _validate_user_repo_params(user, repo) unless user? && repo?
23
- _validate_presence_of issue_id
24
-
25
- _normalize_params_keys(params)
26
- # _merge_mime_type(:issue_comment, params)
27
-
28
- response = get("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
29
- return response unless block_given?
30
- response.each { |el| yield el }
31
- end
32
- alias :issue_comments :comments
33
- alias :list_comments :comments
34
- alias :list_issue_comments :comments
35
-
36
- # Get a single comment
37
- #
38
- # = Examples
39
- # @github = Github.new
40
- # @github.issues.comment 'user-name', 'repo-name', 'comment-id'
41
- #
42
- def comment(user_name, repo_name, comment_id, params={})
43
- _update_user_repo_params(user_name, repo_name)
44
- _validate_user_repo_params(user, repo) unless user? && repo?
45
- _validate_presence_of comment_id
46
-
47
- _normalize_params_keys(params)
48
- # _merge_mime_type(:issue_comment, params)
49
-
50
- get("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
51
- end
52
- alias :issue_comment :comment
53
- alias :get_comment :comment
54
-
55
- # Create a comment
56
- #
57
- # = Inputs
58
- # <tt>:body</tt> Required string
59
- #
60
- # = Examples
61
- # @github = Github.new
62
- # @github.issues.create_comment 'user-name', 'repo-name', 'issue-id',
63
- # "body" => 'a new comment'
64
- #
65
- def create_comment(user_name, repo_name, issue_id, params={})
66
- _update_user_repo_params(user_name, repo_name)
67
- _validate_user_repo_params(user, repo) unless user? && repo?
68
- _validate_presence_of issue_id
69
-
70
- _normalize_params_keys(params)
71
- # _merge_mime_type(:issue_comment, params)
72
- _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
73
- _validate_inputs(%w[ body ], params)
74
-
75
- post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
76
- end
77
- alias :create_issue_comment :create_comment
78
-
79
- # Edit a comment
80
- #
81
- # = Inputs
82
- # <tt>:body</tt> Required string
83
- #
84
- # = Examples
85
- # @github = Github.new
86
- # @github.issues.edit_comment 'user-name', 'repo-name', 'comment-id',
87
- # "body" => 'a new comment'
88
- #
89
- def edit_comment(user_name, repo_name, comment_id, params={})
90
- _update_user_repo_params(user_name, repo_name)
91
- _validate_user_repo_params(user, repo) unless user? && repo?
92
- _validate_presence_of comment_id
93
-
94
- _normalize_params_keys(params)
95
- # _merge_mime_type(:issue_comment, params)
96
- _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
97
- _validate_inputs(%w[ body ], params)
98
-
99
- patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
100
- end
101
- alias :edit_issue_comment :edit_comment
102
-
103
- # Delete a comment
104
- #
105
- # = Examples
106
- # @github = Github.new
107
- # @github.issues.delete_comment 'user-name', 'repo-name', 'comment-id'
108
- #
109
- def delete_comment(user_name, repo_name, comment_id, params={})
110
- _update_user_repo_params(user_name, repo_name)
111
- _validate_user_repo_params(user, repo) unless user? && repo?
112
- _validate_presence_of comment_id
113
-
114
- _normalize_params_keys(params)
115
- # _merge_mime_type(:issue_comment, params)
116
-
117
- delete("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
118
- end
119
- alias :delete_issue_comment :delete_comment
120
-
121
- end # Comments
122
- end # Issues
4
+ class Issues::Comments < API
5
+
6
+ VALID_ISSUE_COMMENT_PARAM_NAME = %w[
7
+ body
8
+ resource
9
+ mime_type
10
+ ].freeze
11
+
12
+ # Creates new Issues::Comments API
13
+ def initialize(options = {})
14
+ super(options)
15
+ end
16
+
17
+ # List comments on an issue
18
+ #
19
+ # = Examples
20
+ # github = Github.new
21
+ # github.issues.comments.all 'user-name', 'repo-name', 'issue-id'
22
+ # github.issues.comments.all 'user-name', 'repo-name', 'issue-id' {|com| .. }
23
+ #
24
+ def list(user_name, repo_name, issue_id, params={})
25
+ _update_user_repo_params(user_name, repo_name)
26
+ _validate_user_repo_params(user, repo) unless user? && repo?
27
+ _validate_presence_of issue_id
28
+
29
+ _normalize_params_keys(params)
30
+ # _merge_mime_type(:issue_comment, params)
31
+
32
+ response = get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
33
+ return response unless block_given?
34
+ response.each { |el| yield el }
35
+ end
36
+ alias :all :list
37
+
38
+ # Get a single comment
39
+ #
40
+ # = Examples
41
+ # github = Github.new
42
+ # github.issues.comments.find 'user-name', 'repo-name', 'comment-id'
43
+ #
44
+ def get(user_name, repo_name, comment_id, params={})
45
+ _update_user_repo_params(user_name, repo_name)
46
+ _validate_user_repo_params(user, repo) unless user? && repo?
47
+ _validate_presence_of comment_id
48
+
49
+ _normalize_params_keys(params)
50
+ # _merge_mime_type(:issue_comment, params)
51
+
52
+ get_request("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
53
+ end
54
+ alias :find :get
55
+
56
+ # Create a comment
57
+ #
58
+ # = Inputs
59
+ # <tt>:body</tt> Required string
60
+ #
61
+ # = Examples
62
+ # github = Github.new
63
+ # github.issues.comments.create 'user-name', 'repo-name', 'issue-id',
64
+ # "body" => 'a new comment'
65
+ #
66
+ def create(user_name, repo_name, issue_id, params={})
67
+ _update_user_repo_params(user_name, repo_name)
68
+ _validate_user_repo_params(user, repo) unless user? && repo?
69
+ _validate_presence_of issue_id
70
+
71
+ _normalize_params_keys(params)
72
+ # _merge_mime_type(:issue_comment, params)
73
+ _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
74
+ _validate_inputs(%w[ body ], params)
75
+
76
+ post_request("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
77
+ end
78
+
79
+ # Edit a comment
80
+ #
81
+ # = Inputs
82
+ # <tt>:body</tt> Required string
83
+ #
84
+ # = Examples
85
+ # github = Github.new
86
+ # github.issues.comments.edit 'user-name', 'repo-name', 'comment-id',
87
+ # "body" => 'a new comment'
88
+ #
89
+ def edit(user_name, repo_name, comment_id, params={})
90
+ _update_user_repo_params(user_name, repo_name)
91
+ _validate_user_repo_params(user, repo) unless user? && repo?
92
+ _validate_presence_of comment_id
93
+
94
+ _normalize_params_keys(params)
95
+ # _merge_mime_type(:issue_comment, params)
96
+ _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
97
+ _validate_inputs(%w[ body ], params)
98
+
99
+ patch_request("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
100
+ end
101
+
102
+ # Delete a comment
103
+ #
104
+ # = Examples
105
+ # github = Github.new
106
+ # github.issues.comments.delete 'user-name', 'repo-name', 'comment-id'
107
+ #
108
+ def delete(user_name, repo_name, comment_id, params={})
109
+ _update_user_repo_params(user_name, repo_name)
110
+ _validate_user_repo_params(user, repo) unless user? && repo?
111
+ _validate_presence_of comment_id
112
+
113
+ _normalize_params_keys(params)
114
+ # _merge_mime_type(:issue_comment, params)
115
+
116
+ delete_request("/repos/#{user}/#{repo}/issues/comments/#{comment_id}", params)
117
+ end
118
+
119
+ end # Issues::Comments
123
120
  end # Github
@@ -1,54 +1,55 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
- class Issues
5
- module Events
4
+ class Issues::Events < API
5
+
6
+ # Creates new Issues::Events API
7
+ def initialize(options = {})
8
+ super(options)
9
+ end
6
10
 
7
11
  # List events for an issue
8
12
  #
9
13
  # = Examples
10
- # @github = Github.new
11
- # @github.issues.events 'user-name', 'repo-name', 'issue-id'
14
+ # github = Github.new
15
+ # github.issues.events.list 'user-name', 'repo-name', 'issue-id'
12
16
  #
13
17
  # List events for a repository
14
18
  #
15
19
  # = Examples
16
- # @github = Github.new
17
- # @github.issues.events 'user-name', 'repo-name'
20
+ # github = Github.new
21
+ # github.issues.events.list 'user-name', 'repo-name'
18
22
  #
19
- def events(user_name, repo_name, issue_id=nil, params={})
23
+ def list(user_name, repo_name, issue_id=nil, params={})
20
24
  _update_user_repo_params(user_name, repo_name)
21
25
  _validate_user_repo_params(user, repo) unless user? && repo?
22
26
  _normalize_params_keys(params)
23
27
 
24
28
  response = if issue_id
25
- get("/repos/#{user}/#{repo}/issues/#{issue_id}/events", params)
29
+ get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/events", params)
26
30
  else
27
- get("/repos/#{user}/#{repo}/issues/events", params)
31
+ get_request("/repos/#{user}/#{repo}/issues/events", params)
28
32
  end
29
33
  return response unless block_given?
30
34
  response.each { |el| yield el }
31
35
  end
32
- alias :list_events :events
33
- alias :issue_events :events
34
- alias :repo_events :events
36
+ alias :all :list
35
37
 
36
38
  # Get a single event
37
39
  #
38
40
  # = Examples
39
- # @github = Github.new
40
- # @github.issues.event 'user-name', 'repo-name', 'event-id'
41
+ # github = Github.new
42
+ # github.issues.events.get 'user-name', 'repo-name', 'event-id'
41
43
  #
42
- def event(user_name, repo_name, event_id, params={})
44
+ def get(user_name, repo_name, event_id, params={})
43
45
  _update_user_repo_params(user_name, repo_name)
44
46
  _validate_user_repo_params(user, repo) unless user? && repo?
45
47
  _validate_presence_of event_id
46
48
  _normalize_params_keys(params)
47
49
 
48
- get("/repos/#{user}/#{repo}/issues/events/#{event_id}")
50
+ get_request("/repos/#{user}/#{repo}/issues/events/#{event_id}")
49
51
  end
50
- alias :get_event :event
52
+ alias :find :get
51
53
 
52
- end # Events
53
- end # Issues
54
+ end # Issues::Events
54
55
  end # Github