Sha256: f9f34eb043b46dcf31e18ff2d32a433737e11e6281a41f245460b59063bdecc3

Contents?: true

Size: 945 Bytes

Versions: 29

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

require "rails/zeitwerk_checker"

report_unchecked = ->(unchecked) do
  puts
  puts <<~EOS
    WARNING: The following directories will only be checked if you configure
    them to be eager loaded:
  EOS
  puts

  unchecked.each { |dir| puts "  #{dir}" }
  puts

  puts <<~EOS
    You may verify them manually, or add them to config.eager_load_paths
    in config/application.rb and run zeitwerk:check again.
  EOS
  puts
end

namespace :zeitwerk do
  desc "Check project structure for Zeitwerk compatibility"
  task check: :environment do
    puts "Hold on, I am eager loading the application."

    begin
      unchecked = Rails::ZeitwerkChecker.check
    rescue Zeitwerk::NameError => e
      abort e.message.sub(/#{Regexp.escape(Rails.root.to_s)}./, "")
    end

    if unchecked.empty?
      puts "All is good!"
    else
      report_unchecked[unchecked]
      puts "Otherwise, all is good!"
    end
  end
end

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
railties-8.0.0 lib/rails/tasks/zeitwerk.rake
railties-7.2.2 lib/rails/tasks/zeitwerk.rake
railties-7.1.5 lib/rails/tasks/zeitwerk.rake
railties-8.0.0.rc2 lib/rails/tasks/zeitwerk.rake
railties-7.2.1.2 lib/rails/tasks/zeitwerk.rake
railties-7.1.4.2 lib/rails/tasks/zeitwerk.rake
railties-8.0.0.rc1 lib/rails/tasks/zeitwerk.rake
railties-7.2.1.1 lib/rails/tasks/zeitwerk.rake
railties-7.1.4.1 lib/rails/tasks/zeitwerk.rake
railties-8.0.0.beta1 lib/rails/tasks/zeitwerk.rake
omg-railties-8.0.0.alpha9 lib/rails/tasks/zeitwerk.rake
omg-railties-8.0.0.alpha8 lib/rails/tasks/zeitwerk.rake
omg-railties-8.0.0.alpha7 lib/rails/tasks/zeitwerk.rake
omg-railties-8.0.0.alpha4 lib/rails/tasks/zeitwerk.rake
omg-railties-8.0.0.alpha3 lib/rails/tasks/zeitwerk.rake
railties-7.1.4 lib/rails/tasks/zeitwerk.rake
railties-7.2.1 lib/rails/tasks/zeitwerk.rake
railties-7.2.0 lib/rails/tasks/zeitwerk.rake
railties-7.2.0.rc1 lib/rails/tasks/zeitwerk.rake
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/railties-7.1.3.4/lib/rails/tasks/zeitwerk.rake