Class: Guard::JslintOnRails

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/jslint-on-rails.rb

Constant Summary collapse

VERSION =
'0.2.0'

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ JslintOnRails

Returns a new instance of JslintOnRails.



10
11
12
13
# File 'lib/guard/jslint-on-rails.rb', line 10

def initialize(watchers=[], options={})
  super
  @config_path = File.join(Dir.pwd, options[:config_path] || 'config/jslint.yml')
end

Instance Method Details

#run_on_change(paths) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/guard/jslint-on-rails.rb', line 19

def run_on_change(paths)
  error = nil
  begin
    output = capture_output do
      lint = ::JSLint::Lint.new(
        :paths => paths,
        :config_path => @config_path 
      )
      lint.run
    end
  rescue ::JSLint::LintCheckFailure => e
    error = e
  end
  Notifier.notify((error ? 'failed' : 'passed'), :title => 'JSLint results', :image => (error ? :failed : :success))
  true
end

#startObject



15
16
17
# File 'lib/guard/jslint-on-rails.rb', line 15

def start
  UI.info "Guard::JsLintOnRails started using config: #{@config_path}"
end