octokit 4.22.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +113 -75
  3. data/Rakefile +20 -14
  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_artifacts.rb +71 -0
  8. data/lib/octokit/client/actions_secrets.rb +10 -9
  9. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  10. data/lib/octokit/client/actions_workflow_runs.rb +23 -3
  11. data/lib/octokit/client/actions_workflows.rb +27 -2
  12. data/lib/octokit/client/apps.rb +26 -26
  13. data/lib/octokit/client/checks.rb +18 -9
  14. data/lib/octokit/client/code_scanning.rb +53 -0
  15. data/lib/octokit/client/codespaces_secrets.rb +59 -0
  16. data/lib/octokit/client/commit_branches.rb +2 -2
  17. data/lib/octokit/client/commit_comments.rb +8 -8
  18. data/lib/octokit/client/commit_pulls.rb +2 -2
  19. data/lib/octokit/client/commits.rb +25 -33
  20. data/lib/octokit/client/community_profile.rb +2 -3
  21. data/lib/octokit/client/contents.rb +20 -21
  22. data/lib/octokit/client/dependabot_secrets.rb +59 -0
  23. data/lib/octokit/client/deployments.rb +6 -6
  24. data/lib/octokit/client/downloads.rb +5 -6
  25. data/lib/octokit/client/emojis.rb +3 -3
  26. data/lib/octokit/client/environments.rb +55 -0
  27. data/lib/octokit/client/events.rb +4 -5
  28. data/lib/octokit/client/feeds.rb +4 -5
  29. data/lib/octokit/client/gists.rb +6 -6
  30. data/lib/octokit/client/gitignore.rb +3 -3
  31. data/lib/octokit/client/hooks.rb +9 -19
  32. data/lib/octokit/client/issues.rb +14 -15
  33. data/lib/octokit/client/labels.rb +10 -10
  34. data/lib/octokit/client/legacy_search.rb +3 -3
  35. data/lib/octokit/client/licenses.rb +3 -6
  36. data/lib/octokit/client/markdown.rb +3 -3
  37. data/lib/octokit/client/marketplace.rb +4 -4
  38. data/lib/octokit/client/meta.rb +4 -5
  39. data/lib/octokit/client/milestones.rb +5 -5
  40. data/lib/octokit/client/notifications.rb +6 -6
  41. data/lib/octokit/client/oauth_applications.rb +0 -6
  42. data/lib/octokit/client/objects.rb +14 -14
  43. data/lib/octokit/client/organizations.rb +100 -56
  44. data/lib/octokit/client/pages.rb +5 -7
  45. data/lib/octokit/client/projects.rb +44 -64
  46. data/lib/octokit/client/pub_sub_hubbub.rb +15 -15
  47. data/lib/octokit/client/pull_requests.rb +54 -42
  48. data/lib/octokit/client/rate_limit.rb +9 -11
  49. data/lib/octokit/client/reactions.rb +13 -16
  50. data/lib/octokit/client/refs.rb +14 -17
  51. data/lib/octokit/client/releases.rb +13 -13
  52. data/lib/octokit/client/repositories.rb +49 -69
  53. data/lib/octokit/client/repository_invitations.rb +3 -3
  54. data/lib/octokit/client/reviews.rb +8 -8
  55. data/lib/octokit/client/say.rb +4 -5
  56. data/lib/octokit/client/search.rb +24 -10
  57. data/lib/octokit/client/service_status.rb +19 -9
  58. data/lib/octokit/client/source_import.rb +7 -12
  59. data/lib/octokit/client/stats.rb +10 -9
  60. data/lib/octokit/client/statuses.rb +5 -5
  61. data/lib/octokit/client/tokens.rb +31 -0
  62. data/lib/octokit/client/traffic.rb +6 -11
  63. data/lib/octokit/client/users.rb +27 -33
  64. data/lib/octokit/client.rb +40 -16
  65. data/lib/octokit/configurable.rb +34 -30
  66. data/lib/octokit/connection.rb +28 -21
  67. data/lib/octokit/default.rb +48 -35
  68. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  69. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  70. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  71. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  72. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  73. data/lib/octokit/enterprise_admin_client.rb +9 -3
  74. data/lib/octokit/enterprise_management_console_client/management_console.rb +32 -32
  75. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  76. data/lib/octokit/error.rb +45 -34
  77. data/lib/octokit/gist.rb +3 -4
  78. data/lib/octokit/middleware/follow_redirects.rb +12 -11
  79. data/lib/octokit/organization.rb +3 -1
  80. data/lib/octokit/rate_limit.rb +8 -6
  81. data/lib/octokit/repo_arguments.rb +2 -3
  82. data/lib/octokit/repository.rb +24 -24
  83. data/lib/octokit/response/base_middleware.rb +10 -0
  84. data/lib/octokit/response/feed_parser.rb +5 -7
  85. data/lib/octokit/response/raise_error.rb +4 -4
  86. data/lib/octokit/user.rb +4 -2
  87. data/lib/octokit/version.rb +4 -2
  88. data/lib/octokit/warnable.rb +4 -5
  89. data/lib/octokit.rb +15 -8
  90. data/octokit.gemspec +12 -11
  91. metadata +20 -33
  92. data/lib/octokit/client/authorizations.rb +0 -182
  93. data/lib/octokit/preview.rb +0 -46
@@ -1,31 +1,46 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'octokit/middleware/follow_redirects'
2
4
  require 'octokit/response/raise_error'
3
5
  require 'octokit/response/feed_parser'
4
6
  require 'octokit/version'
7
+ require 'octokit/warnable'
5
8
 
6
- module Octokit
9
+ if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
10
+ begin
11
+ require 'faraday/retry'
12
+ rescue LoadError
13
+ Octokit::Warnable.octokit_warn 'To use retry middleware with Faraday v2.0+, install `faraday-retry` gem'
14
+ end
15
+ end
7
16
 
17
+ module Octokit
8
18
  # Default configuration options for {Client}
9
19
  module Default
10
-
11
20
  # Default API endpoint
12
- API_ENDPOINT = "https://api.github.com".freeze
21
+ API_ENDPOINT = 'https://api.github.com'
13
22
 
14
23
  # Default User Agent header string
15
- USER_AGENT = "Octokit Ruby Gem #{Octokit::VERSION}".freeze
24
+ USER_AGENT = "Octokit Ruby Gem #{Octokit::VERSION}"
16
25
 
17
26
  # Default media type
18
- MEDIA_TYPE = "application/vnd.github.v3+json".freeze
27
+ MEDIA_TYPE = 'application/vnd.github.v3+json'
19
28
 
20
29
  # Default WEB endpoint
21
- WEB_ENDPOINT = "https://github.com".freeze
22
-
23
- # In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder
24
- RACK_BUILDER_CLASS = defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
30
+ WEB_ENDPOINT = 'https://github.com'
25
31
 
26
32
  # Default Faraday middleware stack
27
- MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder|
28
- builder.use Faraday::Request::Retry, exceptions: [Octokit::ServerError]
33
+ MIDDLEWARE = Faraday::RackBuilder.new do |builder|
34
+ # In Faraday 2.x, Faraday::Request::Retry was moved to a separate gem
35
+ # so we use it only when it's available.
36
+ if defined?(Faraday::Request::Retry)
37
+ retry_exceptions = Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Octokit::ServerError]
38
+ builder.use Faraday::Request::Retry, exceptions: retry_exceptions
39
+ elsif defined?(Faraday::Retry::Middleware)
40
+ retry_exceptions = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Octokit::ServerError]
41
+ builder.use Faraday::Retry::Middleware, exceptions: retry_exceptions
42
+ end
43
+
29
44
  builder.use Octokit::Middleware::FollowRedirects
30
45
  builder.use Octokit::Response::RaiseError
31
46
  builder.use Octokit::Response::FeedParser
@@ -33,68 +48,67 @@ module Octokit
33
48
  end
34
49
 
35
50
  class << self
36
-
37
51
  # Configuration options
38
52
  # @return [Hash]
39
53
  def options
40
- Hash[Octokit::Configurable.keys.map{|key| [key, send(key)]}]
54
+ Octokit::Configurable.keys.to_h { |key| [key, send(key)] }
41
55
  end
42
56
 
43
57
  # Default access token from ENV
44
58
  # @return [String]
45
59
  def access_token
46
- ENV['OCTOKIT_ACCESS_TOKEN']
60
+ ENV.fetch('OCTOKIT_ACCESS_TOKEN', nil)
47
61
  end
48
62
 
49
63
  # Default API endpoint from ENV or {API_ENDPOINT}
50
64
  # @return [String]
51
65
  def api_endpoint
52
- ENV['OCTOKIT_API_ENDPOINT'] || API_ENDPOINT
66
+ ENV.fetch('OCTOKIT_API_ENDPOINT') { API_ENDPOINT }
53
67
  end
54
68
 
55
69
  # Default pagination preference from ENV
56
70
  # @return [String]
57
71
  def auto_paginate
58
- ENV['OCTOKIT_AUTO_PAGINATE']
72
+ ENV.fetch('OCTOKIT_AUTO_PAGINATE', nil)
59
73
  end
60
74
 
61
75
  # Default bearer token from ENV
62
76
  # @return [String]
63
77
  def bearer_token
64
- ENV['OCTOKIT_BEARER_TOKEN']
78
+ ENV.fetch('OCTOKIT_BEARER_TOKEN', nil)
65
79
  end
66
80
 
67
81
  # Default OAuth app key from ENV
68
82
  # @return [String]
69
83
  def client_id
70
- ENV['OCTOKIT_CLIENT_ID']
84
+ ENV.fetch('OCTOKIT_CLIENT_ID', nil)
71
85
  end
72
86
 
73
87
  # Default OAuth app secret from ENV
74
88
  # @return [String]
75
89
  def client_secret
76
- ENV['OCTOKIT_SECRET']
90
+ ENV.fetch('OCTOKIT_SECRET', nil)
77
91
  end
78
92
 
79
93
  # Default management console password from ENV
80
94
  # @return [String]
81
95
  def management_console_password
82
- ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD']
96
+ ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD', nil)
83
97
  end
84
98
 
85
99
  # Default management console endpoint from ENV
86
100
  # @return [String]
87
101
  def management_console_endpoint
88
- ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT']
102
+ ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT', nil)
89
103
  end
90
104
 
91
105
  # Default options for Faraday::Connection
92
106
  # @return [Hash]
93
107
  def connection_options
94
108
  {
95
- :headers => {
96
- :accept => default_media_type,
97
- :user_agent => user_agent
109
+ headers: {
110
+ accept: default_media_type,
111
+ user_agent: user_agent
98
112
  }
99
113
  }
100
114
  end
@@ -102,13 +116,13 @@ module Octokit
102
116
  # Default media type from ENV or {MEDIA_TYPE}
103
117
  # @return [String]
104
118
  def default_media_type
105
- ENV['OCTOKIT_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
119
+ ENV.fetch('OCTOKIT_DEFAULT_MEDIA_TYPE') { MEDIA_TYPE }
106
120
  end
107
121
 
108
122
  # Default GitHub username for Basic Auth from ENV
109
123
  # @return [String]
110
124
  def login
111
- ENV['OCTOKIT_LOGIN']
125
+ ENV.fetch('OCTOKIT_LOGIN', nil)
112
126
  end
113
127
 
114
128
  # Default middleware stack for Faraday::Connection
@@ -121,21 +135,21 @@ module Octokit
121
135
  # Default GitHub password for Basic Auth from ENV
122
136
  # @return [String]
123
137
  def password
124
- ENV['OCTOKIT_PASSWORD']
138
+ ENV.fetch('OCTOKIT_PASSWORD', nil)
125
139
  end
126
140
 
127
141
  # Default pagination page size from ENV
128
142
  # @return [Integer] Page size
129
143
  def per_page
130
- page_size = ENV['OCTOKIT_PER_PAGE']
144
+ page_size = ENV.fetch('OCTOKIT_PER_PAGE', nil)
131
145
 
132
- page_size.to_i if page_size
146
+ page_size&.to_i
133
147
  end
134
148
 
135
149
  # Default proxy server URI for Faraday connection from ENV
136
150
  # @return [String]
137
151
  def proxy
138
- ENV['OCTOKIT_PROXY']
152
+ ENV.fetch('OCTOKIT_PROXY', nil)
139
153
  end
140
154
 
141
155
  # Default SSL verify mode from ENV
@@ -150,27 +164,26 @@ module Octokit
150
164
  # Default User-Agent header string from ENV or {USER_AGENT}
151
165
  # @return [String]
152
166
  def user_agent
153
- ENV['OCTOKIT_USER_AGENT'] || USER_AGENT
167
+ ENV.fetch('OCTOKIT_USER_AGENT') { USER_AGENT }
154
168
  end
155
169
 
156
170
  # Default web endpoint from ENV or {WEB_ENDPOINT}
157
171
  # @return [String]
158
172
  def web_endpoint
159
- ENV['OCTOKIT_WEB_ENDPOINT'] || WEB_ENDPOINT
173
+ ENV.fetch('OCTOKIT_WEB_ENDPOINT') { WEB_ENDPOINT }
160
174
  end
161
175
 
162
176
  # Default behavior for reading .netrc file
163
177
  # @return [Boolean]
164
178
  def netrc
165
- ENV['OCTOKIT_NETRC'] || false
179
+ ENV.fetch('OCTOKIT_NETRC', false)
166
180
  end
167
181
 
168
182
  # Default path for .netrc file
169
183
  # @return [String]
170
184
  def netrc_file
171
- ENV['OCTOKIT_NETRC_FILE'] || File.join(ENV['HOME'].to_s, '.netrc')
185
+ ENV.fetch('OCTOKIT_NETRC_FILE') { File.join(Dir.home.to_s, '.netrc') }
172
186
  end
173
-
174
187
  end
175
188
  end
176
189
  end
@@ -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