Sha256: 561f044af8d07b5cbcb449aea3968a1318caf9ca96e57d8c6d316e84d189e4c0

Contents?: true

Size: 1.8 KB

Versions: 15

Compression:

Stored size: 1.8 KB

Contents

require "zeitwerk"

module Jets
  class Autoloaders
    class GemInflector < Zeitwerk::Inflector
      def camelize(basename, _abspath)
        map = {
          cli: "CLI",
          io: "IO",
          version: "VERSION"
        }
        map[basename.to_sym] || super
      end
    end

    # for jets gem itself
    class Gem
      def autoloader
        loader = Zeitwerk::Loader.new
        loader.tag = "jets.gem"
        loader.inflector = GemInflector.new
        loader.push_dir(lib)
        loader.do_not_eager_load(do_not_eager_load)
        loader.ignore(ignore_paths) # loader.ignore requires full dir or path
        # loader.log!
        loader
      end

      def lib
        File.expand_path("#{__dir__}/../..") # jets/lib
      end

      # For jets/info.rb see Jets::Info property Middleware for why we do not eager load.
      def do_not_eager_load
        paths = %w[
          jets/info.rb
          jets/spec_helpers
          jets/spec_helpers.rb
          jets/commands
          jets/commands.rb
          jets/generators
          jets/generators.rb
        ]
        paths.map { |path| "#{lib}/#{path}" } # do_not_eager_load requires full dir or path
      end

      def ignore_paths
        # commands
        paths = %w[
          jets/application/dummy_config.rb
          jets/application/dummy_erb_compiler.rb
          jets/builders/rackup_wrappers
          jets/builders/templates
          jets/commands/templates
          jets/controller/middleware/webpacker_setup.rb
          jets/core_ext
          jets/core_ext.rb
          jets/generator
          jets/overrides
          jets/ruby_version_check.rb
          jets/cli.rb
          jets/commands.rb
          jets/generators/jets/app/ignore
          jets/tasks.rb
        ]
        paths.map { |path| "#{lib}/#{path}" }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/autoloaders/gem.rb
jets-5.0.12 lib/jets/autoloaders/gem.rb
jets-5.0.11 lib/jets/autoloaders/gem.rb
jets-5.0.10 lib/jets/autoloaders/gem.rb
jets-5.0.9 lib/jets/autoloaders/gem.rb
jets-5.0.8 lib/jets/autoloaders/gem.rb
jets-5.0.7 lib/jets/autoloaders/gem.rb
jets-5.0.6 lib/jets/autoloaders/gem.rb
jets-5.0.5 lib/jets/autoloaders/gem.rb
jets-5.0.4 lib/jets/autoloaders/gem.rb
jets-5.0.3 lib/jets/autoloaders/gem.rb
jets-5.0.2 lib/jets/autoloaders/gem.rb
jets-5.0.1 lib/jets/autoloaders/gem.rb
jets-5.0.0 lib/jets/autoloaders/gem.rb
jets-5.0.0.beta1 lib/jets/autoloaders/gem.rb