31 lines
908 B
Ruby
Raw Normal View History

# typed: strict
# frozen_string_literal: true
require_relative "../../../global"
2024-03-30 13:07:16 +00:00
require "utils/tty"
module Tapioca
module Compilers
class Tty < Tapioca::Dsl::Compiler
2024-03-17 20:28:54 +00:00
# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
ConstantType = type_member { { fixed: Module } }
2024-03-17 20:28:54 +00:00
# rubocop:enable Style/MutableConstant
sig { override.returns(T::Enumerable[Module]) }
2024-03-30 13:07:16 +00:00
def self.gather_constants = [::Tty]
sig { override.void }
def decorate
2024-03-30 13:07:16 +00:00
root.create_module(T.must(constant.name)) do |mod|
dynamic_methods = ::Tty::COLOR_CODES.keys + ::Tty::STYLE_CODES.keys + ::Tty::SPECIAL_CODES.keys
2024-03-30 13:07:16 +00:00
dynamic_methods.each do |method|
mod.create_method(method.to_s, return_type: "String", class_method: true)
end
end
end
end
end
end