Class: Filewatcher::CLI::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/filewatcher/cli/runner.rb

Overview

Get runner command by filename

Constant Summary collapse

RUNNERS =

Define runners for ‘–exec` option

{
  python: %w[py],
  node: %w[js],
  ruby: %w[rb],
  perl: %w[pl],
  awk: %w[awk],
  php: %w[php phtml php4 php3 php5 phps]
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Runner

Returns a new instance of Runner.



17
18
19
20
# File 'lib/filewatcher/cli/runner.rb', line 17

def initialize(filename)
  @filename = filename
  @ext = File.extname(filename).delete('.')
end

Instance Method Details

#commandObject



22
23
24
# File 'lib/filewatcher/cli/runner.rb', line 22

def command
  "env #{runner} #{@filename}" if runner
end