Skip to content

Use autoload #16

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

Merged
merged 1 commit into from
Jun 3, 2025
Merged

Use autoload #16

merged 1 commit into from
Jun 3, 2025

Conversation

tangrufus
Copy link
Member

No description provided.

@tangrufus tangrufus added the enhancement New feature or request label Jun 3, 2025
@tangrufus tangrufus enabled auto-merge (squash) June 3, 2025 00:40
@tangrufus tangrufus requested a review from Copilot June 3, 2025 00:40
@tangrufus tangrufus disabled auto-merge June 3, 2025 00:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces autoload-based lazy loading for Rails::AppEnv and updates related tests and configuration files accordingly.

  • Replace multiple require_relative calls with autoload declarations in lib/rails/app_env.rb.
  • Update test files and the Railtie configuration to reference the new autoloaded constants.
  • Adjust configuration in test/dummy/config/application.rb to enable eager loading in CI environments.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/units/app_env/credentials_test.rb Added test to confirm AlreadyInitializedError inherits from the correct error.
test/units/app_env/console_test.rb Updated console require and assertion to match namespace changes.
test/features/credentials_test.rb Modified path assertions to use the dummy_path helper.
test/dummy/config/application.rb Configured eager_load to activate when running in CI.
lib/rails/rails_ext/credentials_command.rb Marked the config method as private.
lib/rails/app_env/railtie.rb Updated initialization and console configuration to use autoloaded constants.
lib/rails/app_env/credentials.rb Changed error class inheritance to reference the autoloaded Error constant.
lib/rails/app_env.rb Removed require_relative calls and replaced them with autoload declarations.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the AppEnv library to use Ruby’s autoload for module components, cleans up Railtie initialization, and updates tests and dummy app config.

  • Replace explicit require_relative calls with autoload declarations in lib/rails/app_env.rb
  • Simplify Railtie hooks to use scoped constants (Credentials and Console) and remove redundant requires
  • Update unit and feature tests to use dummy_path for credentials and adjust test requires; make dummy app’s eager_load conditional on ENV["CI"]

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/units/app_env/credentials_test.rb Add inheritance test for AlreadyInitializedError
test/units/app_env/console_test.rb Update test require and name for Console class
test/features/credentials_test.rb Use dummy_path helper for credentials file assertions
test/dummy/config/application.rb Make config.eager_load conditional on CI environment
lib/rails/rails_ext/credentials_command.rb Scope config method under private
lib/rails/app_env/railtie.rb Reference Credentials and Console directly; remove require_relative
lib/rails/app_env/credentials.rb Shorten AlreadyInitializedError superclass to Error
lib/rails/app_env.rb Introduce autoload declarations for AppEnv components
Comments suppressed due to low confidence (1)

test/units/app_env/console_test.rb:3

  • [nitpick] The test is trying to load Rails::AppEnv::Console but requires the internal IRBConsole. Consider requiring rails/app_env/console (or the main rails/app_env entrypoint) so the AppEnv Console class is properly loaded.
require "rails/commands/console/irb_console"

@tangrufus tangrufus enabled auto-merge (squash) June 3, 2025 00:47
@tangrufus tangrufus merged commit a6c3859 into main Jun 3, 2025
8 checks passed
@tangrufus tangrufus deleted the autoload branch June 3, 2025 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

1 participant