guard-jshint-node 0.0.7 → 0.0.8

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0cf2e8c9e4f974585c2055c6a944b4738f58f69c
4
+ data.tar.gz: e31222fdaee29b43cd6f37864809c41df4c3fb75
5
+ SHA512:
6
+ metadata.gz: 9bf2a6e43d68a7d6df1ea22c5cbd4b8474613523d4bd9e9641f07dca8e2c6ffcd8db64fb947616e318ff3c903f45699f21b73c076330c30c4585a55f655658d7
7
+ data.tar.gz: be83535549407a4363ffe8e291c6336410a00122983e0b70315d8967e0fd23c4e817267f5d69b2df0285b880e12577063d808d0dddc8156dfd594d58f20963bf
@@ -0,0 +1,2 @@
1
+ {
2
+ }
@@ -1,5 +1,6 @@
1
1
  require 'guard'
2
2
  require 'guard/guard'
3
+ require 'shellwords'
3
4
 
4
5
  module Guard
5
6
  class JshintNode < Guard
@@ -8,7 +9,8 @@ module Guard
8
9
  :config => 'jshint-config.json',
9
10
  :executable => 'jshint',
10
11
  :notify_on_success => true,
11
- :notify_on_failure => true
12
+ :notify_on_failure => true,
13
+ :run_at_start => true
12
14
  }
13
15
 
14
16
  # Initialize a Guard.
@@ -20,30 +22,39 @@ module Guard
20
22
  super(watchers, @options)
21
23
  end
22
24
 
25
+ def start
26
+ run_all if options[:run_at_start]
27
+ end
28
+
29
+ def reload
30
+ run_all
31
+ end
32
+
33
+ def run_all
34
+ run_on_changes(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))
35
+ end
36
+
23
37
  # Called on file(s) modifications that the Guard watches.
24
38
  # @param [Array<String>] paths the changes files or paths
25
39
  # @raise [:task_has_failed] when run_on_changes has failed
26
40
  def run_on_changes(paths)
27
- paths.each do |path|
28
-
29
- is_old_version = (Gem::Version.new(`#{@options[:executable]} --version`) < Gem::Version.new('0.5.2'))
30
- results = `#{@options[:executable]} #{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_on_success]
34
- ::Guard::Notifier.notify('No errors found.', :title => 'JSHint', :image => :success)
35
- end
36
- return true
37
- else
38
- if options[:notify_on_failure]
39
- ::Guard::Notifier.notify(results, :title => 'JSHint Errors', :image => :failed)
40
- end
41
- print results
42
- return false
43
- end
41
+ cmd = "#{options[:executable]} --config #{@options[:config]} #{paths.map { |p| p.shellescape }.join(' ')}"
42
+ results = `#{cmd}`
43
+
44
+ success = ($?.to_i == 0)
44
45
 
46
+ if success
47
+ if options[:notify_on_success]
48
+ ::Guard::Notifier.notify('No errors found.', :title => 'JSHint', :image => :success)
49
+ end
50
+ else
51
+ if options[:notify_on_failure]
52
+ ::Guard::Notifier.notify(results, :title => 'JSHint Errors', :image => :failed)
53
+ end
54
+ print results
45
55
  end
56
+ return success
46
57
  end
47
58
 
48
59
  end
49
- end
60
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module JshintNodeVersion
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
data/spec/fixtures/bad.js CHANGED
@@ -1 +1 @@
1
- var n = parseInt(666);
1
+ if (1 = 2) {}
@@ -1 +1 @@
1
- var n = parseInt(666, 10);
1
+ if (1 === 2) {}
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-jshint-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Patrik Henningsson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: guard
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.10.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.10.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -73,6 +66,7 @@ files:
73
66
  - README.md
74
67
  - Rakefile
75
68
  - guard-jshint-node.gemspec
69
+ - jshint-config.json
76
70
  - lib/guard/jshint-node.rb
77
71
  - lib/guard/jshint-node/templates/Guardfile
78
72
  - lib/guard/jshint-node/version.rb
@@ -81,27 +75,26 @@ files:
81
75
  - spec/guard/jshint-node_spec.rb
82
76
  homepage: http://github.com/pahen/guard-jshint-node
83
77
  licenses: []
78
+ metadata: {}
84
79
  post_install_message:
85
80
  rdoc_options: []
86
81
  require_paths:
87
82
  - lib
88
83
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
84
  requirements:
91
- - - ! '>='
85
+ - - '>='
92
86
  - !ruby/object:Gem::Version
93
87
  version: '0'
94
88
  required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
89
  requirements:
97
- - - ! '>='
90
+ - - '>='
98
91
  - !ruby/object:Gem::Version
99
92
  version: 1.3.6
100
93
  requirements: []
101
94
  rubyforge_project: guard-jshint-node
102
- rubygems_version: 1.8.24
95
+ rubygems_version: 2.0.3
103
96
  signing_key:
104
- specification_version: 3
97
+ specification_version: 4
105
98
  summary: Guard gem for running JSHint
106
99
  test_files:
107
100
  - spec/fixtures/bad.js