Class: Guard::JshintOnRails

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of JshintOnRails.



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

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



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

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

#startObject



14
15
16
# File 'lib/guard/jshint-on-rails.rb', line 14

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