octokit 0.6.4 → 0.6.5

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 (58) hide show
  1. data/.travis.yml +2 -2
  2. data/CHANGELOG.md +1 -0
  3. data/README.md +46 -24
  4. data/Rakefile +0 -0
  5. data/lib/octokit/authentication.rb +1 -3
  6. data/lib/octokit/client.rb +3 -1
  7. data/lib/octokit/client/commits.rb +3 -2
  8. data/lib/octokit/client/issues.rb +11 -62
  9. data/lib/octokit/client/labels.rb +153 -0
  10. data/lib/octokit/client/milestones.rb +1 -1
  11. data/lib/octokit/client/pub_sub_hubbub/service_hooks.rb +2 -4
  12. data/lib/octokit/client/repositories.rb +41 -31
  13. data/lib/octokit/client/timelines.rb +1 -2
  14. data/lib/octokit/configuration.rb +5 -12
  15. data/lib/octokit/repository.rb +1 -1
  16. data/lib/octokit/version.rb +1 -1
  17. data/octokit.gemspec +16 -25
  18. data/spec/fixtures/v3/branches.json +16 -0
  19. data/spec/fixtures/v3/collaborators.json +62 -0
  20. data/spec/fixtures/v3/commit.json +1 -0
  21. data/spec/fixtures/v3/commits.json +1 -0
  22. data/spec/fixtures/v3/contributors.json +891 -0
  23. data/spec/fixtures/v3/forks.json +872 -0
  24. data/spec/fixtures/v3/labels.json +3 -3
  25. data/spec/fixtures/v3/languages.json +5 -0
  26. data/spec/fixtures/v3/public_key.json +5 -0
  27. data/spec/fixtures/v3/public_keys.json +7 -0
  28. data/spec/fixtures/v3/repositories.json +872 -0
  29. data/spec/fixtures/v3/repository.json +34 -0
  30. data/spec/fixtures/v3/tags.json +173 -0
  31. data/spec/fixtures/v3/teams.json +12 -0
  32. data/spec/fixtures/v3/watchers.json +182 -0
  33. data/spec/helper.rb +3 -3
  34. data/spec/octokit/client/commits_spec.rb +5 -5
  35. data/spec/octokit/client/issues_spec.rb +14 -61
  36. data/spec/octokit/client/labels_spec.rb +152 -0
  37. data/spec/octokit/client/milestones_spec.rb +6 -6
  38. data/spec/octokit/client/objects_spec.rb +6 -6
  39. data/spec/octokit/client/organizations_spec.rb +19 -19
  40. data/spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb +2 -2
  41. data/spec/octokit/client/pub_sub_hubbub_spec.rb +3 -3
  42. data/spec/octokit/client/pulls_spec.rb +4 -4
  43. data/spec/octokit/client/repositories_spec.rb +81 -80
  44. data/spec/octokit/client/timelines_spec.rb +3 -3
  45. data/spec/octokit/client/users_spec.rb +21 -21
  46. data/spec/octokit/client_spec.rb +1 -11
  47. data/spec/octokit_spec.rb +1 -1
  48. metadata +125 -215
  49. data/.autotest +0 -1
  50. data/spec/fixtures/v2/branches.json +0 -1
  51. data/spec/fixtures/v2/collaborators.json +0 -1
  52. data/spec/fixtures/v2/commit.json +0 -1
  53. data/spec/fixtures/v2/commits.json +0 -1
  54. data/spec/fixtures/v2/contributors.json +0 -1
  55. data/spec/fixtures/v2/languages.json +0 -1
  56. data/spec/fixtures/v2/network.json +0 -1
  57. data/spec/fixtures/v2/repository.json +0 -1
  58. data/spec/fixtures/v2/watchers.json +0 -1
@@ -1,8 +1,8 @@
1
1
  rvm:
2
2
  - 1.8.7
3
- - 1.9.1
4
3
  - 1.9.2
4
+ - 1.9.3
5
5
  - jruby
6
6
  - rbx
7
+ - rbx-2.0
7
8
  - ree
8
- - ruby-head
@@ -1,5 +1,6 @@
1
1
  # CHANGELOG
2
2
 
3
+ * [0.6.4 - July 2, 2011](https://github.com/pengwynn/octokit/compare/v0.6.3...v0.6.4)
3
4
  * [0.6.3 - May 5, 2011](https://github.com/pengwynn/octokit/compare/v0.6.2...v0.6.3)
4
5
  * [0.6.2 - April 26, 2011](https://github.com/pengwynn/octokit/compare/v0.6.1...v0.6.2)
5
6
  * [0.6.1 - April 6, 2011](https://github.com/pengwynn/octokit/compare/v0.6.0...v0.6.1)
data/README.md CHANGED
@@ -1,31 +1,23 @@
1
- Octokit
2
- =======
1
+ # Octokit
3
2
  Simple Ruby wrapper for the GitHub v2 API.
4
3
 
5
4
  ![The Puppeteer](https://github.com/pengwynn/octokit/raw/master/puppeteer.jpg "The Puppeteer") by [![Cameron McEfee)](https://secure.gravatar.com/avatar/a79ff2bb7da84e275361857d2feb2b1b?s=20 "Cameron McEfee")](https://github.com/cameronmcefee)
6
5
 
7
- Installation
8
- ------------
6
+ ## <a name="installation">Installation</a>
9
7
  gem install octokit
10
8
 
11
- Continuous Integration
12
- ----------------------
13
- [![Build Status](http://travis-ci.org/pengwynn/octokit.png)](http://travis-ci.org/pengwynn/octokit)
9
+ ## <a name="ci">Continuous Integration</a>
10
+ [![Build Status](https://secure.travis-ci.org/pengwynn/octokit.png)](http://travis-ci.org/pengwynn/octokit)
14
11
 
15
- Documentation
16
- -------------
12
+ ## <a name="documentation">Documentation</a>
17
13
  http://rdoc.info/gems/octokit
18
14
 
19
- Examples
20
- -------------
21
-
15
+ ## <a name="examples">Examples</a>
22
16
  ### Show a user
23
-
24
17
  Octokit.user("sferik")
25
18
  => <#Hashie::Rash blog="http://twitter.com/sferik" company="Code for America" created_at="2008/05/14 13:36:12 -0700" email="sferik@gmail.com" followers_count=177 following_count=83 gravatar_id="1f74b13f1e5c6c69cb5d7fbaabb1e2cb" id=10308 location="San Francisco" login="sferik" name="Erik Michaels-Ober" permission=nil public_gist_count=16 public_repo_count=30 type="User">
26
19
 
27
20
  ### Show who a user follows
28
-
29
21
  Octokit.following("sferik")
30
22
  => ["rails", "puls", "wycats", "dhh", "jm3", "joshsusser", "nkallen", "technoweenie", "blaine", "al3x", "defunkt", "schacon", "bmizerany", "rtomayko", "jpr5", "lholden", "140proof", "ephramzerb", "carlhuda", "carllerche", "jnunemaker", "josh", "hoverbird", "jamiew", "jeremyevans", "brynary", "mojodna", "mojombo", "joshbuddy", "igrigorik", "perplexes", "joearasin", "hassox", "nickmarden", "pengwynn", "mmcgrana", "reddavis", "reinh", "mzsanford", "aanand", "pjhyett", "kneath", "tekkub", "adamstac", "timtrueman", "aaronblohowiak", "josevalim", "kaapa", "hurrycane", "jackdempsey", "drogus", "cameronpriest", "danmelton", "marcel", "r", "atmos", "mbleigh", "isaacs", "maxogden", "codeforamerica", "chadk", "laserlemon", "gruber", "lsegal", "bblimke", "wayneeseguin", "brixen", "dkubb", "bhb", "bcardarella", "elliottcable", "fbjork", "mlightner", "dianakimball", "amerine", "danchoi", "develop", "dmfrancisco", "unruthless", "trotter", "hannestyden", "codahale", "ry"]
31
23
 
@@ -40,15 +32,21 @@ For convenience, methods that require a repoistory argument may be passed in any
40
32
  Octokit.repo("pengwynn/octokit")
41
33
  => <#Hashie::Rash created_at="2009/12/10 13:41:49 -0800" description="Simple Ruby wrapper for the GitHub v2 API and feeds" fork=false forks=25 has_downloads=true has_issues=true has_wiki=true homepage="http://wynnnetherland.com/projects/octokit" integrate_branch="master" language="Ruby" name="octokit" open_issues=8 owner="pengwynn" private=false pushed_at="2011/05/05 10:48:57 -0700" size=1804 url="https://github.com/pengwynn/octokit" watchers=92>
42
34
 
43
- Authenticated requests
44
- ----------------------
45
- Some methods require authentication so you'll need to pass a login and an api_token. You can find your GitHub API token on your [account page](https://github.com/account).
35
+ ## <a name="authenticated_requests">Authenticated requests</a>
36
+ For methods that require authentication, you'll need to setup a client with
37
+ your login and password.
38
+
39
+ client = Octokit::Client.new(:login => "me", :password => "sekret")
40
+ client.follow!("sferik")
41
+
42
+ Alternately, you can authenticate with a GitHub OAuth2 token. Note: this is
43
+ **NOT** the GitHub API token on your [account
44
+ page](https://github.com/account).
46
45
 
47
- client = Octokit::Client.new(:login => "pengwynn", :token => "OU812")
46
+ client = Octokit::Client.new(:login => "me", :oauth_token => "oauth2token")
48
47
  client.follow!("sferik")
49
48
 
50
- Submitting a Pull Request
51
- -------------------------
49
+ ## <a name="pulls">Submitting a Pull Request</a>
52
50
  1. Fork the project.
53
51
  2. Create a topic branch.
54
52
  3. Implement your feature or bug fix.
@@ -59,11 +57,35 @@ Submitting a Pull Request
59
57
  8. Commit and push your changes.
60
58
  9. Submit a pull request. Please do not include changes to the version or gemspec. (If you want to create your own version for some reason, please do so in a separate commit.)
61
59
 
62
- Inspiration
63
- -----------
60
+ ## <a name="rubies">Supported Rubies</a>
61
+ This library aims to support and is [tested
62
+ against](http://travis-ci.org/pengwynn/octokit) the following Ruby
63
+ implementations:
64
+
65
+ * Ruby 1.8.7
66
+ * Ruby 1.9.1
67
+ * Ruby 1.9.2
68
+ * [JRuby](http://www.jruby.org/)
69
+ * [Rubinius](http://rubini.us/)
70
+ * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
71
+
72
+ If something doesn't work on one of these interpreters, it should be considered
73
+ a bug.
74
+
75
+ This library may inadvertently work (or seem to work) on other Ruby
76
+ implementations, however support will only be provided for the versions listed
77
+ above.
78
+
79
+ If you would like this library to support another Ruby version, you may
80
+ volunteer to be a maintainer. Being a maintainer entails making sure all tests
81
+ run and pass on that implementation. When something breaks on your
82
+ implementation, you will be personally responsible for providing patches in a
83
+ timely fashion. If critical issues for a particular implementation exist at the
84
+ time of a major release, support for that Ruby version may be dropped.
85
+
86
+ ## <a name="inspiration">Inspiration</a>
64
87
  Octokit was inspired by [Octopi](https://github.com/fcoury/octopi) and aims to be a lightweight, less-ActiveResourcey alternative.
65
88
 
66
- Copyright
67
- ---------
89
+ ## <a name="copyright">Copyright</a>
68
90
  Copyright (c) 2011 [Wynn Netherland](http://wynnnetherland.com), [Adam Stacoviak](http://adamstacoviak.com/), [Erik Michaels-Ober](https://github.com/sferik).
69
91
  See [LICENSE](https://github.com/pengwynn/octokit/blob/master/LICENSE) for details.
data/Rakefile CHANGED
File without changes
@@ -1,9 +1,7 @@
1
1
  module Octokit
2
2
  module Authentication
3
3
  def authentication
4
- if login && token
5
- {:login => "#{login}/token", :password => token}
6
- elsif login && password
4
+ if login && password
7
5
  {:login => login, :password => password}
8
6
  else
9
7
  {}
@@ -5,6 +5,7 @@ require 'octokit/request'
5
5
 
6
6
  require 'octokit/client/commits'
7
7
  require 'octokit/client/issues'
8
+ require 'octokit/client/labels'
8
9
  require 'octokit/client/network'
9
10
  require 'octokit/client/milestones'
10
11
  require 'octokit/client/objects'
@@ -18,7 +19,7 @@ require 'octokit/client/users'
18
19
 
19
20
  module Octokit
20
21
  class Client
21
- attr_accessor *Configuration::VALID_OPTIONS_KEYS
22
+ attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
22
23
 
23
24
  def initialize(options={})
24
25
  options = Octokit.options.merge(options)
@@ -33,6 +34,7 @@ module Octokit
33
34
 
34
35
  include Octokit::Client::Commits
35
36
  include Octokit::Client::Issues
37
+ include Octokit::Client::Labels
36
38
  include Octokit::Client::Network
37
39
  include Octokit::Client::Milestones
38
40
  include Octokit::Client::Objects
@@ -3,12 +3,13 @@ module Octokit
3
3
  module Commits
4
4
 
5
5
  def commits(repo, branch="master", options={})
6
- get("/api/v2/json/commits/list/#{Repository.new(repo)}/#{branch}", options)['commits']
6
+ options = { :per_page => 35, :sha => branch }.merge options
7
+ get("/repos/#{Repository.new(repo)}/commits", options, 3)
7
8
  end
8
9
  alias :list_commits :commits
9
10
 
10
11
  def commit(repo, sha, options={})
11
- get("/api/v2/json/commits/show/#{Repository.new(repo)}/#{sha}", options)['commit']
12
+ get("/repos/#{Repository.new(repo)}/commits/#{sha}", options, 3)
12
13
  end
13
14
 
14
15
  end
@@ -4,7 +4,7 @@ module Octokit
4
4
 
5
5
  # Search issues within a repository
6
6
  #
7
- # @param repository [String, Repository, Hash] A GitHub repository.
7
+ # @param repo [String, Repository, Hash] A GitHub repository
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
@@ -38,7 +38,7 @@ module Octokit
38
38
 
39
39
  # Create an issue for a repository
40
40
  #
41
- # @param repository [String, Repository, Hash] A GitHub repository.
41
+ # @param repo [String, Repository, Hash] A GitHub repository
42
42
  # @param title [String] A descriptive title
43
43
  # @param body [String] A concise description
44
44
  # @return [Issue] Your newly created issue
@@ -52,7 +52,7 @@ module Octokit
52
52
 
53
53
  # Get a single issue from a repository
54
54
  #
55
- # @param repository [String, Repository, Hash] A GitHub repository.
55
+ # @param repo [String, Repository, Hash] A GitHub repository
56
56
  # @param number [String] Number ID of the issue
57
57
  # @return [Issue] The issue you requested, if it exists
58
58
  # @see http://developer.github.com/v3/issues/#get-a-single-issue
@@ -64,7 +64,7 @@ module Octokit
64
64
 
65
65
  # Close an issue
66
66
  #
67
- # @param repository [String, Repository, Hash] A GitHub repository.
67
+ # @param repo [String, Repository, Hash] A GitHub repository
68
68
  # @param number [String] Number ID of the issue
69
69
  # @return [Issue] The updated Issue
70
70
  # @see http://develop.github.com/p/issues.html
@@ -78,7 +78,7 @@ module Octokit
78
78
 
79
79
  # Reopen an issue
80
80
  #
81
- # @param repository [String, Repository, Hash] A GitHub repository.
81
+ # @param repo [String, Repository, Hash] A GitHub repository
82
82
  # @param number [String] Number ID of the issue
83
83
  # @return [Issue] The updated Issue
84
84
  # @see http://develop.github.com/p/issues.html
@@ -92,7 +92,7 @@ module Octokit
92
92
 
93
93
  # Update an issue
94
94
  #
95
- # @param repository [String, Repository, Hash] A GitHub repository.
95
+ # @param repo [String, Repository, Hash] A GitHub repository
96
96
  # @param number [String] Number ID of the issue
97
97
  # @param title [String] Updated title for the issue
98
98
  # @param body [String] Updated body of the issue
@@ -106,60 +106,9 @@ module Octokit
106
106
  post("/api/v2/json/issues/edit/#{Repository.new(repo)}/#{number}", options.merge({:title => title, :body => body}))['issue']
107
107
  end
108
108
 
109
- # List available labels for a repository
110
- #
111
- # @param repository [String, Repository, Hash] A GitHub repository.
112
- # @return [Array] A list of the labels currently on the issue
113
- # @see http://develop.github.com/p/issues.html
114
- # @see http://developer.github.com/v3/issues/labels/
115
- # @example List labels for pengwynn/octokit
116
- # Octokit.labels("pengwynn/octokit")
117
- def labels(repo, options={})
118
- get("repos/#{Repository.new(repo)}/labels", options, 3)
119
- end
120
-
121
- # Get single label for a repository
122
- #
123
- # @param repository [String, Repository, Hash] A GitHub repository.
124
- # @param name [String] Name of the label
125
- # @return [Label] A single label from the repository
126
- # @see http://developer.github.com/v3/issues/labels/#get-a-single-label
127
- # @example Get the "V3 Addition" label from pengwynn/octokit
128
- # Octokit.labels("pengwynn/octokit")
129
- def label(repo, name, options={})
130
- get("repos/#{Repository.new(repo)}/labels/#{URI.encode(name)}", options, 3)
131
- end
132
- # Add a label to a repository
133
- #
134
- # @param repository [String, Repository, Hash] A GitHub repository.
135
- # @param label [String] A new label
136
- # @param color [String] A color, in hex, without the leading #
137
- # @return [Array] A list of the labels currently on the issue
138
- # @see http://developer.github.com/v3/issues/labels/
139
- # @example Add a new label "Version 1.0" with color "#cccccc"
140
- # Octokit.add_label("pengwynn/octokit", "Version 1.0", "cccccc")
141
- def add_label(repo, label, color="ffffff", options={})
142
- post("repos/#{Repository.new(repo)}/labels", options.merge({:name => label, :color => color}), 3)
143
- end
144
-
145
- # Remove a label from a repository
146
- #
147
- # @param repository [String, Repository, Hash] A GitHub repository.
148
- # @param label [String] Label you wish to remove
149
- # @param number [Integer] Optional Issue number to remove the label from
150
- # @note Leaving the number parameter out will remove this label from all issues
151
- # @return [Array] A list of the labels currently on the issue
152
- # @see http://develop.github.com/p/issues.html
153
- # @see http://developer.github.com/v3/issues/labels/
154
- # @example Remove the label "Version 1.0" from the repository
155
- # Octokit.remove_label("pengwynn/octokit", "Version 1.0")
156
- def remove_label(repo, label, number=nil, options={})
157
- post(["/api/v2/json/issues/label/remove/#{Repository.new(repo)}/#{label}", number].compact.join('/'), options)['labels']
158
- end
159
-
160
109
  # Get all comments attached to an issue
161
110
  #
162
- # @param repository [String, Repository, Hash] A GitHub repository.
111
+ # @param repo [String, Repository, Hash] A GitHub repository
163
112
  # @param number [String] Number ID of the issue
164
113
  # @return [Array] Array of comments that belong to an issue
165
114
  # @see http://developer.github.com/v3/issues/comments
@@ -171,7 +120,7 @@ module Octokit
171
120
 
172
121
  # Get a single comment attached to an issue
173
122
  #
174
- # @param repository [String, Repository, Hash] A GitHub repository.
123
+ # @param repo [String, Repository, Hash] A GitHub repository
175
124
  # @param number [String] Number ID of the issue
176
125
  # @return [Array] Array of comments that belong to an issue
177
126
  # @see http://developer.github.com/v3/issues/comments/#get-a-single-comment
@@ -183,7 +132,7 @@ module Octokit
183
132
 
184
133
  # Add a comment to an issue
185
134
  #
186
- # @param repository [String, Repository, Hash] A GitHub repository.
135
+ # @param repo [String, Repository, Hash] A GitHub repository
187
136
  # @param number [Integer] Issue number
188
137
  # @param comment [String] Comment to be added
189
138
  # @return [Comment] A JSON encoded Comment
@@ -196,7 +145,7 @@ module Octokit
196
145
 
197
146
  # Update a single comment on an issue
198
147
  #
199
- # @param repository [String, Repository, Hash] A GitHub repository.
148
+ # @param repo [String, Repository, Hash] A GitHub repository
200
149
  # @param number [Integer] Comment number
201
150
  # @param comment [String] Body of the comment which will replace the existing body.
202
151
  # @return [Comment] A JSON encoded Comment
@@ -209,7 +158,7 @@ module Octokit
209
158
 
210
159
  # Delete a single comment
211
160
  #
212
- # @param repository [String, Repository, Hash] A GitHub repository.
161
+ # @param repo [String, Repository, Hash] A GitHub repository
213
162
  # @param number [Integer] Comment number
214
163
  # @return [Response] A response object with status
215
164
  # @see http://developer.github.com/v3/issues/comments/#delete-a-comment
@@ -0,0 +1,153 @@
1
+ module Octokit
2
+ class Client
3
+ module Labels
4
+
5
+ # List available labels for a repository
6
+ #
7
+ # @param repo [String, Repository, Hash] A GitHub repository
8
+ # @return [Array] A list of the labels across the repository
9
+ # @see http://developer.github.com/v3/issues/labels/
10
+ # @example List labels for pengwynn/octokit
11
+ # Octokit.labels("pengwynn/octokit")
12
+ def labels(repo, options={})
13
+ get("repos/#{Repository.new(repo)}/labels", options, 3)
14
+ end
15
+
16
+ # Get single label for a repository
17
+ #
18
+ # @param repo [String, Repository, Hash] A GitHub repository
19
+ # @param name [String] Name of the label
20
+ # @return [Label] A single label from the repository
21
+ # @see http://developer.github.com/v3/issues/labels/#get-a-single-label
22
+ # @example Get the "V3 Addition" label from pengwynn/octokit
23
+ # Octokit.labels("pengwynn/octokit")
24
+ def label(repo, name, options={})
25
+ get("repos/#{Repository.new(repo)}/labels/#{URI.encode_www_form_component(name)}", options, 3)
26
+ end
27
+
28
+ # Add a label to a repository
29
+ #
30
+ # @param repo [String, Repository, Hash] A GitHub repository
31
+ # @param label [String] A new label
32
+ # @param color [String] A color, in hex, without the leading #
33
+ # @return [Label] A Hashie of the new label
34
+ # @see http://developer.github.com/v3/issues/labels/
35
+ # @example Add a new label "Version 1.0" with color "#cccccc"
36
+ # Octokit.add_label("pengwynn/octokit", "Version 1.0", "cccccc")
37
+ def add_label(repo, label, color="ffffff", options={})
38
+ post("repos/#{Repository.new(repo)}/labels", options.merge({:name => label, :color => color}), 3)
39
+ end
40
+
41
+ # Update a label
42
+ #
43
+ # @param repo [String, Repository, Hash] A GitHub repository
44
+ # @param label [String] The name of the label which will be updated
45
+ # @param options [Hash] A customizable set of options.
46
+ # @option options [String] :title An updated label name
47
+ # @option options [String] :color An updated color value, in hex, without leading #
48
+ # @return [Label] A Hashie of the updated label
49
+ # @see http://developer.github.com/v3/issues/labels/#update-a-label
50
+ # @example Update the label "Version 1.0" with new color "#cceeaa"
51
+ # Octokit.update_label("pengwynn/octokit", "Version 1.0", {:color => "cceeaa"})
52
+ def update_label(repo, label, options={})
53
+ post("repos/#{Repository.new(repo)}/labels/#{URI.encode_www_form_component(label)}", options, 3)
54
+ end
55
+
56
+ # Delete a label from a repository.
57
+ #
58
+ # This deletes the label from the repository, and removes it from all issues.
59
+ #
60
+ # @param repo [String, Repository, Hash] A GitHub repository
61
+ # @param label [String] String name of the label
62
+ # @return [Response] A Faraday Response object
63
+ # @see http://developer.github.com/v3/issues/labels/#delete-a-label
64
+ # @see http://rubydoc.info/gems/faraday/0.5.3/Faraday/Response
65
+ # @example Delete the label "Version 1.0" from the repository.
66
+ # Octokit.delete_label!("pengwynn/octokit", "Version 1.0")
67
+ def delete_label!(repo, label, options={})
68
+ delete("repos/#{Repository.new(repo)}/labels/#{URI.encode_www_form_component(label)}", options, 3, true, true)
69
+ end
70
+
71
+ # Remove a label from an Issue
72
+ #
73
+ # This removes the label from the Issue
74
+ #
75
+ # @param repo [String, Repository, Hash] A GitHub repository
76
+ # @param number [String] Number ID of the issue
77
+ # @param label [String] String name of the label
78
+ # @return [Array] A list of the labels currently on the issue
79
+ # @see http://rubydoc.info/gems/faraday/0.5.3/Faraday/Response
80
+ # @see http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
81
+ # @example Remove the label "Version 1.0" from the repository.
82
+ # Octokit.remove_label("pengwynn/octokit", 23, "Version 1.0")
83
+ def remove_label(repo, number, label, options={})
84
+ delete("repos/#{Repository.new(repo)}/issues/#{number}/labels/#{URI.encode_www_form_component(label)}", options, 3, true)
85
+ end
86
+
87
+ # Remove all label from an Issue
88
+ #
89
+ # This removes the label from the Issue
90
+ #
91
+ # @param repo [String, Repository, Hash] A GitHub repository
92
+ # @param number [String] Number ID of the issue
93
+ # @return [Array] A list of the labels currently on the issue
94
+ # @see http://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue
95
+ # @example Remove all labels from Issue #23
96
+ # Octokit.remove_all_labels("pengwynn/octokit", 23)
97
+ def remove_all_labels(repo, number, options={})
98
+ delete("repos/#{Repository.new(repo)}/issues/#{number}/labels", options, 3, true, true)
99
+ end
100
+
101
+ # List labels for a given issue
102
+ #
103
+ # @param repo [String, Repository, Hash] A GitHub repository
104
+ # @param number [String] Number ID of the issue
105
+ # @return [Array] A list of the labels currently on the issue
106
+ # @see http://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
107
+ # @example List labels for pengwynn/octokit
108
+ # Octokit.labels("pengwynn/octokit")
109
+ def labels_for_issue(repo, number, options={})
110
+ get("repos/#{Repository.new(repo)}/issues/#{number}/labels", options, 3)
111
+ end
112
+
113
+ # Add label(s) to an Issue
114
+ #
115
+ # @param repo [String, Repository, Hash] A Github repository
116
+ # @param number [String] Number ID of the issue
117
+ # @param labels [Array] An array of labels to apply to this Issue
118
+ # @return [Array] A list of the labels currently on the issue
119
+ # @see http://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
120
+ # @example Add two labels for pengwynn/octokit
121
+ # Octokit.add_labels_to_an_issue("pengwynn/octokit", 10, ['V3 Transition', 'Improvement'])
122
+ def add_labels_to_an_issue(repo, number, labels)
123
+ post("repos/#{Repository.new(repo)}/issues/#{number}/labels", labels, 3)
124
+ end
125
+
126
+ # Replace all labels on an Issue
127
+ #
128
+ # @param repo [String, Repository, Hash] A Github repository
129
+ # @param number [String] Number ID of the issue
130
+ # @param labels [Array] An array of labels to use as replacement
131
+ # @return [Array] A list of the labels currently on the issue
132
+ # @see http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue
133
+ # @example Replace labels for pengwynn/octokit Issue #10
134
+ # Octokit.replace_all_labels("pengwynn/octokit", 10, ['V3 Transition', 'Improvement'])
135
+ def replace_all_labels(repo, number, labels, options={})
136
+ put("repos/#{Repository.new(repo)}/issues/#{number}/labels", labels, 3)
137
+ end
138
+
139
+ # Get labels for every issue in a milestone
140
+ #
141
+ # @param repo [String, Repository, Hash] A GitHub repository
142
+ # @param number [String] Number ID of the milestone
143
+ # @return [Array] A list of the labels across the milestone
144
+ # @see http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
145
+ # @example List all labels for milestone #2 on pengwynn/octokit
146
+ # Octokit.labels_for_milestone("pengwynn/octokit", 2)
147
+ def labels_for_milestone(repo, number, options={})
148
+ get("repos/#{Repository.new(repo)}/milestones/#{number}/labels", options, 3)
149
+ end
150
+
151
+ end
152
+ end
153
+ end