Module: Tapioca::Compilers::Sorbet
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/compilers/sorbet.rb
Constant Summary collapse
- SORBET_GEM_SPEC =
T.let( Gem::Specification.find_by_name("sorbet-static"), Gem::Specification )
- SORBET =
T.let( Pathname.new(SORBET_GEM_SPEC.full_gem_path) / "libexec" / "sorbet", Pathname )
- EXE_PATH_ENV_VAR =
"TAPIOCA_SORBET_EXE"
- FEATURE_REQUIREMENTS =
T.let({ # First tag that includes https://github.com/sorbet/sorbet/pull/4706 to_ary_nil_support: Gem::Requirement.new(">= 0.5.9220"), }.freeze, T::Hash[Symbol, Gem::Requirement])
Class Method Summary collapse
Class Method Details
.run(*args) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tapioca/compilers/sorbet.rb', line 29 def run(*args) IO.popen( [ sorbet_path, "--quiet", *args, ].join(" "), err: "/dev/null" ).read end |
.sorbet_path ⇒ Object
41 42 43 44 45 |
# File 'lib/tapioca/compilers/sorbet.rb', line 41 def sorbet_path sorbet_path = ENV.fetch(EXE_PATH_ENV_VAR, SORBET) sorbet_path = SORBET if sorbet_path.empty? sorbet_path.to_s.shellescape end |
.supports?(feature, version: nil) ⇒ Boolean
48 49 50 51 52 53 54 55 |
# File 'lib/tapioca/compilers/sorbet.rb', line 48 def supports?(feature, version: nil) version = SORBET_GEM_SPEC.version unless version requirement = FEATURE_REQUIREMENTS[feature] raise "Invalid Sorbet feature #{feature}" unless requirement requirement.satisfied_by?(version) end |