Sha256: 5fc0fe73c84dcfaabe772dea94ed5613dc7d51acc1ac54960c3d07317d78df4b

Contents?: true

Size: 744 Bytes

Versions: 7

Compression:

Stored size: 744 Bytes

Contents

# frozen_string_literal: true
# typed: strong

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

7 entries across 7 versions & 1 rubygems

Version Path
tapioca-0.4.6 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.5 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.4 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.3 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.2 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.1 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.0 lib/tapioca/compilers/todos_compiler.rb