guard-jshint-on-rails 0.0.1
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +43 -0
- data/Rakefile +2 -0
- data/guard-jshint-on-rails.gemspec +22 -0
- data/lib/guard/jshint-on-rails.rb +47 -0
- data/lib/guard/jshint-on-rails/templates/Guardfile +6 -0
- metadata +77 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Guard::JshintOnRails
|
2
|
+
=============
|
3
|
+
This project is a fork from wireframe's [guard-jslint-on-rails](https://github.com/wireframe/guard-jslint-on-rails).
|
4
|
+
Instead of using the original [jslint-on-rails](https://github.com/psionides/jslint_on_rails), [jshint-on-rails](https://github.com/liquid/jshint_on_rails) is used here.
|
5
|
+
|
6
|
+
=============
|
7
|
+
|
8
|
+
Guard plugin to verify that Javascript files comply with [JSHint](http://jslint.com/) validations.
|
9
|
+
|
10
|
+
|
11
|
+
Install
|
12
|
+
-------
|
13
|
+
|
14
|
+
Install and configure the [JSHint on Rails](https://github.com/liquid/jshint_on_rails) gem.
|
15
|
+
|
16
|
+
Install the gem:
|
17
|
+
|
18
|
+
$ gem install guard-jshint-on-rails
|
19
|
+
|
20
|
+
Add it to your Gemfile (inside development group):
|
21
|
+
|
22
|
+
``` ruby
|
23
|
+
gem 'guard-jshint-on-rails'
|
24
|
+
```
|
25
|
+
|
26
|
+
Add guard definition to your Guardfile by running this command:
|
27
|
+
|
28
|
+
$ guard init jshint-on-rails
|
29
|
+
|
30
|
+
Configuration
|
31
|
+
-------------
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
# Guardfile
|
35
|
+
guard 'jshint-on-rails' do
|
36
|
+
# watch for changes to application javascript files
|
37
|
+
watch(%r{^app/assets/javascripts/.*\.js$})
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
Additional option `:config_path` is available to specify the path to the yaml file.
|
42
|
+
|
43
|
+
Please read [Guard doc](https://github.com/guard/guard#readme) for more information about the Guardfile DSL.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-s
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "guard-jshint-on-rails"
|
5
|
+
s.version = "0.0.1"
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.authors = ["Johnson Liang", "Andrew Liu", "Ryan Sonnek"]
|
8
|
+
s.email = ["johnsonliang7@gmail.com", "ryan@codecrate.com"]
|
9
|
+
s.homepage = "https://github.com/MrOrz/guard-jshint-on-rails"
|
10
|
+
s.summary = %q{Guard Javascript changes to ensure JSHint complience}
|
11
|
+
s.description = %q{Guard Javascript changes, ensuring JSHint complience}
|
12
|
+
|
13
|
+
s.rubyforge_project = "guard-jshint-on-rails"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency 'guard', '>= 1.0.0'
|
21
|
+
s.add_dependency 'jshint', '>= 1.0.2'
|
22
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/notifier'
|
4
|
+
require 'jshint'
|
5
|
+
|
6
|
+
module Guard
|
7
|
+
class JshintOnRails < Guard
|
8
|
+
|
9
|
+
def initialize(watchers=[], options={})
|
10
|
+
super
|
11
|
+
@config_path = File.join(Dir.pwd, options[:config_path] || 'config/jslint.yml')
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
UI.info "Guard::JsHintOnRails started using #{@config_path}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_on_change(paths)
|
19
|
+
error = nil
|
20
|
+
begin
|
21
|
+
output = capture_output do
|
22
|
+
lint = ::JSHint::Lint.new(
|
23
|
+
:paths => paths,
|
24
|
+
:config_path => @config_path
|
25
|
+
)
|
26
|
+
lint.run
|
27
|
+
end
|
28
|
+
rescue ::JSHint::LintCheckFailure => e
|
29
|
+
error = e
|
30
|
+
end
|
31
|
+
Notifier.notify((error ? 'failed' : 'passed'), :title => 'JSHint results', :image => (error ? :failed : :success))
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def capture_output
|
37
|
+
out = StringIO.new
|
38
|
+
$stdout = out
|
39
|
+
$stderr = out
|
40
|
+
yield
|
41
|
+
return out
|
42
|
+
ensure
|
43
|
+
$stderr = STDERR
|
44
|
+
$stdout = STDOUT
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-jshint-on-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Johnson Liang
|
9
|
+
- Andrew Liu
|
10
|
+
- Ryan Sonnek
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2012-03-07 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: guard
|
18
|
+
requirement: &2156642540 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *2156642540
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jshint
|
29
|
+
requirement: &2156641300 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.2
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *2156641300
|
38
|
+
description: Guard Javascript changes, ensuring JSHint complience
|
39
|
+
email:
|
40
|
+
- johnsonliang7@gmail.com
|
41
|
+
- ryan@codecrate.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- Gemfile
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- guard-jshint-on-rails.gemspec
|
51
|
+
- lib/guard/jshint-on-rails.rb
|
52
|
+
- lib/guard/jshint-on-rails/templates/Guardfile
|
53
|
+
homepage: https://github.com/MrOrz/guard-jshint-on-rails
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project: guard-jshint-on-rails
|
73
|
+
rubygems_version: 1.8.10
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Guard Javascript changes to ensure JSHint complience
|
77
|
+
test_files: []
|