diff --git a/CHANGELOG.md b/CHANGELOG.md index 4250466..15c351e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/countless.rb b/lib/countless.rb index 6c46f05..1198b83 100644 --- a/lib/countless.rb +++ b/lib/countless.rb @@ -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 diff --git a/lib/countless/configuration.rb b/lib/countless/configuration.rb index c1bf345..631078f 100644 --- a/lib/countless/configuration.rb +++ b/lib/countless/configuration.rb @@ -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