jshint_on_rails 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ The default config allows you to:
27
27
 
28
28
  To start checking your stuff run the following:
29
29
 
30
- [bundle exec] rake jslint
30
+ [bundle exec] rake jshint
31
31
 
32
32
  Then you should see:
33
33
 
@@ -60,7 +60,7 @@ If anything is wrong, you will get something like this instead:
60
60
  If you want to test specific file or files (just once, without modifying the config), you can pass paths to include
61
61
  and/or paths to exclude to the rake task:
62
62
 
63
- rake jslint paths=public/javascripts/models/*.js,public/javascripts/lib/*.js exclude_paths=public/javascripts/lib/jquery.js
63
+ rake jshint paths=public/javascripts/models/*.js,public/javascripts/lib/*.js exclude_paths=public/javascripts/lib/jquery.js
64
64
 
65
65
 
66
66
  ## Credits
@@ -2,6 +2,6 @@ require 'jshint/errors'
2
2
  require 'jshint/utils'
3
3
  require 'jshint/lint'
4
4
 
5
- if defined?(Rails) && Rails::VERSION::MAJOR == 3
5
+ if defined?(Rails) && Rails::VERSION::MAJOR >= 3
6
6
  require 'jshint/railtie'
7
7
  end
@@ -5,6 +5,7 @@ desc "Run JSHint check on selected Javascript files"
5
5
  task :jshint do
6
6
  include_paths = JSHint::Utils.paths_from_command_line('paths')
7
7
  exclude_paths = JSHint::Utils.paths_from_command_line('exclude_paths')
8
+ config_path = JSHint::Utils.path_from_command_line('config_path')
8
9
 
9
10
  if include_paths && exclude_paths.nil?
10
11
  # if you pass paths= on command line but not exclude_paths=, and you have exclude_paths
@@ -13,7 +14,10 @@ task :jshint do
13
14
  exclude_paths = []
14
15
  end
15
16
 
16
- lint = JSHint::Lint.new :paths => include_paths, :exclude_paths => exclude_paths
17
+ options = {:paths => include_paths, :exclude_paths => exclude_paths}
18
+ options[:config_path] = config_path if config_path
19
+
20
+ lint = JSHint::Lint.new options
17
21
  lint.run
18
22
  end
19
23
 
@@ -3,7 +3,7 @@ require 'yaml'
3
3
 
4
4
  module JSHint
5
5
 
6
- VERSION = "1.0.2"
6
+ VERSION = "1.0.3"
7
7
  DEFAULT_CONFIG_FILE = File.expand_path(File.dirname(__FILE__) + "/config/jshint.yml")
8
8
 
9
9
  class << self
@@ -43,6 +43,10 @@ module JSHint
43
43
  list.reject { |entry| excluded.any? { |f| File.identical?(f, entry) }}
44
44
  end
45
45
 
46
+ def path_from_command_line(field)
47
+ ENV[field] || ENV[field.upcase]
48
+ end
49
+
46
50
  def paths_from_command_line(field)
47
51
  argument = ENV[field] || ENV[field.upcase]
48
52
  argument && argument.split(/,/)
@@ -13,50 +13,71 @@ describe JSHint::Utils do
13
13
  JSHint.config_path.should == 'some/path'
14
14
  end
15
15
 
16
+ describe "path_from_command_line" do
17
+ it "should extract a path from the command line argument" do
18
+ ENV['test_arg'] = 'file.js'
19
+ JSU.path_from_command_line('test_arg').should == 'file.js'
20
+ end
21
+
22
+ it "should work if the argument name is given in uppercase" do
23
+ ENV['TEST_ARG'] = 'file.js'
24
+ JSU.path_from_command_line('test_arg').should == 'file.js'
25
+ end
26
+
27
+ it "should return nil if the argument isn't set" do
28
+ JSU.path_from_command_line('crash').should be_nil
29
+ end
30
+
31
+ after :each do
32
+ ENV['test_arg'] = nil
33
+ ENV['TEST_ARG'] = nil
34
+ end
35
+ end
36
+
16
37
  describe "paths_from_command_line" do
17
38
  it "should extract an array of paths from command line argument" do
18
39
  ENV['test_arg'] = 'one,two,three'
19
40
  JSU.paths_from_command_line('test_arg').should == ['one', 'two', 'three']
20
41
  end
21
-
42
+
22
43
  it "should also work if the argument name is given in uppercase" do
23
44
  ENV['TEST_ARG'] = 'ruby,python,js'
24
45
  JSU.paths_from_command_line('test_arg').should == ['ruby', 'python', 'js']
25
46
  end
26
-
47
+
27
48
  it "should return nil if the argument isn't set" do
28
49
  JSU.paths_from_command_line('crash').should be_nil
29
50
  end
30
-
51
+
31
52
  after :each do
32
53
  ENV['test_arg'] = nil
33
54
  ENV['TEST_ARG'] = nil
34
55
  end
35
56
  end
36
-
57
+
37
58
  describe "load_config_file" do
38
-
59
+
39
60
  before :all do
40
61
  File.open("sample.yml", "w") { |f| f.puts("framework: rails") }
41
62
  Dir.mkdir("tmp")
42
63
  end
43
-
64
+
44
65
  it "should load a YAML file if it can be read" do
45
66
  JSU.load_config_file("sample.yml").should == { 'framework' => 'rails' }
46
67
  end
47
-
68
+
48
69
  it "should return an empty hash if file name is nil" do
49
70
  JSU.load_config_file(nil).should == {}
50
71
  end
51
-
72
+
52
73
  it "should return an empty hash if file doesn't exist" do
53
74
  JSU.load_config_file("crack.exe").should == {}
54
75
  end
55
-
76
+
56
77
  it "should return an empty hash if file is not a file" do
57
78
  JSU.load_config_file("tmp").should == {}
58
79
  end
59
-
80
+
60
81
  it "should return an empty hash if file is not readable" do
61
82
  File.should_receive(:readable?).once.with("sample.yml").and_return(false)
62
83
  JSU.load_config_file("sample.yml").should == {}
metadata CHANGED
@@ -1,32 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jshint_on_rails
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bruno Gouveia
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-26 00:00:00 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: JSHint wrapped in a Ruby gem for easier use
22
15
  email: brunogouveia@buzungo.com.br
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
19
+ files:
30
20
  - MIT-LICENSE
31
21
  - README.markdown
32
22
  - Changelog.markdown
@@ -51,36 +41,28 @@ files:
51
41
  - spec/utils_spec.rb
52
42
  homepage: http://github.com/bgouveia/jshint_on_rails
53
43
  licenses: []
54
-
55
44
  post_install_message:
56
45
  rdoc_options: []
57
-
58
- require_paths:
46
+ require_paths:
59
47
  - lib
60
- required_ruby_version: !ruby/object:Gem::Requirement
48
+ required_ruby_version: !ruby/object:Gem::Requirement
61
49
  none: false
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- hash: 3
66
- segments:
67
- - 0
68
- version: "0"
69
- required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
55
  none: false
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- hash: 3
75
- segments:
76
- - 0
77
- version: "0"
78
- requirements:
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements:
79
61
  - Java JRE (5.0 or later)
80
62
  rubyforge_project:
81
- rubygems_version: 1.8.8
63
+ rubygems_version: 1.8.24
82
64
  signing_key:
83
65
  specification_version: 3
84
- summary: JSHint is a little more flexible JavaScript checker, wrapped in a Ruby gem for easier use
66
+ summary: JSHint is a little more flexible JavaScript checker, wrapped in a Ruby gem
67
+ for easier use
85
68
  test_files: []
86
-