octokit 4.21.0 → 4.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +90 -63
  3. data/Rakefile +5 -3
  4. data/lib/ext/sawyer/relation.rb +4 -2
  5. data/lib/octokit/arguments.rb +2 -2
  6. data/lib/octokit/authentication.rb +10 -3
  7. data/lib/octokit/client/actions_secrets.rb +2 -3
  8. data/lib/octokit/client/actions_workflow_runs.rb +2 -0
  9. data/lib/octokit/client/actions_workflows.rb +2 -1
  10. data/lib/octokit/client/apps.rb +26 -26
  11. data/lib/octokit/client/authorizations.rb +20 -17
  12. data/lib/octokit/client/checks.rb +18 -9
  13. data/lib/octokit/client/commit_branches.rb +2 -2
  14. data/lib/octokit/client/commit_comments.rb +8 -8
  15. data/lib/octokit/client/commit_pulls.rb +2 -2
  16. data/lib/octokit/client/commits.rb +31 -34
  17. data/lib/octokit/client/community_profile.rb +2 -2
  18. data/lib/octokit/client/contents.rb +20 -21
  19. data/lib/octokit/client/deployments.rb +6 -6
  20. data/lib/octokit/client/downloads.rb +5 -6
  21. data/lib/octokit/client/emojis.rb +3 -3
  22. data/lib/octokit/client/events.rb +4 -4
  23. data/lib/octokit/client/feeds.rb +4 -5
  24. data/lib/octokit/client/gists.rb +6 -6
  25. data/lib/octokit/client/gitignore.rb +3 -3
  26. data/lib/octokit/client/hooks.rb +10 -10
  27. data/lib/octokit/client/issues.rb +14 -14
  28. data/lib/octokit/client/labels.rb +10 -10
  29. data/lib/octokit/client/legacy_search.rb +3 -3
  30. data/lib/octokit/client/licenses.rb +3 -3
  31. data/lib/octokit/client/markdown.rb +3 -3
  32. data/lib/octokit/client/marketplace.rb +4 -4
  33. data/lib/octokit/client/meta.rb +4 -5
  34. data/lib/octokit/client/milestones.rb +5 -5
  35. data/lib/octokit/client/notifications.rb +6 -6
  36. data/lib/octokit/client/oauth_applications.rb +0 -2
  37. data/lib/octokit/client/objects.rb +14 -14
  38. data/lib/octokit/client/organizations.rb +48 -48
  39. data/lib/octokit/client/pages.rb +3 -3
  40. data/lib/octokit/client/projects.rb +18 -19
  41. data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
  42. data/lib/octokit/client/pull_requests.rb +41 -42
  43. data/lib/octokit/client/rate_limit.rb +9 -11
  44. data/lib/octokit/client/reactions.rb +6 -6
  45. data/lib/octokit/client/refs.rb +14 -15
  46. data/lib/octokit/client/releases.rb +13 -13
  47. data/lib/octokit/client/repositories.rb +36 -36
  48. data/lib/octokit/client/repository_invitations.rb +3 -3
  49. data/lib/octokit/client/reviews.rb +7 -7
  50. data/lib/octokit/client/say.rb +4 -5
  51. data/lib/octokit/client/search.rb +9 -9
  52. data/lib/octokit/client/service_status.rb +19 -9
  53. data/lib/octokit/client/source_import.rb +6 -6
  54. data/lib/octokit/client/stats.rb +10 -9
  55. data/lib/octokit/client/statuses.rb +5 -5
  56. data/lib/octokit/client/traffic.rb +2 -3
  57. data/lib/octokit/client/users.rb +27 -26
  58. data/lib/octokit/client.rb +28 -14
  59. data/lib/octokit/configurable.rb +33 -27
  60. data/lib/octokit/connection.rb +22 -23
  61. data/lib/octokit/default.rb +30 -18
  62. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  63. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  64. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  65. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  66. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  67. data/lib/octokit/enterprise_admin_client.rb +9 -3
  68. data/lib/octokit/enterprise_management_console_client/management_console.rb +32 -32
  69. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  70. data/lib/octokit/error.rb +27 -23
  71. data/lib/octokit/gist.rb +2 -3
  72. data/lib/octokit/middleware/follow_redirects.rb +15 -11
  73. data/lib/octokit/organization.rb +3 -1
  74. data/lib/octokit/preview.rb +29 -29
  75. data/lib/octokit/rate_limit.rb +3 -3
  76. data/lib/octokit/repo_arguments.rb +2 -3
  77. data/lib/octokit/repository.rb +23 -24
  78. data/lib/octokit/response/base_middleware.rb +10 -0
  79. data/lib/octokit/response/feed_parser.rb +5 -7
  80. data/lib/octokit/response/raise_error.rb +4 -4
  81. data/lib/octokit/user.rb +4 -2
  82. data/lib/octokit/version.rb +3 -1
  83. data/lib/octokit/warnable.rb +4 -5
  84. data/lib/octokit.rb +15 -8
  85. data/octokit.gemspec +11 -9
  86. metadata +19 -17
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Pull Requests API
5
6
  #
6
7
  # @see https://developer.github.com/v3/pulls/
7
8
  module PullRequests
8
-
9
9
  # List pull requests for a repository
10
10
  #
11
11
  # @overload pull_requests(repo, options)
@@ -19,7 +19,7 @@ module Octokit
19
19
  def pull_requests(repo, options = {})
20
20
  paginate "#{Repository.path repo}/pulls", options
21
21
  end
22
- alias :pulls :pull_requests
22
+ alias pulls pull_requests
23
23
 
24
24
  # Get a pull request
25
25
  #
@@ -28,11 +28,11 @@ module Octokit
28
28
  # @param number [Integer] Number of the pull request to fetch
29
29
  # @return [Sawyer::Resource] Pull request info
30
30
  # @example
31
- # Octokit.pull_request('rails/rails', 42, :state => 'closed')
31
+ # Octokit.pull_request('rails/rails', 42, :state => 'closed')
32
32
  def pull_request(repo, number, options = {})
33
33
  get "#{Repository.path repo}/pulls/#{number}", options
34
34
  end
35
- alias :pull :pull_request
35
+ alias pull pull_request
36
36
 
37
37
  # Create a pull request
38
38
  #
@@ -51,9 +51,9 @@ module Octokit
51
51
  # "Pull Request title", "Pull Request body")
52
52
  def create_pull_request(repo, base, head, title, body = nil, options = {})
53
53
  pull = {
54
- :base => base,
55
- :head => head,
56
- :title => title,
54
+ base: base,
55
+ head: head,
56
+ title: title
57
57
  }
58
58
  pull[:body] = body unless body.nil?
59
59
  post "#{Repository.path repo}/pulls", options.merge(pull)
@@ -72,9 +72,9 @@ module Octokit
72
72
  # @return [Sawyer::Resource] The newly created pull request
73
73
  def create_pull_request_for_issue(repo, base, head, issue, options = {})
74
74
  pull = {
75
- :base => base,
76
- :head => head,
77
- :issue => issue
75
+ base: base,
76
+ head: head,
77
+ issue: issue
78
78
  }
79
79
  post "#{Repository.path repo}/pulls", options.merge(pull)
80
80
  end
@@ -103,7 +103,7 @@ module Octokit
103
103
  # @client.update_pull_request('octokit/octokit.rb', 67, nil, '')
104
104
  def update_pull_request(*args)
105
105
  arguments = Octokit::Arguments.new(args)
106
- repo = arguments.shift
106
+ repo = arguments.shift
107
107
  number = arguments.shift
108
108
  patch "#{Repository.path repo}/pulls/#{number}", arguments.options
109
109
  end
@@ -117,7 +117,7 @@ module Octokit
117
117
  # @example
118
118
  # @client.close_pull_request('octokit/octokit.rb', 67)
119
119
  def close_pull_request(repo, number, options = {})
120
- options.merge! :state => 'closed'
120
+ options.merge! state: 'closed'
121
121
  update_pull_request(repo, number, options)
122
122
  end
123
123
 
@@ -130,7 +130,7 @@ module Octokit
130
130
  def pull_request_commits(repo, number, options = {})
131
131
  paginate "#{Repository.path repo}/pulls/#{number}/commits", options
132
132
  end
133
- alias :pull_commits :pull_request_commits
133
+ alias pull_commits pull_request_commits
134
134
 
135
135
  # List pull request comments for a repository
136
136
  #
@@ -160,8 +160,8 @@ module Octokit
160
160
  def pull_requests_comments(repo, options = {})
161
161
  paginate("#{Repository.path repo}/pulls/comments", options)
162
162
  end
163
- alias :pulls_comments :pull_requests_comments
164
- alias :reviews_comments :pull_requests_comments
163
+ alias pulls_comments pull_requests_comments
164
+ alias reviews_comments pull_requests_comments
165
165
 
166
166
  # List comments on a pull request
167
167
  #
@@ -173,8 +173,8 @@ module Octokit
173
173
  # return the comments for a pull request
174
174
  paginate("#{Repository.path repo}/pulls/#{number}/comments", options)
175
175
  end
176
- alias :pull_comments :pull_request_comments
177
- alias :review_comments :pull_request_comments
176
+ alias pull_comments pull_request_comments
177
+ alias review_comments pull_request_comments
178
178
 
179
179
  # Get a pull request comment
180
180
  #
@@ -187,8 +187,8 @@ module Octokit
187
187
  def pull_request_comment(repo, comment_id, options = {})
188
188
  get "#{Repository.path repo}/pulls/comments/#{comment_id}", options
189
189
  end
190
- alias :pull_comment :pull_request_comment
191
- alias :review_comment :pull_request_comment
190
+ alias pull_comment pull_request_comment
191
+ alias review_comment pull_request_comment
192
192
 
193
193
  # Create a pull request comment
194
194
  #
@@ -205,15 +205,15 @@ module Octokit
205
205
  # "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
206
206
  def create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {})
207
207
  options.merge!({
208
- :body => body,
209
- :commit_id => commit_id,
210
- :path => path,
211
- :position => position
212
- })
208
+ body: body,
209
+ commit_id: commit_id,
210
+ path: path,
211
+ position: position
212
+ })
213
213
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
214
214
  end
215
- alias :create_pull_comment :create_pull_request_comment
216
- alias :create_view_comment :create_pull_request_comment
215
+ alias create_pull_comment create_pull_request_comment
216
+ alias create_view_comment create_pull_request_comment
217
217
 
218
218
  # Create reply to a pull request comment
219
219
  #
@@ -227,13 +227,13 @@ module Octokit
227
227
  # @client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
228
228
  def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
229
229
  options.merge!({
230
- :body => body,
231
- :in_reply_to => comment_id
232
- })
230
+ body: body,
231
+ in_reply_to: comment_id
232
+ })
233
233
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
234
234
  end
235
- alias :create_pull_reply :create_pull_request_comment_reply
236
- alias :create_review_reply :create_pull_request_comment_reply
235
+ alias create_pull_reply create_pull_request_comment_reply
236
+ alias create_review_reply create_pull_request_comment_reply
237
237
 
238
238
  # Update pull request comment
239
239
  #
@@ -245,11 +245,11 @@ module Octokit
245
245
  # @example
246
246
  # @client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
247
247
  def update_pull_request_comment(repo, comment_id, body, options = {})
248
- options.merge! :body => body
248
+ options.merge! body: body
249
249
  patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
250
250
  end
251
- alias :update_pull_comment :update_pull_request_comment
252
- alias :update_review_comment :update_pull_request_comment
251
+ alias update_pull_comment update_pull_request_comment
252
+ alias update_review_comment update_pull_request_comment
253
253
 
254
254
  # Delete pull request comment
255
255
  #
@@ -262,8 +262,8 @@ module Octokit
262
262
  def delete_pull_request_comment(repo, comment_id, options = {})
263
263
  boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
264
264
  end
265
- alias :delete_pull_comment :delete_pull_request_comment
266
- alias :delete_review_comment :delete_pull_request_comment
265
+ alias delete_pull_comment delete_pull_request_comment
266
+ alias delete_review_comment delete_pull_request_comment
267
267
 
268
268
  # List files on a pull request
269
269
  #
@@ -274,7 +274,7 @@ module Octokit
274
274
  def pull_request_files(repo, number, options = {})
275
275
  paginate "#{Repository.path repo}/pulls/#{number}/files", options
276
276
  end
277
- alias :pull_files :pull_request_files
277
+ alias pull_files pull_request_files
278
278
 
279
279
  # Merge a pull request
280
280
  #
@@ -283,8 +283,8 @@ module Octokit
283
283
  # @param number [Integer] Number of pull request
284
284
  # @param commit_message [String] Optional commit message for the merge commit
285
285
  # @return [Array<Sawyer::Resource>] Merge commit info if successful
286
- def merge_pull_request(repo, number, commit_message='', options = {})
287
- put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({:commit_message => commit_message})
286
+ def merge_pull_request(repo, number, commit_message = '', options = {})
287
+ put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({ commit_message: commit_message })
288
288
  end
289
289
 
290
290
  # Check pull request merge status
@@ -296,8 +296,7 @@ module Octokit
296
296
  def pull_merged?(repo, number, options = {})
297
297
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
298
298
  end
299
- alias :pull_request_merged? :pull_merged?
300
-
299
+ alias pull_request_merged? pull_merged?
301
300
  end
302
301
  end
303
302
  end
@@ -1,17 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for API rate limiting info
5
6
  #
6
7
  # @see https://developer.github.com/v3/#rate-limiting
7
8
  module RateLimit
8
-
9
9
  # Get rate limit info from last response if available
10
10
  # or make a new request to fetch rate limit
11
11
  #
12
12
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
13
13
  # @return [Octokit::RateLimit] Rate limit info
14
- def rate_limit(options = {})
14
+ def rate_limit(_options = {})
15
15
  return rate_limit! if last_response.nil?
16
16
 
17
17
  Octokit::RateLimit.from_response(last_response)
@@ -22,8 +22,8 @@ module Octokit
22
22
  #
23
23
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
24
24
  # @return [Integer] Number of requests remaining in this period
25
- def rate_limit_remaining(options = {})
26
- octokit_warn "Deprecated: Please use .rate_limit.remaining"
25
+ def rate_limit_remaining(_options = {})
26
+ octokit_warn 'Deprecated: Please use .rate_limit.remaining'
27
27
  rate_limit.remaining
28
28
  end
29
29
  alias ratelimit_remaining rate_limit_remaining
@@ -32,8 +32,8 @@ module Octokit
32
32
  #
33
33
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
34
34
  # @return [Octokit::RateLimit] Rate limit info
35
- def rate_limit!(options = {})
36
- get "rate_limit"
35
+ def rate_limit!(_options = {})
36
+ get 'rate_limit'
37
37
  Octokit::RateLimit.from_response(last_response)
38
38
  end
39
39
  alias ratelimit! rate_limit!
@@ -42,13 +42,11 @@ module Octokit
42
42
  #
43
43
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
44
44
  # @return [Integer] Number of requests remaining in this period
45
- def rate_limit_remaining!(options = {})
46
- octokit_warn "Deprecated: Please use .rate_limit!.remaining"
45
+ def rate_limit_remaining!(_options = {})
46
+ octokit_warn 'Deprecated: Please use .rate_limit!.remaining'
47
47
  rate_limit!.remaining
48
48
  end
49
49
  alias ratelimit_remaining! rate_limit_remaining!
50
-
51
50
  end
52
51
  end
53
52
  end
54
-
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Reacions API
5
6
  #
6
7
  # @see https://developer.github.com/v3/reactions/
7
8
  module Reactions
8
-
9
9
  # List reactions for a commit comment
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -34,7 +34,7 @@ module Octokit
34
34
  #
35
35
  # @return [<Sawyer::Resource>] Hash representing the reaction
36
36
  def create_commit_comment_reaction(repo, id, reaction, options = {})
37
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
37
+ options = ensure_api_media_type(:reactions, options.merge(content: reaction))
38
38
  post "#{Repository.path repo}/comments/#{id}/reactions", options
39
39
  end
40
40
 
@@ -67,7 +67,7 @@ module Octokit
67
67
  #
68
68
  # @return [<Sawyer::Resource>] Hash representing the reaction.
69
69
  def create_issue_reaction(repo, number, reaction, options = {})
70
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
70
+ options = ensure_api_media_type(:reactions, options.merge(content: reaction))
71
71
  post "#{Repository.path repo}/issues/#{number}/reactions", options
72
72
  end
73
73
 
@@ -101,7 +101,7 @@ module Octokit
101
101
  #
102
102
  # @return [<Sawyer::Resource>] Hashes representing the reaction.
103
103
  def create_issue_comment_reaction(repo, id, reaction, options = {})
104
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
104
+ options = ensure_api_media_type(:reactions, options.merge(content: reaction))
105
105
  post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
106
106
  end
107
107
 
@@ -135,7 +135,7 @@ module Octokit
135
135
  #
136
136
  # @return [<Sawyer::Resource>] Hash representing the reaction.
137
137
  def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
138
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
138
+ options = ensure_api_media_type(:reactions, options.merge(content: reaction))
139
139
  post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
140
140
  end
141
141
 
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for References for Git Data API
5
6
  #
6
7
  # @see https://developer.github.com/v3/git/refs/
7
8
  module Refs
8
-
9
9
  # List all refs for a given user and repo
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -19,9 +19,9 @@ module Octokit
19
19
  path += "/#{namespace}" unless namespace.nil?
20
20
  paginate path, options
21
21
  end
22
- alias :list_refs :refs
23
- alias :references :refs
24
- alias :list_references :refs
22
+ alias list_refs refs
23
+ alias references refs
24
+ alias list_references refs
25
25
 
26
26
  # Fetch matching refs
27
27
  #
@@ -46,7 +46,7 @@ module Octokit
46
46
  def ref(repo, ref, options = {})
47
47
  get "#{Repository.path repo}/git/refs/#{ref}", options
48
48
  end
49
- alias :reference :ref
49
+ alias reference ref
50
50
 
51
51
  # Create a reference
52
52
  #
@@ -58,14 +58,14 @@ module Octokit
58
58
  # @example Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132
59
59
  # Octokit.create_ref("octocat/Hello-World", "heads/master", "827efc6d56897b048c772eb4087f854f46256132")
60
60
  def create_ref(repo, ref, sha, options = {})
61
- ref = "refs/#{ref}" unless ref =~ %r{refs/}
61
+ ref = "refs/#{ref}" unless ref =~ %r{\Arefs/}
62
62
  parameters = {
63
- :ref => ref,
64
- :sha => sha
63
+ ref: ref,
64
+ sha: sha
65
65
  }
66
66
  post "#{Repository.path repo}/git/refs", options.merge(parameters)
67
67
  end
68
- alias :create_reference :create_ref
68
+ alias create_reference create_ref
69
69
 
70
70
  # Update a reference
71
71
  #
@@ -81,12 +81,12 @@ module Octokit
81
81
  # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
82
82
  def update_ref(repo, ref, sha, force = true, options = {})
83
83
  parameters = {
84
- :sha => sha,
85
- :force => force
84
+ sha: sha,
85
+ force: force
86
86
  }
87
87
  patch "#{Repository.path repo}/git/refs/#{ref}", options.merge(parameters)
88
88
  end
89
- alias :update_reference :update_ref
89
+ alias update_reference update_ref
90
90
 
91
91
  # Update a branch
92
92
  #
@@ -127,8 +127,7 @@ module Octokit
127
127
  def delete_ref(repo, ref, options = {})
128
128
  boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
129
129
  end
130
- alias :delete_reference :delete_ref
131
-
130
+ alias delete_reference delete_ref
132
131
  end
133
132
  end
134
133
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Releases API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/releases/
7
8
  module Releases
8
-
9
9
  # List releases for a repository
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -14,7 +14,7 @@ module Octokit
14
14
  def releases(repo, options = {})
15
15
  paginate "#{Repository.path repo}/releases", options
16
16
  end
17
- alias :list_releases :releases
17
+ alias list_releases releases
18
18
 
19
19
  # Create a release
20
20
  #
@@ -28,7 +28,7 @@ module Octokit
28
28
  # @return [Sawyer::Resource] The release
29
29
  # @see https://developer.github.com/v3/repos/releases/#create-a-release
30
30
  def create_release(repo, tag_name, options = {})
31
- opts = options.merge(:tag_name => tag_name)
31
+ opts = options.merge(tag_name: tag_name)
32
32
  post "#{Repository.path repo}/releases", opts
33
33
  end
34
34
 
@@ -55,7 +55,7 @@ module Octokit
55
55
  def update_release(url, options = {})
56
56
  patch url, options
57
57
  end
58
- alias :edit_release :update_release
58
+ alias edit_release update_release
59
59
 
60
60
  # Delete a release
61
61
  #
@@ -84,17 +84,18 @@ module Octokit
84
84
  # @return [Sawyer::Resource] The release asset
85
85
  # @see https://developer.github.com/v3/repos/releases/#upload-a-release-asset
86
86
  def upload_asset(release_url, path_or_file, options = {})
87
- file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "rb")
87
+ file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, 'rb')
88
88
  options[:content_type] ||= content_type_from_file(file)
89
- raise Octokit::MissingContentType.new if options[:content_type].nil?
89
+ raise Octokit::MissingContentType if options[:content_type].nil?
90
+
90
91
  unless name = options[:name]
91
92
  name = File.basename(file.path)
92
93
  end
93
- upload_url = release(release_url).rels[:upload].href_template.expand(:name => name)
94
+ upload_url = release(release_url).rels[:upload].href_template.expand(name: name)
94
95
 
95
96
  request :post, upload_url, file.read, parse_query_and_convenience_headers(options)
96
97
  ensure
97
- file.close if file
98
+ file&.close
98
99
  end
99
100
 
100
101
  # Get a single release asset
@@ -117,7 +118,7 @@ module Octokit
117
118
  def update_release_asset(asset_url, options = {})
118
119
  patch(asset_url, options)
119
120
  end
120
- alias :edit_release_asset :update_release_asset
121
+ alias edit_release_asset update_release_asset
121
122
 
122
123
  # Delete a release asset
123
124
  #
@@ -155,10 +156,9 @@ module Octokit
155
156
  mime_type.content_type
156
157
  end
157
158
  rescue LoadError
158
- msg = "Please pass content_type or install mime-types gem to guess content type from file"
159
- raise Octokit::MissingContentType.new(msg)
159
+ msg = 'Please pass content_type or install mime-types gem to guess content type from file'
160
+ raise Octokit::MissingContentType, msg
160
161
  end
161
-
162
162
  end
163
163
  end
164
164
  end