Class: Filewatcher::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/filewatcher/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.



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

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

Instance Method Details

#commandObject



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

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