Class: Tapioca::Compilers::RequiresCompiler

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/compilers/requires_compiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(sorbet_path) ⇒ RequiresCompiler

Returns a new instance of RequiresCompiler.



12
13
14
# File 'lib/tapioca/compilers/requires_compiler.rb', line 12

def initialize(sorbet_path)
  @sorbet_path = sorbet_path
end

Instance Method Details

#compileObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tapioca/compilers/requires_compiler.rb', line 17

def compile
  config = Spoom::Sorbet::Config.parse_file(@sorbet_path)
  files = collect_files(config)
  files.flat_map do |file|
    collect_requires(file).reject do |req|
      name_in_project?(files, req)
    end
  end.sort.uniq.map do |name|
    "require '#{name}'\n"
  end.join
end