octokit 2.7.2 → 3.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,44 +32,6 @@ module Octokit
32
32
  get "repos/#{Repository.new(repo)}/downloads/#{id}", options
33
33
  end
34
34
 
35
- # Create a download in a repository
36
- #
37
- # @param repo [String, Repository, Hash] A GitHub repository
38
- # @param name [String, Repository, Hash] A display name for the download
39
- # @option options [String] :description The download description
40
- # @option options [String] :content_type The content type. Defaults to 'text/plain'
41
- # @return [Sawyer::Resource] A single download from the repository
42
- # @deprecated As of December 11th, 2012: https://github.com/blog/1302-goodbye-uploads
43
- # @see http://developer.github.com/v3/repos/downloads/#create-a-new-download-part-1-create-the-resource
44
- # @example Create the "Robawt" download on Github/Hubot
45
- # Octokit.create_download("github/hubot", 'Robawt')
46
- def create_download(repo, name, options={})
47
- options[:content_type] ||= 'text/plain'
48
- file = Faraday::UploadIO.new(name, options[:content_type])
49
- resource = create_download_resource(repo, file.original_filename, File.size(name), options)
50
-
51
- resource_hash = {
52
- 'key' => resource.path,
53
- 'acl' => resource.acl,
54
- 'success_action_status' => 201,
55
- 'Filename' => resource.name,
56
- 'AWSAccessKeyId' => resource.accesskeyid,
57
- 'Policy' => resource.policy,
58
- 'Signature' => resource.signature,
59
- 'Content-Type' => resource.mime_type,
60
- 'file' => file
61
- }
62
-
63
- conn = Faraday.new(resource.rels[:s3].href) do |builder|
64
- builder.request :multipart
65
- builder.request :url_encoded
66
- builder.adapter :net_http
67
- end
68
-
69
- response = conn.post '/', resource_hash
70
- response.status == 201
71
- end
72
-
73
35
  # Delete a single download for a repository
74
36
  #
75
37
  # @param repo [String, Repository, Hash] A GitHub repository
@@ -83,11 +45,6 @@ module Octokit
83
45
  boolean_from_response :delete, "repos/#{Repository.new(repo)}/downloads/#{id}", options
84
46
  end
85
47
 
86
- private
87
-
88
- def create_download_resource(repo, name, size, options={})
89
- post "repos/#{Repository.new(repo)}/downloads", options.merge({:name => name, :size => size})
90
- end
91
48
  end
92
49
  end
93
50
  end
@@ -77,7 +77,7 @@ module Octokit
77
77
  # @example List events for a repository's network
78
78
  # Octokit.repository_network_events("sferik/rails_admin")
79
79
  def repository_network_events(repo, options = {})
80
- paginate "networks/#{Repository.new repo}/events", options
80
+ paginate "networks/#{Repository.new(repo)}/events", options
81
81
  end
82
82
 
83
83
  # List all events for an organization
@@ -114,7 +114,7 @@ module Octokit
114
114
  # @example Get all Issue Events for Octokit
115
115
  # Octokit.repository_issue_events("octokit/octokit.rb")
116
116
  def repository_issue_events(repo, options = {})
117
- paginate "repos/#{Repository.new repo}/issues/events", options
117
+ paginate "repos/#{Repository.new(repo)}/issues/events", options
118
118
  end
119
119
  alias :repo_issue_events :repository_issue_events
120
120
 
@@ -19,7 +19,7 @@ module Octokit
19
19
 
20
20
  # Get a Feed by name
21
21
  #
22
- # @param [Symbol, String] Name of feed to retrieve.
22
+ # @param name [Symbol, String] Name of feed to retrieve.
23
23
  # @return [Feed] Parsed feed in the format returned by the configured
24
24
  # parser.
25
25
  def feed(name, options = {})
@@ -48,7 +48,7 @@ module Octokit
48
48
  # @return [Sawyer::Resource] Gist information
49
49
  # @see http://developer.github.com/v3/gists/#get-a-single-gist
50
50
  def gist(gist, options = {})
51
- get "gists/#{Gist.new gist}", options
51
+ get "gists/#{Gist.new(gist)}", options
52
52
  end
53
53
 
54
54
  # Create a gist
@@ -85,7 +85,7 @@ module Octokit
85
85
  # :files => {"boo.md" => {"content" => "updated stuff"}}
86
86
  # })
87
87
  def edit_gist(gist, options = {})
88
- patch "gists/#{Gist.new gist}", options
88
+ patch "gists/#{Gist.new(gist)}", options
89
89
  end
90
90
 
91
91
  #
@@ -95,7 +95,7 @@ module Octokit
95
95
  # @return [Boolean] Indicates if gist is starred successfully
96
96
  # @see http://developer.github.com/v3/gists/#star-a-gist
97
97
  def star_gist(gist, options = {})
98
- boolean_from_response :put, "gists/#{Gist.new gist}/star", options
98
+ boolean_from_response :put, "gists/#{Gist.new(gist)}/star", options
99
99
  end
100
100
 
101
101
  # Unstar a gist
@@ -104,7 +104,7 @@ module Octokit
104
104
  # @return [Boolean] Indicates if gist is unstarred successfully
105
105
  # @see http://developer.github.com/v3/gists/#unstar-a-gist
106
106
  def unstar_gist(gist, options = {})
107
- boolean_from_response :delete, "gists/#{Gist.new gist}/star", options
107
+ boolean_from_response :delete, "gists/#{Gist.new(gist)}/star", options
108
108
  end
109
109
 
110
110
  # Check if a gist is starred
@@ -113,7 +113,7 @@ module Octokit
113
113
  # @return [Boolean] Indicates if gist is starred
114
114
  # @see http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
115
115
  def gist_starred?(gist, options = {})
116
- boolean_from_response :get, "gists/#{Gist.new gist}/star", options
116
+ boolean_from_response :get, "gists/#{Gist.new(gist)}/star", options
117
117
  end
118
118
 
119
119
  # Fork a gist
@@ -122,7 +122,7 @@ module Octokit
122
122
  # @return [Sawyer::Resource] Data for the new gist
123
123
  # @see http://developer.github.com/v3/gists/#fork-a-gist
124
124
  def fork_gist(gist, options = {})
125
- post "gists/#{Gist.new gist}/forks", options
125
+ post "gists/#{Gist.new(gist)}/forks", options
126
126
  end
127
127
 
128
128
  # Delete a gist
@@ -131,7 +131,7 @@ module Octokit
131
131
  # @return [Boolean] Indicating success of deletion
132
132
  # @see http://developer.github.com/v3/gists/#delete-a-gist
133
133
  def delete_gist(gist, options = {})
134
- boolean_from_response :delete, "gists/#{Gist.new gist}", options
134
+ boolean_from_response :delete, "gists/#{Gist.new(gist)}", options
135
135
  end
136
136
 
137
137
  # List gist comments
@@ -6,7 +6,7 @@ module Octokit
6
6
  # @see http://developer.github.com/v3/issues/
7
7
  module Issues
8
8
 
9
- # List issues for a the authenticated user or repository
9
+ # List issues for the authenticated user or repository
10
10
  #
11
11
  # @param repository [String, Repository, Hash] A GitHub repository.
12
12
  # @param options [Sawyer::Resource] A customizable set of options.
@@ -40,7 +40,7 @@ module Octokit
40
40
  #
41
41
  # @param options [Sawyer::Resource] A customizable set of options.
42
42
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
43
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>all</tt>.
43
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
44
44
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
45
45
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
46
46
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
@@ -61,18 +61,18 @@ module Octokit
61
61
  # @param org [String] Organization GitHub username.
62
62
  # @param options [Sawyer::Resource] A customizable set of options.
63
63
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
64
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>all</tt>.
64
+ # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
65
65
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
66
66
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
67
67
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
68
68
  # @option options [Integer] :page (1) Page number.
69
69
  # @option options [String] :since Timestamp in ISO 8601
70
70
  # format: YYYY-MM-DDTHH:MM:SSZ
71
- # @return [Array<Sawyer::Resource>] A list of issues for a repository.
71
+ # @return [Array<Sawyer::Resource>] A list of issues.
72
72
  # @see http://developer.github.com/v3/issues/#list-issues
73
- # @example List issues for the authenticted user across owned and member repositories
73
+ # @example List all issues for a given organization for the authenticated user
74
74
  # @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
75
- # @client.user_issues
75
+ # @client.org_issues("octokit")
76
76
  def org_issues(org, options = {})
77
77
  paginate "orgs/#{org}/issues", options
78
78
  end
@@ -190,7 +190,7 @@ module Octokit
190
190
  # :since => '2010-05-04T23:45:02Z'
191
191
  # })
192
192
  def issues_comments(repo, options = {})
193
- paginate "repos/#{Repository.new repo}/issues/comments", options
193
+ paginate "repos/#{Repository.new(repo)}/issues/comments", options
194
194
  end
195
195
 
196
196
  # Get all comments attached to an issue
@@ -46,7 +46,7 @@ module Octokit
46
46
  # @example Get your notifications for octokit/octokit.rb since a time.
47
47
  # @client.repository_notifications({since: '2012-10-09T23:39:01Z'})
48
48
  def repository_notifications(repo, options = {})
49
- paginate "repos/#{Repository.new repo}/notifications", options
49
+ paginate "repos/#{Repository.new(repo)}/notifications", options
50
50
  end
51
51
  alias :repo_notifications :repository_notifications
52
52
 
@@ -87,7 +87,7 @@ module Octokit
87
87
  # @example
88
88
  # @client.mark_notifications_as_read("octokit/octokit.rb")
89
89
  def mark_repository_notifications_as_read(repo, options = {})
90
- request :put, "repos/#{Repository.new repo}/notifications", options
90
+ request :put, "repos/#{Repository.new(repo)}/notifications", options
91
91
 
92
92
  last_response.status == 205
93
93
  end
@@ -93,7 +93,7 @@ module Octokit
93
93
  # @example Fetch a tag
94
94
  # Octokit.tag('octokit/octokit.rb', '23aad20633f4d2981b1c7209a800db3014774e96')
95
95
  def tag(repo, tag_sha, options = {})
96
- get "repos/#{Repository.new repo}/git/tags/#{tag_sha}", options
96
+ get "repos/#{Repository.new(repo)}/git/tags/#{tag_sha}", options
97
97
  end
98
98
 
99
99
  # Create a tag
@@ -134,7 +134,7 @@ module Octokit
134
134
  :date => tagger_date
135
135
  }
136
136
  )
137
- post "repos/#{Repository.new repo}/git/tags", options
137
+ post "repos/#{Repository.new(repo)}/git/tags", options
138
138
  end
139
139
  end
140
140
  end
@@ -374,7 +374,7 @@ module Octokit
374
374
  # @example
375
375
  # @client.team_repo?(8675309, 'octokit/octokit.rb')
376
376
  def team_repository?(team_id, repo, options = {})
377
- boolean_from_response :get, "teams/#{team_id}/repos/#{Repository.new repo}"
377
+ boolean_from_response :get, "teams/#{team_id}/repos/#{Repository.new(repo)}"
378
378
  end
379
379
  alias :team_repo? :team_repository?
380
380
 
@@ -0,0 +1,38 @@
1
+ module Octokit
2
+ class Client
3
+
4
+ # Methods for the Pages API
5
+ #
6
+ # @see http://developer.github.com/v3/repos/pages/
7
+ module Pages
8
+
9
+ # List Pages information for a repository
10
+ #
11
+ # @param repo [String, Repository, Hash] A GitHub repository
12
+ # @return Sawyer::Resource A GitHub Pages resource
13
+ # @see http://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site
14
+ def pages(repo, options = {})
15
+ get "repos/#{Repository.new(repo)}/pages", options
16
+ end
17
+
18
+ # List Pages builds for a repository
19
+ #
20
+ # @param repo [String, Repository, Hash] A GitHub repository
21
+ # @return [Array<Sawyer::Resource>] A list of build history for a repository.
22
+ # @see http://developer.github.com/v3/repos/pages/#list-pages-builds
23
+ def pages_builds(repo, options = {})
24
+ get "repos/#{Repository.new(repo)}/pages/builds", options
25
+ end
26
+ alias :list_pages_builds :pages_builds
27
+
28
+ # List the latest Pages build information for a repository
29
+ #
30
+ # @param repo [String, Repository, Hash] A GitHub repository
31
+ # @return Sawyer::Resource A GitHub Pages resource about a build
32
+ # @see http://developer.github.com/v3/repos/pages/#list-latest-pages-build
33
+ def latest_pages_build(repo, options = {})
34
+ get "repos/#{Repository.new(repo)}/pages/builds/latest", options
35
+ end
36
+ end
37
+ end
38
+ end
@@ -17,17 +17,20 @@ module Octokit
17
17
  #
18
18
  # @param topic [String] A recoginized and supported pubsub topic
19
19
  # @param callback [String] A callback url to be posted to when the topic event is fired
20
+ # @param secret [String] An optional shared secret used to generate a SHA1 HMAC of the outgoing body content
20
21
  # @return [Boolean] true if the subscribe was successful, otherwise an error is raised
21
22
  # @see http://developer.github.com/v3/repos/hooks/#subscribing
22
23
  # @example Subscribe to push events from one of your repositories, having an email sent when fired
23
24
  # client = Octokit::Client.new(:oauth_token = "token")
24
25
  # client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
25
- def subscribe(topic, callback)
26
+ def subscribe(topic, callback, secret = nil)
26
27
  options = {
27
28
  :"hub.callback" => callback,
28
29
  :"hub.mode" => "subscribe",
29
30
  :"hub.topic" => topic
30
31
  }
32
+ options.merge!(:"hub.secret" => secret) unless secret.nil?
33
+
31
34
  response = pub_sub_hubbub_request(options)
32
35
 
33
36
  response.status == 204
@@ -60,14 +63,16 @@ module Octokit
60
63
  # @param service_arguments [Hash] params that will be passed by subscribed hook.
61
64
  # List of services is available @ https://github.com/github/github-services/tree/master/docs.
62
65
  # Please refer Data node for complete list of arguments.
66
+ # @param secret [String] An optional shared secret used to generate a SHA1 HMAC of the outgoing body content
67
+ # @return [Boolean] True if subscription successful, false otherwise
63
68
  # @see http://developer.github.com/v3/repos/hooks/#subscribing
64
69
  # @example Subscribe to push events to one of your repositories to Travis-CI
65
70
  # client = Octokit::Client.new(:oauth_token = "token")
66
71
  # client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })
67
- def subscribe_service_hook(repo, service_name, service_arguments = {})
72
+ def subscribe_service_hook(repo, service_name, service_arguments = {}, secret = nil)
68
73
  topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
69
74
  callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].map{ |p| URI.encode_www_form_component(p) }.join("=") }.join("&") }"
70
- subscribe(topic, callback)
75
+ subscribe(topic, callback, secret)
71
76
  end
72
77
 
73
78
  # Unsubscribe repository through pubsub
@@ -102,7 +107,7 @@ module Octokit
102
107
  http.adapter Faraday.default_adapter
103
108
  end
104
109
 
105
- response = conn.post do |req|
110
+ conn.post do |req|
106
111
  req.url "hub"
107
112
  req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
108
113
  req.body = options
@@ -8,16 +8,28 @@ module Octokit
8
8
 
9
9
  # List pull requests for a repository
10
10
  #
11
- # @see http://developer.github.com/v3/pulls/#list-pull-requests
12
- # @param repo [String, Hash, Repository] A GitHub repository
13
- # @param options [Hash] Method options
14
- # @option options [String] :state `open` or `closed`. Default is `open`.
11
+ # @overload pull_requests(repo, options)
12
+ # @param repo [String, Hash, Repository] A GitHub repository
13
+ # @param options [Hash] Method options
14
+ # @option options [String] :state `open` or `closed`.
15
+ # @overload pull_requests(repo, state, options)
16
+ # @deprecated
17
+ # @param repo [String, Hash, Repository] A GitHub repository
18
+ # @param state [String] `open` or `closed`.
19
+ # @param options [Hash] Method options
15
20
  # @return [Array<Sawyer::Resource>] Array of pulls
21
+ # @see http://developer.github.com/v3/pulls/#list-pull-requests
16
22
  # @example
17
- # Octokit.pull_requests('rails/rails')
18
- def pull_requests(repo, state = nil, options = {})
19
- options[:state] = state if state
20
- paginate "repos/#{Repository.new(repo)}/pulls", options
23
+ # Octokit.pull_requests('rails/rails', :state => 'closed')
24
+ def pull_requests(*args)
25
+ arguments = Arguments.new(args)
26
+ opts = arguments.options
27
+ repo = arguments.shift
28
+ if state = arguments.shift
29
+ warn "DEPRECATED: Client#pull_requests: Passing state as positional argument is deprecated. Please use :state => '#{state}'"
30
+ opts[:state] = state if state
31
+ end
32
+ paginate "repos/#{Repository.new(repo)}/pulls", opts
21
33
  end
22
34
  alias :pulls :pull_requests
23
35
 
@@ -100,10 +112,7 @@ module Octokit
100
112
  arguments = Octokit::Arguments.new(args)
101
113
  repo = arguments.shift
102
114
  number = arguments.shift
103
- title = arguments.shift
104
- body = arguments.shift
105
- state = arguments.shift
106
- patch "repos/#{Repository.new repo}/pulls/#{number}", arguments.options
115
+ patch "repos/#{Repository.new(repo)}/pulls/#{number}", arguments.options
107
116
  end
108
117
 
109
118
  # Close a pull request
@@ -156,7 +165,7 @@ module Octokit
156
165
  # :since => '2010-05-04T23:45:02Z'
157
166
  # })
158
167
  def pull_requests_comments(repo, options = {})
159
- get("repos/#{Repository.new repo}/pulls/comments", options)
168
+ get("repos/#{Repository.new(repo)}/pulls/comments", options)
160
169
  end
161
170
  alias :pulls_comments :pull_requests_comments
162
171
  alias :reviews_comments :pull_requests_comments
@@ -183,7 +192,7 @@ module Octokit
183
192
  # @example
184
193
  # @client.pull_request_comment("pengwynn/octkit", 1903950)
185
194
  def pull_request_comment(repo, comment_id, options = {})
186
- get "repos/#{Repository.new repo}/pulls/comments/#{comment_id}", options
195
+ get "repos/#{Repository.new(repo)}/pulls/comments/#{comment_id}", options
187
196
  end
188
197
  alias :pull_comment :pull_request_comment
189
198
  alias :review_comment :pull_request_comment
@@ -208,7 +217,7 @@ module Octokit
208
217
  :path => path,
209
218
  :position => position
210
219
  })
211
- post "repos/#{Repository.new repo}/pulls/#{pull_id}/comments", options
220
+ post "repos/#{Repository.new(repo)}/pulls/#{pull_id}/comments", options
212
221
  end
213
222
  alias :create_pull_comment :create_pull_request_comment
214
223
  alias :create_view_comment :create_pull_request_comment
@@ -228,7 +237,7 @@ module Octokit
228
237
  :body => body,
229
238
  :in_reply_to => comment_id
230
239
  })
231
- post "repos/#{Repository.new repo}/pulls/#{pull_id}/comments", options
240
+ post "repos/#{Repository.new(repo)}/pulls/#{pull_id}/comments", options
232
241
  end
233
242
  alias :create_pull_reply :create_pull_request_comment_reply
234
243
  alias :create_review_reply :create_pull_request_comment_reply
@@ -244,7 +253,7 @@ module Octokit
244
253
  # @client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
245
254
  def update_pull_request_comment(repo, comment_id, body, options = {})
246
255
  options.merge! :body => body
247
- patch("repos/#{Repository.new repo}/pulls/comments/#{comment_id}", options)
256
+ patch("repos/#{Repository.new(repo)}/pulls/comments/#{comment_id}", options)
248
257
  end
249
258
  alias :update_pull_comment :update_pull_request_comment
250
259
  alias :update_review_comment :update_pull_request_comment
@@ -258,7 +267,7 @@ module Octokit
258
267
  # @example
259
268
  # @client.delete_pull_request_comment("octokit/octokit.rb", 1902707)
260
269
  def delete_pull_request_comment(repo, comment_id, options = {})
261
- boolean_from_response(:delete, "repos/#{Repository.new repo}/pulls/comments/#{comment_id}", options)
270
+ boolean_from_response(:delete, "repos/#{Repository.new(repo)}/pulls/comments/#{comment_id}", options)
262
271
  end
263
272
  alias :delete_pull_comment :delete_pull_request_comment
264
273
  alias :delete_review_comment :delete_pull_request_comment
@@ -136,7 +136,7 @@ module Octokit
136
136
  end
137
137
  rescue LoadError
138
138
  msg = "Please pass content_type or install mime-types gem to guess content type from file"
139
- raise Octokit::MissingContentType.new msg
139
+ raise Octokit::MissingContentType.new(msg)
140
140
  end
141
141
 
142
142
  end
@@ -12,7 +12,7 @@ module Octokit
12
12
  # @param repo [String, Hash, Repository] A GitHub repository
13
13
  # @return [Sawyer::Resource] if a repository exists, false otherwise
14
14
  def repository?(repo, options = {})
15
- repository(repo, options)
15
+ !!repository(repo, options)
16
16
  rescue Octokit::NotFound
17
17
  false
18
18
  end
@@ -23,7 +23,7 @@ module Octokit
23
23
  # @param repo [String, Hash, Repository] A GitHub repository
24
24
  # @return [Sawyer::Resource] Repository information
25
25
  def repository(repo, options = {})
26
- get "repos/#{Repository.new repo}", options
26
+ get "repos/#{Repository.new(repo)}", options
27
27
  end
28
28
  alias :repo :repository
29
29
 
@@ -56,6 +56,7 @@ module Octokit
56
56
  # authenticated user are returned
57
57
  #
58
58
  # @see http://developer.github.com/v3/repos/#list-your-repositories
59
+ # @see http://developer.github.com/v3/repos/#list-user-repositories
59
60
  # @param username [String] Optional username for which to list repos
60
61
  # @return [Array<Sawyer::Resource>] List of repositories
61
62
  def repositories(username=nil, options = {})
@@ -90,7 +91,7 @@ module Octokit
90
91
  # @return [Boolean] `true` if successfully starred
91
92
  # @see http://developer.github.com/v3/activity/starring/#star-a-repository
92
93
  def star(repo, options = {})
93
- boolean_from_response :put, "user/starred/#{Repository.new repo}", options
94
+ boolean_from_response :put, "user/starred/#{Repository.new(repo)}", options
94
95
  end
95
96
 
96
97
  # Unstar a repository
@@ -99,7 +100,7 @@ module Octokit
99
100
  # @return [Boolean] `true` if successfully unstarred
100
101
  # @see http://developer.github.com/v3/activity/starring/#unstar-a-repository
101
102
  def unstar(repo, options = {})
102
- boolean_from_response :delete, "user/starred/#{Repository.new repo}", options
103
+ boolean_from_response :delete, "user/starred/#{Repository.new(repo)}", options
103
104
  end
104
105
 
105
106
  # Watch a repository
@@ -109,7 +110,7 @@ module Octokit
109
110
  # @deprecated Use #star instead
110
111
  # @see http://developer.github.com/v3/activity/watching/#watch-a-repository-legacy
111
112
  def watch(repo, options = {})
112
- boolean_from_response :put, "user/watched/#{Repository.new repo}", options
113
+ boolean_from_response :put, "user/watched/#{Repository.new(repo)}", options
113
114
  end
114
115
 
115
116
  # Unwatch a repository
@@ -119,7 +120,7 @@ module Octokit
119
120
  # @deprecated Use #unstar instead
120
121
  # @see http://developer.github.com/v3/activity/watching/#stop-watching-a-repository-legacy
121
122
  def unwatch(repo, options = {})
122
- boolean_from_response :delete, "user/watched/#{Repository.new repo}", options
123
+ boolean_from_response :delete, "user/watched/#{Repository.new(repo)}", options
123
124
  end
124
125
 
125
126
  # Fork a repository
@@ -128,7 +129,7 @@ module Octokit
128
129
  # @return [Sawyer::Resource] Repository info for the new fork
129
130
  # @see http://developer.github.com/v3/repos/forks/#create-a-fork
130
131
  def fork(repo, options = {})
131
- post "repos/#{Repository.new repo}/forks", options
132
+ post "repos/#{Repository.new(repo)}/forks", options
132
133
  end
133
134
 
134
135
  # Create a repository for a user or organization
@@ -167,7 +168,7 @@ module Octokit
167
168
  # @param repo [String, Hash, Repository] A GitHub repository
168
169
  # @return [Boolean] `true` if repository was deleted
169
170
  def delete_repository(repo, options = {})
170
- boolean_from_response :delete, "repos/#{Repository.new repo}", options
171
+ boolean_from_response :delete, "repos/#{Repository.new(repo)}", options
171
172
  end
172
173
  alias :delete_repo :delete_repository
173
174
 
@@ -201,7 +202,7 @@ module Octokit
201
202
  # @example
202
203
  # @client.list_deploy_keys('octokit/octokit.rb')
203
204
  def deploy_keys(repo, options = {})
204
- paginate "repos/#{Repository.new repo}/keys", options
205
+ paginate "repos/#{Repository.new(repo)}/keys", options
205
206
  end
206
207
  alias :list_deploy_keys :deploy_keys
207
208
 
@@ -214,7 +215,7 @@ module Octokit
214
215
  # @example
215
216
  # @client.deploy_key('octokit/octokit.rb', 8675309)
216
217
  def deploy_key(repo, id, options={})
217
- get "repos/#{Repository.new repo}/keys/#{id}", options
218
+ get "repos/#{Repository.new(repo)}/keys/#{id}", options
218
219
  end
219
220
 
220
221
  # Add deploy key to a repo
@@ -229,7 +230,7 @@ module Octokit
229
230
  # @example
230
231
  # @client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')
231
232
  def add_deploy_key(repo, title, key, options = {})
232
- post "repos/#{Repository.new repo}/keys", options.merge(:title => title, :key => key)
233
+ post "repos/#{Repository.new(repo)}/keys", options.merge(:title => title, :key => key)
233
234
  end
234
235
 
235
236
  # Edit a deploy key
@@ -246,7 +247,7 @@ module Octokit
246
247
  # @example
247
248
  # @client.update_deploy_key('octokit/octokit.rb', 8675309, :title => 'Uber', :key => 'ssh-rsa BBB...'))
248
249
  def edit_deploy_key(repo, id, options)
249
- patch "repos/#{Repository.new repo}/keys/#{id}", options
250
+ patch "repos/#{Repository.new(repo)}/keys/#{id}", options
250
251
  end
251
252
  alias :update_deploy_key :edit_deploy_key
252
253
 
@@ -261,7 +262,7 @@ module Octokit
261
262
  # @example
262
263
  # @client.remove_deploy_key('octokit/octokit.rb', 100000)
263
264
  def remove_deploy_key(repo, id, options = {})
264
- boolean_from_response :delete, "repos/#{Repository.new repo}/keys/#{id}", options
265
+ boolean_from_response :delete, "repos/#{Repository.new(repo)}/keys/#{id}", options
265
266
  end
266
267
 
267
268
  # List collaborators
@@ -278,7 +279,7 @@ module Octokit
278
279
  # @example
279
280
  # @client.collabs('octokit/octokit.rb')
280
281
  def collaborators(repo, options = {})
281
- paginate "repos/#{Repository.new repo}/collaborators", options
282
+ paginate "repos/#{Repository.new(repo)}/collaborators", options
282
283
  end
283
284
  alias :collabs :collaborators
284
285
 
@@ -295,7 +296,7 @@ module Octokit
295
296
  # @example
296
297
  # @client.add_collab('octokit/octokit.rb', 'holman')
297
298
  def add_collaborator(repo, collaborator, options = {})
298
- boolean_from_response :put, "repos/#{Repository.new repo}/collaborators/#{collaborator}", options
299
+ boolean_from_response :put, "repos/#{Repository.new(repo)}/collaborators/#{collaborator}", options
299
300
  end
300
301
  alias :add_collab :add_collaborator
301
302
 
@@ -312,7 +313,7 @@ module Octokit
312
313
  # @example
313
314
  # @client.remove_collab('octokit/octokit.rb', 'holman')
314
315
  def remove_collaborator(repo, collaborator, options = {})
315
- boolean_from_response :delete, "repos/#{Repository.new repo}/collaborators/#{collaborator}", options
316
+ boolean_from_response :delete, "repos/#{Repository.new(repo)}/collaborators/#{collaborator}", options
316
317
  end
317
318
  alias :remove_collab :remove_collaborator
318
319
 
@@ -327,7 +328,7 @@ module Octokit
327
328
  # @example
328
329
  # @client.collaborator?('octokit/octokit.rb', 'holman')
329
330
  def collaborator?(repo, collaborator, options={})
330
- boolean_from_response :get, "repos/#{Repository.new repo}/collaborators/#{collaborator}", options
331
+ boolean_from_response :get, "repos/#{Repository.new(repo)}/collaborators/#{collaborator}", options
331
332
  end
332
333
 
333
334
  # List teams for a repo
@@ -344,7 +345,7 @@ module Octokit
344
345
  # @example
345
346
  # @client.teams('octokit/pengwynn')
346
347
  def repository_teams(repo, options = {})
347
- paginate "repos/#{Repository.new repo}/teams", options
348
+ paginate "repos/#{Repository.new(repo)}/teams", options
348
349
  end
349
350
  alias :repo_teams :repository_teams
350
351
  alias :teams :repository_teams
@@ -365,7 +366,7 @@ module Octokit
365
366
  # @client.contribs('octokit/octokit.rb')
366
367
  def contributors(repo, anon = nil, options = {})
367
368
  options[:anon] = 1 if anon.to_s[/1|true/]
368
- paginate "repos/#{Repository.new repo}/contributors", options
369
+ paginate "repos/#{Repository.new(repo)}/contributors", options
369
370
  end
370
371
  alias :contribs :contributors
371
372
 
@@ -381,7 +382,7 @@ module Octokit
381
382
  # @example
382
383
  # @client.stargazers('octokit/octokit.rb')
383
384
  def stargazers(repo, options = {})
384
- paginate "repos/#{Repository.new repo}/stargazers", options
385
+ paginate "repos/#{Repository.new(repo)}/stargazers", options
385
386
  end
386
387
 
387
388
  # @deprecated Use {#stargazers} instead
@@ -398,7 +399,7 @@ module Octokit
398
399
  # @example
399
400
  # @client.watchers('octokit/octokit.rb')
400
401
  def watchers(repo, options = {})
401
- paginate "repos/#{Repository.new repo}/watchers", options
402
+ paginate "repos/#{Repository.new(repo)}/watchers", options
402
403
  end
403
404
 
404
405
  # List forks
@@ -415,7 +416,7 @@ module Octokit
415
416
  # @example
416
417
  # @client.forks('octokit/octokit.rb')
417
418
  def forks(repo, options = {})
418
- paginate "repos/#{Repository.new repo}/forks", options
419
+ paginate "repos/#{Repository.new(repo)}/forks", options
419
420
  end
420
421
  alias :network :forks
421
422
 
@@ -431,7 +432,7 @@ module Octokit
431
432
  # @example
432
433
  # @client.languages('octokit/octokit.rb')
433
434
  def languages(repo, options = {})
434
- paginate "repos/#{Repository.new repo}/languages", options
435
+ paginate "repos/#{Repository.new(repo)}/languages", options
435
436
  end
436
437
 
437
438
  # List tags
@@ -446,7 +447,7 @@ module Octokit
446
447
  # @example
447
448
  # @client.tags('octokit/octokit.rb')
448
449
  def tags(repo, options = {})
449
- paginate "repos/#{Repository.new repo}/tags", options
450
+ paginate "repos/#{Repository.new(repo)}/tags", options
450
451
  end
451
452
 
452
453
  # List branches
@@ -461,7 +462,7 @@ module Octokit
461
462
  # @example
462
463
  # @client.branches('octokit/octokit.rb')
463
464
  def branches(repo, options = {})
464
- paginate "repos/#{Repository.new repo}/branches", options
465
+ paginate "repos/#{Repository.new(repo)}/branches", options
465
466
  end
466
467
 
467
468
  # Get a single branch from a repository
@@ -473,7 +474,7 @@ module Octokit
473
474
  # @example Get branch 'master` from octokit/octokit.rb
474
475
  # Octokit.branch("octokit/octokit.rb", "master")
475
476
  def branch(repo, branch, options = {})
476
- get "repos/#{Repository.new repo}/branches/#{branch}", options
477
+ get "repos/#{Repository.new(repo)}/branches/#{branch}", options
477
478
  end
478
479
  alias :get_branch :branch
479
480
 
@@ -487,7 +488,7 @@ module Octokit
487
488
  # @example
488
489
  # @client.hooks('octokit/octokit.rb')
489
490
  def hooks(repo, options = {})
490
- paginate "repos/#{Repository.new repo}/hooks", options
491
+ paginate "repos/#{Repository.new(repo)}/hooks", options
491
492
  end
492
493
 
493
494
  # Get single hook
@@ -501,7 +502,7 @@ module Octokit
501
502
  # @example
502
503
  # @client.hook('octokit/octokit.rb', 100000)
503
504
  def hook(repo, id, options = {})
504
- get "repos/#{Repository.new repo}/hooks/#{id}", options
505
+ get "repos/#{Repository.new(repo)}/hooks/#{id}", options
505
506
  end
506
507
 
507
508
  # Create a hook
@@ -537,7 +538,7 @@ module Octokit
537
538
  # )
538
539
  def create_hook(repo, name, config, options = {})
539
540
  options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
540
- post "repos/#{Repository.new repo}/hooks", options
541
+ post "repos/#{Repository.new(repo)}/hooks", options
541
542
  end
542
543
 
543
544
  # Edit a hook
@@ -580,7 +581,7 @@ module Octokit
580
581
  # )
581
582
  def edit_hook(repo, id, name, config, options = {})
582
583
  options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
583
- patch "repos/#{Repository.new repo}/hooks/#{id}", options
584
+ patch "repos/#{Repository.new(repo)}/hooks/#{id}", options
584
585
  end
585
586
 
586
587
  # Delete hook
@@ -594,7 +595,7 @@ module Octokit
594
595
  # @example
595
596
  # @client.remove_hook('octokit/octokit.rb', 1000000)
596
597
  def remove_hook(repo, id, options = {})
597
- boolean_from_response :delete, "repos/#{Repository.new repo}/hooks/#{id}", options
598
+ boolean_from_response :delete, "repos/#{Repository.new(repo)}/hooks/#{id}", options
598
599
  end
599
600
 
600
601
  # Test hook
@@ -608,7 +609,7 @@ module Octokit
608
609
  # @example
609
610
  # @client.test_hook('octokit/octokit.rb', 1000000)
610
611
  def test_hook(repo, id, options = {})
611
- boolean_from_response :post, "repos/#{Repository.new repo}/hooks/#{id}/tests", options
612
+ boolean_from_response :post, "repos/#{Repository.new(repo)}/hooks/#{id}/tests", options
612
613
  end
613
614
 
614
615
  # List users available for assigning to issues.
@@ -625,7 +626,7 @@ module Octokit
625
626
  # @example
626
627
  # @client.repository_assignees('octokit/octokit.rb')
627
628
  def repository_assignees(repo, options = {})
628
- paginate "repos/#{Repository.new repo}/assignees", options
629
+ paginate "repos/#{Repository.new(repo)}/assignees", options
629
630
  end
630
631
  alias :repo_assignees :repository_assignees
631
632
 
@@ -638,7 +639,7 @@ module Octokit
638
639
  # @example
639
640
  # Octokit.check_assignee('octokit/octokit.rb', 'andrew')
640
641
  def check_assignee(repo, assignee, options = {})
641
- boolean_from_response :get, "repos/#{Repository.new repo}/assignees/#{assignee}", options
642
+ boolean_from_response :get, "repos/#{Repository.new(repo)}/assignees/#{assignee}", options
642
643
  end
643
644
 
644
645
  # List watchers subscribing to notifications for a repo
@@ -649,7 +650,7 @@ module Octokit
649
650
  # @example
650
651
  # @client.subscribers("octokit/octokit.rb")
651
652
  def subscribers(repo, options = {})
652
- paginate "repos/#{Repository.new repo}/subscribers", options
653
+ paginate "repos/#{Repository.new(repo)}/subscribers", options
653
654
  end
654
655
 
655
656
  # Get a repository subscription
@@ -660,7 +661,7 @@ module Octokit
660
661
  # @example
661
662
  # @client.subscription("octokit/octokit.rb")
662
663
  def subscription(repo, options = {})
663
- get "repos/#{Repository.new repo}/subscription", options
664
+ get "repos/#{Repository.new(repo)}/subscription", options
664
665
  end
665
666
 
666
667
  # Update repository subscription
@@ -677,7 +678,7 @@ module Octokit
677
678
  # @example Subscribe to notifications for a repository
678
679
  # @client.update_subscription("octokit/octokit.rb", {subscribed: true})
679
680
  def update_subscription(repo, options = {})
680
- put "repos/#{Repository.new repo}/subscription", options
681
+ put "repos/#{Repository.new(repo)}/subscription", options
681
682
  end
682
683
 
683
684
  # Delete a repository subscription
@@ -689,7 +690,7 @@ module Octokit
689
690
  # @example
690
691
  # @client.delete_subscription("octokit/octokit.rb")
691
692
  def delete_subscription(repo, options = {})
692
- boolean_from_response :delete, "repos/#{Repository.new repo}/subscription", options
693
+ boolean_from_response :delete, "repos/#{Repository.new(repo)}/subscription", options
693
694
  end
694
695
  end
695
696
  end