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.27 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.26 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.25 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.24 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.23 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.22 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.21 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.20 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.19 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.18 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.17 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.16 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.15 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.14 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.13 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.12 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.11 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.10 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.9 lib/tapioca/compilers/todos_compiler.rb
tapioca-0.4.8 lib/tapioca/compilers/todos_compiler.rb