octokit 0.6.5 → 1.0.0

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 (84) hide show
  1. data/.rspec +1 -2
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +1 -0
  4. data/Gemfile +1 -1
  5. data/README.md +41 -28
  6. data/Rakefile +11 -0
  7. data/lib/faraday/response/raise_octokit_error.rb +4 -2
  8. data/lib/octokit/client.rb +2 -0
  9. data/lib/octokit/client/commits.rb +12 -0
  10. data/lib/octokit/client/events.rb +26 -0
  11. data/lib/octokit/client/issues.rb +35 -7
  12. data/lib/octokit/client/labels.rb +5 -5
  13. data/lib/octokit/client/objects.rb +10 -6
  14. data/lib/octokit/client/organizations.rb +25 -21
  15. data/lib/octokit/client/pub_sub_hubbub/service_hooks.rb +2 -2
  16. data/lib/octokit/client/pulls.rb +4 -4
  17. data/lib/octokit/client/repositories.rb +18 -18
  18. data/lib/octokit/client/users.rb +19 -14
  19. data/lib/octokit/configuration.rb +14 -11
  20. data/lib/octokit/connection.rb +3 -3
  21. data/lib/octokit/request.rb +17 -1
  22. data/lib/octokit/version.rb +1 -1
  23. data/octokit.gemspec +13 -12
  24. data/spec/fixtures/v3/blob.json +7 -0
  25. data/spec/fixtures/v3/commit_comment.json +19 -0
  26. data/spec/fixtures/v3/commit_comments.json +78 -0
  27. data/spec/fixtures/v3/emails.json +4 -0
  28. data/spec/fixtures/v3/followers.json +212 -0
  29. data/spec/fixtures/v3/following.json +209 -0
  30. data/spec/fixtures/v3/issue.json +37 -0
  31. data/spec/fixtures/v3/issue_closed.json +37 -0
  32. data/spec/fixtures/v3/issue_event.json +44 -0
  33. data/spec/fixtures/v3/issue_events.json +72 -0
  34. data/spec/fixtures/v3/list_commit_comments.json +572 -0
  35. data/spec/fixtures/v3/organization-repositories.json +4292 -0
  36. data/spec/fixtures/v3/organization-repository.json +42 -0
  37. data/spec/fixtures/v3/organization.json +18 -0
  38. data/spec/fixtures/v3/organization_members.json +576 -0
  39. data/spec/fixtures/v3/organization_team_members.json +16 -0
  40. data/spec/fixtures/v3/organization_team_repos.json +62 -0
  41. data/spec/fixtures/v3/organizations.json +44 -0
  42. data/spec/fixtures/v3/public_events.json +1110 -0
  43. data/spec/fixtures/v3/pull_created.json +138 -0
  44. data/spec/fixtures/v3/pull_request.json +138 -0
  45. data/spec/fixtures/v3/pull_requests.json +187 -0
  46. data/spec/fixtures/v3/repo_events.json +1668 -0
  47. data/spec/fixtures/v3/repo_issues_events.json +134 -0
  48. data/spec/fixtures/v3/team.json +8 -0
  49. data/spec/fixtures/v3/teams.json +4 -4
  50. data/spec/fixtures/v3/tree.json +112 -0
  51. data/spec/fixtures/v3/watched.json +1022 -0
  52. data/spec/helper.rb +3 -3
  53. data/spec/octokit/client/commits_spec.rb +33 -0
  54. data/spec/octokit/client/events_spec.rb +27 -0
  55. data/spec/octokit/client/issue_events_spec.rb +30 -0
  56. data/spec/octokit/client/issues_spec.rb +31 -20
  57. data/spec/octokit/client/labels_spec.rb +1 -1
  58. data/spec/octokit/client/objects_spec.rb +9 -8
  59. data/spec/octokit/client/organizations_spec.rb +56 -67
  60. data/spec/octokit/client/pulls_spec.rb +19 -18
  61. data/spec/octokit/client/repositories_spec.rb +24 -38
  62. data/spec/octokit/client/users_spec.rb +50 -51
  63. data/spec/octokit/client_spec.rb +16 -0
  64. metadata +111 -81
  65. data/puppeteer.jpg +0 -0
  66. data/spec/fixtures/v2/blob.json +0 -1
  67. data/spec/fixtures/v2/comment.json +0 -1
  68. data/spec/fixtures/v2/comments.json +0 -1
  69. data/spec/fixtures/v2/delete_failure.json +0 -1
  70. data/spec/fixtures/v2/delete_token.json +0 -1
  71. data/spec/fixtures/v2/emails.json +0 -1
  72. data/spec/fixtures/v2/followers.json +0 -1
  73. data/spec/fixtures/v2/following.json +0 -1
  74. data/spec/fixtures/v2/issue.json +0 -1
  75. data/spec/fixtures/v2/labels.json +0 -1
  76. data/spec/fixtures/v2/organization.json +0 -1
  77. data/spec/fixtures/v2/organizations.json +0 -1
  78. data/spec/fixtures/v2/public_keys.json +0 -1
  79. data/spec/fixtures/v2/pull.json +0 -1
  80. data/spec/fixtures/v2/pulls.json +0 -1
  81. data/spec/fixtures/v2/tags.json +0 -1
  82. data/spec/fixtures/v2/team.json +0 -1
  83. data/spec/fixtures/v2/teams.json +0 -1
  84. data/spec/fixtures/v2/tree.json +0 -1
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --format=nested
3
- --backtrace
2
+ --order random
@@ -4,5 +4,4 @@ rvm:
4
4
  - 1.9.3
5
5
  - jruby
6
6
  - rbx
7
- - rbx-2.0
8
7
  - ree
@@ -1,5 +1,6 @@
1
1
  # CHANGELOG
2
2
 
3
+ * [0.6.5 - October 15, 2011](https://github.com/pengwynn/octokit/compare/v0.6.4...v0.6.5)
3
4
  * [0.6.4 - July 2, 2011](https://github.com/pengwynn/octokit/compare/v0.6.3...v0.6.4)
4
5
  * [0.6.3 - May 5, 2011](https://github.com/pengwynn/octokit/compare/v0.6.2...v0.6.3)
5
6
  * [0.6.2 - April 26, 2011](https://github.com/pengwynn/octokit/compare/v0.6.1...v0.6.2)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  platforms :jruby do
4
4
  gem "jruby-openssl", "~> 0.7"
data/README.md CHANGED
@@ -1,18 +1,18 @@
1
- # Octokit
2
- Simple Ruby wrapper for the GitHub v2 API.
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]
2
+ Simple Ruby wrapper for the GitHub v2 & v3 API.
3
3
 
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)
4
+ [travis]: http://travis-ci.org/pengwynn/octokit
5
+ [gemnasium]: https://gemnasium.com/pengwynn/octokit
5
6
 
6
- ## <a name="installation">Installation</a>
7
+ ## <a name="installation"></a>Installation
7
8
  gem install octokit
8
9
 
9
- ## <a name="ci">Continuous Integration</a>
10
- [![Build Status](https://secure.travis-ci.org/pengwynn/octokit.png)](http://travis-ci.org/pengwynn/octokit)
10
+ ## <a name="documentation"></a>Documentation
11
+ [http://rdoc.info/gems/octokit][documentation]
11
12
 
12
- ## <a name="documentation">Documentation</a>
13
- http://rdoc.info/gems/octokit
13
+ [documentation]: http://rdoc.info/gems/octokit
14
14
 
15
- ## <a name="examples">Examples</a>
15
+ ## <a name="examples"></a>Examples
16
16
  ### Show a user
17
17
  Octokit.user("sferik")
18
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">
@@ -32,7 +32,7 @@ For convenience, methods that require a repoistory argument may be passed in any
32
32
  Octokit.repo("pengwynn/octokit")
33
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>
34
34
 
35
- ## <a name="authenticated_requests">Authenticated requests</a>
35
+ ## <a name="authenticated_requests"></a>Authenticated Requests
36
36
  For methods that require authentication, you'll need to setup a client with
37
37
  your login and password.
38
38
 
@@ -40,34 +40,42 @@ your login and password.
40
40
  client.follow!("sferik")
41
41
 
42
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).
43
+ **NOT** the GitHub API token on your [account page][account].
44
+
45
+ [account]: https://github.com/account
45
46
 
46
47
  client = Octokit::Client.new(:login => "me", :oauth_token => "oauth2token")
47
48
  client.follow!("sferik")
48
49
 
49
- ## <a name="pulls">Submitting a Pull Request</a>
50
+ ## <a name="pulls"></a>Submitting a Pull Request
50
51
  1. Fork the project.
51
52
  2. Create a topic branch.
52
53
  3. Implement your feature or bug fix.
53
54
  4. Add documentation for your feature or bug fix.
54
- 5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
55
+ 5. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
56
+ back to step 4.
55
57
  6. Add specs for your feature or bug fix.
56
- 7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
58
+ 7. Run `bundle exec rake spec`. If your changes are not 100% covered, go back
59
+ to step 6.
57
60
  8. Commit and push your changes.
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
+ 9. Submit a pull request. Please do not include changes to the version or
62
+ gemspec. (If you want to create your own version for some reason, please do
63
+ so in a separate commit.)
59
64
 
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
65
+ ## <a name="versions"></a>Supported Ruby Versions
66
+ This library aims to support and is [tested against][travis] the following Ruby
63
67
  implementations:
64
68
 
65
69
  * Ruby 1.8.7
66
- * Ruby 1.9.1
67
70
  * Ruby 1.9.2
68
- * [JRuby](http://www.jruby.org/)
69
- * [Rubinius](http://rubini.us/)
70
- * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
71
+ * Ruby 1.9.3
72
+ * [JRuby][]
73
+ * [Rubinius][]
74
+ * [Ruby Enterprise Edition][ree]
75
+
76
+ [jruby]: http://www.jruby.org/
77
+ [rubinius]: http://rubini.us/
78
+ [ree]: http://www.rubyenterpriseedition.com/
71
79
 
72
80
  If something doesn't work on one of these interpreters, it should be considered
73
81
  a bug.
@@ -83,9 +91,14 @@ implementation, you will be personally responsible for providing patches in a
83
91
  timely fashion. If critical issues for a particular implementation exist at the
84
92
  time of a major release, support for that Ruby version may be dropped.
85
93
 
86
- ## <a name="inspiration">Inspiration</a>
87
- Octokit was inspired by [Octopi](https://github.com/fcoury/octopi) and aims to be a lightweight, less-ActiveResourcey alternative.
94
+ ## <a name="inspiration"></a>Inspiration
95
+ Octokit was inspired by [Octopi][] and aims to be a lightweight,
96
+ less-ActiveResourcey alternative.
97
+
98
+ [octopi]: https://github.com/fcoury/octopi
99
+
100
+ ## <a name="copyright"></a>Copyright
101
+ Copyright (c) 2011 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober. See
102
+ [LICENSE][] for details.
88
103
 
89
- ## <a name="copyright">Copyright</a>
90
- Copyright (c) 2011 [Wynn Netherland](http://wynnnetherland.com), [Adam Stacoviak](http://adamstacoviak.com/), [Erik Michaels-Ober](https://github.com/sferik).
91
- See [LICENSE](https://github.com/pengwynn/octokit/blob/master/LICENSE) for details.
104
+ [license]: https://github.com/pengwynn/octokit/blob/master/LICENSE
data/Rakefile CHANGED
@@ -8,3 +8,14 @@ RSpec::Core::RakeTask.new(:spec)
8
8
 
9
9
  task :test => :spec
10
10
  task :default => :spec
11
+
12
+ namespace :doc do
13
+ require 'yard'
14
+ YARD::Rake::YardocTask.new do |task|
15
+ task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
16
+ task.options = [
17
+ '--output-dir', 'doc/yard',
18
+ '--markup', 'markdown',
19
+ ]
20
+ end
21
+ end
@@ -30,8 +30,10 @@ module Faraday
30
30
  end
31
31
 
32
32
  def error_message(response)
33
- message = if body = response[:body]
34
- body = ::MultiJson.decode(body) if body.is_a? String
33
+ message = if ( body = response[:body] ) && !body.empty?
34
+ if body.is_a? String
35
+ body = ::MultiJson.decode body, :symbolize_keys => true
36
+ end
35
37
  ": #{body[:error] || body[:message] || ''}"
36
38
  else
37
39
  ''
@@ -16,6 +16,7 @@ require 'octokit/client/pulls'
16
16
  require 'octokit/client/repositories'
17
17
  require 'octokit/client/timelines'
18
18
  require 'octokit/client/users'
19
+ require 'octokit/client/events'
19
20
 
20
21
  module Octokit
21
22
  class Client
@@ -45,5 +46,6 @@ module Octokit
45
46
  include Octokit::Client::Repositories
46
47
  include Octokit::Client::Timelines
47
48
  include Octokit::Client::Users
49
+ include Octokit::Client::Events
48
50
  end
49
51
  end
@@ -12,6 +12,18 @@ module Octokit
12
12
  get("/repos/#{Repository.new(repo)}/commits/#{sha}", options, 3)
13
13
  end
14
14
 
15
+ def list_commit_comments(repo, options={})
16
+ get("/repos/#{Repository.new(repo)}/comments", options, 3)
17
+ end
18
+
19
+ def commit_comments(repo, sha, options={})
20
+ get("/repos/#{Repository.new(repo)}/commits/#{sha}/comments", options, 3)
21
+ end
22
+
23
+ def commit_comment(repo, id, options={})
24
+ get("/repos/#{Repository.new(repo)}/comments/#{id}", options, 3)
25
+ end
26
+
15
27
  end
16
28
  end
17
29
  end
@@ -0,0 +1,26 @@
1
+ module Octokit
2
+ class Client
3
+ module Events
4
+ # List all public events for GitHub
5
+ #
6
+ # @return [Array] A list of all public events from GitHub
7
+ # @see http://developer.github.com/v3/events
8
+ # @example List all pubilc events
9
+ # Octokit.public_events
10
+ def public_events(options={})
11
+ get("/events", options, 3)
12
+ end
13
+
14
+ # List events for a repository
15
+ #
16
+ # @param repo [String, Repository, Hash] A GitHub repository
17
+ # @return [Array] A list of events for a repository
18
+ # @see http://developer.github.com/v3/events
19
+ # @example List events for a repository
20
+ # Octokit.repository_events("sferik/rails_admin")
21
+ def repository_events(repo, options={})
22
+ get("/repos/#{Repository.new(repo)}/events", options, 3)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -12,7 +12,7 @@ module Octokit
12
12
  # @example Search for 'test' in the open issues for sferik/rails_admin
13
13
  # Octokit.search_issues("sferik/rails_admin", 'test', 'open')
14
14
  def search_issues(repo, search_term, state='open', options={})
15
- get("/api/v2/json/issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options)['issues']
15
+ get("/api/v2/json/issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options, 2)['issues']
16
16
  end
17
17
 
18
18
  # List issues for a repository
@@ -46,7 +46,7 @@ module Octokit
46
46
  # @example Create a new Issues for a repository
47
47
  # Octokit.create_issue("sferik/rails_admin")
48
48
  def create_issue(repo, title, body, options={})
49
- post("/api/v2/json/issues/open/#{Repository.new(repo)}", options.merge({:title => title, :body => body}))['issue']
49
+ post("/repos/#{Repository.new(repo)}/issues", options.merge({:title => title, :body => body}), 3)
50
50
  end
51
51
  alias :open_issue :create_issue
52
52
 
@@ -59,7 +59,7 @@ module Octokit
59
59
  # @example Get issue #25 from pengwynn/octokit
60
60
  # Octokit.issue("pengwynn/octokit", "25")
61
61
  def issue(repo, number, options={})
62
- get("/api/v2/json/issues/show/#{Repository.new(repo)}/#{number}", options)['issue']
62
+ get("/repos/#{Repository.new(repo)}/issues/#{number}", options, 3)
63
63
  end
64
64
 
65
65
  # Close an issue
@@ -73,7 +73,7 @@ module Octokit
73
73
  # @example Close Issue #25 from pengwynn/octokit
74
74
  # Octokit.close_issue("pengwynn/octokit", "25")
75
75
  def close_issue(repo, number, options={})
76
- post("/api/v2/json/issues/close/#{Repository.new(repo)}/#{number}", options)['issue']
76
+ post("/repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "closed"}), 3)
77
77
  end
78
78
 
79
79
  # Reopen an issue
@@ -87,7 +87,7 @@ module Octokit
87
87
  # @example Reopen Issue #25 from pengwynn/octokit
88
88
  # Octokit.reopen_issue("pengwynn/octokit", "25")
89
89
  def reopen_issue(repo, number, options={})
90
- post("/api/v2/json/issues/reopen/#{Repository.new(repo)}/#{number}", options)['issue']
90
+ post("/repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "open"}), 3)
91
91
  end
92
92
 
93
93
  # Update an issue
@@ -103,7 +103,7 @@ module Octokit
103
103
  # @example Change the title of Issue #25
104
104
  # Octokit.update_issue("pengwynn/octokit", "25", "A new title", "the same body"")
105
105
  def update_issue(repo, number, title, body, options={})
106
- post("/api/v2/json/issues/edit/#{Repository.new(repo)}/#{number}", options.merge({:title => title, :body => body}))['issue']
106
+ post("/repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:title => title, :body => body}), 3)
107
107
  end
108
108
 
109
109
  # Get all comments attached to an issue
@@ -122,7 +122,7 @@ module Octokit
122
122
  #
123
123
  # @param repo [String, Repository, Hash] A GitHub repository
124
124
  # @param number [String] Number ID of the issue
125
- # @return [Array] Array of comments that belong to an issue
125
+ # @return [Comment] The specific comment in question
126
126
  # @see http://developer.github.com/v3/issues/comments/#get-a-single-comment
127
127
  # @example Get comments for issue #25 from pengwynn/octokit
128
128
  # Octokit.issue_comments("pengwynn/octokit", "25")
@@ -167,6 +167,34 @@ module Octokit
167
167
  def delete_comment(repo, number, options={})
168
168
  delete("/repos/#{Repository.new(repo)}/issues/comments/#{number}", options, 3, true, true)
169
169
  end
170
+
171
+
172
+ # List events for an Issue
173
+ #
174
+ # @param repo [String, Repository, Hash] A GitHub repository
175
+ # @param number [Integer] Issue number
176
+ #
177
+ # @return [Array] Array of events for that issue
178
+ # @see http://developer.github.com/v3/issues/events/
179
+ # @example List all issues events for issue #38 on pengwynn/octokit
180
+ # Octokit.issue_events("pengwynn/octokit", 38)
181
+ def issue_events(repo, number, options={})
182
+ get("/repos/#{Repository.new(repo)}/issues/#{number}/events", options, 3)
183
+ end
184
+
185
+ # Get information on a single Issue Event
186
+ #
187
+ # @param repo [String, Repository, Hash] A GitHub repository
188
+ # @param number [Integer] Event number
189
+ #
190
+ # @return [Event] A single Event for an Issue
191
+ # @see http://developer.github.com/v3/issues/events/#get-a-single-event
192
+ # @example Get Event information for ID 3094334 (a pull request was closed)
193
+ # Octokit.issue_event("pengwynn/octokit", 3094334)
194
+ def issue_event(repo, number, options={})
195
+ get("/repos/#{Repository.new(repo)}/issues/events/#{number}", options, 3)
196
+ end
197
+
170
198
  end
171
199
  end
172
200
  end
@@ -38,7 +38,7 @@ module Octokit
38
38
  post("repos/#{Repository.new(repo)}/labels", options.merge({:name => label, :color => color}), 3)
39
39
  end
40
40
 
41
- # Update a label
41
+ # Update a label
42
42
  #
43
43
  # @param repo [String, Repository, Hash] A GitHub repository
44
44
  # @param label [String] The name of the label which will be updated
@@ -53,7 +53,7 @@ module Octokit
53
53
  post("repos/#{Repository.new(repo)}/labels/#{URI.encode_www_form_component(label)}", options, 3)
54
54
  end
55
55
 
56
- # Delete a label from a repository.
56
+ # Delete a label from a repository.
57
57
  #
58
58
  # This deletes the label from the repository, and removes it from all issues.
59
59
  #
@@ -140,12 +140,12 @@ module Octokit
140
140
  #
141
141
  # @param repo [String, Repository, Hash] A GitHub repository
142
142
  # @param number [String] Number ID of the milestone
143
- # @return [Array] A list of the labels across the milestone
143
+ # @return [Array] A list of the labels across the milestone
144
144
  # @see http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
145
145
  # @example List all labels for milestone #2 on pengwynn/octokit
146
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)
147
+ def labels_for_milestone(repo, number, options={})
148
+ get("repos/#{Repository.new(repo)}/milestones/#{number}/labels", options, 3)
149
149
  end
150
150
 
151
151
  end
@@ -2,27 +2,31 @@ module Octokit
2
2
  class Client
3
3
  module Objects
4
4
  def tree(repo, tree_sha, options={})
5
- get("/api/v2/json/tree/show/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
5
+ get("repos/#{Repository.new(repo)}/git/trees/#{tree_sha}", options)
6
6
  end
7
7
 
8
- def blob(repo, tree_sha, path, options={})
9
- get("/api/v2/json/blob/show/#{Repository.new(repo)}/#{tree_sha}/#{path}", options)['blob']
8
+ def blob(repo, tree_sha, options={})
9
+ get("repos/#{Repository.new(repo)}/git/blobs/#{tree_sha}", options)
10
10
  end
11
11
 
12
+ # Depreciated
12
13
  def blobs(repo, tree_sha, options={})
13
- get("/api/v2/json/blob/all/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
14
+ get("/api/v2/json/blob/all/#{Repository.new(repo)}/#{tree_sha}", options, 2)['blobs']
14
15
  end
15
16
 
17
+ # Depreciated
16
18
  def blob_metadata(repo, tree_sha, options={})
17
- get("/api/v2/json/blob/full/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
19
+ get("/api/v2/json/blob/full/#{Repository.new(repo)}/#{tree_sha}", options, 2)['blobs']
18
20
  end
19
21
  alias :blob_meta :blob_metadata
20
22
 
23
+ # Depreciated
21
24
  def tree_metadata(repo, tree_sha, options={})
22
- get("/api/v2/json/tree/full/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
25
+ get("/api/v2/json/tree/full/#{Repository.new(repo)}/#{tree_sha}", options, 2)['tree']
23
26
  end
24
27
  alias :tree_meta :tree_metadata
25
28
 
29
+ # Depreciated
26
30
  def raw(repo, sha, options={})
27
31
  get("/api/v2/json/blob/show/#{Repository.new(repo)}/#{sha}", options, 2, true, true).body
28
32
  end
@@ -2,86 +2,90 @@ module Octokit
2
2
  class Client
3
3
  module Organizations
4
4
  def organization(org, options={})
5
- get("/api/v2/json/organizations/#{org}", options)['organization']
5
+ get("orgs/#{org}", options, 3)
6
6
  end
7
7
  alias :org :organization
8
8
 
9
9
  def update_organization(org, values, options={})
10
- put("/api/v2/json/organizations/#{org}", options.merge({:organization => values}))['organization']
10
+ patch("orgs/#{org}", options.merge({:organization => values}), 3)
11
11
  end
12
12
  alias :update_org :update_organization
13
13
 
14
14
  def organizations(user=nil, options={})
15
15
  if user
16
- get("/api/v2/json/user/show/#{user}/organizations", options)
16
+ get("users/#{user}/orgs", options, 3)
17
17
  else
18
- get("/api/v2/json/organizations", options)
19
- end['organizations']
18
+ get("user/orgs", options, 3)
19
+ end
20
20
  end
21
21
  alias :list_organizations :organizations
22
22
  alias :list_orgs :organizations
23
23
  alias :orgs :organizations
24
24
 
25
25
  def organization_repositories(org=nil, options={})
26
- if org
27
- get("/api/v2/json/organizations/#{org}/public_repositories", options)
26
+ if org.nil?
27
+ # Depreciated
28
+ get("/api/v2/json/organizations/repositories", options, 2)
28
29
  else
29
- get("/api/v2/json/organizations/repositories", options)
30
- end['repositories']
30
+ get("orgs/#{org}/repos", options, 3)
31
+ end
31
32
  end
32
33
  alias :org_repositories :organization_repositories
33
34
  alias :org_repos :organization_repositories
34
35
 
35
36
  def organization_members(org, options={})
36
- get("/api/v2/json/organizations/#{org}/public_members", options)['users']
37
+ get("orgs/#{org}/members", options, 3)
37
38
  end
38
39
  alias :org_members :organization_members
39
40
 
40
41
  def organization_teams(org, options={})
41
- get("/api/v2/json/organizations/#{org}/teams", options)['teams']
42
+ get("orgs/#{org}/teams", options, 3)
42
43
  end
43
44
  alias :org_teams :organization_teams
44
45
 
45
46
  def create_team(org, values, options={})
46
- post("/api/v2/json/organizations/#{org}/teams", options.merge({:team => values}))['team']
47
+ post("orgs/#{org}/teams", options.merge({:team => values}), 3)
47
48
  end
48
49
 
49
50
  def team(team_id, options={})
50
- get("/api/v2/json/teams/#{team_id}", options)['team']
51
+ get("teams/#{team_id}", options, 3)
51
52
  end
52
53
 
53
54
  def update_team(team_id, values, options={})
54
- put("/api/v2/json/teams/#{team_id}", options.merge({:team => values}))['team']
55
+ patch("teams/#{team_id}", options.merge({:team => values}), 3)
55
56
  end
56
57
 
57
58
  def delete_team(team_id, options={})
58
- delete("/api/v2/json/teams/#{team_id}", options)['team']
59
+ delete("teams/#{team_id}", options, 3, true, true)
59
60
  end
60
61
 
61
62
  def team_members(team_id, options={})
62
- get("/api/v2/json/teams/#{team_id}/members", options)['users']
63
+ get("teams/#{team_id}/members", options, 3)
63
64
  end
64
65
 
65
66
  def add_team_member(team_id, user, options={})
66
- post("/api/v2/json/teams/#{team_id}/members", options.merge({:name => user}))['user']
67
+ # There's a bug in this API call. The docs say to leave the body blank,
68
+ # but it fails if the body is both blank and the content-length header
69
+ # is not 0.
70
+ put("teams/#{team_id}/members/#{user}", options.merge({:name => user}), 3, true, raw=true).status == 204
67
71
  end
68
72
 
69
73
  def remove_team_member(team_id, user, options={})
70
- delete("/api/v2/json/teams/#{team_id}/members", options.merge({:name => user}))['user']
74
+ delete("teams/#{team_id}/members/#{user}", options, 3, true, raw=true).status == 204
71
75
  end
72
76
 
73
77
  def team_repositories(team_id, options={})
74
- get("/api/v2/json/teams/#{team_id}/repositories", options)['repositories']
78
+ get("teams/#{team_id}/repos", options, 3)
75
79
  end
76
80
  alias :team_repos :team_repositories
77
81
 
78
82
  def add_team_repository(team_id, repo, options={})
79
- post("/api/v2/json/teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
83
+ put("teams/#{team_id}/repos/#{Repository.new(repo)}", options.merge(:name => Repository.new(repo)), 3, true, raw=true).status == 204
80
84
  end
81
85
  alias :add_team_repo :add_team_repository
82
86
 
83
87
  def remove_team_repository(team_id, repo, options={})
84
- delete("/api/v2/json/teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
88
+ delete("teams/#{team_id}/repos/#{Repository.new(repo)}", options, 3, true, raw=true).status == 204
85
89
  end
86
90
  alias :remove_team_repo :remove_team_repository
87
91
  end