guard-jshint-node 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Guard::JshintNode
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/pahen/guard-jshint-node.png)](http://travis-ci.org/pahen/guard-jshint-node)
4
+
3
5
  This guard will run [JSHint](http://www.jshint.com/) for you automatically when files are modified.
4
6
 
5
7
  ## Install
@@ -34,6 +36,6 @@ If Growl messages should be displayed or not.
34
36
 
35
37
  ### Example
36
38
 
37
- guard 'jshint', :config => 'path/to/config.json' do
39
+ guard 'jshint-node', :config => 'path/to/config.json' do
38
40
  watch(%r{^scripts\/.*\.js$})
39
41
  end
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -19,4 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency 'guard', '>= 0.8.8'
22
+ s.add_dependency 'rake'
23
+
24
+ s.add_development_dependency 'bundler', '~> 1.0'
25
+ s.add_development_dependency 'rspec', '~> 2.6'
26
+
22
27
  end
@@ -2,42 +2,48 @@ require 'guard'
2
2
  require 'guard/guard'
3
3
 
4
4
  module Guard
5
- class JshintNode < Guard
6
-
7
- VERSION = '0.0.1'
8
-
9
- DEFAULT_OPTIONS = {
10
- :config => 'jshint-config.json',
11
- :notify => true,
12
- }
13
-
14
- # Initialize a Guard.
15
- # @param [Array<Guard::Watcher>] watchers the Guard file watchers
16
- # @param [Hash] options the custom Guard options
17
- def initialize(watchers = [], options = {})
18
- defaults = DEFAULT_OPTIONS.clone
19
- @options = defaults.merge(options)
20
- super(watchers, @options)
21
- end
22
-
23
- # Called on file(s) modifications that the Guard watches.
24
- # @param [Array<String>] paths the changes files or paths
25
- # @raise [:task_has_failed] when run_on_change has failed
26
- def run_on_change(paths)
27
- paths.each do |path|
28
- results = `jshint #{path} --config #{@options[:config]}`
29
- if results.include? 'Lint Free!'
30
- if options[:notify]
31
- ::Guard::Notifier.notify('No errors found.', :title => 'JSHint', :image => :success)
32
- end
33
- else
34
- if options[:notify]
35
- ::Guard::Notifier.notify(results, :title => 'JSHint Errors', :image => :failed)
36
- end
37
- print results
38
- end
39
- end
40
- end
41
-
42
- end
5
+ class JshintNode < Guard
6
+
7
+ VERSION = '0.0.2'
8
+
9
+ DEFAULT_OPTIONS = {
10
+ :config => 'jshint-config.json',
11
+ :notify => true,
12
+ }
13
+
14
+ # Initialize a Guard.
15
+ # @param [Array<Guard::Watcher>] watchers the Guard file watchers
16
+ # @param [Hash] options the custom Guard options
17
+ def initialize(watchers = [], options = {})
18
+ defaults = DEFAULT_OPTIONS.clone
19
+ @options = defaults.merge(options)
20
+ super(watchers, @options)
21
+ end
22
+
23
+ # Called on file(s) modifications that the Guard watches.
24
+ # @param [Array<String>] paths the changes files or paths
25
+ # @raise [:task_has_failed] when run_on_change has failed
26
+ def run_on_change(paths)
27
+ paths.each do |path|
28
+
29
+ is_old_version = (Gem::Version.new(`jshint --version`) < Gem::Version.new('0.5.2'))
30
+ results = `jshint #{path} --config #{@options[:config]}`
31
+
32
+ if (is_old_version and results.include? 'Lint Free!') or (!is_old_version and $?.to_i == 0) then
33
+ if options[:notify]
34
+ ::Guard::Notifier.notify('No errors found.', :title => 'JSHint', :image => :success)
35
+ end
36
+ return true
37
+ else
38
+ if options[:notify]
39
+ ::Guard::Notifier.notify(results, :title => 'JSHint Errors', :image => :failed)
40
+ end
41
+ print results
42
+ return false
43
+ end
44
+
45
+ end
46
+ end
47
+
48
+ end
43
49
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-jshint-node
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrik Henningsson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-20 00:00:00 Z
18
+ date: 2012-05-06 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: guard
@@ -33,6 +33,50 @@ dependencies:
33
33
  version: 0.8.8
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: bundler
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 0
62
+ version: "1.0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 15
74
+ segments:
75
+ - 2
76
+ - 6
77
+ version: "2.6"
78
+ type: :development
79
+ version_requirements: *id004
36
80
  description: Guard::JshintNode automatically runs JSHint when watched files are modified.
37
81
  email:
38
82
  - patrik.henningsson@gmail.com