octokit 4.24.0 → 4.25.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -3
  3. data/lib/ext/sawyer/relation.rb +4 -2
  4. data/lib/octokit/arguments.rb +2 -2
  5. data/lib/octokit/authentication.rb +4 -5
  6. data/lib/octokit/client/actions_secrets.rb +2 -3
  7. data/lib/octokit/client/actions_workflow_runs.rb +2 -0
  8. data/lib/octokit/client/actions_workflows.rb +2 -1
  9. data/lib/octokit/client/apps.rb +26 -26
  10. data/lib/octokit/client/authorizations.rb +20 -17
  11. data/lib/octokit/client/checks.rb +5 -5
  12. data/lib/octokit/client/commit_branches.rb +2 -2
  13. data/lib/octokit/client/commit_comments.rb +8 -8
  14. data/lib/octokit/client/commit_pulls.rb +2 -2
  15. data/lib/octokit/client/commits.rb +25 -33
  16. data/lib/octokit/client/community_profile.rb +2 -2
  17. data/lib/octokit/client/contents.rb +20 -21
  18. data/lib/octokit/client/deployments.rb +6 -6
  19. data/lib/octokit/client/downloads.rb +5 -6
  20. data/lib/octokit/client/emojis.rb +3 -3
  21. data/lib/octokit/client/events.rb +4 -4
  22. data/lib/octokit/client/feeds.rb +4 -5
  23. data/lib/octokit/client/gists.rb +6 -6
  24. data/lib/octokit/client/gitignore.rb +3 -3
  25. data/lib/octokit/client/hooks.rb +10 -10
  26. data/lib/octokit/client/issues.rb +14 -14
  27. data/lib/octokit/client/labels.rb +6 -6
  28. data/lib/octokit/client/legacy_search.rb +3 -3
  29. data/lib/octokit/client/licenses.rb +3 -3
  30. data/lib/octokit/client/markdown.rb +3 -3
  31. data/lib/octokit/client/marketplace.rb +4 -4
  32. data/lib/octokit/client/meta.rb +4 -5
  33. data/lib/octokit/client/milestones.rb +5 -5
  34. data/lib/octokit/client/notifications.rb +6 -6
  35. data/lib/octokit/client/oauth_applications.rb +0 -2
  36. data/lib/octokit/client/objects.rb +14 -14
  37. data/lib/octokit/client/organizations.rb +42 -42
  38. data/lib/octokit/client/pages.rb +3 -3
  39. data/lib/octokit/client/projects.rb +18 -19
  40. data/lib/octokit/client/pub_sub_hubbub.rb +15 -15
  41. data/lib/octokit/client/pull_requests.rb +41 -42
  42. data/lib/octokit/client/rate_limit.rb +9 -11
  43. data/lib/octokit/client/reactions.rb +6 -6
  44. data/lib/octokit/client/refs.rb +13 -14
  45. data/lib/octokit/client/releases.rb +13 -13
  46. data/lib/octokit/client/repositories.rb +36 -36
  47. data/lib/octokit/client/repository_invitations.rb +3 -3
  48. data/lib/octokit/client/reviews.rb +7 -7
  49. data/lib/octokit/client/say.rb +4 -5
  50. data/lib/octokit/client/search.rb +9 -9
  51. data/lib/octokit/client/service_status.rb +2 -2
  52. data/lib/octokit/client/source_import.rb +6 -6
  53. data/lib/octokit/client/stats.rb +10 -9
  54. data/lib/octokit/client/statuses.rb +5 -5
  55. data/lib/octokit/client/traffic.rb +2 -3
  56. data/lib/octokit/client/users.rb +27 -26
  57. data/lib/octokit/client.rb +25 -11
  58. data/lib/octokit/configurable.rb +33 -27
  59. data/lib/octokit/connection.rb +19 -20
  60. data/lib/octokit/default.rb +16 -15
  61. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  62. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  63. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  64. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  65. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  66. data/lib/octokit/enterprise_admin_client.rb +9 -3
  67. data/lib/octokit/enterprise_management_console_client/management_console.rb +30 -30
  68. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  69. data/lib/octokit/error.rb +23 -21
  70. data/lib/octokit/gist.rb +2 -3
  71. data/lib/octokit/middleware/follow_redirects.rb +12 -11
  72. data/lib/octokit/organization.rb +3 -1
  73. data/lib/octokit/preview.rb +29 -29
  74. data/lib/octokit/rate_limit.rb +3 -3
  75. data/lib/octokit/repo_arguments.rb +2 -3
  76. data/lib/octokit/repository.rb +23 -24
  77. data/lib/octokit/response/base_middleware.rb +2 -0
  78. data/lib/octokit/response/feed_parser.rb +3 -5
  79. data/lib/octokit/response/raise_error.rb +2 -2
  80. data/lib/octokit/user.rb +4 -2
  81. data/lib/octokit/version.rb +4 -2
  82. data/lib/octokit/warnable.rb +3 -6
  83. data/lib/octokit.rb +14 -6
  84. data/octokit.gemspec +10 -8
  85. metadata +22 -21
@@ -1,18 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class EnterpriseAdminClient
3
-
4
5
  # Methods for the Enterprise Admin Stats API
5
6
  #
6
7
  # @see https://developer.github.com/v3/enterprise-admin/admin_stats/
7
8
  module AdminStats
8
-
9
9
  # Get all available stats
10
10
  #
11
11
  # @return [Sawyer::Resource] All available stats
12
12
  # @example Get all available stats
13
13
  # @client.admin_stats
14
14
  def admin_stats
15
- get_admin_stats "all"
15
+ get_admin_stats 'all'
16
16
  end
17
17
 
18
18
  # Get only repository-related stats
@@ -21,7 +21,7 @@ module Octokit
21
21
  # @example Get only repository-related stats
22
22
  # @client.admin_repository_stats
23
23
  def admin_repository_stats
24
- get_admin_stats "repos"
24
+ get_admin_stats 'repos'
25
25
  end
26
26
 
27
27
  # Get only hooks-related stats
@@ -30,7 +30,7 @@ module Octokit
30
30
  # @example Get only hooks-related stats
31
31
  # @client.admin_hooks_stats
32
32
  def admin_hooks_stats
33
- get_admin_stats "hooks"
33
+ get_admin_stats 'hooks'
34
34
  end
35
35
 
36
36
  # Get only pages-related stats
@@ -39,7 +39,7 @@ module Octokit
39
39
  # @example Get only pages-related stats
40
40
  # @client.admin_pages_stats
41
41
  def admin_pages_stats
42
- get_admin_stats "pages"
42
+ get_admin_stats 'pages'
43
43
  end
44
44
 
45
45
  # Get only organization-related stats
@@ -48,7 +48,7 @@ module Octokit
48
48
  # @example Get only organization-related stats
49
49
  # @client.admin_organization_stats
50
50
  def admin_organization_stats
51
- get_admin_stats "orgs"
51
+ get_admin_stats 'orgs'
52
52
  end
53
53
 
54
54
  # Get only user-related stats
@@ -57,7 +57,7 @@ module Octokit
57
57
  # @example Get only user-related stats
58
58
  # @client.admin_users_stats
59
59
  def admin_users_stats
60
- get_admin_stats "users"
60
+ get_admin_stats 'users'
61
61
  end
62
62
 
63
63
  # Get only pull request-related stats
@@ -66,7 +66,7 @@ module Octokit
66
66
  # @example Get only pull request-related stats
67
67
  # @client.admin_pull_requests_stats
68
68
  def admin_pull_requests_stats
69
- get_admin_stats "pulls"
69
+ get_admin_stats 'pulls'
70
70
  end
71
71
 
72
72
  # Get only issue-related stats
@@ -75,7 +75,7 @@ module Octokit
75
75
  # @example Get only issue-related stats
76
76
  # @client.admin_issues_stats
77
77
  def admin_issues_stats
78
- get_admin_stats "issues"
78
+ get_admin_stats 'issues'
79
79
  end
80
80
 
81
81
  # Get only milestone-related stats
@@ -84,7 +84,7 @@ module Octokit
84
84
  # @example Get only milestone-related stats
85
85
  # @client.admin_milestones_stats
86
86
  def admin_milestones_stats
87
- get_admin_stats "milestones"
87
+ get_admin_stats 'milestones'
88
88
  end
89
89
 
90
90
  # Get only gist-related stats
@@ -93,7 +93,7 @@ module Octokit
93
93
  # @example Get only gist-related stats
94
94
  # @client.admin_gits_stats
95
95
  def admin_gists_stats
96
- get_admin_stats "gists"
96
+ get_admin_stats 'gists'
97
97
  end
98
98
 
99
99
  # Get only comment-related stats
@@ -102,7 +102,7 @@ module Octokit
102
102
  # @example Get only comment-related stats
103
103
  # @client.admin_comments_stats
104
104
  def admin_comments_stats
105
- get_admin_stats "comments"
105
+ get_admin_stats 'comments'
106
106
  end
107
107
 
108
108
  private
@@ -115,6 +115,5 @@ module Octokit
115
115
  get "enterprise/stats/#{metric}"
116
116
  end
117
117
  end
118
-
119
118
  end
120
119
  end
@@ -1,18 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class EnterpriseAdminClient
3
-
4
5
  # Methods for the Enterprise License API
5
6
  #
6
7
  # @see https://developer.github.com/v3/enterprise-admin/license/
7
8
  module License
8
-
9
9
  # Get information about the Enterprise license
10
10
  #
11
11
  # @return [Sawyer::Resource] The license information
12
12
  def license_info
13
- get "enterprise/settings/license"
13
+ get 'enterprise/settings/license'
14
14
  end
15
-
16
15
  end
17
16
  end
18
17
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class EnterpriseAdminClient
3
-
4
5
  # Methods for the Enterprise Orgs API
5
6
  #
6
7
  # @see https://developer.github.com/v3/enterprise-admin/orgs/
7
8
  module Orgs
8
-
9
9
  # Create a new organization on the instance.
10
10
  #
11
11
  # @param login [String] The organization's username.
@@ -19,9 +19,8 @@ module Octokit
19
19
  def create_organization(login, admin, options = {})
20
20
  options[:login] = login
21
21
  options[:admin] = admin
22
- post "admin/organizations", options
22
+ post 'admin/organizations', options
23
23
  end
24
-
25
24
  end
26
25
  end
27
26
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class EnterpriseAdminClient
3
-
4
5
  # Methods for the Enterprise Search Indexing API
5
6
  #
6
7
  # @see https://developer.github.com/v3/enterprise-admin/search_indexing/
7
8
  module SearchIndexing
8
-
9
9
  # Queue a User or Organization to be indexed
10
10
  #
11
11
  # @param user [String] A GitHub Enterprise user or organization
@@ -13,7 +13,7 @@ module Octokit
13
13
  def index_user(user)
14
14
  queue_index user
15
15
  end
16
- alias :index_organization :index_user
16
+ alias index_organization index_user
17
17
 
18
18
  # Queue a Repository to be indexed
19
19
  #
@@ -46,7 +46,7 @@ module Octokit
46
46
  def index_users_repositories(user)
47
47
  queue_index "#{user}/*"
48
48
  end
49
- alias :index_organizations_repositories :index_users_repositories
49
+ alias index_organizations_repositories index_users_repositories
50
50
 
51
51
  # Queue an index of all the issues across all of a user's or
52
52
  # organization's repositories
@@ -56,7 +56,7 @@ module Octokit
56
56
  def index_users_repositories_issues(user)
57
57
  queue_index "#{user}/*/issues"
58
58
  end
59
- alias :index_organizations_repositories_issues :index_users_repositories_issues
59
+ alias index_organizations_repositories_issues index_users_repositories_issues
60
60
 
61
61
  # Queue an index of all the code contained in all of a user's or
62
62
  # organization's repositories
@@ -66,7 +66,7 @@ module Octokit
66
66
  def index_users_repositories_code(user)
67
67
  queue_index "#{user}/*/code"
68
68
  end
69
- alias :index_organizations_repositories_code :index_users_repositories_code
69
+ alias index_organizations_repositories_code index_users_repositories_code
70
70
 
71
71
  private
72
72
 
@@ -75,9 +75,8 @@ module Octokit
75
75
  # @param target [String] Target to index
76
76
  # @return [Sawyer:Resource] Result of the queuing containing `:message`
77
77
  def queue_index(target)
78
- post "staff/indexing_jobs", :target => target
78
+ post 'staff/indexing_jobs', target: target
79
79
  end
80
80
  end
81
-
82
81
  end
83
82
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class EnterpriseAdminClient
3
-
4
5
  # Methods for the Enterprise User Administration API
5
6
  #
6
7
  # @see https://developer.github.com/enterprise/v3/enterprise-admin/users/
@@ -15,7 +16,7 @@ module Octokit
15
16
  def create_user(login, email, options = {})
16
17
  options[:login] = login
17
18
  options[:email] = email
18
- post "admin/users", options
19
+ post 'admin/users', options
19
20
  end
20
21
 
21
22
  # Promote an ordinary user to a site administrator
@@ -111,7 +112,7 @@ module Octokit
111
112
  # @example
112
113
  # @admin_client.list_all_keys
113
114
  def list_all_keys(options = {})
114
- get "admin/keys", options
115
+ get 'admin/keys', options
115
116
  end
116
117
 
117
118
  # Deletes a public SSH keys.
@@ -121,7 +122,7 @@ module Octokit
121
122
  # @example
122
123
  # @admin_client.delete_key(1)
123
124
  def delete_key(id, options = {})
124
- boolean_from_response :delete, "admin/keys/#{id}", options
125
+ boolean_from_response :delete, "admin/keys/#{id}", options
125
126
  end
126
127
  end
127
128
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'octokit/connection'
2
4
  require 'octokit/configurable'
3
5
  require 'octokit/warnable'
@@ -8,7 +10,6 @@ require 'octokit/enterprise_admin_client/search_indexing'
8
10
  require 'octokit/enterprise_admin_client/users'
9
11
 
10
12
  module Octokit
11
-
12
13
  # EnterpriseAdminClient is only meant to be used by GitHub Enterprise Admins
13
14
  # and provides access the Admin only API endpoints including Admin Stats,
14
15
  # Management Console, and the Search Indexing API.
@@ -17,7 +18,6 @@ module Octokit
17
18
  # and GitHub Enterprise.
18
19
  # @see https://developer.github.com/v3/enterprise/
19
20
  class EnterpriseAdminClient
20
-
21
21
  include Octokit::Configurable
22
22
  include Octokit::Connection
23
23
  include Octokit::Warnable
@@ -29,12 +29,18 @@ module Octokit
29
29
 
30
30
  def initialize(options = {})
31
31
  # Use options passed in, but fall back to module defaults
32
+ #
33
+ # rubocop:disable Style/HashEachMethods
34
+ #
35
+ # This may look like a `.keys.each` which should be replaced with `#each_key`, but
36
+ # this doesn't actually work, since `#keys` is just a method we've defined ourselves.
37
+ # The class doesn't fulfill the whole `Enumerable` contract.
32
38
  Octokit::Configurable.keys.each do |key|
39
+ # rubocop:enable Style/HashEachMethods
33
40
  instance_variable_set(:"@#{key}", options[key] || Octokit.instance_variable_get(:"@#{key}"))
34
41
  end
35
42
 
36
43
  login_from_netrc unless user_authenticated? || application_authenticated?
37
44
  end
38
-
39
45
  end
40
46
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class EnterpriseManagementConsoleClient
3
-
4
5
  # Methods for the Enterprise Management Console API
5
6
  #
6
7
  # @see https://developer.github.com/v3/enterprise-admin/management_console/
7
8
  module ManagementConsole
8
-
9
9
  # Uploads a license for the first time
10
10
  #
11
11
  # @param license [String] The path to your .ghl license file.
@@ -16,19 +16,19 @@ module Octokit
16
16
  def upload_license(license, settings = nil)
17
17
  conn = faraday_configuration
18
18
 
19
- params = { }
19
+ params = {}
20
20
  params[:license] = Faraday::UploadIO.new(license, 'binary')
21
21
  params[:password] = @management_console_password
22
- params[:settings] = "#{settings.to_json}" unless settings.nil?
22
+ params[:settings] = settings.to_json.to_s unless settings.nil?
23
23
 
24
- @last_response = conn.post("/setup/api/start", params)
24
+ @last_response = conn.post('/setup/api/start', params)
25
25
  end
26
26
 
27
27
  # Start a configuration process.
28
28
  #
29
29
  # @return nil
30
30
  def start_configuration
31
- post "/setup/api/configure", password_hash
31
+ post '/setup/api/configure', password_hash
32
32
  end
33
33
 
34
34
  # Upgrade an Enterprise installation
@@ -39,27 +39,27 @@ module Octokit
39
39
  def upgrade(license)
40
40
  conn = faraday_configuration
41
41
 
42
- params = { }
42
+ params = {}
43
43
  params[:license] = Faraday::UploadIO.new(license, 'binary')
44
44
  params[:api_key] = @management_console_password
45
- @last_response = conn.post("/setup/api/upgrade", params)
45
+ @last_response = conn.post('/setup/api/upgrade', params)
46
46
  end
47
47
 
48
48
  # Get information about the Enterprise installation
49
49
  #
50
50
  # @return [Sawyer::Resource] The installation information
51
51
  def config_status
52
- get "/setup/api/configcheck", password_hash
52
+ get '/setup/api/configcheck', password_hash
53
53
  end
54
- alias :config_check :config_status
54
+ alias config_check config_status
55
55
 
56
56
  # Get information about the Enterprise installation
57
57
  #
58
58
  # @return [Sawyer::Resource] The settings
59
59
  def settings
60
- get "/setup/api/settings", password_hash
60
+ get '/setup/api/settings', password_hash
61
61
  end
62
- alias :get_settings :settings
62
+ alias get_settings settings
63
63
 
64
64
  # Modify the Enterprise settings
65
65
  #
@@ -68,17 +68,17 @@ module Octokit
68
68
  # @return [nil]
69
69
  def edit_settings(settings)
70
70
  queries = password_hash
71
- queries[:query][:settings] = "#{settings.to_json}"
72
- put "/setup/api/settings", queries
71
+ queries[:query][:settings] = settings.to_json.to_s
72
+ put '/setup/api/settings', queries
73
73
  end
74
74
 
75
75
  # Get information about the Enterprise maintenance status
76
76
  #
77
77
  # @return [Sawyer::Resource] The maintenance status
78
78
  def maintenance_status
79
- get "/setup/api/maintenance", password_hash
79
+ get '/setup/api/maintenance', password_hash
80
80
  end
81
- alias :get_maintenance_status :maintenance_status
81
+ alias get_maintenance_status maintenance_status
82
82
 
83
83
  # Start (or turn off) the Enterprise maintenance mode
84
84
  #
@@ -86,18 +86,18 @@ module Octokit
86
86
  # @return [nil]
87
87
  def set_maintenance_status(maintenance)
88
88
  queries = password_hash
89
- queries[:query][:maintenance] = "#{maintenance.to_json}"
90
- post "/setup/api/maintenance", queries
89
+ queries[:query][:maintenance] = maintenance.to_json.to_s
90
+ post '/setup/api/maintenance', queries
91
91
  end
92
- alias :edit_maintenance_status :set_maintenance_status
92
+ alias edit_maintenance_status set_maintenance_status
93
93
 
94
94
  # Fetch the authorized SSH keys on the Enterprise install
95
95
  #
96
96
  # @return [Sawyer::Resource] An array of authorized SSH keys
97
97
  def authorized_keys
98
- get "/setup/api/settings/authorized-keys", password_hash
98
+ get '/setup/api/settings/authorized-keys', password_hash
99
99
  end
100
- alias :get_authorized_keys :authorized_keys
100
+ alias get_authorized_keys authorized_keys
101
101
 
102
102
  # Add an authorized SSH keys on the Enterprise install
103
103
  #
@@ -108,7 +108,7 @@ module Octokit
108
108
  case key
109
109
  when String
110
110
  if File.exist?(key)
111
- key = File.open(key, "r")
111
+ key = File.open(key, 'r')
112
112
  content = key.read.strip
113
113
  key.close
114
114
  else
@@ -120,7 +120,7 @@ module Octokit
120
120
  end
121
121
 
122
122
  queries[:query][:authorized_key] = content
123
- post "/setup/api/settings/authorized-keys", queries
123
+ post '/setup/api/settings/authorized-keys', queries
124
124
  end
125
125
 
126
126
  # Removes an authorized SSH keys from the Enterprise install
@@ -132,7 +132,7 @@ module Octokit
132
132
  case key
133
133
  when String
134
134
  if File.exist?(key)
135
- key = File.open(key, "r")
135
+ key = File.open(key, 'r')
136
136
  content = key.read.strip
137
137
  key.close
138
138
  else
@@ -144,27 +144,27 @@ module Octokit
144
144
  end
145
145
 
146
146
  queries[:query][:authorized_key] = content
147
- delete "/setup/api/settings/authorized-keys", queries
147
+ delete '/setup/api/settings/authorized-keys', queries
148
148
  end
149
- alias :delete_authorized_key :remove_authorized_key
150
-
149
+ alias delete_authorized_key remove_authorized_key
151
150
  end
151
+
152
152
  private
153
153
 
154
154
  def password_hash
155
- { :query => { :api_key => @management_console_password } }
155
+ { query: { api_key: @management_console_password } }
156
156
  end
157
157
 
158
158
  # We fall back to raw Faraday for handling the licenses because I'm suspicious
159
159
  # that Sawyer isn't handling binary POSTs correctly: https://github.com/lostisland/sawyer/blob/03fca4c020f465ec42856d0486ec3991859b0aed/lib/sawyer/agent.rb#L85
160
160
  def faraday_configuration
161
- @faraday_configuration ||= Faraday.new(:url => @management_console_endpoint) do |http|
161
+ @faraday_configuration ||= Faraday.new(url: @management_console_endpoint) do |http|
162
162
  http.headers[:user_agent] = user_agent
163
163
  http.request :multipart
164
164
  http.request :url_encoded
165
165
 
166
166
  # Disabling SSL is essential for certain self-hosted Enterprise instances
167
- if self.connection_options[:ssl] && !self.connection_options[:ssl][:verify]
167
+ if connection_options[:ssl] && !connection_options[:ssl][:verify]
168
168
  http.ssl[:verify] = false
169
169
  end
170
170
 
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'octokit/configurable'
2
4
  require 'octokit/connection'
3
5
  require 'octokit/warnable'
4
6
  require 'octokit/enterprise_management_console_client/management_console'
5
7
 
6
8
  module Octokit
7
-
8
9
  # EnterpriseManagementConsoleClient is only meant to be used by GitHub Enterprise Admins
9
10
  # and provides access to the management console API endpoints.
10
11
  #
@@ -12,7 +13,6 @@ module Octokit
12
13
  # and GitHub Enterprise.
13
14
  # @see https://developer.github.com/v3/enterprise-admin/management_console/
14
15
  class EnterpriseManagementConsoleClient
15
-
16
16
  include Octokit::Configurable
17
17
  include Octokit::Connection
18
18
  include Octokit::Warnable
@@ -20,7 +20,13 @@ module Octokit
20
20
 
21
21
  def initialize(options = {})
22
22
  # Use options passed in, but fall back to module defaults
23
+ # rubocop:disable Style/HashEachMethods
24
+ #
25
+ # This may look like a `.keys.each` which should be replaced with `#each_key`, but
26
+ # this doesn't actually work, since `#keys` is just a method we've defined ourselves.
27
+ # The class doesn't fulfill the whole `Enumerable` contract.
23
28
  Octokit::Configurable.keys.each do |key|
29
+ # rubocop:enable Style/HashEachMethods
24
30
  instance_variable_set(:"@#{key}", options[key] || Octokit.instance_variable_get(:"@#{key}"))
25
31
  end
26
32
  end
data/lib/octokit/error.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  # Custom error class for rescuing from all GitHub errors
3
5
  class Error < StandardError
@@ -34,13 +36,13 @@ module Octokit
34
36
  end
35
37
  end
36
38
 
37
- def build_error_context
38
- if RATE_LIMITED_ERRORS.include?(self.class)
39
- @context = Octokit::RateLimit.from_response(@response)
40
- end
41
- end
39
+ def build_error_context
40
+ if RATE_LIMITED_ERRORS.include?(self.class)
41
+ @context = Octokit::RateLimit.from_response(@response)
42
+ end
43
+ end
42
44
 
43
- def initialize(response=nil)
45
+ def initialize(response = nil)
44
46
  @response = response
45
47
  super(build_error_message)
46
48
  build_error_context
@@ -118,7 +120,7 @@ module Octokit
118
120
  # Array of validation errors
119
121
  # @return [Array<Hash>] Error info
120
122
  def errors
121
- if data && data.is_a?(Hash)
123
+ if data&.is_a?(Hash)
122
124
  data[:errors] || []
123
125
  else
124
126
  []
@@ -152,15 +154,13 @@ module Octokit
152
154
  @data ||=
153
155
  if (body = @response[:body]) && !body.empty?
154
156
  if body.is_a?(String) &&
155
- @response[:response_headers] &&
156
- @response[:response_headers][:content_type] =~ /json/
157
+ @response[:response_headers] &&
158
+ @response[:response_headers][:content_type] =~ /json/
157
159
 
158
160
  Sawyer::Agent.serializer.decode(body)
159
161
  else
160
162
  body
161
163
  end
162
- else
163
- nil
164
164
  end
165
165
  end
166
166
 
@@ -183,7 +183,7 @@ module Octokit
183
183
  summary = +"\nError summary:\n"
184
184
  summary << data[:errors].map do |error|
185
185
  if error.is_a? Hash
186
- error.map { |k,v| " #{k}: #{v}" }
186
+ error.map { |k, v| " #{k}: #{v}" }
187
187
  else
188
188
  " #{error}"
189
189
  end
@@ -196,18 +196,20 @@ module Octokit
196
196
  return nil if @response.nil?
197
197
 
198
198
  message = +"#{@response[:method].to_s.upcase} "
199
- message << redact_url(@response[:url].to_s.dup) + ": "
199
+ message << redact_url(@response[:url].to_s.dup) + ': '
200
200
  message << "#{@response[:status]} - "
201
- message << "#{response_message}" unless response_message.nil?
202
- message << "#{response_error}" unless response_error.nil?
203
- message << "#{response_error_summary}" unless response_error_summary.nil?
201
+ message << response_message.to_s unless response_message.nil?
202
+ message << response_error.to_s unless response_error.nil?
203
+ message << response_error_summary.to_s unless response_error_summary.nil?
204
204
  message << " // See: #{documentation_url}" unless documentation_url.nil?
205
205
  message
206
206
  end
207
207
 
208
208
  def redact_url(url_string)
209
209
  %w[client_secret access_token].each do |token|
210
- url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include? token
210
+ if url_string.include? token
211
+ url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)")
212
+ end
211
213
  end
212
214
  url_string
213
215
  end
@@ -225,10 +227,10 @@ module Octokit
225
227
  # Raised when GitHub returns a 401 HTTP status code
226
228
  # and headers include "X-GitHub-OTP"
227
229
  class OneTimePasswordRequired < ClientError
228
- #@private
229
- OTP_DELIVERY_PATTERN = /required; (\w+)/i
230
+ # @private
231
+ OTP_DELIVERY_PATTERN = /required; (\w+)/i.freeze
230
232
 
231
- #@private
233
+ # @private
232
234
  def self.required_header(headers)
233
235
  OTP_DELIVERY_PATTERN.match headers['X-GitHub-OTP'].to_s
234
236
  end
@@ -350,5 +352,5 @@ module Octokit
350
352
  # Raised when a repository is created with an invalid format
351
353
  class InvalidRepository < ArgumentError; end
352
354
 
353
- RATE_LIMITED_ERRORS = [Octokit::TooManyRequests, Octokit::AbuseDetected]
355
+ RATE_LIMITED_ERRORS = [Octokit::TooManyRequests, Octokit::AbuseDetected].freeze
354
356
  end
data/lib/octokit/gist.rb CHANGED
@@ -1,8 +1,8 @@
1
- module Octokit
1
+ # frozen_string_literal: true
2
2
 
3
+ module Octokit
3
4
  # Class to parse and create Gist URLs
4
5
  class Gist
5
-
6
6
  # !@attribute id
7
7
  # @return [String] Gist ID
8
8
  attr_accessor :id
@@ -31,6 +31,5 @@ module Octokit
31
31
  def url
32
32
  "https://gist.github.com/#{@id}"
33
33
  end
34
-
35
34
  end
36
35
  end