lib/tapioca/commands/abstract_gem.rb in tapioca-0.16.5 vs lib/tapioca/commands/abstract_gem.rb in tapioca-0.16.6

- old
+ new

@@ -25,10 +25,11 @@ number_of_workers: T.nilable(Integer), auto_strictness: T::Boolean, dsl_dir: String, rbi_formatter: RBIFormatter, halt_upon_load_error: T::Boolean, + lsp_addon: T.nilable(T::Boolean), ).void end def initialize( gem_names:, exclude:, @@ -43,11 +44,12 @@ include_exported_rbis:, number_of_workers: nil, auto_strictness: true, dsl_dir: DEFAULT_DSL_DIR, rbi_formatter: DEFAULT_RBI_FORMATTER, - halt_upon_load_error: true + halt_upon_load_error: true, + lsp_addon: false ) @gem_names = gem_names @exclude = exclude @include_dependencies = include_dependencies @prerequire = prerequire @@ -57,10 +59,11 @@ @file_header = file_header @number_of_workers = number_of_workers @auto_strictness = auto_strictness @dsl_dir = dsl_dir @rbi_formatter = rbi_formatter + @lsp_addon = lsp_addon super() @bundle = T.let(Gemfile.new(exclude), Gemfile) @existing_rbis = T.let(nil, T.nilable(T::Hash[String, String])) @@ -70,42 +73,9 @@ @include_exported_rbis = include_exported_rbis @halt_upon_load_error = halt_upon_load_error end private - - sig { params(gem_names: T::Array[String]).returns(T::Array[Gemfile::GemSpec]) } - def gems_to_generate(gem_names) - return @bundle.dependencies if gem_names.empty? - - gem_names.each_with_object([]) do |gem_name, gems| - gem = @bundle.gem(gem_name) - - if gem.nil? - raise Thor::Error, set_color("Error: Cannot find gem '#{gem_name}'", :red) - end - - gems.concat(gem_dependencies(gem)) if @include_dependencies - gems << gem - end - end - - sig do - params( - gem: Gemfile::GemSpec, - dependencies: T::Array[Gemfile::GemSpec], - ).returns(T::Array[Gemfile::GemSpec]) - end - def gem_dependencies(gem, dependencies = []) - direct_dependencies = gem.dependencies.filter_map { |dependency| @bundle.gem(dependency.name) } - gems = dependencies | direct_dependencies - - if direct_dependencies.empty? - gems - else - direct_dependencies.reduce(gems) { |result, gem| gem_dependencies(gem, result) } - end - end sig { params(gem: Gemfile::GemSpec).void } def compile_gem_rbi(gem) gem_name = set_color(gem.name, :yellow, :bold)