Module: Tapioca::SorbetHelper
- Extended by:
- T::Sig
- Included in:
- Cli, Commands::Dsl, Commands::Gem, Commands::Todo, Dsl::Compilers::ActiveRecordRelations, Tapioca::Static::SymbolLoader, TypeVariableHelper
- Defined in:
- lib/tapioca/helpers/sorbet_helper.rb
Constant Summary collapse
- SORBET_GEM_SPEC =
T.let( ::Gem::Specification.find_by_name("sorbet-static"), ::Gem::Specification )
- SORBET_BIN =
T.let( Pathname.new(SORBET_GEM_SPEC.full_gem_path) / "libexec" / "sorbet", Pathname )
- SORBET_EXE_PATH_ENV_VAR =
"TAPIOCA_SORBET_EXE"- FEATURE_REQUIREMENTS =
T.let({ to_ary_nil_support: ::Gem::Requirement.new(">= 0.5.9220"), # https://github.com/sorbet/sorbet/pull/4706 print_payload_sources: ::Gem::Requirement.new(">= 0.5.9818"), # https://github.com/sorbet/sorbet/pull/5504 type_variable_block_syntax: ::Gem::Requirement.new(">= 0.5.9892"), # https://github.com/sorbet/sorbet/pull/5639 }.freeze, T::Hash[Symbol, ::Gem::Requirement])
Instance Method Summary collapse
- #sorbet(*sorbet_args) ⇒ Object
- #sorbet_path ⇒ Object
- #sorbet_supports?(feature, version: nil) ⇒ Boolean
Instance Method Details
#sorbet(*sorbet_args) ⇒ Object
30 31 32 |
# File 'lib/tapioca/helpers/sorbet_helper.rb', line 30 def sorbet(*sorbet_args) Spoom::Sorbet.srb(sorbet_args.join(" "), sorbet_bin: sorbet_path, capture_err: true) end |
#sorbet_path ⇒ Object
35 36 37 38 39 |
# File 'lib/tapioca/helpers/sorbet_helper.rb', line 35 def sorbet_path sorbet_path = ENV.fetch(SORBET_EXE_PATH_ENV_VAR, SORBET_BIN) sorbet_path = SORBET_BIN if sorbet_path.empty? sorbet_path.to_s.shellescape end |
#sorbet_supports?(feature, version: nil) ⇒ Boolean
42 43 44 45 46 47 48 49 |
# File 'lib/tapioca/helpers/sorbet_helper.rb', line 42 def sorbet_supports?(feature, version: nil) version = SORBET_GEM_SPEC.version unless version requirement = FEATURE_REQUIREMENTS[feature] Kernel.raise "Invalid Sorbet feature #{feature}" unless requirement requirement.satisfied_by?(version) end |