jslint_on_rails 1.1 → 1.1.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/Changelog.markdown +4 -0
- data/lib/jslint/lint.rb +1 -1
- data/lib/jslint/utils.rb +22 -14
- data/spec/spec_helper.rb +6 -16
- data/spec/utils_spec.rb +35 -8
- metadata +38 -19
data/Changelog.markdown
CHANGED
data/lib/jslint/lint.rb
CHANGED
@@ -37,7 +37,7 @@ module JSLint
|
|
37
37
|
|
38
38
|
def run
|
39
39
|
check_java
|
40
|
-
Utils.
|
40
|
+
Utils.log "Running JSLint:\n\n"
|
41
41
|
arguments = "#{JSLINT_FILE} #{option_string.inspect.gsub(/\$/, "\\$")} #{@file_list.join(' ')}"
|
42
42
|
success = call_java_with_status(RHINO_JAR_FILE, RHINO_JAR_CLASS, arguments)
|
43
43
|
raise LintCheckFailure, "JSLint test failed." unless success
|
data/lib/jslint/utils.rb
CHANGED
@@ -3,27 +3,36 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module JSLint
|
5
5
|
|
6
|
-
VERSION = "1.1"
|
6
|
+
VERSION = "1.1.1"
|
7
7
|
DEFAULT_CONFIG_FILE = File.expand_path(File.dirname(__FILE__) + "/config/jslint.yml")
|
8
8
|
|
9
9
|
class << self
|
10
|
-
|
11
|
-
end
|
10
|
+
attr_writer :config_path
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'config/jslint.yml'
|
12
|
+
def config_path
|
13
|
+
@config_path || JSLint::Utils.default_config_path
|
14
|
+
end
|
17
15
|
end
|
18
16
|
|
19
17
|
module Utils
|
20
18
|
class << self
|
19
|
+
def in_rails?
|
20
|
+
defined?(Rails)
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_config_path
|
24
|
+
if in_rails?
|
25
|
+
File.expand_path(File.join(Rails.root, 'config', 'jslint.yml'))
|
26
|
+
else
|
27
|
+
'config/jslint.yml'
|
28
|
+
end
|
29
|
+
end
|
21
30
|
|
22
|
-
def
|
31
|
+
def display(txt)
|
23
32
|
print txt
|
24
33
|
end
|
25
34
|
|
26
|
-
def
|
35
|
+
def log(txt)
|
27
36
|
puts txt
|
28
37
|
end
|
29
38
|
|
@@ -55,14 +64,13 @@ module JSLint
|
|
55
64
|
end
|
56
65
|
|
57
66
|
def copy_config_file
|
58
|
-
|
59
|
-
xprint "Creating example JSLint config file in #{File.expand_path(JSLint.config_path)}... "
|
67
|
+
display "Creating example JSLint config file in #{File.expand_path(JSLint.config_path)}... "
|
60
68
|
if File.exists?(JSLint.config_path)
|
61
|
-
|
62
|
-
|
69
|
+
log "\n\nWarning: config file exists, so it won't be overwritten. " +
|
70
|
+
"You can copy it manually from the jslint_on_rails directory if you want to reset it."
|
63
71
|
else
|
64
72
|
FileUtils.copy(JSLint::DEFAULT_CONFIG_FILE, JSLint.config_path)
|
65
|
-
|
73
|
+
log "done."
|
66
74
|
end
|
67
75
|
end
|
68
76
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,23 +2,7 @@ require 'jslint'
|
|
2
2
|
require 'pp' # fix for fakefs/pp incompatibility in Ruby 1.9.3
|
3
3
|
require 'fakefs'
|
4
4
|
|
5
|
-
module JSLint::Utils
|
6
|
-
# disable logging to stdout
|
7
|
-
def self.xprint(x) ; end
|
8
|
-
def self.xputs(x) ; end
|
9
|
-
end
|
10
|
-
|
11
5
|
module Rails
|
12
|
-
class Railtie
|
13
|
-
def self.rake_tasks
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module FileUtils
|
19
|
-
def copy(*args)
|
20
|
-
cp(*args)
|
21
|
-
end
|
22
6
|
end
|
23
7
|
|
24
8
|
module FakeFS
|
@@ -42,4 +26,10 @@ end
|
|
42
26
|
|
43
27
|
RSpec.configure do |config|
|
44
28
|
config.include SpecHelper
|
29
|
+
|
30
|
+
config.before do
|
31
|
+
# disable logging to stdout
|
32
|
+
JSLint::Utils.stub(:display)
|
33
|
+
JSLint::Utils.stub(:log)
|
34
|
+
end
|
45
35
|
end
|
data/spec/utils_spec.rb
CHANGED
@@ -8,9 +8,41 @@ describe JSLint::Utils do
|
|
8
8
|
create_config "default config file"
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
describe ".config_path" do
|
12
|
+
context "if config path is set explicitly" do
|
13
|
+
let(:path) { 'some/path' }
|
14
|
+
|
15
|
+
before { JSLint.config_path = path }
|
16
|
+
|
17
|
+
it "should return the path that was set" do
|
18
|
+
JSLint.config_path.should == path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "if config path is not set" do
|
23
|
+
before { JSLint.config_path = nil }
|
24
|
+
|
25
|
+
context "if JSLint is run within Rails" do
|
26
|
+
before do
|
27
|
+
JSLint::Utils.stub(:in_rails? => true)
|
28
|
+
Rails.stub(:root => '/dir')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return config/jslint.yml in Rails project directory" do
|
32
|
+
JSLint.config_path.should == '/dir/config/jslint.yml'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "if JSLint is not run within Rails" do
|
37
|
+
before do
|
38
|
+
JSLint::Utils.stub(:in_rails? => false)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return config/jslint.yml in current directory" do
|
42
|
+
JSLint.config_path.should == 'config/jslint.yml'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
14
46
|
end
|
15
47
|
|
16
48
|
describe "paths_from_command_line" do
|
@@ -90,11 +122,6 @@ describe JSLint::Utils do
|
|
90
122
|
end
|
91
123
|
|
92
124
|
describe "copy_config_file" do
|
93
|
-
it "throw an error if config path isn't set" do
|
94
|
-
JSLint.config_path = nil
|
95
|
-
lambda { JSLint::Utils.copy_config_file }.should raise_error(ArgumentError)
|
96
|
-
end
|
97
|
-
|
98
125
|
it "should copy default config to config_path" do
|
99
126
|
JSLint.config_path = "newfile.yml"
|
100
127
|
FileUtils.should_receive(:copy).with(JSLint::DEFAULT_CONFIG_FILE, "newfile.yml")
|
metadata
CHANGED
@@ -1,22 +1,32 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jslint_on_rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Jakub Suder
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-04-16 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description:
|
15
22
|
email: jakub.suder@gmail.com
|
16
23
|
executables: []
|
24
|
+
|
17
25
|
extensions: []
|
26
|
+
|
18
27
|
extra_rdoc_files: []
|
19
|
-
|
28
|
+
|
29
|
+
files:
|
20
30
|
- MIT-LICENSE
|
21
31
|
- README.markdown
|
22
32
|
- Changelog.markdown
|
@@ -40,27 +50,36 @@ files:
|
|
40
50
|
- spec/utils_spec.rb
|
41
51
|
homepage: http://github.com/psionides/jslint_on_rails
|
42
52
|
licenses: []
|
53
|
+
|
43
54
|
post_install_message:
|
44
55
|
rdoc_options: []
|
45
|
-
|
56
|
+
|
57
|
+
require_paths:
|
46
58
|
- lib
|
47
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
60
|
none: false
|
49
|
-
requirements:
|
50
|
-
- -
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
|
53
|
-
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
69
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements:
|
60
78
|
- Java JRE (5.0 or later)
|
61
79
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.8.
|
80
|
+
rubygems_version: 1.8.18
|
63
81
|
signing_key:
|
64
82
|
specification_version: 3
|
65
83
|
summary: JSLint JavaScript checker wrapped in a Ruby gem for easier use
|
66
84
|
test_files: []
|
85
|
+
|