octokit 1.23.0 → 1.24.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ # 1.24.0
4
+
5
+ * Missing issues methods, thanks [@andrew](https://github.com/andrew)
6
+ * Don't bypass SSL verification
7
+
8
+ View [the full changelog][1.24.0].
9
+ [1.24.0]: https://github.com/pengwynn/octokit/compare/v1.23.0...v1.24.0
10
+
3
11
  # 1.23.0
4
12
 
5
13
  * [Meta API][]
@@ -13,6 +13,6 @@
13
13
  10. Add, commit, and push your changes.
14
14
  11. [Submit a pull request.][pr]
15
15
 
16
- [fork]: http://help.github.com/fork-a-repo/
16
+ [fork]: https://help.github.com/articles/fork-a-repo
17
17
  [branch]: http://learn.github.com/p/branching.html
18
- [pr]: http://help.github.com/send-pull-requests/
18
+ [pr]: https://help.github.com/articles/using-pull-requests
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
1
+ Copyright (c) 2011-2013 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,18 @@
1
- # Octokit [![Build Status](https://secure.travis-ci.org/pengwynn/octokit.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/pengwynn/octokit.png?travis)][gemnasium] [![Code Climate](https://codeclimate.com/badge.png)][codeclimate]
2
- Simple Ruby wrapper for the GitHub v3 API.
1
+ # Octokit
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/octokit.png)][gem]
4
+ [![Build Status](https://secure.travis-ci.org/pengwynn/octokit.png?branch=master)][travis]
5
+ [![Dependency Status](https://gemnasium.com/pengwynn/octokit.png?travis)][gemnasium]
6
+ [![Code Climate](https://codeclimate.com/github/pengwynn/octokit.png)][codeclimate]
7
+ [![Coverage Status](https://coveralls.io/repos/pengwynn/octokit/badge.png?branch=master)][coveralls]
3
8
 
9
+ [gem]: https://rubygems.org/gems/octokit
4
10
  [travis]: http://travis-ci.org/pengwynn/octokit
5
11
  [gemnasium]: https://gemnasium.com/pengwynn/octokit
6
12
  [codeclimate]: https://codeclimate.com/github/pengwynn/octokit
13
+ [coveralls]: https://coveralls.io/r/pengwynn/octokit
14
+
15
+ Simple Ruby wrapper for the GitHub v3 API.
7
16
 
8
17
  ## Installation
9
18
  gem install octokit
@@ -63,6 +72,8 @@ client.follow("sferik")
63
72
 
64
73
  Alternately, you can authenticate with a [GitHub OAuth2 token][oauth].
65
74
 
75
+ [oauth]: http://developer.github.com/v3/oauth
76
+
66
77
  ```ruby
67
78
  client = Octokit::Client.new(:login => "me", :oauth_token => "oauth2token")
68
79
  client.follow("sferik")
@@ -73,6 +84,8 @@ client.follow("sferik")
73
84
  Octokit now supports [`.netrc`][netrc] files for storing your GitHub Basic Auth
74
85
  credentials. Given a `~/.netrc` like the following
75
86
 
87
+ [netrc]: http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-File.html
88
+
76
89
  ```
77
90
  machine api.github.com login pengwynn password 0ct0c4tz4ev3r!
78
91
  ```
@@ -90,6 +103,8 @@ Octokit.user # authenticates as 'pengwynn' user
90
103
  You can pass an `:accept` option value to request a particular [media
91
104
  type][media-types].
92
105
 
106
+ [media-types]: http://developer.github.com/v3/media/
107
+
93
108
  ```ruby
94
109
  Octokit.contents 'pengwynn/octokit', :path => 'README.md', :accept => 'application/vnd.github.html'
95
110
  ```
@@ -111,11 +126,14 @@ end
111
126
  ## Supported Ruby Versions
112
127
 
113
128
  This library aims to support and is [tested against][travis] the following Ruby
114
- versions:
129
+ implementations:
115
130
 
116
131
  * Ruby 1.8.7
117
132
  * Ruby 1.9.2
118
133
  * Ruby 1.9.3
134
+ * Ruby 2.0.0
135
+
136
+ If something doesn't work on one of these Ruby versions, it's a bug.
119
137
 
120
138
  This library may inadvertently work (or seem to work) on other Ruby
121
139
  implementations, however support will only be provided for the versions listed
@@ -124,9 +142,9 @@ above.
124
142
  If you would like this library to support another Ruby version, you may
125
143
  volunteer to be a maintainer. Being a maintainer entails making sure all tests
126
144
  run and pass on that implementation. When something breaks on your
127
- implementation, you will be personally responsible for providing patches in a
128
- timely fashion. If critical issues for a particular implementation exist at the
129
- time of a major release, support for that Ruby version may be dropped.
145
+ implementation, you will be responsible for providing patches in a timely
146
+ fashion. If critical issues for a particular implementation exist at the time
147
+ of a major release, support for that Ruby version may be dropped.
130
148
 
131
149
  ## Versioning
132
150
 
@@ -170,10 +188,7 @@ less-ActiveResourcey alternative.
170
188
  [octopi]: https://github.com/fcoury/octopi
171
189
 
172
190
  ## Copyright
173
- Copyright (c) 2011 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober. See
174
- [LICENSE][] for details.
191
+ Copyright (c) 2011-2013 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober.
192
+ See [LICENSE][] for details.
175
193
 
176
- [license]: https://github.com/pengwynn/octokit/blob/master/LICENSE.md
177
- [media-types]: http://developer.github.com/v3/media/
178
- [oauth]: http://developer.github.com/v3/oauth
179
- [netrc]: http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-File.html
194
+ [license]: LICENSE.md
@@ -206,14 +206,8 @@ module Octokit
206
206
  # @example
207
207
  # Octokit.commits_on('pengwynn/octokit', '2012-10-01')
208
208
  def commits_on(repo, date, sha_or_branch="master", options={})
209
- begin
210
- # defaults to 00:00:00
211
- start_date = DateTime.parse(date)
212
- # addition defaults to n days
213
- end_date = start_date + 1
214
- rescue ArgumentError
215
- raise ArgumentError, "#{date} is not a valid date"
216
- end
209
+ start_date = parse_date(date)
210
+ end_date = start_date + 1
217
211
  params = { :since => iso8601(start_date), :until => iso8601(end_date) }
218
212
  commits(repo, sha_or_branch, params.merge(options))
219
213
  end
@@ -229,20 +223,8 @@ module Octokit
229
223
  # @example
230
224
  # Octokit.commits_on('pengwynn/octokit', '2012-10-01', '2012-11-01')
231
225
  def commits_between(repo, start_date, end_date, sha_or_branch="master", options={})
232
- begin
233
- # defaults to 00:00:00
234
- # use a second var for the parsed date so error message is consistent
235
- _start_date = DateTime.parse(start_date)
236
- rescue ArgumentError
237
- raise ArgumentError, "#{start_date} is not a valid date"
238
- end
239
- begin
240
- # defaults to 00:00:00
241
- # use a second var for the parsed date so error message is consistent
242
- _end_date = DateTime.parse(end_date)
243
- rescue ArgumentError
244
- raise ArgumentError, "#{end_date} is not a valid date"
245
- end
226
+ _start_date = parse_date(start_date)
227
+ _end_date = parse_date(end_date)
246
228
  if _end_date < _start_date
247
229
  raise ArgumentError, "Start date #{start_date} does not precede #{end_date}"
248
230
  end
@@ -267,12 +249,11 @@ module Octokit
267
249
  # @param date [String] String representation of a date
268
250
  # @return [DateTime]
269
251
  def parse_date(date)
270
- begin
271
- date = DateTime.parse(date)
272
- rescue ArgumentError
273
- raise ArgumentError, "#{date} is not a valid date"
274
- end
252
+ date = DateTime.parse(date)
253
+ rescue ArgumentError
254
+ raise ArgumentError, "#{date} is not a valid date"
275
255
  end
256
+
276
257
  end
277
258
  end
278
259
  end
@@ -65,7 +65,7 @@ module Octokit
65
65
  # @param options [Hash] Gist information.
66
66
  # @option options [String] :description
67
67
  # @option options [Boolean] :public Sets gist visibility
68
- # @option options [Array<Hash>] :files Files that make up this gist. Keys
68
+ # @option options [Hash] :files Files that make up this gist. Keys
69
69
  # should be the filename, the value a Hash with a :content key with text
70
70
  # content of the Gist.
71
71
  #
@@ -75,6 +75,10 @@ module Octokit
75
75
  # @return
76
76
  # [Hashie::Mash] Newly created gist info
77
77
  # @see http://developer.github.com/v3/gists/#edit-a-gist
78
+ # @example Update a gist
79
+ # @client.edit_gist('some_id', {
80
+ # :files => {"boo.md" => {"content" => "updated stuff"}}
81
+ # })
78
82
  def edit_gist(gist, options={})
79
83
  patch "gists/#{Gist.new gist}", options
80
84
  end
@@ -8,7 +8,6 @@ module Octokit
8
8
  # @param search_term [String] The term to search for
9
9
  # @param state [String] :state (open) <tt>open</tt> or <tt>closed</tt>.
10
10
  # @return [Array] A list of issues matching the search term and state
11
- # @see http://develop.github.com/p/issues.html
12
11
  # @example Search for 'test' in the open issues for sferik/rails_admin
13
12
  # Octokit.search_issues("sferik/rails_admin", 'test', 'open')
14
13
  def search_issues(repo, search_term, state='open', options={})
@@ -43,15 +42,60 @@ module Octokit
43
42
  end
44
43
  alias :issues :list_issues
45
44
 
45
+ # List all issues across owned and member repositories for the authenticated user
46
+ #
47
+ # @param options [Hash] A customizable set of options.
48
+ # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
49
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>all</tt>.
50
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
51
+ # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
52
+ # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
53
+ # @option options [Integer] :page (1) Page number.
54
+ # @option options [String] :since Timestamp in ISO 8601
55
+ # format: YYYY-MM-DDTHH:MM:SSZ
56
+ # @return [Array] A list of issues for a repository.
57
+ # @see http://developer.github.com/v3/issues/#list-issues
58
+ # @example List issues for the authenticted user across owned and member repositories
59
+ # @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
60
+ # @client.user_issues
61
+ def user_issues(options={})
62
+ get('/user/issues', options)
63
+ end
64
+
65
+ # List all issues for a given organization for the authenticated user
66
+ #
67
+ # @param org [String] Organization GitHub username.
68
+ # @param options [Hash] A customizable set of options.
69
+ # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
70
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>all</tt>.
71
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
72
+ # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
73
+ # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
74
+ # @option options [Integer] :page (1) Page number.
75
+ # @option options [String] :since Timestamp in ISO 8601
76
+ # format: YYYY-MM-DDTHH:MM:SSZ
77
+ # @return [Array] A list of issues for a repository.
78
+ # @see http://developer.github.com/v3/issues/#list-issues
79
+ # @example List issues for the authenticted user across owned and member repositories
80
+ # @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
81
+ # @client.user_issues
82
+ def org_issues(org, options={})
83
+ get("/orgs/#{org}/issues", options)
84
+ end
85
+
46
86
  # Create an issue for a repository
47
87
  #
48
88
  # @param repo [String, Repository, Hash] A GitHub repository
49
89
  # @param title [String] A descriptive title
50
90
  # @param body [String] A concise description
91
+ # @param options [Hash] A customizable set of options.
92
+ # @option options [String] :assignee User login.
93
+ # @option options [Integer] :milestone Milestone number.
94
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
51
95
  # @return [Issue] Your newly created issue
52
- # @see http://develop.github.com/p/issues.html
96
+ # @see http://developer.github.com/v3/issues/#create-an-issue
53
97
  # @example Create a new Issues for a repository
54
- # Octokit.create_issue("sferik/rails_admin")
98
+ # Octokit.create_issue("sferik/rails_admin", 'Updated Docs', 'Added some extra links')
55
99
  def create_issue(repo, title, body, options={})
56
100
  post("repos/#{Repository.new(repo)}/issues", options.merge({:title => title, :body => body}))
57
101
  end
@@ -73,28 +117,32 @@ module Octokit
73
117
  #
74
118
  # @param repo [String, Repository, Hash] A GitHub repository
75
119
  # @param number [String] Number ID of the issue
120
+ # @param options [Hash] A customizable set of options.
121
+ # @option options [String] :assignee User login.
122
+ # @option options [Integer] :milestone Milestone number.
123
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
76
124
  # @return [Issue] The updated Issue
77
- # @see http://develop.github.com/p/issues.html
78
- # @note This implementation needs to be adjusted with switch to API v3
79
125
  # @see http://developer.github.com/v3/issues/#edit-an-issue
80
126
  # @example Close Issue #25 from pengwynn/octokit
81
127
  # Octokit.close_issue("pengwynn/octokit", "25")
82
128
  def close_issue(repo, number, options={})
83
- post("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "closed"}))
129
+ patch("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "closed"}))
84
130
  end
85
131
 
86
132
  # Reopen an issue
87
133
  #
88
134
  # @param repo [String, Repository, Hash] A GitHub repository
89
135
  # @param number [String] Number ID of the issue
136
+ # @param options [Hash] A customizable set of options.
137
+ # @option options [String] :assignee User login.
138
+ # @option options [Integer] :milestone Milestone number.
139
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
90
140
  # @return [Issue] The updated Issue
91
- # @see http://develop.github.com/p/issues.html
92
- # @note This implementation needs to be adjusted with switch to API v3
93
141
  # @see http://developer.github.com/v3/issues/#edit-an-issue
94
142
  # @example Reopen Issue #25 from pengwynn/octokit
95
143
  # Octokit.reopen_issue("pengwynn/octokit", "25")
96
144
  def reopen_issue(repo, number, options={})
97
- post("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "open"}))
145
+ patch("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "open"}))
98
146
  end
99
147
 
100
148
  # Update an issue
@@ -103,14 +151,16 @@ module Octokit
103
151
  # @param number [String] Number ID of the issue
104
152
  # @param title [String] Updated title for the issue
105
153
  # @param body [String] Updated body of the issue
154
+ # @param options [Hash] A customizable set of options.
155
+ # @option options [String] :assignee User login.
156
+ # @option options [Integer] :milestone Milestone number.
157
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
106
158
  # @return [Issue] The updated Issue
107
- # @see http://develop.github.com/p/issues.html
108
- # @note This implementation needs to be adjusted with switch to API v3
109
159
  # @see http://developer.github.com/v3/issues/#edit-an-issue
110
160
  # @example Change the title of Issue #25
111
161
  # Octokit.update_issue("pengwynn/octokit", "25", "A new title", "the same body"")
112
162
  def update_issue(repo, number, title, body, options={})
113
- post("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:title => title, :body => body}))
163
+ patch("repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:title => title, :body => body}))
114
164
  end
115
165
 
116
166
  # Get all comments attached to issues for the repository
@@ -157,11 +207,11 @@ module Octokit
157
207
  # Get a single comment attached to an issue
158
208
  #
159
209
  # @param repo [String, Repository, Hash] A GitHub repository
160
- # @param number [String] Number ID of the issue
210
+ # @param number [String] Number ID of the comment
161
211
  # @return [Comment] The specific comment in question
162
212
  # @see http://developer.github.com/v3/issues/comments/#get-a-single-comment
163
- # @example Get comments for issue #25 from pengwynn/octokit
164
- # Octokit.issue_comments("pengwynn/octokit", "25")
213
+ # @example Get comment #1194549 from an issue on pengwynn/octokit
214
+ # Octokit.issue_comments("pengwynn/octokit", 1194549)
165
215
  def issue_comment(repo, number, options={})
166
216
  get("repos/#{Repository.new(repo)}/issues/comments/#{number}", options)
167
217
  end
@@ -186,10 +236,10 @@ module Octokit
186
236
  # @param comment [String] Body of the comment which will replace the existing body.
187
237
  # @return [Comment] A JSON encoded Comment
188
238
  # @see http://developer.github.com/v3/issues/comments/#edit-a-comment
189
- # @example Update the comment "I've started this on my 25-issue-comments-v3 fork" on Issue #25 on pengwynn/octokit
190
- # Octokit.update_comment("pengwynn/octokit", 25, "Almost to v1, added this on my fork")
239
+ # @example Update the comment #1194549 with body "I've started this on my 25-issue-comments-v3 fork" on an issue on pengwynn/octokit
240
+ # Octokit.update_comment("pengwynn/octokit", 1194549, "Almost to v1, added this on my fork")
191
241
  def update_comment(repo, number, comment, options={})
192
- post("repos/#{Repository.new(repo)}/issues/comments/#{number}", options.merge({:body => comment}))
242
+ patch("repos/#{Repository.new(repo)}/issues/comments/#{number}", options.merge({:body => comment}))
193
243
  end
194
244
 
195
245
  # Delete a single comment
@@ -198,20 +248,19 @@ module Octokit
198
248
  # @param number [Integer] Comment number
199
249
  # @return [Boolean] Success
200
250
  # @see http://developer.github.com/v3/issues/comments/#delete-a-comment
201
- # @example Delete the comment "I've started this on my 25-issue-comments-v3 fork" on Issue #25 on pengwynn/octokit
251
+ # @example Delete the comment #1194549 on an issue on pengwynn/octokit
202
252
  # Octokit.delete_comment("pengwynn/octokit", 1194549)
203
253
  def delete_comment(repo, number, options={})
204
254
  boolean_from_response(:delete, "repos/#{Repository.new(repo)}/issues/comments/#{number}", options)
205
255
  end
206
256
 
207
-
208
257
  # List events for an Issue
209
258
  #
210
259
  # @param repo [String, Repository, Hash] A GitHub repository
211
260
  # @param number [Integer] Issue number
212
261
  #
213
262
  # @return [Array] Array of events for that issue
214
- # @see http://developer.github.com/v3/issues/events/
263
+ # @see http://developer.github.com/v3/issues/events/#list-events-for-an-issue
215
264
  # @example List all issues events for issue #38 on pengwynn/octokit
216
265
  # Octokit.issue_events("pengwynn/octokit", 38)
217
266
  def issue_events(repo, number, options={})
@@ -52,7 +52,7 @@ module Octokit
52
52
  # @example Update the label "Version 1.0" with new color "#cceeaa"
53
53
  # Octokit.update_label("pengwynn/octokit", "Version 1.0", {:color => "cceeaa"})
54
54
  def update_label(repo, label, options={})
55
- post("repos/#{Repository.new(repo)}/labels/#{CGI.escape(label)}", options)
55
+ patch("repos/#{Repository.new(repo)}/labels/#{CGI.escape(label)}", options)
56
56
  end
57
57
 
58
58
  # Delete a label from a repository.
@@ -65,7 +65,7 @@ module Octokit
65
65
  # @example Update a milestone for a repository
66
66
  # Octokit.update_milestone("pengwynn/octokit", 1, {:description => 'Add support for v3 of Github API'})
67
67
  def update_milestone(repository, number, options={})
68
- post("repos/#{Repository.new(repository)}/milestones/#{number}", options)
68
+ patch("repos/#{Repository.new(repository)}/milestones/#{number}", options)
69
69
  end
70
70
  alias :edit_milestone :update_milestone
71
71
 
@@ -81,11 +81,9 @@ module Octokit
81
81
  # @example
82
82
  # @client.mark_notifications_as_read
83
83
  def mark_notifications_as_read(options={})
84
- begin
85
- request(:put, "notifications", options).status == 205
86
- rescue
87
- false
88
- end
84
+ request(:put, "notifications", options).status == 205
85
+ rescue Octokit::Error
86
+ false
89
87
  end
90
88
 
91
89
  # Mark notifications from a specific repository as read
@@ -110,11 +108,9 @@ module Octokit
110
108
  # @example
111
109
  # @client.mark_notifications_as_read("pengwynn/octokit")
112
110
  def mark_repository_notifications_as_read(repo, options={})
113
- begin
114
- request(:put, "repos/#{Repository.new repo}/notifications", options).status == 205
115
- rescue
116
- false
117
- end
111
+ request(:put, "repos/#{Repository.new repo}/notifications", options).status == 205
112
+ rescue Octokit::Error
113
+ false
118
114
  end
119
115
  alias :mark_repo_notifications_as_read :mark_repository_notifications_as_read
120
116
 
@@ -149,11 +145,9 @@ module Octokit
149
145
  # @example
150
146
  # @client.mark_thread_as_ready(1, :read => false)
151
147
  def mark_thread_as_read(thread_id, options={})
152
- begin
153
- request(:patch, "notifications/threads/#{thread_id}", options).status == 205
154
- rescue
155
- false
156
- end
148
+ request(:patch, "notifications/threads/#{thread_id}", options).status == 205
149
+ rescue Octokit::Error
150
+ false
157
151
  end
158
152
 
159
153
  # Get thread subscription
@@ -90,7 +90,7 @@ module Octokit
90
90
  :state => state
91
91
  })
92
92
  options.reject! { |_, value| value.nil? }
93
- post("repos/#{Repository.new repo}/pulls/#{id}", options)
93
+ patch("repos/#{Repository.new repo}/pulls/#{id}", options)
94
94
  end
95
95
 
96
96