hybridgroup-octokit 0.6.1

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 (82) hide show
  1. data/.document +4 -0
  2. data/.gemtest +0 -0
  3. data/.gitignore +24 -0
  4. data/.rspec +3 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +20 -0
  8. data/README.markdown +73 -0
  9. data/Rakefile +8 -0
  10. data/changelog.markdown +42 -0
  11. data/lib/faraday/response/raise_error.rb +33 -0
  12. data/lib/octokit/client/authentication.rb +23 -0
  13. data/lib/octokit/client/commits.rb +16 -0
  14. data/lib/octokit/client/connection.rb +34 -0
  15. data/lib/octokit/client/issues.rb +60 -0
  16. data/lib/octokit/client/network.rb +15 -0
  17. data/lib/octokit/client/objects.rb +33 -0
  18. data/lib/octokit/client/organizations.rb +90 -0
  19. data/lib/octokit/client/pulls.rb +25 -0
  20. data/lib/octokit/client/repositories.rb +138 -0
  21. data/lib/octokit/client/request.rb +41 -0
  22. data/lib/octokit/client/timelines.rb +22 -0
  23. data/lib/octokit/client/users.rb +75 -0
  24. data/lib/octokit/client.rb +40 -0
  25. data/lib/octokit/configuration.rb +61 -0
  26. data/lib/octokit/repository.rb +39 -0
  27. data/lib/octokit/version.rb +3 -0
  28. data/lib/octokit.rb +53 -0
  29. data/octokit.gemspec +33 -0
  30. data/spec/faraday/response_spec.rb +34 -0
  31. data/spec/fixtures/blob.json +1 -0
  32. data/spec/fixtures/blob_metadata.json +1 -0
  33. data/spec/fixtures/blobs.json +1 -0
  34. data/spec/fixtures/branches.json +1 -0
  35. data/spec/fixtures/collaborators.json +1 -0
  36. data/spec/fixtures/comment.json +1 -0
  37. data/spec/fixtures/comments.json +1 -0
  38. data/spec/fixtures/commit.json +1 -0
  39. data/spec/fixtures/commits.json +1 -0
  40. data/spec/fixtures/contributors.json +1 -0
  41. data/spec/fixtures/delete_token.json +1 -0
  42. data/spec/fixtures/emails.json +1 -0
  43. data/spec/fixtures/followers.json +1 -0
  44. data/spec/fixtures/following.json +1 -0
  45. data/spec/fixtures/issue.json +1 -0
  46. data/spec/fixtures/issues.json +1 -0
  47. data/spec/fixtures/labels.json +1 -0
  48. data/spec/fixtures/languages.json +1 -0
  49. data/spec/fixtures/network.json +1 -0
  50. data/spec/fixtures/network_data.json +1 -0
  51. data/spec/fixtures/network_meta.json +1 -0
  52. data/spec/fixtures/organization.json +1 -0
  53. data/spec/fixtures/organizations.json +1 -0
  54. data/spec/fixtures/public_keys.json +1 -0
  55. data/spec/fixtures/pull.json +1 -0
  56. data/spec/fixtures/pulls.json +1 -0
  57. data/spec/fixtures/raw.txt +7 -0
  58. data/spec/fixtures/repositories.json +1 -0
  59. data/spec/fixtures/repository.json +1 -0
  60. data/spec/fixtures/tags.json +1 -0
  61. data/spec/fixtures/team.json +1 -0
  62. data/spec/fixtures/teams.json +1 -0
  63. data/spec/fixtures/timeline.json +1237 -0
  64. data/spec/fixtures/tree.json +1 -0
  65. data/spec/fixtures/tree_metadata.json +1 -0
  66. data/spec/fixtures/user.json +1 -0
  67. data/spec/fixtures/users.json +1 -0
  68. data/spec/fixtures/watchers.json +1 -0
  69. data/spec/helper.rb +64 -0
  70. data/spec/octokit/client/commits_spec.rb +32 -0
  71. data/spec/octokit/client/issues_spec.rb +154 -0
  72. data/spec/octokit/client/network_spec.rb +32 -0
  73. data/spec/octokit/client/objects_spec.rb +81 -0
  74. data/spec/octokit/client/organizations_spec.rb +234 -0
  75. data/spec/octokit/client/pulls_spec.rb +44 -0
  76. data/spec/octokit/client/repositories_spec.rb +331 -0
  77. data/spec/octokit/client/timelines_spec.rb +42 -0
  78. data/spec/octokit/client/users_spec.rb +274 -0
  79. data/spec/octokit/client_spec.rb +12 -0
  80. data/spec/octokit_spec.rb +15 -0
  81. data/spec/repository_spec.rb +54 -0
  82. metadata +403 -0
data/.document ADDED
@@ -0,0 +1,4 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ features/**/*.feature
4
+ LICENSE
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ *.tmproj
5
+ *~
6
+ .DS_Store
7
+ .\#*
8
+ .bundle
9
+ .config
10
+ .yardoc
11
+ Gemfile.lock
12
+ InstalledFiles
13
+ \#*
14
+ _yardoc
15
+ coverage
16
+ doc/
17
+ lib/bundler/man
18
+ pkg
19
+ rdoc
20
+ spec/reports
21
+ test/tmp
22
+ test/version_tmp
23
+ tmp
24
+ tmtags
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - ree
5
+ - rbx
6
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,73 @@
1
+ Octokit
2
+ =======
3
+ Simple Ruby wrapper for the GitHub v2 API.
4
+
5
+ Installation
6
+ ------------
7
+ gem install octokit
8
+
9
+ Continuous Integration
10
+ ----------------------
11
+ [![Build Status](http://travis-ci.org/pengwynn/octokit.png)](http://travis-ci.org/pengwynn/octokit)
12
+
13
+ Some examples
14
+ -------------
15
+
16
+ ### Show a user
17
+
18
+ Octokit.user('pengwynn')
19
+ => <#Hashie::Mash blog="http://wynnnetherland.com" company="Orrka" created_at="2008/02/25 10:24:19 -0800" email="wynn.netherland@gmail.com" followers_count=21 following_count=55 id=865 location="Dallas, TX" login="pengwynn" name="Wynn Netherland" public_gist_count=4 public_repo_count=16>
20
+
21
+ ### Show who a user follows
22
+
23
+ Octokit.following('pengwynn')
24
+ => ["cglee", "bryansray", "rails", "zachinglis", "wycats", "obie", "mully", "squeejee", "jderrett", "Shopify", "ReinH", "technoweenie", "errfree", "defunkt", "joshsusser", "hashrocket", "newbamboo", "bigtiger", "github", "jamis", "jeresig", "thoughtbot", "therealadam", "jnunemaker", "seaofclouds", "choan", "llimllib", "kwhinnery", "marshall", "handcrafted", "adamstac", "jashkenas", "dan", "remy", "hayesdavis", "documentcloud", "imathis", "mdeiters", "njonsson", "asenchi", "mattsa", "marclove", "webiest", "brogers", "polomasta", "stephp", "mchelen", "piyush", "davidnorth", "rmetzler", "jferris", "madrobby", "zh", "erikvold", "desandro"]
25
+
26
+ Working with repositories
27
+ -------------------------
28
+ For convenience, methods that require a repo argument may be passed in any of the following forms
29
+
30
+ * "pengwynn/linked"
31
+ * {:username => 'pengwynn', :name => 'linkedin'}
32
+ * {:username => 'pengwynn', :repo => 'linkedin'}
33
+ * instance of Repository
34
+
35
+ ### Show a repo
36
+
37
+ Octokit.repo("pengwynn/linkedin")
38
+ => <#Hashie::Mash description="Ruby wrapper for the LinkedIn API" fork=false forks=1 homepage="http://bit.ly/ruby-linkedin" name="linkedin" open_issues=2 owner="pengwynn" private=false url="http://github.com/pengwynn/linkedin" watchers=36>
39
+
40
+ Authenticated requests
41
+ ----------------------
42
+ 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)
43
+
44
+ client = Octokit::Client.new(:login => 'pengwynn', :token => 'OU812')
45
+ client.follow!('adamstac')
46
+
47
+ Read the full [docs](http://rdoc.info/projects/pengwynn/octokit)
48
+
49
+ TODO
50
+ ----
51
+ * Feed parsing
52
+ * More examples
53
+
54
+ Submitting a Pull Request
55
+ -------------------------
56
+ 1. Fork the project.
57
+ 2. Create a topic branch.
58
+ 3. Implement your feature or bug fix.
59
+ 4. Add documentation for your feature or bug fix.
60
+ 5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
61
+ 6. Add specs for your feature or bug fix.
62
+ 7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
63
+ 8. Commit and push your changes.
64
+ 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.)
65
+
66
+ Credits
67
+ -------
68
+ Octokit is inspired by [Octopi](http://github.com/fcoury/octopi) and aims to be a lightweight, less active-resourcey alternative.
69
+
70
+ Copyright
71
+ ---------
72
+ Copyright (c) 2011 [Wynn Netherland](http://wynnnetherland.com), [Adam Stacoviak](http://adamstacoviak.com/), [Erik Michaels-Ober](https://github.com/sferik).
73
+ See [LICENSE](https://github.com/pengwynn/octokit/blob/master/LICENSE) for details.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :test => :spec
8
+ task :default => :spec
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+ ## 0.5.0
3
+ * Rewrote all tests in rspec
4
+ * A handful of backwards-incompatible API changes
5
+ ## 0.4.1
6
+ * Patch from [karlfreeman](http://github.com/karlfreeman) to fix user search
7
+ ## 0.4.0
8
+ * Renamed to Ocotokit
9
+ * Switched to Faraday from HTTParty
10
+ ## 0.3.0
11
+ * Added set_repo_info patch from [Scott Bronson](http://github.com/bronson)
12
+ ## 0.2.4
13
+ * Rev'd HTTParty dependency, switched to Bundler
14
+ ## 0.2.3
15
+ * Patch from [Sutto](http://github.com/Sutto) to use authentication with list repos if available
16
+ ## 0.2.2
17
+ * Patch from [abrader](http://github.com/abrader) to add auth_params query to the blob, tree, and repo class methods
18
+ ## 0.2.1
19
+ * Contributors API courtesy of @enricob
20
+ ## 0.2.0
21
+ * Commits API courtesy of @enricob
22
+
23
+ ## 0.1.4
24
+
25
+ * Preserved links array and content for events parsed from feeds
26
+
27
+ ## 0.1.3
28
+
29
+ * Added Download event
30
+
31
+ ## 0.1.2
32
+
33
+ * Added Delete event type
34
+ * Added Public event type
35
+
36
+ ## 0.1.1
37
+
38
+ * Added Comment event type
39
+
40
+ ## 0.0.1 Initial version
41
+
42
+ * GitHub v2 API complete
@@ -0,0 +1,33 @@
1
+ require 'faraday'
2
+
3
+ # @api private
4
+ module Faraday
5
+ class Response::RaiseError < Response::Middleware
6
+ def on_complete(response)
7
+ case response[:status].to_i
8
+ when 400
9
+ raise Octokit::BadRequest, error_message(response)
10
+ when 401
11
+ raise Octokit::Unauthorized, error_message(response)
12
+ when 403
13
+ raise Octokit::Forbidden, error_message(response)
14
+ when 404
15
+ raise Octokit::NotFound, error_message(response)
16
+ when 406
17
+ raise Octokit::NotAcceptable, error_message(response)
18
+ when 500
19
+ raise Octokit::InternalServerError, error_message(response)
20
+ when 501
21
+ raise Octokit::NotImplemented, error_message(response)
22
+ when 502
23
+ raise Octokit::BadGateway, error_message(response)
24
+ when 503
25
+ raise Octokit::ServiceUnavailable, error_message(response)
26
+ end
27
+ end
28
+
29
+ def error_message(response)
30
+ "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]}#{(': ' + response[:body].inspect) if response[:body]}"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ module Octokit
2
+ class Client
3
+ module Authentication
4
+ def authentication
5
+ if login && token
6
+ {:login => "#{login}/token", :password => token}
7
+ elsif login && password
8
+ {:login => login, :password => password}
9
+ else
10
+ {}
11
+ end
12
+ end
13
+
14
+ def authenticated?
15
+ !authentication.empty?
16
+ end
17
+
18
+ def oauthed?
19
+ !oauth_token.nil?
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ module Octokit
2
+ class Client
3
+ module Commits
4
+
5
+ def commits(repo, branch="master", options={})
6
+ get("commits/list/#{Repository.new(repo)}/#{branch}", options)['commits']
7
+ end
8
+ alias :list_commits :commits
9
+
10
+ def commit(repo, sha, options={})
11
+ get("commits/show/#{Repository.new(repo)}/#{sha}", options)['commits']
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,34 @@
1
+ require 'faraday_middleware'
2
+ require 'faraday/response/raise_error'
3
+
4
+ module Octokit
5
+ class Client
6
+ # @private
7
+ module Connection
8
+ private
9
+
10
+ def connection(raw=false, authenticate=true)
11
+ options = {
12
+ :proxy => proxy,
13
+ :ssl => {:verify => false},
14
+ :url => endpoint,
15
+ }
16
+
17
+ options.merge!(:params => { :access_token => oauth_token }) if oauthed? && !authenticated?
18
+
19
+ Faraday::Connection.new(options) do |connection|
20
+ connection.use Faraday::Response::RaiseError
21
+ unless raw
22
+ connection.use Faraday::Response::Mashify
23
+ case format.to_s.downcase
24
+ when 'json' then connection.use Faraday::Response::ParseJson
25
+ when 'xml' then connection.use Faraday::Response::ParseXml
26
+ end
27
+ end
28
+ connection.basic_auth authentication[:login], authentication[:password] if authenticate and authenticated?
29
+ connection.adapter(adapter)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,60 @@
1
+ module Octokit
2
+ class Client
3
+ module Issues
4
+
5
+ def search_issues(repo, search_term, state='open', options={})
6
+ get("issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options)['issues']
7
+ end
8
+
9
+ def issues(repo, state='open', options={})
10
+ get("issues/list/#{Repository.new(repo)}/#{state}", options)['issues']
11
+ end
12
+ alias :list_issues :issues
13
+
14
+ def issues_labeled(repo, label, options={})
15
+ get("issues/list/#{Repository.new(repo)}/label/#{label}", options)['issues']
16
+ end
17
+
18
+ def issue(repo, number, options={})
19
+ get("issues/show/#{Repository.new(repo)}/#{number}", options)['issue']
20
+ end
21
+
22
+ def issue_comments(repo, number, options={})
23
+ get("issues/comments/#{Repository.new(repo)}/#{number}", options)['comments']
24
+ end
25
+
26
+ def create_issue(repo, title, body, options={})
27
+ post("issues/open/#{Repository.new(repo)}", options.merge({:title => title, :body => body}))['issue']
28
+ end
29
+ alias :open_issue :create_issue
30
+
31
+ def close_issue(repo, number, options={})
32
+ post("issues/close/#{Repository.new(repo)}/#{number}", options)['issue']
33
+ end
34
+
35
+ def reopen_issue(repo, number, options={})
36
+ post("issues/reopen/#{Repository.new(repo)}/#{number}", options)['issue']
37
+ end
38
+
39
+ def update_issue(repo, number, title, body, options={})
40
+ post("issues/edit/#{Repository.new(repo)}/#{number}", options.merge({:title => title, :body => body}))['issue']
41
+ end
42
+
43
+ def labels(repo, options={})
44
+ get("issues/labels/#{Repository.new(repo)}", options)['labels']
45
+ end
46
+
47
+ def add_label(repo, label, number=nil, options={})
48
+ post(["issues/label/add/#{Repository.new(repo)}/#{label}", number].compact.join('/'), options)['labels']
49
+ end
50
+
51
+ def remove_label(repo, label, number=nil, options={})
52
+ post(["issues/label/remove/#{Repository.new(repo)}/#{label}", number].compact.join('/'), options)['labels']
53
+ end
54
+
55
+ def add_comment(repo, number, comment, options={})
56
+ post("issues/comment/#{Repository.new(repo)}/#{number}", options.merge({:comment => comment}))['comment']
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,15 @@
1
+ module Octokit
2
+ class Client
3
+ module Network
4
+
5
+ def network_meta(repo, options={})
6
+ get("#{Repository.new(repo)}/network_meta", options, false, false)
7
+ end
8
+
9
+ def network_data(repo, options={})
10
+ get("#{Repository.new(repo)}/network_data_chunk", options, false, false)['commits']
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,33 @@
1
+ module Octokit
2
+ class Client
3
+ module Objects
4
+
5
+ def tree(repo, tree_sha, options={})
6
+ get("tree/show/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
7
+ end
8
+
9
+ def blob(repo, tree_sha, path, options={})
10
+ get("blob/show/#{Repository.new(repo)}/#{tree_sha}/#{path}", options)['blob']
11
+ end
12
+
13
+ def blobs(repo, tree_sha, options={})
14
+ get("blob/all/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
15
+ end
16
+
17
+ def blob_metadata(repo, tree_sha, options={})
18
+ get("blob/full/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
19
+ end
20
+ alias :blob_meta :blob_metadata
21
+
22
+ def tree_metadata(repo, tree_sha, options={})
23
+ get("tree/full/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
24
+ end
25
+ alias :tree_meta :tree_metadata
26
+
27
+ def raw(repo, sha, options={})
28
+ get("blob/show/#{Repository.new(repo)}/#{sha}", options, true).body
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,90 @@
1
+ module Octokit
2
+ class Client
3
+ module Organizations
4
+
5
+ def organization(org, options={})
6
+ get("organizations/#{org}", options)['organization']
7
+ end
8
+ alias :org :organization
9
+
10
+ def update_organization(org, values, options={})
11
+ put("organizations/#{org}", options.merge({:organization => values}))['organization']
12
+ end
13
+ alias :update_org :update_organization
14
+
15
+ def organizations(user=nil, options={})
16
+ if user
17
+ get("user/show/#{user}/organizations", options)
18
+ else
19
+ get("organizations", options)
20
+ end['organizations']
21
+ end
22
+ alias :list_organizations :organizations
23
+ alias :list_orgs :organizations
24
+ alias :orgs :organizations
25
+
26
+ def organization_repositories(org=nil, options={})
27
+ if org
28
+ get("organizations/#{org}/public_repositories", options)
29
+ else
30
+ get("organizations/repositories", options)
31
+ end['repositories']
32
+ end
33
+ alias :org_repositories :organization_repositories
34
+ alias :org_repos :organization_repositories
35
+
36
+ def organization_members(org, options={})
37
+ get("organizations/#{org}/public_members", options)['users']
38
+ end
39
+ alias :org_members :organization_members
40
+
41
+ def organization_teams(org, options={})
42
+ get("organizations/#{org}/teams", options)['teams']
43
+ end
44
+ alias :org_teams :organization_teams
45
+
46
+ def create_team(org, values, options={})
47
+ post("organizations/#{org}/teams", options.merge({:team => values}))['team']
48
+ end
49
+
50
+ def team(team_id, options={})
51
+ get("teams/#{team_id}", options)['team']
52
+ end
53
+
54
+ def update_team(team_id, values, options={})
55
+ put("teams/#{team_id}", options.merge({:team => values}))['team']
56
+ end
57
+
58
+ def delete_team(team_id, options={})
59
+ delete("teams/#{team_id}", options)['team']
60
+ end
61
+
62
+ def team_members(team_id, options={})
63
+ get("teams/#{team_id}/members", options)['users']
64
+ end
65
+
66
+ def add_team_member(team_id, user, options={})
67
+ post("teams/#{team_id}/members", options.merge({:name => user}))['user']
68
+ end
69
+
70
+ def remove_team_member(team_id, user, options={})
71
+ delete("teams/#{team_id}/members", options.merge({:name => user}))['user']
72
+ end
73
+
74
+ def team_repositories(team_id, options={})
75
+ get("teams/#{team_id}/repositories", options)['repositories']
76
+ end
77
+ alias :team_repos :team_repositories
78
+
79
+ def add_team_repository(team_id, repo, options={})
80
+ post("teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
81
+ end
82
+ alias :add_team_repo :add_team_repository
83
+
84
+ def remove_team_repository(team_id, repo, options={})
85
+ delete("teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
86
+ end
87
+ alias :remove_team_repo :remove_team_repository
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,25 @@
1
+ module Octokit
2
+ class Client
3
+ module Pulls
4
+ def create_pull_request(repo, base, head, title, body, options={})
5
+ pull = {
6
+ :base => base,
7
+ :head => head,
8
+ :title => title,
9
+ :body => body,
10
+ }
11
+ post("pulls/#{Repository.new(repo)}", options.merge({:pull => pull}))['pulls']
12
+ end
13
+
14
+ def pull_requests(repo, state='open', options={})
15
+ get("pulls/#{Repository.new(repo)}/#{state}", options)['pulls']
16
+ end
17
+ alias :pulls :pull_requests
18
+
19
+ def pull_request(repo, number, options={})
20
+ get("pulls/#{Repository.new(repo)}/#{number}", options)['pull']
21
+ end
22
+ alias :pull :pull_request
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,138 @@
1
+ module Octokit
2
+ class Client
3
+ module Repositories
4
+
5
+ def search_repositories(q, options={})
6
+ get("repos/search/#{q}", options)['repositories']
7
+ end
8
+ alias :search_repos :search_repositories
9
+
10
+ def repository(repo, options={})
11
+ get("repos/show/#{Repository.new(repo)}", options)['repository']
12
+ end
13
+ alias :repo :repository
14
+
15
+ def update_repository(repo, values, options={})
16
+ post("repos/show/#{Repository.new(repo)}", options.merge({:values => values}))['repository']
17
+ end
18
+ alias :update_repo :update_repository
19
+
20
+ def repositories(username=login, options={})
21
+ get(["repos/show", username].compact.join('/'), options)['repositories']
22
+ end
23
+ alias :list_repositories :repositories
24
+ alias :list_repos :repositories
25
+ alias :repos :repositories
26
+
27
+ def watch(repo, options={})
28
+ post("repos/watch/#{Repository.new(repo)}", options)['repository']
29
+ end
30
+
31
+ def unwatch(repo, options={})
32
+ post("repos/unwatch/#{Repository.new(repo)}", options)['repository']
33
+ end
34
+
35
+ def fork(repo, options={})
36
+ post("repos/fork/#{Repository.new(repo)}", options)['repository']
37
+ end
38
+
39
+ def create_repository(name, options={})
40
+ post("repos/create", options.merge(:name => name))['repository']
41
+ end
42
+ alias :create_repo :create_repository
43
+ alias :create :create_repository
44
+
45
+ def delete_repository(repo, options={})
46
+ response = post("repos/delete/#{Repository.new(repo)}", options)
47
+ if response.respond_to?(:delete_token)
48
+ response['delete_token']
49
+ else
50
+ response['repository']
51
+ end
52
+ end
53
+ alias :delete_repo :delete_repository
54
+
55
+ def delete_repository!(repo, options={})
56
+ response = post("repos/delete/#{Repository.new(repo)}", options)
57
+ post("repos/delete/#{Repository.new(repo)}", options.merge(:delete_token => response['delete_token']))['repository']
58
+ end
59
+ alias :delete_repo! :delete_repository!
60
+
61
+ def set_private(repo, options={})
62
+ post("repos/set/private/#{Repository.new(repo)}", options)['repository']
63
+ end
64
+
65
+ def set_public(repo, options={})
66
+ post("repos/set/public/#{Repository.new(repo)}", options)['repository']
67
+ end
68
+
69
+ def deploy_keys(repo, options={})
70
+ get("repos/keys/#{Repository.new(repo)}", options)['public_keys']
71
+ end
72
+ alias :list_deploy_keys :deploy_keys
73
+
74
+ def add_deploy_key(repo, title, key, options={})
75
+ post("repos/key/#{Repository.new(repo)}/add", options)['public_keys']
76
+ end
77
+
78
+ def remove_deploy_key(repo, id, options={})
79
+ post("repos/key/#{Repository.new(repo)}/remove", options.merge(:id => id))['public_keys']
80
+ end
81
+
82
+ def collaborators(repo, options={})
83
+ get("repos/show/#{Repository.new(repo)}/collaborators", options)['collaborators']
84
+ end
85
+ alias :collabs :collaborators
86
+
87
+ def add_collaborator(repo, collaborator, options={})
88
+ post("repos/collaborators/#{Repository.new(repo)}/add/#{collaborator}")['collaborators']
89
+ end
90
+ alias :add_collab :add_collaborator
91
+
92
+ def remove_collaborator(repo, collaborator, options={})
93
+ post("repos/collaborators/#{Repository.new(repo)}/remove/#{collaborator}")['collaborators']
94
+ end
95
+ alias :remove_collab :remove_collaborator
96
+
97
+ def pushable(options={})
98
+ get("repos/pushable", options)['repositories']
99
+ end
100
+
101
+ def repository_teams(repo, options={})
102
+ get("repos/show/#{Repository.new(repo)}/teams", options)['teams']
103
+ end
104
+ alias :repo_teams :repository_teams
105
+ alias :teams :repository_teams
106
+
107
+ def contributors(repo, anon=false, options={})
108
+ if anon
109
+ get("repos/show/#{Repository.new(repo)}/contributors/anon", options)
110
+ else
111
+ get("repos/show/#{Repository.new(repo)}/contributors", options)
112
+ end['contributors']
113
+ end
114
+ alias :contribs :contributors
115
+
116
+ def watchers(repo, options={})
117
+ get("repos/show/#{Repository.new(repo)}/watchers", options)['watchers']
118
+ end
119
+
120
+ def network(repo, options={})
121
+ get("repos/show/#{Repository.new(repo)}/network", options)['network']
122
+ end
123
+
124
+ def languages(repo, options={})
125
+ get("repos/show/#{Repository.new(repo)}/languages", options)['languages']
126
+ end
127
+
128
+ def tags(repo, options={})
129
+ get("repos/show/#{Repository.new(repo)}/tags", options)['tags']
130
+ end
131
+
132
+ def branches(repo, options={})
133
+ get("repos/show/#{Repository.new(repo)}/branches", options)['branches']
134
+ end
135
+
136
+ end
137
+ end
138
+ end