-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16899 from Homebrew/tapioca-compiler-for-tty-rbi
Convert the `utils/tty` RBI generator to a Tapioca compiler
- Loading branch information
Showing
5 changed files
with
96 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.