github_api 0.13.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6826e6aa63062a779729043a6e29bf543e53eb13
4
- data.tar.gz: cd5c5dafd529f688fc8ec51693bad0a6fff24912
3
+ metadata.gz: 8762ba3a592b9f1ad2f523a8cf8259350755350c
4
+ data.tar.gz: 3fe0fe09e1afad532bbf9238fb6096bd653c1a50
5
5
  SHA512:
6
- metadata.gz: 3bfd3e4f3a4dbbb82090b52d20ff2606609fe0b3dda8d838e7dff3258518c88955308ae9a87ffa46f613b5a5d32bda58e020b83089f9483dddf601f340addfbf
7
- data.tar.gz: 46e9bc11f2d8021f9640c37720b0022134c766f4313ddbcd103efa441b895773a8720733c0bf39ac4dd102987aefb4a41375f2b4b34d78ad10a6d570027b2712
6
+ metadata.gz: 80323205b6a85c10d0097661da59785fb23a36873efb03179bf4c94bf25349d0bfc23825db0d49a7c80725765bd96291e4f28693fe2f2392dadc3543ab0a08bd
7
+ data.tar.gz: eda22421e5cba3767aeb28c655b62096e82c6c389e202d549dd795adc301103f57e7ac78c1bf76f89bca2dc22e8fb586d1881751a08de7dee42a41870b117b82
data/README.md CHANGED
@@ -1,22 +1,22 @@
1
1
  <div align="center">
2
- <a href="http://peter-murach.github.io/github/"><img width="136" src="https://github.com/peter-murach/github/raw/master/icons/github_api.png" alt="github api logo" /></a>
2
+ <a href="http://piotrmurach.github.io/github/"><img width="136" src="https://github.com/piotrmurach/github/raw/master/icons/github_api.png" alt="github api logo" /></a>
3
3
  </div>
4
4
  # GithubAPI
5
5
  [![Gem Version](https://badge.fury.io/rb/github_api.svg)][gem]
6
- [![Build Status](https://secure.travis-ci.org/peter-murach/github.svg?branch=master)][travis]
7
- [![Code Climate](https://codeclimate.com/github/peter-murach/github/badges/gpa.svg)][codeclimate]
8
- [![Coverage Status](https://coveralls.io/repos/peter-murach/github/badge.svg?branch=master)][coverage]
9
- [![Inline docs](http://inch-ci.org/github/peter-murach/github.svg)][inchpages]
10
- [![Dependency Status](https://gemnasium.com/peter-murach/github.svg?travis)][gemnasium]
6
+ [![Build Status](https://secure.travis-ci.org/piotrmurach/github.svg?branch=master)][travis]
7
+ [![Code Climate](https://codeclimate.com/github/piotrmurach/github/badges/gpa.svg)][codeclimate]
8
+ [![Coverage Status](https://coveralls.io/repos/piotrmurach/github/badge.svg?branch=master)][coverage]
9
+ [![Inline docs](http://inch-ci.org/github/piotrmurach/github.svg)][inchpages]
10
+ [![Dependency Status](https://gemnasium.com/piotrmurach/github.svg?travis)][gemnasium]
11
11
 
12
12
  [gem]: http://badge.fury.io/rb/github_api
13
- [travis]: http://travis-ci.org/peter-murach/github
14
- [codeclimate]: https://codeclimate.com/github/peter-murach/github
15
- [coverage]: https://coveralls.io/r/peter-murach/github
16
- [inchpages]: http://inch-ci.org/github/peter-murach/github
17
- [gemnasium]: https://gemnasium.com/peter-murach/github
13
+ [travis]: http://travis-ci.org/piotrmurach/github
14
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/github
15
+ [coverage]: https://coveralls.io/r/piotrmurach/github
16
+ [inchpages]: http://inch-ci.org/github/piotrmurach/github
17
+ [gemnasium]: https://gemnasium.com/piotrmurach/github
18
18
 
19
- [Website](http://peter-murach.github.io/github/) | [Wiki](https://github.com/peter-murach/github/wiki) | [RDocs](http://rubydoc.info/github/peter-murach/github/master/frames)
19
+ [Website](http://piotrmurach.github.io/github/) | [Wiki](https://github.com/piotrmurach/github/wiki) | [RDocs](http://rubydoc.info/github/piotrmurach/github/master/frames)
20
20
 
21
21
  A Ruby client for the official GitHub API.
22
22
 
@@ -87,7 +87,7 @@ gem "github_api"
87
87
  To start using the gem, you can either perform requests directly on `Github` namespace:
88
88
 
89
89
  ```ruby
90
- Github.repos.list user: 'peter-murach'
90
+ Github.repos.list user: 'piotrmurach'
91
91
  ```
92
92
 
93
93
  or create a new client instance like so
@@ -99,7 +99,7 @@ github = Github.new
99
99
  and then call api methods, for instance, to list a given user repositories do
100
100
 
101
101
  ```ruby
102
- github.repos.list user: 'peter-murach'
102
+ github.repos.list user: 'piotrmurach'
103
103
  ```
104
104
 
105
105
  ### 1.1 API Navigation
@@ -108,7 +108,7 @@ The **github_api** closely mirrors the [GitHub API](https://developer.github.com
108
108
 
109
109
  ```ruby
110
110
  github = Github.new
111
- github.repos.contents.create 'peter-murach', 'finite_machine', 'hello.rb',
111
+ github.repos.contents.create 'piotrmurach', 'finite_machine', 'hello.rb',
112
112
  path: 'hello.rb',
113
113
  content: "puts 'hello ruby'"
114
114
  ```
@@ -116,16 +116,16 @@ github.repos.contents.create 'peter-murach', 'finite_machine', 'hello.rb',
116
116
  The whole library reflects the same api navigation. Therefore, if you need to list releases for a repository do:
117
117
 
118
118
  ```ruby
119
- github.repos.releases.list 'peter-murach', 'finite_machine'
119
+ github.repos.releases.list 'piotrmurach', 'finite_machine'
120
120
  ```
121
121
 
122
122
  or to list a user's followers:
123
123
 
124
124
  ```ruby
125
- github.users.followers.list 'peter-murach'
125
+ github.users.followers.list 'piotrmurach'
126
126
  ```
127
127
 
128
- The code base has been extensively documented with examples of how to use each method. Please refer to the [documentation](http://rubydoc.info/github/peter-murach/github/master/frames) under the `Github::Client` class name.
128
+ The code base has been extensively documented with examples of how to use each method. Please refer to the [documentation](http://rubydoc.info/github/piotrmurach/github/master/frames) under the `Github::Client` class name.
129
129
 
130
130
  Alternatively, you can find out which methods are supported by an api by calling `actions` on a class or instance. For example, in order to find out available endpoints for `Github::Client::Repos::Contents` api call `actions` method:
131
131
 
@@ -140,10 +140,10 @@ The code base is modular. This means that you can work specifically with a given
140
140
 
141
141
  ```ruby
142
142
  starring = Github::Client::Activity::Starring.new oauth_token: token
143
- starring.star 'peter-murach', 'github'
143
+ starring.star 'piotrmurach', 'github'
144
144
  ```
145
145
 
146
- Please refer to the [documentation](http://rubydoc.info/github/peter-murach/github/master/frames) and look under `Github::Client` to see all available classes.
146
+ Please refer to the [documentation](http://rubydoc.info/github/piotrmurach/github/master/frames) and look under `Github::Client` to see all available classes.
147
147
 
148
148
  ### 1.3 Arguments
149
149
 
@@ -153,20 +153,20 @@ Arguments can be passed directly inside the method called. The `required` argume
153
153
 
154
154
  ```ruby
155
155
  issues = Github::Client::Issues.new
156
- issues.milestones.list 'peter-murach', 'github', state: 'open'
156
+ issues.milestones.list 'piotrmurach', 'github', state: 'open'
157
157
  ```
158
158
 
159
159
  In the previous example, the order of arguments is important. However, each method also allows you to specify `required` arguments using hash symbols and thus remove the need for ordering. Therefore, the same example could be rewritten like so:
160
160
 
161
161
  ```ruby
162
162
  issues = Github::Client::Issues.new
163
- issues.milestones.list user: 'peter-murach', repo: 'github', state: 'open'
163
+ issues.milestones.list user: 'piotrmurach', repo: 'github', state: 'open'
164
164
  ```
165
165
 
166
166
  Furthermore, `required` arguments can be passed during instance creation:
167
167
 
168
168
  ```ruby
169
- issues = Github::Client::Issues.new user: 'peter-murach', repo: 'github'
169
+ issues = Github::Client::Issues.new user: 'piotrmurach', repo: 'github'
170
170
  issues.milestones.list state: 'open'
171
171
  ```
172
172
 
@@ -174,13 +174,13 @@ Similarly, the `required` arguments for the request can be passed inside the cur
174
174
 
175
175
  ```ruby
176
176
  issues = Github::Client::Issues.new
177
- issues.milestones(user: 'peter-murach', repo: 'github').list state: 'open'
177
+ issues.milestones(user: 'piotrmurach', repo: 'github').list state: 'open'
178
178
  ```
179
179
 
180
180
  But why limit ourselves? You can mix and match arguments, for example:
181
181
 
182
182
  ```ruby
183
- issues = Github::Client::Issues.new user: 'peter-murach'
183
+ issues = Github::Client::Issues.new user: 'piotrmurach'
184
184
  issues.milestones(repo: 'github').list
185
185
  issues.milestones(repo: 'tty').list
186
186
  ```
@@ -189,18 +189,18 @@ You can also use a bit of syntactic sugar whereby "username/repository" can be p
189
189
 
190
190
  ```ruby
191
191
  issues = Github::Client::Issues.new
192
- issues.milestones('peter-murach/github').list
193
- issues.milestones.list 'peter-murach/github'
192
+ issues.milestones('piotrmurach/github').list
193
+ issues.milestones.list 'piotrmurach/github'
194
194
  ```
195
195
 
196
196
  Finally, use the `with` scope to clearly denote your requests
197
197
 
198
198
  ```ruby
199
199
  issues = Github::Client::Issues.new
200
- issues.milestones.with(user: 'peter-murach', repo: 'github').list
200
+ issues.milestones.with(user: 'piotrmurach', repo: 'github').list
201
201
  ```
202
202
 
203
- Please consult the method [documentation](http://rubydoc.info/github/peter-murach/github/master/frames) or [GitHub specification](https://developer.github.com/v3/) to see which arguments are required and what are the option parameters.
203
+ Please consult the method [documentation](http://rubydoc.info/github/piotrmurach/github/master/frames) or [GitHub specification](https://developer.github.com/v3/) to see which arguments are required and what are the option parameters.
204
204
 
205
205
  ### 1.4 Response Querying
206
206
 
@@ -210,7 +210,7 @@ For example, when request is issued to list all the branches on a given reposito
210
210
 
211
211
  ```ruby
212
212
  repos = Github::Client::Repos.new
213
- repos.branches user: 'peter-murach', repo: 'github' do |branch|
213
+ repos.branches user: 'piotrmurach', repo: 'github' do |branch|
214
214
  puts branch.name
215
215
  end
216
216
  ```
@@ -220,7 +220,7 @@ end
220
220
  The `ResponseWrapper` allows you to call json attributes directly as method calls. there is no magic here, all calls are delegated to the response body. Therefore, you can directly inspect request body by calling `body` method on the `ResponseWrapper` like so:
221
221
 
222
222
  ```ruby
223
- response = repos.branches user: 'peter-murach', repo: 'github'
223
+ response = repos.branches user: 'piotrmurach', repo: 'github'
224
224
  response.body # => Array of branches
225
225
  ```
226
226
 
@@ -229,7 +229,7 @@ response.body # => Array of branches
229
229
  Each response comes packaged with methods allowing for inspection of HTTP start line and headers. For example, to check for rate limits and status codes do:
230
230
 
231
231
  ```ruby
232
- response = Github::Client::Repos.branches 'peter-murach', 'github'
232
+ response = Github::Client::Repos.branches 'piotrmurach', 'github'
233
233
  response.headers.ratelimit_limit # "5000"
234
234
  response.headers.ratelimit_remaining # "4999"
235
235
  response.headers.status # "200"
@@ -243,7 +243,7 @@ response.headers.cache_control # "public, max-age=60, s-maxage=60"
243
243
  If you want to verify if the response was success, namely, that the `200` code was returned call the `success?` like so:
244
244
 
245
245
  ```ruby
246
- response = Github::Client::Repos.branches 'peter-murach', 'github'
246
+ response = Github::Client::Repos.branches 'piotrmurach', 'github'
247
247
  response.success? # => true
248
248
  ```
249
249
 
@@ -267,7 +267,7 @@ In order to set custom media types for a request use the accept header. By using
267
267
 
268
268
  ```ruby
269
269
  issues = Github::Client::Issues.new
270
- issues.get 'peter-murach', 'github', 108, accept: 'application/vnd.github.raw'
270
+ issues.get 'piotrmurach', 'github', 108, accept: 'application/vnd.github.raw'
271
271
  ```
272
272
 
273
273
  ## 2 Configuration
@@ -282,7 +282,7 @@ The configuration options can be set by using the `configure` helper
282
282
  Github.configure do |c|
283
283
  c.basic_auth = "login:password"
284
284
  c.adapter = :typheous
285
- c.user = 'peter-murach'
285
+ c.user = 'piotrmurach'
286
286
  c.repo = 'finite_machine'
287
287
  end
288
288
  ```
@@ -302,7 +302,7 @@ or simply by passing hash of options to an instance like so
302
302
  ```ruby
303
303
  github = Github.new basic_auth: 'login:password',
304
304
  adapter: :typheous,
305
- user: 'peter-murach',
305
+ user: 'piotrmurach',
306
306
  repo: 'finite_machine'
307
307
  ```
308
308
 
@@ -384,7 +384,7 @@ You can now configure cache parameters as follows
384
384
 
385
385
  ```ruby
386
386
  Github.configure do |config|
387
- config.stack do |builder|
387
+ config.stack = proc do |builder|
388
388
  builder.use Faraday::HttpCache, store: Rails.cache
389
389
  end
390
390
  end
@@ -452,7 +452,7 @@ To list the scopes that the particular GitHub API action checks for do:
452
452
 
453
453
  ```ruby
454
454
  repos = Github::Client::Repos.new
455
- response = repos.list user: 'peter-murach'
455
+ response = repos.list user: 'piotrmurach'
456
456
  response.headers.accepted_oauth_scopes # => ['delete_repo', 'repo', 'public_repo']
457
457
  ```
458
458
 
@@ -679,8 +679,8 @@ The `mock` tests are in the `spec` directory and their primary concern is to tes
679
679
 
680
680
  ## Development
681
681
 
682
- Questions or problems? Please post them on the [issue tracker](https://github.com/peter-murach/github/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running `bundle` and `rake`.
682
+ Questions or problems? Please post them on the [issue tracker](https://github.com/piotrmurach/github/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running `bundle` and `rake`.
683
683
 
684
684
  ## Copyright
685
685
 
686
- Copyright (c) 2011-2014 Piotr Murach. See LICENSE.txt for further details.
686
+ Copyright (c) 2011-2016 Piotr Murach. See LICENSE.txt for further details.
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Github
4
4
  class Client::Activity::Feeds < API
5
-
6
5
  # List all the feeds available to the authenticated user.
7
6
  #
8
7
  # @see https://developer.github.com/v3/activity/feeds/#list-feeds
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Github
4
4
  class Client::Activity::Notifications < API
5
-
6
5
  # List your notifications
7
6
  #
8
7
  # List all notifications for the current user, grouped by repository.
@@ -5,18 +5,13 @@ module Github
5
5
 
6
6
  require_all 'github_api/client/gists', 'comments'
7
7
 
8
- REQUIRED_GIST_INPUTS = %w[
9
- description
10
- public
11
- files
12
- content
13
- ].freeze
14
-
15
8
  # Access to Gists::Comments API
16
9
  namespace :comments
17
10
 
18
11
  # List a user's gists
19
12
  #
13
+ # @see https://developer.github.com/v3/gists/#list-a-users-gists
14
+ #
20
15
  # @example
21
16
  # github = Github.new
22
17
  # github.gists.list user: 'user-name'
@@ -30,6 +25,8 @@ module Github
30
25
  #
31
26
  # List all public gists
32
27
  #
28
+ # @see https://developer.github.com/v3/gists/#list-all-public-gists
29
+ #
33
30
  # github = Github.new
34
31
  # github.gists.list :public
35
32
  #
@@ -49,13 +46,15 @@ module Github
49
46
  return response unless block_given?
50
47
  response.each { |el| yield el }
51
48
  end
52
- alias :all :list
49
+ alias_method :all, :list
53
50
 
54
51
  # List the authenticated user's starred gists
55
52
  #
53
+ # @see https://developer.github.com/v3/gists/#list-starred-gists
54
+ #
56
55
  # @example
57
- # github = Github.new oauth_token: '...'
58
- # github.gists.starred
56
+ # github = Github.new oauth_token: '...'
57
+ # github.gists.starred
59
58
  #
60
59
  # @return [Hash]
61
60
  #
@@ -69,9 +68,19 @@ module Github
69
68
 
70
69
  # Get a single gist
71
70
  #
71
+ # @see https://developer.github.com/v3/gists/#get-a-single-gist
72
+ #
72
73
  # @example
73
- # github = Github.new
74
- # github.gists.get 'gist-id'
74
+ # github = Github.new
75
+ # github.gists.get 'gist-id'
76
+ #
77
+ # Get a specific revision of gist
78
+ #
79
+ # @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
80
+ #
81
+ # @example
82
+ # github = Github.new
83
+ # github.gists.get 'gist-id', sha: '
75
84
  #
76
85
  # @return [Hash]
77
86
  #
@@ -79,12 +88,18 @@ module Github
79
88
  def get(*args)
80
89
  arguments(args, required: [:id])
81
90
 
82
- get_request("/gists/#{arguments.id}", arguments.params)
91
+ if (sha = arguments.params.delete('sha'))
92
+ get_request("/gists/#{arguments.id}/#{sha}")
93
+ else
94
+ get_request("/gists/#{arguments.id}", arguments.params)
95
+ end
83
96
  end
84
- alias :find :get
97
+ alias_method :find, :get
85
98
 
86
99
  # Create a gist
87
100
  #
101
+ # @see https://developer.github.com/v3/gists/#create-a-gist
102
+ #
88
103
  # @param [Hash] params
89
104
  # @option params [String] :description
90
105
  # Optional string
@@ -112,15 +127,15 @@ module Github
112
127
  #
113
128
  # @api public
114
129
  def create(*args)
115
- arguments(args) do
116
- assert_required REQUIRED_GIST_INPUTS
117
- end
130
+ arguments(args)
118
131
 
119
132
  post_request("/gists", arguments.params)
120
133
  end
121
134
 
122
135
  # Edit a gist
123
136
  #
137
+ # @see https://developer.github.com/v3/gists/#edit-a-gist
138
+ #
124
139
  # @param [Hash] params
125
140
  # @option [String] :description
126
141
  # Optional string
@@ -162,6 +177,8 @@ module Github
162
177
 
163
178
  # List gist commits
164
179
  #
180
+ # @see https://developer.github.com/v3/gists/#list-gist-commits
181
+ #
165
182
  # @example
166
183
  # github = Github.new
167
184
  # github.gists.commits 'gist-id'
@@ -177,6 +194,8 @@ module Github
177
194
 
178
195
  # Star a gist
179
196
  #
197
+ # @see https://developer.github.com/v3/gists/#star-a-gist
198
+ #
180
199
  # @example
181
200
  # github = Github.new
182
201
  # github.gists.star 'gist-id'
@@ -190,6 +209,8 @@ module Github
190
209
 
191
210
  # Unstar a gist
192
211
  #
212
+ # @see https://developer.github.com/v3/gists/#unstar-a-gist
213
+ #
193
214
  # @xample
194
215
  # github = Github.new
195
216
  # github.gists.unstar 'gist-id'
@@ -203,10 +224,13 @@ module Github
203
224
 
204
225
  # Check if a gist is starred
205
226
  #
206
- # = Examples
207
- # github = Github.new
208
- # github.gists.starred? 'gist-id'
227
+ # @see https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
209
228
  #
229
+ # @example
230
+ # github = Github.new
231
+ # github.gists.starred? 'gist-id'
232
+ #
233
+ # @api public
210
234
  def starred?(*args)
211
235
  arguments(args, required: [:id])
212
236
  get_request("/gists/#{arguments.id}/star", arguments.params)
@@ -225,14 +249,16 @@ module Github
225
249
  def fork(*args)
226
250
  arguments(args, required: [:id])
227
251
 
228
- post_request("/gists/#{arguments.id}/fork", arguments.params)
252
+ post_request("/gists/#{arguments.id}/forks", arguments.params)
229
253
  end
230
254
 
231
255
  # List gist forks
232
256
  #
257
+ # @see https://developer.github.com/v3/gists/#list-gist-forks
258
+ #
233
259
  # @example
234
- # github = Github.new
235
- # github.gists.forks 'gist-id'
260
+ # github = Github.new
261
+ # github.gists.forks 'gist-id'
236
262
  #
237
263
  # @api public
238
264
  def forks(*args)
@@ -245,6 +271,8 @@ module Github
245
271
 
246
272
  # Delete a gist
247
273
  #
274
+ # @see https://developer.github.com/v3/gists/#delete-a-gist
275
+ #
248
276
  # @example
249
277
  # github = Github.new
250
278
  # github.gists.delete 'gist-id'
@@ -2,22 +2,13 @@
2
2
 
3
3
  module Github
4
4
  class Client::Gists::Comments < API
5
-
6
- REQUIRED_GIST_COMMENT_OPTIONS = %w[
7
- body
8
- ].freeze
9
-
10
- VALID_GIST_COMMENT_OPTIONS = %w[
11
- body
12
- mime_type
13
- resource
14
- ].freeze
15
-
16
5
  # List comments on a gist
17
6
  #
7
+ # @see https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
8
+ #
18
9
  # @example
19
- # github = Github.new
20
- # github.gists.comments.list 'gist-id'
10
+ # github = Github.new
11
+ # github.gists.comments.list 'gist-id'
21
12
  #
22
13
  # @return [Hash]
23
14
  #
@@ -25,76 +16,83 @@ module Github
25
16
  def list(*args)
26
17
  arguments(args, required: [:gist_id])
27
18
 
28
- response = get_request("/gists/#{arguments.gist_id}/comments", arguments.params)
19
+ response = get_request("/gists/#{arguments.gist_id}/comments",
20
+ arguments.params)
29
21
  return response unless block_given?
30
22
  response.each { |el| yield el }
31
23
  end
32
- alias :all :list
24
+ alias_method :all, :list
33
25
 
34
26
  # Get a single comment
35
27
  #
28
+ # @see https://developer.github.com/v3/gists/comments/#get-a-single-comment
29
+ #
36
30
  # @example
37
- # github = Github.new
38
- # github.gists.comments.get 'gist-id', 'comment-id'
31
+ # github = Github.new
32
+ # github.gists.comments.get 'gist-id', 'comment-id'
39
33
  #
40
34
  # @api public
41
35
  def get(*args)
42
36
  arguments(args, required: [:gist_id, :id])
43
37
 
44
- get_request("/gists/#{arguments.gist_id}/comments/#{arguments.id}", arguments.params)
38
+ get_request("/gists/#{arguments.gist_id}/comments/#{arguments.id}",
39
+ arguments.params)
45
40
  end
46
- alias :find :get
41
+ alias_method :find, :get
47
42
 
48
43
  # Create a comment
49
44
  #
45
+ # @see https://developer.github.com/v3/gists/comments/#create-a-comment
46
+ #
50
47
  # @param [Hash] params
51
48
  # @option params [String] :body
52
49
  # Required. The comment text.
53
50
  #
54
51
  # @example
55
- # github = Github.new
56
- # github.gists.comments.create 'gist-id'
52
+ # github = Github.new
53
+ # github.gists.comments.create 'gist-id'
57
54
  #
58
55
  # @api public
59
56
  def create(*args)
60
- arguments(args, required: [:gist_id]) do
61
- permit VALID_GIST_COMMENT_OPTIONS
62
- assert_required REQUIRED_GIST_COMMENT_OPTIONS
63
- end
57
+ arguments(args, required: [:gist_id])
64
58
 
65
59
  post_request("/gists/#{arguments.gist_id}/comments", arguments.params)
66
60
  end
67
61
 
68
62
  # Edit a comment
69
63
  #
64
+ # @see https://developer.github.com/v3/gists/comments/#edit-a-comment
65
+ #
70
66
  # @param [Hash] params
71
67
  # @option params [String] :body
72
68
  # Required. The comment text.
73
69
  #
74
70
  # @example
75
- # github = Github.new
76
- # github.gists.comments.edit 'gist-id', 'comment-id'
71
+ # github = Github.new
72
+ # github.gists.comments.edit 'gist-id', 'comment-id'
77
73
  #
78
74
  # @api public
79
75
  def edit(*args)
80
- arguments(args, required: [:gist_id, :id]) do
81
- permit VALID_GIST_COMMENT_OPTIONS
82
- assert_required REQUIRED_GIST_COMMENT_OPTIONS
83
- end
76
+ arguments(args, required: [:gist_id, :id])
84
77
 
85
- patch_request("/gists/#{arguments.gist_id}/comments/#{arguments.id}", arguments.params)
78
+ patch_request("/gists/#{arguments.gist_id}/comments/#{arguments.id}",
79
+ arguments.params)
86
80
  end
87
81
 
88
82
  # Delete a comment
89
83
  #
84
+ # @see https://developer.github.com/v3/gists/comments/#delete-a-comment
85
+ #
90
86
  # @xample
91
- # github = Github.new
92
- # github.gists.comments.delete 'gist-id', 'comment-id'
87
+ # github = Github.new
88
+ # github.gists.comments.delete 'gist-id', 'comment-id'
93
89
  #
90
+ # @api public
94
91
  def delete(*args)
95
92
  arguments(args, required: [:gist_id, :id])
96
93
 
97
- delete_request("/gists/#{arguments.gist_id}/comments/#{arguments.id}", arguments.params)
94
+ delete_request("/gists/#{arguments.gist_id}/comments/#{arguments.id}",
95
+ arguments.params)
98
96
  end
99
97
  end # Gists::Comments
100
98
  end # Github
@@ -3,24 +3,7 @@
3
3
  module Github
4
4
  class Client::PullRequests < API
5
5
 
6
- require_all 'github_api/client/pull_requests',
7
- 'comments'
8
-
9
- VALID_REQUEST_PARAM_NAMES = %w[
10
- title
11
- body
12
- base
13
- head
14
- state
15
- issue
16
- commit_message
17
- mime_type
18
- resource
19
- ].freeze
20
-
21
- VALID_REQUEST_PARAM_VALUES = {
22
- 'state' => %w[ open closed all ]
23
- }
6
+ require_all 'github_api/client/pull_requests', 'comments'
24
7
 
25
8
  # Access to PullRequests::Comments API
26
9
  namespace :comments
@@ -38,16 +21,14 @@ module Github
38
21
  #
39
22
  # @api public
40
23
  def list(*args)
41
- arguments(args, required: [:user, :repo]) do
42
- permit VALID_REQUEST_PARAM_NAMES
43
- assert_values VALID_REQUEST_PARAM_VALUES
44
- end
24
+ arguments(args, required: [:user, :repo])
45
25
 
46
- response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls", arguments.params)
26
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls",
27
+ arguments.params)
47
28
  return response unless block_given?
48
29
  response.each { |el| yield el }
49
30
  end
50
- alias :all :list
31
+ alias_method :all, :list
51
32
 
52
33
  # Get a single pull request
53
34
  #
@@ -63,12 +44,12 @@ module Github
63
44
 
64
45
  get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}", arguments.params)
65
46
  end
66
- alias :find :get
47
+ alias_method :find, :get
67
48
 
68
49
  # Create a pull request
69
50
  #
70
51
  # @param [Hash] params
71
- # @option params [String] :title
52
+ # @option params [String] :title
72
53
  # Required string
73
54
  # @option params [String] :body
74
55
  # Optional string
@@ -102,11 +83,10 @@ module Github
102
83
  #
103
84
  # @api public
104
85
  def create(*args)
105
- arguments(args, required: [:user, :repo]) do
106
- permit VALID_REQUEST_PARAM_NAMES
107
- end
86
+ arguments(args, required: [:user, :repo])
108
87
 
109
- post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls", arguments.params)
88
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls",
89
+ arguments.params)
110
90
  end
111
91
 
112
92
  # Update a pull request
@@ -129,10 +109,7 @@ module Github
129
109
  #
130
110
  # @api public
131
111
  def update(*args)
132
- arguments(args, required: [:user, :repo, :number]) do
133
- permit VALID_REQUEST_PARAM_NAMES
134
- assert_values VALID_REQUEST_PARAM_VALUES
135
- end
112
+ arguments(args, required: [:user, :repo, :number])
136
113
 
137
114
  patch_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}", arguments.params)
138
115
  end
@@ -183,11 +160,19 @@ module Github
183
160
  false
184
161
  end
185
162
 
163
+ PREVIEW_MEDIA = 'application/vnd.github.polaris-preview+json'.freeze # :nodoc:
164
+
186
165
  # Merge a pull request(Merge Button)
187
166
  #
188
167
  # @param [Hash] params
168
+ # @option params [String] :commit_title
169
+ # Optional string - The first line of the message that will be used for the merge commit
189
170
  # @option params [String] :commit_message
190
171
  # Optional string - The message that will be used for the merge commit
172
+ # @option params [String] :sha
173
+ # Optional string - The SHA that pull request head must match to allow merge
174
+ # @option params [Boolean] :squash
175
+ # Optional boolean - Commit a single commit to the head branch.
191
176
  #
192
177
  # @example
193
178
  # github = Github.new
@@ -195,11 +180,11 @@ module Github
195
180
  #
196
181
  # @api public
197
182
  def merge(*args)
198
- arguments(args, required: [:user, :repo, :number]) do
199
- permit VALID_REQUEST_PARAM_NAMES
200
- end
183
+ arguments(args, required: [:user, :repo, :number])
184
+ params = arguments.params
185
+ params['accept'] ||= PREVIEW_MEDIA
201
186
 
202
- put_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/merge", arguments.params)
187
+ put_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/merge", params)
203
188
  end
204
189
  end # PullRequests
205
190
  end # Github
@@ -2,17 +2,6 @@
2
2
 
3
3
  module Github
4
4
  class Client::PullRequests::Comments < API
5
-
6
- VALID_REQUEST_COM_PARAM_NAMES = %w[
7
- body
8
- commit_id
9
- path
10
- position
11
- in_reply_to
12
- mime_type
13
- resource
14
- ].freeze
15
-
16
5
  # List comments on a pull request
17
6
  #
18
7
  # @example
@@ -51,7 +40,7 @@ module Github
51
40
  return response unless block_given?
52
41
  response.each { |el| yield el }
53
42
  end
54
- alias :all :list
43
+ alias_method :all, :list
55
44
 
56
45
  # Get a single comment for pull requests
57
46
  #
@@ -71,7 +60,7 @@ module Github
71
60
 
72
61
  get_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/comments/#{arguments.number}", arguments.params)
73
62
  end
74
- alias :find :get
63
+ alias_method :find, :get
75
64
 
76
65
  # Create a pull request comment
77
66
  #
@@ -110,9 +99,7 @@ module Github
110
99
  #
111
100
  # @api public
112
101
  def create(*args)
113
- arguments(args, required: [:user, :repo, :number]) do
114
- permit VALID_REQUEST_COM_PARAM_NAMES
115
- end
102
+ arguments(args, required: [:user, :repo, :number])
116
103
 
117
104
  post_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/#{arguments.number}/comments", arguments.params)
118
105
  end
@@ -130,9 +117,7 @@ module Github
130
117
  #
131
118
  # @api public
132
119
  def edit(*args)
133
- arguments(args, required: [:user, :repo, :number]) do
134
- permit VALID_REQUEST_COM_PARAM_NAMES
135
- end
120
+ arguments(args, required: [:user, :repo, :number])
136
121
 
137
122
  patch_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/comments/#{arguments.number}", arguments.params)
138
123
  end
@@ -149,17 +134,5 @@ module Github
149
134
 
150
135
  delete_request("/repos/#{arguments.user}/#{arguments.repo}/pulls/comments/#{arguments.number}", arguments.params)
151
136
  end
152
-
153
- private
154
-
155
- # To let user know that the params supplied are wrong before request is made
156
- def _validate_reply_to(params)
157
- if params['in_reply_to'] && !assert_required_keys(%w[ body in_reply_to ], params)
158
- raise ArgumentError, "Required params are: #{%w[ body in_reply_to].join(',')}"
159
-
160
- elsif !assert_required_keys(VALID_REQUEST_COM_PARAM_NAMES - %w[ in_reply_to ], params)
161
- raise ArgumentError, "Required params are: #{VALID_REQUEST_COM_PARAM_NAMES.join(', ')}"
162
- end
163
- end
164
137
  end # PullRequests::Comments
165
138
  end # Github
@@ -132,6 +132,9 @@ module Github
132
132
  permit %w[ user org type sort direction since ]
133
133
  end
134
134
  params = arguments.params
135
+ unless params.symbolize_keys[:per_page]
136
+ params.merge!(Pagination.per_page_as_param(current_options[:per_page]))
137
+ end
135
138
 
136
139
  response = if (user_name = params.delete('user') || user)
137
140
  get_request("/users/#{user_name}/repos", params)
@@ -59,8 +59,7 @@ module Github
59
59
  def connection(api, options = {})
60
60
  connection_options = default_options(options)
61
61
  clear_cache unless options.empty?
62
- builder = api.stack ? api.stack : stack(options.merge!(api: api))
63
- connection_options.merge!(builder: builder)
62
+ connection_options.merge!(builder: stack(options.merge!(api: api)))
64
63
  connection_options.deep_merge!(options[:connection_options]) if options[:connection_options]
65
64
  if ENV['DEBUG']
66
65
  p "Connection options : \n"
@@ -1,32 +1,30 @@
1
1
  # encoding: utf-8
2
- # require 'multi_json'
3
- require 'github_api/jsonable'
2
+
3
+ require 'json'
4
4
 
5
5
  module Github
6
6
  # Raised when GitHub returns any of the HTTP status codes
7
7
  module Error
8
8
  class ServiceError < GithubError
9
- include ::Github::Jsonable
10
-
11
9
  attr_reader :http_headers, :body, :status
12
10
 
13
11
  MIN_BODY_LENGTH = 2
14
12
 
15
13
  def initialize(response)
16
14
  @http_headers = response[:response_headers]
17
- message = parse_response(response)
18
- super(message)
15
+ @body = parse_body(response[:body])
16
+ @status = response[:status]
17
+
18
+ super(create_message(response))
19
19
  end
20
20
 
21
- def parse_response(response)
22
- @body = parse_body(response[:body])
23
- @status = response[:status]
24
- "#{response[:method].to_s.upcase} #{response[:url].to_s}: #{@status} #{@body}"
21
+ def create_message(response)
22
+ "#{response[:method].to_s.upcase} #{response[:url]}: #{@status} #{@body}"
25
23
  end
26
24
 
27
25
  def decode_body(body)
28
26
  if body.respond_to?(:to_str) && body.length >= MIN_BODY_LENGTH
29
- decode body, symbolize_keys: true
27
+ JSON.parse(body, symbolize_names: true)
30
28
  else
31
29
  body
32
30
  end
@@ -41,11 +39,7 @@ module Github
41
39
  body[:error]
42
40
  elsif body[:errors]
43
41
  error = Array(body[:errors]).first
44
- if error.kind_of?(Hash)
45
- error[:message]
46
- else
47
- error
48
- end
42
+ error.is_a?(Hash) ? error[:message] : error
49
43
  elsif body[:message]
50
44
  body[:message]
51
45
  else
@@ -62,7 +56,6 @@ module Github
62
56
  descendants.map { |klass| [klass.new({}).http_status_code, klass] }
63
57
  ]
64
58
  end
65
-
66
- end
59
+ end # ServiceError
67
60
  end # Error
68
61
  end # Github
@@ -24,6 +24,9 @@ module Github
24
24
  builder.use Github::Response::Jsonize
25
25
  builder.use Github::Response::AtomParser
26
26
  end
27
+ if api.stack
28
+ api.stack.call(builder)
29
+ end
27
30
  builder.use Github::Response::RaiseError
28
31
  builder.adapter options[:adapter]
29
32
  end
@@ -91,6 +91,16 @@ module Github
91
91
  page_iterator.next?
92
92
  end
93
93
 
94
+ # Handle pagination params when they are not passed directly
95
+ #
96
+ def self.per_page_as_param(per_page_config)
97
+ params = {}
98
+ if (per_page_config != Github::Configuration.property_set[:per_page])
99
+ params[:per_page] = per_page_config unless per_page_config.nil?
100
+ end
101
+ params
102
+ end
103
+
94
104
  private
95
105
 
96
106
  # Internally used page iterator
@@ -1,16 +1,15 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'faraday'
4
- require 'github_api/jsonable'
4
+ require 'json'
5
5
 
6
6
  module Github
7
7
  class Response::Jsonize < Response
8
- include Github::Jsonable
9
8
 
10
- dependency 'multi_json'
9
+ dependency 'json'
11
10
 
12
11
  define_parser do |body|
13
- Github::Jsonable.decode body
12
+ JSON.parse(body)
14
13
  end
15
14
 
16
15
  def parse(body)
@@ -22,7 +21,7 @@ module Github
22
21
  when 'false'
23
22
  false
24
23
  else
25
- self.class.parser.call body
24
+ self.class.parser.call(body)
26
25
  end
27
26
  end
28
27
  end # Response::Jsonize
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
-
5
4
  # A class responsible for proxing to faraday response
6
5
  class ResponseWrapper
7
6
  extend Forwardable
@@ -130,7 +129,7 @@ module Github
130
129
 
131
130
  # Check if method is defined on the body
132
131
  #
133
- def respond_to?(method_name)
132
+ def respond_to?(method_name, include_all = false)
134
133
  if self.has_key?(method_name.to_s)
135
134
  true
136
135
  else
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github
4
- VERSION = "0.13.1"
4
+ VERSION = "0.14.0"
5
5
  end # Github
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-20 00:00:00.000000000 Z
11
+ date: 2016-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,26 +58,6 @@ dependencies:
58
58
  - - <
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.10'
61
- - !ruby/object:Gem::Dependency
62
- name: multi_json
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - '>='
66
- - !ruby/object:Gem::Version
67
- version: 1.7.5
68
- - - <
69
- - !ruby/object:Gem::Version
70
- version: '2.0'
71
- type: :runtime
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - '>='
76
- - !ruby/object:Gem::Version
77
- version: 1.7.5
78
- - - <
79
- - !ruby/object:Gem::Version
80
- version: '2.0'
81
61
  - !ruby/object:Gem::Dependency
82
62
  name: oauth2
83
63
  requirement: !ruby/object:Gem::Requirement
@@ -236,7 +216,6 @@ files:
236
216
  - lib/github_api/error/validations.rb
237
217
  - lib/github_api/error.rb
238
218
  - lib/github_api/ext/faraday.rb
239
- - lib/github_api/jsonable.rb
240
219
  - lib/github_api/middleware.rb
241
220
  - lib/github_api/mime_type.rb
242
221
  - lib/github_api/normalizer.rb
@@ -274,7 +253,7 @@ files:
274
253
  - lib/github_api.rb
275
254
  - LICENSE.txt
276
255
  - README.md
277
- homepage: http://peter-murach.github.io/github/
256
+ homepage: http://piotrmurach.github.io/github/
278
257
  licenses:
279
258
  - MIT
280
259
  metadata: {}
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'multi_json'
4
-
5
- module Github
6
- module Jsonable
7
- extend self
8
-
9
- def decode(*args)
10
- return unless args.first
11
- if MultiJson.respond_to?(:load)
12
- MultiJson.load *args
13
- else
14
- MultiJson.decode *args
15
- end
16
- end
17
- end
18
- end