octokit 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.travis.yml +1 -0
  2. data/CHANGELOG.md +18 -18
  3. data/README.md +5 -3
  4. data/Rakefile +2 -0
  5. data/lib/faraday/response/{raise_error.rb → raise_octokit_error.rb} +11 -2
  6. data/lib/octokit.rb +18 -46
  7. data/lib/octokit/authentication.rb +21 -0
  8. data/lib/octokit/client.rb +13 -6
  9. data/lib/octokit/client/commits.rb +2 -2
  10. data/lib/octokit/client/issues.rb +184 -21
  11. data/lib/octokit/client/milestones.rb +87 -0
  12. data/lib/octokit/client/network.rb +2 -4
  13. data/lib/octokit/client/objects.rb +6 -8
  14. data/lib/octokit/client/organizations.rb +18 -19
  15. data/lib/octokit/client/pub_sub_hubbub.rb +41 -0
  16. data/lib/octokit/client/pub_sub_hubbub/service_hooks.rb +41 -0
  17. data/lib/octokit/client/pulls.rb +12 -3
  18. data/lib/octokit/client/repositories.rb +28 -30
  19. data/lib/octokit/client/timelines.rb +3 -5
  20. data/lib/octokit/client/users.rb +40 -18
  21. data/lib/octokit/connection.rb +42 -0
  22. data/lib/octokit/error.rb +34 -0
  23. data/lib/octokit/request.rb +44 -0
  24. data/lib/octokit/version.rb +1 -1
  25. data/octokit.gemspec +33 -28
  26. data/puppeteer.jpg +0 -0
  27. data/spec/faraday/response_spec.rb +2 -1
  28. data/spec/fixtures/v2/commit.json +1 -1
  29. data/spec/fixtures/v3/comment.json +14 -0
  30. data/spec/fixtures/v3/comments.json +44 -0
  31. data/spec/fixtures/v3/label.json +5 -0
  32. data/spec/fixtures/v3/labels.json +17 -0
  33. data/spec/fixtures/v3/milestone.json +12 -0
  34. data/spec/fixtures/v3/milestones.json +28 -0
  35. data/spec/fixtures/v3/not_found.json +3 -0
  36. data/spec/fixtures/v3/user.json +20 -0
  37. data/spec/helper.rb +14 -11
  38. data/spec/octokit/client/commits_spec.rb +3 -3
  39. data/spec/octokit/client/issues_spec.rb +82 -44
  40. data/spec/octokit/client/milestones_spec.rb +67 -0
  41. data/spec/octokit/client/objects_spec.rb +6 -6
  42. data/spec/octokit/client/organizations_spec.rb +19 -19
  43. data/spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb +45 -0
  44. data/spec/octokit/client/pub_sub_hubbub_spec.rb +49 -0
  45. data/spec/octokit/client/pulls_spec.rb +15 -3
  46. data/spec/octokit/client/repositories_spec.rb +30 -30
  47. data/spec/octokit/client/users_spec.rb +26 -26
  48. data/spec/octokit/client_spec.rb +2 -2
  49. data/spec/octokit_spec.rb +12 -3
  50. metadata +147 -55
  51. data/lib/octokit/client/authentication.rb +0 -23
  52. data/lib/octokit/client/connection.rb +0 -33
  53. data/lib/octokit/client/request.rb +0 -42
@@ -0,0 +1,87 @@
1
+ module Octokit
2
+ class Client
3
+ module Milestones
4
+
5
+ # List milestones for a repository
6
+ #
7
+ # @param repository [String, Repository, Hash] A GitHub repository.
8
+ # @param options [Hash] A customizable set of options.
9
+ # @option options [Integer] :milestone Milestone number.
10
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
11
+ # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
12
+ # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
13
+ # @return [Array] A list of milestones for a repository.
14
+ # @see http://developer.github.com/v3/issues/milestones/#List-Milestones-for-an-Issue
15
+ # @example List milestones for a repository
16
+ # Octokit.list_milestones("pengwynn/octokit")
17
+ def list_milestones(repository, options={})
18
+ get("/repos/#{Repository.new(repository)}/milestones", options, 3)
19
+ end
20
+ alias :milestones :list_milestones
21
+
22
+ # Get a single milestone for a repository
23
+ #
24
+ # @param repository [String, Repository, Hash] A GitHub repository.
25
+ # @param options [Hash] A customizable set of options.
26
+ # @option options [Integer] :milestone Milestone number.
27
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
28
+ # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
29
+ # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
30
+ # @return [Milestone] A single milestone from a repository.
31
+ # @see http://developer.github.com/v3/issues/milestones/#get-a-single-milestone
32
+ # @example Get a single milestone for a repository
33
+ # Octokit.milestone("pengwynn/octokit", 1)
34
+ def milestone(repository, number, options={})
35
+ get("/repos/#{Repository.new(repository)}/milestones/#{number}", options, 3)
36
+ end
37
+
38
+ # Create a milestone for a repository
39
+ #
40
+ # @param repository [String, Repository, Hash] A GitHub repository.
41
+ # @param title [String] A unique title.
42
+ # @param options [Hash] A customizable set of options.
43
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
44
+ # @option options [String] :description A meaningful description
45
+ # @option options [Time] :due_on Set if the milestone has a due date
46
+ # @return [Milestone] A single milestone object
47
+ # @see http://developer.github.com/v3/issues/milestones/#create-a-milestone
48
+ # @example Create a milestone for a repository
49
+ # Octokit.create_milestone("pengwynn/octokit", "0.7.0", {:description => 'Add support for v3 of Github API'})
50
+ def create_milestone(repository, title, options={})
51
+ post("/repos/#{Repository.new(repository)}/milestones", options.merge({:title => title}), 3)
52
+ end
53
+
54
+ # Update a milestone for a repository
55
+ #
56
+ # @param repository [String, Repository, Hash] A GitHub repository.
57
+ # @param number [String, Integer] Number ID of a milestone
58
+ # @param options [Hash] A customizable set of options.
59
+ # @option options [String] :title A unique title.
60
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
61
+ # @option options [String] :description A meaningful description
62
+ # @option options [Time] :due_on Set if the milestone has a due date
63
+ # @return [Milestone] A single milestone object
64
+ # @see http://developer.github.com/v3/issues/milestones/#update-a-milestone
65
+ # @example Update a milestone for a repository
66
+ # Octokit.update_milestone("pengwynn/octokit", 1, {:description => 'Add support for v3 of Github API'})
67
+ def update_milestone(repository, number, options={})
68
+ post("/repos/#{Repository.new(repository)}/milestones/#{number}", options, 3)
69
+ end
70
+ alias :edit_milestone :update_milestone
71
+
72
+ # Delete a single milestone for a repository
73
+ #
74
+ # @param repository [String, Repository, Hash] A GitHub repository.
75
+ # @param options [Hash] A customizable set of options.
76
+ # @option options [Integer] :milestone Milestone number.
77
+ # @return [Response] Response with status 204, no content
78
+ # @see http://developer.github.com/v3/issues/milestones/#delete-a-milestone
79
+ # @example Delete a single milestone from a repository
80
+ # Octokit.delete_milestone("pengwynn/octokit", 1)
81
+ def delete_milestone(repository, number, options={})
82
+ delete("/repos/#{Repository.new(repository)}/milestones/#{number}", options, 3, true, true)
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -1,15 +1,13 @@
1
1
  module Octokit
2
2
  class Client
3
3
  module Network
4
-
5
4
  def network_meta(repo, options={})
6
- get("#{Repository.new(repo)}/network_meta", options, 2, false)
5
+ get("/#{Repository.new(repo)}/network_meta", options, 2, false)
7
6
  end
8
7
 
9
8
  def network_data(repo, options={})
10
- get("#{Repository.new(repo)}/network_data_chunk", options, 2, false)['commits']
9
+ get("/#{Repository.new(repo)}/network_data_chunk", options, 2, false)['commits']
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -1,33 +1,31 @@
1
1
  module Octokit
2
2
  class Client
3
3
  module Objects
4
-
5
4
  def tree(repo, tree_sha, options={})
6
- get("api/v2/json/tree/show/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
5
+ get("/api/v2/json/tree/show/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
7
6
  end
8
7
 
9
8
  def blob(repo, tree_sha, path, options={})
10
- get("api/v2/json/blob/show/#{Repository.new(repo)}/#{tree_sha}/#{path}", options)['blob']
9
+ get("/api/v2/json/blob/show/#{Repository.new(repo)}/#{tree_sha}/#{path}", options)['blob']
11
10
  end
12
11
 
13
12
  def blobs(repo, tree_sha, options={})
14
- get("api/v2/json/blob/all/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
13
+ get("/api/v2/json/blob/all/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
15
14
  end
16
15
 
17
16
  def blob_metadata(repo, tree_sha, options={})
18
- get("api/v2/json/blob/full/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
17
+ get("/api/v2/json/blob/full/#{Repository.new(repo)}/#{tree_sha}", options)['blobs']
19
18
  end
20
19
  alias :blob_meta :blob_metadata
21
20
 
22
21
  def tree_metadata(repo, tree_sha, options={})
23
- get("api/v2/json/tree/full/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
22
+ get("/api/v2/json/tree/full/#{Repository.new(repo)}/#{tree_sha}", options)['tree']
24
23
  end
25
24
  alias :tree_meta :tree_metadata
26
25
 
27
26
  def raw(repo, sha, options={})
28
- get("api/v2/json/blob/show/#{Repository.new(repo)}/#{sha}", options, 2, true, true).body
27
+ get("/api/v2/json/blob/show/#{Repository.new(repo)}/#{sha}", options, 2, true, true).body
29
28
  end
30
-
31
29
  end
32
30
  end
33
31
  end
@@ -1,22 +1,21 @@
1
1
  module Octokit
2
2
  class Client
3
3
  module Organizations
4
-
5
4
  def organization(org, options={})
6
- get("api/v2/json/organizations/#{org}", options)['organization']
5
+ get("/api/v2/json/organizations/#{org}", options)['organization']
7
6
  end
8
7
  alias :org :organization
9
8
 
10
9
  def update_organization(org, values, options={})
11
- put("api/v2/json/organizations/#{org}", options.merge({:organization => values}))['organization']
10
+ put("/api/v2/json/organizations/#{org}", options.merge({:organization => values}))['organization']
12
11
  end
13
12
  alias :update_org :update_organization
14
13
 
15
14
  def organizations(user=nil, options={})
16
15
  if user
17
- get("api/v2/json/user/show/#{user}/organizations", options)
16
+ get("/api/v2/json/user/show/#{user}/organizations", options)
18
17
  else
19
- get("api/v2/json/organizations", options)
18
+ get("/api/v2/json/organizations", options)
20
19
  end['organizations']
21
20
  end
22
21
  alias :list_organizations :organizations
@@ -25,64 +24,64 @@ module Octokit
25
24
 
26
25
  def organization_repositories(org=nil, options={})
27
26
  if org
28
- get("api/v2/json/organizations/#{org}/public_repositories", options)
27
+ get("/api/v2/json/organizations/#{org}/public_repositories", options)
29
28
  else
30
- get("api/v2/json/organizations/repositories", options)
29
+ get("/api/v2/json/organizations/repositories", options)
31
30
  end['repositories']
32
31
  end
33
32
  alias :org_repositories :organization_repositories
34
33
  alias :org_repos :organization_repositories
35
34
 
36
35
  def organization_members(org, options={})
37
- get("api/v2/json/organizations/#{org}/public_members", options)['users']
36
+ get("/api/v2/json/organizations/#{org}/public_members", options)['users']
38
37
  end
39
38
  alias :org_members :organization_members
40
39
 
41
40
  def organization_teams(org, options={})
42
- get("api/v2/json/organizations/#{org}/teams", options)['teams']
41
+ get("/api/v2/json/organizations/#{org}/teams", options)['teams']
43
42
  end
44
43
  alias :org_teams :organization_teams
45
44
 
46
45
  def create_team(org, values, options={})
47
- post("api/v2/json/organizations/#{org}/teams", options.merge({:team => values}))['team']
46
+ post("/api/v2/json/organizations/#{org}/teams", options.merge({:team => values}))['team']
48
47
  end
49
48
 
50
49
  def team(team_id, options={})
51
- get("api/v2/json/teams/#{team_id}", options)['team']
50
+ get("/api/v2/json/teams/#{team_id}", options)['team']
52
51
  end
53
52
 
54
53
  def update_team(team_id, values, options={})
55
- put("api/v2/json/teams/#{team_id}", options.merge({:team => values}))['team']
54
+ put("/api/v2/json/teams/#{team_id}", options.merge({:team => values}))['team']
56
55
  end
57
56
 
58
57
  def delete_team(team_id, options={})
59
- delete("api/v2/json/teams/#{team_id}", options)['team']
58
+ delete("/api/v2/json/teams/#{team_id}", options)['team']
60
59
  end
61
60
 
62
61
  def team_members(team_id, options={})
63
- get("api/v2/json/teams/#{team_id}/members", options)['users']
62
+ get("/api/v2/json/teams/#{team_id}/members", options)['users']
64
63
  end
65
64
 
66
65
  def add_team_member(team_id, user, options={})
67
- post("api/v2/json/teams/#{team_id}/members", options.merge({:name => user}))['user']
66
+ post("/api/v2/json/teams/#{team_id}/members", options.merge({:name => user}))['user']
68
67
  end
69
68
 
70
69
  def remove_team_member(team_id, user, options={})
71
- delete("api/v2/json/teams/#{team_id}/members", options.merge({:name => user}))['user']
70
+ delete("/api/v2/json/teams/#{team_id}/members", options.merge({:name => user}))['user']
72
71
  end
73
72
 
74
73
  def team_repositories(team_id, options={})
75
- get("api/v2/json/teams/#{team_id}/repositories", options)['repositories']
74
+ get("/api/v2/json/teams/#{team_id}/repositories", options)['repositories']
76
75
  end
77
76
  alias :team_repos :team_repositories
78
77
 
79
78
  def add_team_repository(team_id, repo, options={})
80
- post("api/v2/json/teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
79
+ post("/api/v2/json/teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
81
80
  end
82
81
  alias :add_team_repo :add_team_repository
83
82
 
84
83
  def remove_team_repository(team_id, repo, options={})
85
- delete("api/v2/json/teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
84
+ delete("/api/v2/json/teams/#{team_id}/repositories", options.merge(:name => Repository.new(repo)))['repositories']
86
85
  end
87
86
  alias :remove_team_repo :remove_team_repository
88
87
  end
@@ -0,0 +1,41 @@
1
+ module Octokit
2
+ class Client
3
+ module PubSubHubbub
4
+ # Subscribe to a pubsub topic
5
+ #
6
+ # @param topic [String] A recoginized and supported pubsub topic
7
+ # @param callback [String] A callback url to be posted to when the topic event is fired
8
+ # @return [boolean] true if the subscribe was successful, otherwise an error is raised
9
+ # @example Subscribe to push events from one of your repositories, having an email sent when fired
10
+ # client = Octokit::Client.new(:oauth_token = "token")
11
+ # client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
12
+ def subscribe(topic, callback)
13
+ options = {
14
+ :"hub.mode" => "subscribe",
15
+ :"hub.topic" => topic,
16
+ :"hub.callback" => callback,
17
+ }
18
+ post("/hub", options, 3, true, true, true)
19
+ true
20
+ end
21
+
22
+ # Unsubscribe from a pubsub topic
23
+ #
24
+ # @param topic [String] A recoginized pubsub topic
25
+ # @param callback [String] A callback url to be unsubscribed from
26
+ # @return [boolean] true if the unsubscribe was successful, otherwise an error is raised
27
+ # @example Unsubscribe to push events from one of your repositories, no longer having an email sent when fired
28
+ # client = Octokit::Client.new(:oauth_token = "token")
29
+ # client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
30
+ def unsubscribe(topic, callback)
31
+ options = {
32
+ :"hub.mode" => "unsubscribe",
33
+ :"hub.topic" => topic,
34
+ :"hub.callback" => callback,
35
+ }
36
+ post("/hub", options, 3, true, true, true)
37
+ true
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ module Octokit
2
+ class Client
3
+ module PubSubHubbub
4
+ module ServiceHooks
5
+ # Subscribe to a repository through pubsub
6
+ #
7
+ # @param owner [String] owner of mentioned repository
8
+ # @param repository [String] repository name
9
+ # @param service_name [String] service name owner
10
+ # @param service_arguments [Hash] params that will be passed by subscibed hook.
11
+ # List of services is available @ https://github.com/github/github-services/tree/master/docs.
12
+ # Please refer Data node for complete list of arguments.
13
+ # @example Subscribe to push events to one of your repositories to Travis-CI
14
+ # client = Octokit::Client.new(:oauth_token = "token")
15
+ # client.subscribe_service_hook('joshk', 'device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })
16
+ def subscribe_service_hook(repo, service_name, service_arguments = {})
17
+ topic = "https://github.com/#{Repository.new(repo)}/events/push"
18
+ callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].join("=") }.join("&") }"
19
+ subscribe(topic, callback)
20
+ true
21
+ end
22
+
23
+ # Unsubscribe repository through pubsub
24
+ #
25
+ # @param owner [String] owner of mentioned repository
26
+ # @param repository [String] repository name
27
+ # @param service_name [String] service name owner
28
+ # List of services is available @ https://github.com/github/github-services/tree/master/docs.
29
+ # @example Subscribe to push events to one of your repositories to Travis-CI
30
+ # client = Octokit::Client.new(:oauth_token = "token")
31
+ # client.unsubscribe_service_hook('joshk', 'device_imapable', 'Travis')
32
+ def unsubscribe_service_hook(repo, service_name)
33
+ topic = "https://github.com/#{Repository.new(repo)}/events/push"
34
+ callback = "github://#{service_name}"
35
+ unsubscribe(topic, callback)
36
+ true
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -8,16 +8,25 @@ module Octokit
8
8
  :title => title,
9
9
  :body => body,
10
10
  }
11
- post("api/v2/json/pulls/#{Repository.new(repo)}", options.merge({:pull => pull}))['pulls']
11
+ post("/api/v2/json/pulls/#{Repository.new(repo)}", options.merge({:pull => pull}))['pulls']
12
+ end
13
+
14
+ def create_pull_request_for_issue(repo, base, head, issue, options={})
15
+ pull = {
16
+ :base => base,
17
+ :head => head,
18
+ :issue => issue
19
+ }
20
+ post("/api/v2/json/pulls/#{Repository.new(repo)}", options.merge({:pull => pull}))['pulls']
12
21
  end
13
22
 
14
23
  def pull_requests(repo, state='open', options={})
15
- get("api/v2/json/pulls/#{Repository.new(repo)}/#{state}", options)['pulls']
24
+ get("/api/v2/json/pulls/#{Repository.new(repo)}/#{state}", options)['pulls']
16
25
  end
17
26
  alias :pulls :pull_requests
18
27
 
19
28
  def pull_request(repo, number, options={})
20
- get("api/v2/json/pulls/#{Repository.new(repo)}/#{number}", options)['pull']
29
+ get("/api/v2/json/pulls/#{Repository.new(repo)}/#{number}", options)['pull']
21
30
  end
22
31
  alias :pull :pull_request
23
32
  end
@@ -1,49 +1,48 @@
1
1
  module Octokit
2
2
  class Client
3
3
  module Repositories
4
-
5
4
  def search_repositories(q, options={})
6
- get("api/v2/json/repos/search/#{q}", options)['repositories']
5
+ get("/api/v2/json/repos/search/#{q}", options)['repositories']
7
6
  end
8
7
  alias :search_repos :search_repositories
9
8
 
10
9
  def repository(repo, options={})
11
- get("api/v2/json/repos/show/#{Repository.new(repo)}", options)['repository']
10
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}", options)['repository']
12
11
  end
13
12
  alias :repo :repository
14
13
 
15
14
  def update_repository(repo, values, options={})
16
- post("api/v2/json/repos/show/#{Repository.new(repo)}", options.merge({:values => values}))['repository']
15
+ post("/api/v2/json/repos/show/#{Repository.new(repo)}", options.merge({:values => values}))['repository']
17
16
  end
18
17
  alias :update_repo :update_repository
19
18
 
20
19
  def repositories(username=login, options={})
21
- get(["api/v2/json/repos/show", username].compact.join('/'), options)['repositories']
20
+ get(["/api/v2/json/repos/show", username].compact.join('/'), options)['repositories']
22
21
  end
23
22
  alias :list_repositories :repositories
24
23
  alias :list_repos :repositories
25
24
  alias :repos :repositories
26
25
 
27
26
  def watch(repo, options={})
28
- post("api/v2/json/repos/watch/#{Repository.new(repo)}", options)['repository']
27
+ post("/api/v2/json/repos/watch/#{Repository.new(repo)}", options)['repository']
29
28
  end
30
29
 
31
30
  def unwatch(repo, options={})
32
- post("api/v2/json/repos/unwatch/#{Repository.new(repo)}", options)['repository']
31
+ post("/api/v2/json/repos/unwatch/#{Repository.new(repo)}", options)['repository']
33
32
  end
34
33
 
35
34
  def fork(repo, options={})
36
- post("api/v2/json/repos/fork/#{Repository.new(repo)}", options)['repository']
35
+ post("/api/v2/json/repos/fork/#{Repository.new(repo)}", options)['repository']
37
36
  end
38
37
 
39
38
  def create_repository(name, options={})
40
- post("api/v2/json/repos/create", options.merge(:name => name))['repository']
39
+ post("/api/v2/json/repos/create", options.merge(:name => name))['repository']
41
40
  end
42
41
  alias :create_repo :create_repository
43
42
  alias :create :create_repository
44
43
 
45
44
  def delete_repository(repo, options={})
46
- response = post("api/v2/json/repos/delete/#{Repository.new(repo)}", options)
45
+ response = post("/api/v2/json/repos/delete/#{Repository.new(repo)}", options)
47
46
  if response.respond_to?(:delete_token)
48
47
  response['delete_token']
49
48
  else
@@ -53,86 +52,85 @@ module Octokit
53
52
  alias :delete_repo :delete_repository
54
53
 
55
54
  def delete_repository!(repo, options={})
56
- delete_token = post("api/v2/json/repos/delete/#{Repository.new(repo)}", options)
57
- post("api/v2/json/repos/delete/#{Repository.new(repo)}", options.merge(:delete_token => delete_token))
55
+ delete_token = post("/api/v2/json/repos/delete/#{Repository.new(repo)}", options)
56
+ post("/api/v2/json/repos/delete/#{Repository.new(repo)}", options.merge(:delete_token => delete_token))
58
57
  end
59
58
  alias :delete_repo! :delete_repository!
60
59
 
61
60
  def set_private(repo, options={})
62
- post("api/v2/json/repos/set/private/#{Repository.new(repo)}", options)['repository']
61
+ post("/api/v2/json/repos/set/private/#{Repository.new(repo)}", options)['repository']
63
62
  end
64
63
 
65
64
  def set_public(repo, options={})
66
- post("api/v2/json/repos/set/public/#{Repository.new(repo)}", options)['repository']
65
+ post("/api/v2/json/repos/set/public/#{Repository.new(repo)}", options)['repository']
67
66
  end
68
67
 
69
68
  def deploy_keys(repo, options={})
70
- get("api/v2/json/repos/keys/#{Repository.new(repo)}", options)['public_keys']
69
+ get("/api/v2/json/repos/keys/#{Repository.new(repo)}", options)['public_keys']
71
70
  end
72
71
  alias :list_deploy_keys :deploy_keys
73
72
 
74
73
  def add_deploy_key(repo, title, key, options={})
75
- post("api/v2/json/repos/key/#{Repository.new(repo)}/add", options)['public_keys']
74
+ post("/api/v2/json/repos/key/#{Repository.new(repo)}/add", options)['public_keys']
76
75
  end
77
76
 
78
77
  def remove_deploy_key(repo, id, options={})
79
- post("api/v2/json/repos/key/#{Repository.new(repo)}/remove", options.merge(:id => id))['public_keys']
78
+ post("/api/v2/json/repos/key/#{Repository.new(repo)}/remove", options.merge(:id => id))['public_keys']
80
79
  end
81
80
 
82
81
  def collaborators(repo, options={})
83
- get("api/v2/json/repos/show/#{Repository.new(repo)}/collaborators", options)['collaborators']
82
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/collaborators", options)['collaborators']
84
83
  end
85
84
  alias :collabs :collaborators
86
85
 
87
86
  def add_collaborator(repo, collaborator, options={})
88
- post("api/v2/json/repos/collaborators/#{Repository.new(repo)}/add/#{collaborator}")['collaborators']
87
+ post("/api/v2/json/repos/collaborators/#{Repository.new(repo)}/add/#{collaborator}")['collaborators']
89
88
  end
90
89
  alias :add_collab :add_collaborator
91
90
 
92
91
  def remove_collaborator(repo, collaborator, options={})
93
- post("api/v2/json/repos/collaborators/#{Repository.new(repo)}/remove/#{collaborator}")['collaborators']
92
+ post("/api/v2/json/repos/collaborators/#{Repository.new(repo)}/remove/#{collaborator}")['collaborators']
94
93
  end
95
94
  alias :remove_collab :remove_collaborator
96
95
 
97
96
  def pushable(options={})
98
- get("api/v2/json/repos/pushable", options)['repositories']
97
+ get("/api/v2/json/repos/pushable", options)['repositories']
99
98
  end
100
99
 
101
100
  def repository_teams(repo, options={})
102
- get("api/v2/json/repos/show/#{Repository.new(repo)}/teams", options)['teams']
101
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/teams", options)['teams']
103
102
  end
104
103
  alias :repo_teams :repository_teams
105
104
  alias :teams :repository_teams
106
105
 
107
106
  def contributors(repo, anon=false, options={})
108
107
  if anon
109
- get("api/v2/json/repos/show/#{Repository.new(repo)}/contributors/anon", options)
108
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/contributors/anon", options)
110
109
  else
111
- get("api/v2/json/repos/show/#{Repository.new(repo)}/contributors", options)
110
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/contributors", options)
112
111
  end['contributors']
113
112
  end
114
113
  alias :contribs :contributors
115
114
 
116
115
  def watchers(repo, options={})
117
- get("api/v2/json/repos/show/#{Repository.new(repo)}/watchers", options)['watchers']
116
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/watchers", options)['watchers']
118
117
  end
119
118
 
120
119
  def network(repo, options={})
121
- get("api/v2/json/repos/show/#{Repository.new(repo)}/network", options)['network']
120
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/network", options)['network']
122
121
  end
123
122
 
124
123
  def languages(repo, options={})
125
- get("api/v2/json/repos/show/#{Repository.new(repo)}/languages", options)['languages']
124
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/languages", options)['languages']
126
125
  end
127
126
 
128
127
  def tags(repo, options={})
129
- get("api/v2/json/repos/show/#{Repository.new(repo)}/tags", options)['tags']
128
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/tags", options)['tags']
130
129
  end
131
130
 
132
131
  def branches(repo, options={})
133
- get("api/v2/json/repos/show/#{Repository.new(repo)}/branches", options)['branches']
132
+ get("/api/v2/json/repos/show/#{Repository.new(repo)}/branches", options)['branches']
134
133
  end
135
-
136
134
  end
137
135
  end
138
136
  end