Skip to content

Commit

Permalink
Merge pull request #16899 from Homebrew/tapioca-compiler-for-tty-rbi
Browse files Browse the repository at this point in the history
Convert the `utils/tty` RBI generator to a Tapioca compiler
  • Loading branch information
issyl0 committed Mar 30, 2024
2 parents 02a0ea8 + db39e93 commit a3932b4
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 92 deletions.
1 change: 0 additions & 1 deletion Library/Homebrew/dev-cmd/typecheck.rb
Expand Up @@ -51,7 +51,6 @@ def run
tapioca_args = args.update_all? ? ["--all"] : []

ohai "Updating homegrown RBI files..."
safe_system "bundle", "exec", "ruby", "sorbet/custom_generators/tty.rb"
safe_system "bundle", "exec", "ruby", "sorbet/custom_generators/env_config.rb"

ohai "Updating Tapioca RBI files..."
Expand Down
31 changes: 0 additions & 31 deletions Library/Homebrew/sorbet/custom_generators/tty.rb

This file was deleted.

66 changes: 66 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/tty.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Library/Homebrew/sorbet/tapioca/compilers/tty.rb
@@ -0,0 +1,30 @@
# typed: strict
# frozen_string_literal: true

require_relative "../../../global"
require "utils/tty"

module Tapioca
module Compilers
class Tty < Tapioca::Dsl::Compiler
# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
ConstantType = type_member { { fixed: Module } }
# rubocop:enable Style/MutableConstant

sig { override.returns(T::Enumerable[Module]) }
def self.gather_constants = [::Tty]

sig { override.void }
def decorate
root.create_module(T.must(constant.name)) do |mod|
dynamic_methods = ::Tty::COLOR_CODES.keys + ::Tty::STYLE_CODES.keys + ::Tty::SPECIAL_CODES.keys

dynamic_methods.each do |method|
mod.create_method(method.to_s, return_type: "String", class_method: true)
end
end
end
end
end
end
60 changes: 0 additions & 60 deletions Library/Homebrew/utils/tty.rbi

This file was deleted.

0 comments on commit a3932b4

Please sign in to comment.