Class: Tapioca::Static::RequiresCompiler
- Inherits:
-
Object
- Object
- Tapioca::Static::RequiresCompiler
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/static/requires_compiler.rb
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(sorbet_path) ⇒ RequiresCompiler
constructor
A new instance of RequiresCompiler.
Constructor Details
#initialize(sorbet_path) ⇒ RequiresCompiler
Returns a new instance of RequiresCompiler.
10 11 12 |
# File 'lib/tapioca/static/requires_compiler.rb', line 10 def initialize(sorbet_path) @sorbet_path = sorbet_path end |
Instance Method Details
#compile ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tapioca/static/requires_compiler.rb', line 15 def compile config = Spoom::Sorbet::Config.parse_file(@sorbet_path) files = collect_files(config) names_in_project = files.to_h { |file| [File.basename(file, ".rb"), true] } files.flat_map do |file| collect_requires(file).reject { |req| names_in_project[req] } end.sort.uniq.map do |name| "require \"#{name}\"\n" end.join end |