Skip to content

Commit

Permalink
Do not eager load the configuration.
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann Mayer <[email protected]>
  • Loading branch information
Jack12816 committed Jan 13, 2025
1 parent 7372922 commit 115b803
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### next

* TODO: Replace this bullet point with an actual description of a change.
* Do not eager load the configuration (#6)

### 1.4.0 (3 January 2025)

Expand Down
4 changes: 4 additions & 0 deletions lib/countless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@

# The top level namespace for the countless gem.
module Countless
# Configure the relative gem code base location
root_path = Pathname.new("#{__dir__}/countless")

# Setup a Zeitwerk autoloader instance and configure it
loader = Zeitwerk::Loader.for_gem

# Do not automatically load the Rake tasks
loader.ignore("#{__dir__}/countless/rake_tasks.rb")
loader.do_not_eager_load(root_path.join('configuration.rb'))

# Finish the auto loader configuration
loader.setup
Expand Down
6 changes: 3 additions & 3 deletions lib/countless/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class Configuration
# prefix to all relative path/file configurations.
config_accessor(:base_path) do
# Check for a Rake invoked call
if defined? Rake
if defined?(Rake) && Rake.respond_to?(:application)
path = Rake.application.rakefile_location
path = Rake.application.original_dir unless path.present?
next path
path ||= Rake.application.original_dir
next path if path.present?
end

# Check for Rails as fallback
Expand Down

0 comments on commit 115b803

Please sign in to comment.