Class: Verifiers

Inherits:
Object
  • Object
show all
Defined in:
lib/elelem/tools/verify.rb

Constant Summary collapse

SYNTAX =
{
  ".rb" => "ruby -c %{path}",
  ".erb" => "erb -x %{path} | ruby -c",
  ".py" => "python -m py_compile %{path}",
  ".go" => "go vet %{path}",
  ".rs" => "cargo check --quiet",
  ".ts" => "npx tsc --noEmit %{path}",
  ".js" => "node --check %{path}",
}.freeze

Class Method Summary collapse

Class Method Details

.for(path) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/elelem/tools/verify.rb', line 14

def self.for(path)
  return [] unless path

  cmds = []
  ext = File.extname(path)
  cmds << (SYNTAX[ext] % { path: path }) if SYNTAX[ext]
  cmds << test_runner
  cmds.compact
end

.test_runner ⇒ Object



24
25
26
# File 'lib/elelem/tools/verify.rb', line 24

def self.test_runner
  %w[bin/test script/test].find { |s| File.executable?(s) }
end