Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clients autoload #1351

Merged
merged 2 commits into from May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/octokit.rb
@@ -1,10 +1,11 @@
require 'octokit/client'
require 'octokit/enterprise_admin_client'
require 'octokit/enterprise_management_console_client'
require 'octokit/default'
require 'octokit/configurable'

# Ruby toolkit for the GitHub API
module Octokit
autoload(:Client, File.join(__dir__, 'octokit/client'))
autoload(:EnterpriseAdminClient, File.join(__dir__, 'octokit/enterprise_admin_client'))
autoload(:EnterpriseManagementConsoleClient, File.join(__dir__, 'octokit/enterprise_management_console_client'))

class << self
include Octokit::Configurable
Expand Down
1 change: 0 additions & 1 deletion lib/octokit/client.rb
Expand Up @@ -2,7 +2,6 @@
require 'octokit/warnable'
require 'octokit/arguments'
require 'octokit/repo_arguments'
require 'octokit/configurable'
require 'octokit/authentication'
require 'octokit/gist'
require 'octokit/rate_limit'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move these to autoloads in the Octokit module as well in case they are referenced before Client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right... it depends on the API of the gem. It looks like they are all public API and you expect these modules to be pluggable by other client types.

I'll take a look at the modules that aren't under Client and see if it makes sense to autoload them. If they are trivial enough, we could consider just moving the require.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to autoload all constants nested in Octokit besides Configurable (because that's used immediately in the main module). It should be roughly the same performance diff that way.

Expand Down