Sha256: f7c5ff72c1acb8517a3974419978bd3d5058e695bc87d852a49b8c4e2022d74c

Contents?: true

Size: 744 Bytes

Versions: 21

Compression:

Stored size: 744 Bytes

Contents

# typed: strong
# frozen_string_literal: true

module Tapioca
  module Compilers
    # Taken from https://github.com/sorbet/sorbet/blob/master/gems/sorbet/lib/todo-rbi.rb
    class TodosCompiler
      extend(T::Sig)

      sig do
        returns(String)
      end
      def compile
        list_todos.each_line.map do |line|
          next if line.include?("<") || line.include?("class_of")
          "module #{line.strip.gsub('T.untyped::', '')}; end"
        end.compact.join("\n")
      end

      private

      sig { returns(String) }
      def list_todos
        Tapioca::Compilers::Sorbet.run(
          "--print=missing-constants",
          "--stdout-hup-hack",
          "--no-error-count"
        ).strip
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
tapioca-0.4.7 lib/tapioca/compilers/todos_compiler.rb