Class: Sorbet::Private::TodoRBI

Inherits:
Object
  • Object
show all
Includes:
StepInterface
Defined in:
lib/todo-rbi.rb

Constant Summary collapse

OUTPUT =
'sorbet/rbi/todo.rbi'
HEADER =
Sorbet::Private::Serialize.header('strong', 'todo')

Class Method Summary collapse

Class Method Details

.mainObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/todo-rbi.rb', line 15

def self.main
  File.delete(OUTPUT) if File.exist?(OUTPUT)

  IO.popen(
    [
      File.realpath("#{__dir__}/../bin/srb"),
      'tc',
      '--print=missing-constants',
      '--stdout-hup-hack',
      '--silence-dev-message',
      '--no-error-count',
    ],
    err: '/dev/null',
  ) do |io|
    missing_constants = io.read.split("\n")

    output = String.new
    output << HEADER
    missing_constants.each do |const|
      next if const.include?("<") || const.include?("class_of")
      output << "module #{const.gsub('T.untyped::', '')}; end\n"
    end
    File.write(OUTPUT, output) if output != HEADER
  end
end

.output_fileObject



41
42
43
# File 'lib/todo-rbi.rb', line 41

def self.output_file
  OUTPUT
end