lib/tapioca/gemfile.rb in tapioca-0.1.3 vs lib/tapioca/gemfile.rb in tapioca-0.1.4

- old
+ new

@@ -60,25 +60,38 @@ @definition ||= Bundler::Dsl.evaluate(gemfile, lockfile, {}) end sig { params(spec: Spec).returns(T::Boolean) } def ignore_gem_spec?(spec) - spec.name == "sorbet" || + ["sorbet", "sorbet-static"].include?(spec.name) || spec.full_gem_path.start_with?(gemfile_dir) end sig { returns(String) } def gemfile_dir File.expand_path(gemfile.path + "/..") end + sig { returns(T::Array[T.untyped]) } + def rails_engines + engines = [] + + return engines unless Object.const_defined?("Rails::Engine") + + base = Object.const_get("Rails::Engine") + ObjectSpace.each_object(base.singleton_class) do |k| + k = T.cast(k, Class) + next if k.singleton_class? + engines.unshift(k) unless k == base + end + + engines.reject(&:abstract_railtie?) + end + sig { void } def load_rails_engines - return unless Object.const_defined?("Rails::Engine") - engines = Object.const_get("Rails::Engine").descendants.reject(&:abstract_railtie?) - - engines.each do |engine| + rails_engines.each do |engine| errored_files = [] engine.config.eager_load_paths.each do |load_path| Dir.glob("#{load_path}/**/*.rb").sort.each do |file| require(file) @@ -100,10 +113,10 @@ class Gem extend(T::Sig) sig { params(spec: Spec).void } def initialize(spec) - @spec = T.let(spec, Spec) + @spec = T.let(spec, Tapioca::Gemfile::Spec) end sig { returns(String) } def full_gem_path @spec.full_gem_path.to_s