guard-coffeelint 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/guard-coffeelint.gemspec +2 -2
- data/lib/guard/coffeelint.rb +58 -39
- data/lib/guard/coffeelint/version.rb +1 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41e5b08c576ce32fa08bc7823921d5635341b06
|
4
|
+
data.tar.gz: 0e233d3b4146f6c3473a9e8d3e663c41ead44a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489610cdb138a55f65303c08027ebdec02a07955899b3b2d8b7964e3fa3659f47c0f88c57936310c082775a069b2531514990a887e32f690533a16cbd69118e6
|
7
|
+
data.tar.gz: 62e2bd453ac6f61440af1a2226a7320099eeb5a0d89c6baa73b9961ecfeb19928df20106411699180a18ccf5a48a34ae7464dc4ce8267140c316596907e6c00b
|
data/guard-coffeelint.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'guard', '~> 2.
|
22
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'guard', '~> 2.0'
|
22
|
+
spec.add_dependency 'colorize'
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake"
|
data/lib/guard/coffeelint.rb
CHANGED
@@ -1,77 +1,96 @@
|
|
1
|
-
|
2
1
|
require 'guard'
|
3
2
|
require 'guard/plugin'
|
4
|
-
require '
|
3
|
+
require 'JSON'
|
4
|
+
require 'colorize'
|
5
5
|
|
6
6
|
module Guard
|
7
7
|
class Coffeelint < Plugin
|
8
8
|
|
9
9
|
def initialize(options = {})
|
10
10
|
super
|
11
|
-
@config_file = options[:config_file]
|
11
|
+
@config_file = options[:config_file]
|
12
12
|
end
|
13
13
|
|
14
14
|
def start
|
15
15
|
UI.info "Guard::Coffeelint linting against #{@config_file}"
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# @return [Object] the task result
|
22
|
-
#
|
23
|
-
def run_on_changes(paths)
|
24
|
-
# Total errors across all files
|
25
|
-
error_count = 0
|
26
|
-
|
27
|
-
paths.each do |path|
|
28
|
-
errors = lint_and_report(path)
|
29
|
-
|
30
|
-
error_count += errors.length
|
31
|
-
end
|
32
|
-
|
33
|
-
notify(paths, error_count)
|
18
|
+
def run_on_additions(paths)
|
19
|
+
lint_and_report paths
|
20
|
+
end
|
34
21
|
|
35
|
-
|
22
|
+
def run_on_modifications(paths)
|
23
|
+
lint_and_report paths
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_all
|
27
|
+
lint_and_report
|
36
28
|
end
|
37
29
|
|
38
30
|
protected
|
39
31
|
|
40
|
-
def notify(
|
41
|
-
|
42
|
-
"#{error_count} errors in #{paths[0]}"
|
43
|
-
else
|
44
|
-
"#{error_count} errors in #{paths.length} files"
|
45
|
-
end
|
46
|
-
|
32
|
+
def notify(file_count, error_count)
|
33
|
+
msg = summary file_count, error_count
|
47
34
|
image = if error_count > 0
|
48
35
|
:failed
|
49
36
|
else
|
50
37
|
:success
|
51
38
|
end
|
52
|
-
|
53
|
-
Notifier.notify(message, title: "Coffeelint", image: image)
|
39
|
+
Notifier.notify(msg, title: "CoffeeLint", image: image)
|
54
40
|
end
|
55
41
|
|
56
42
|
|
57
|
-
def lint_and_report(
|
58
|
-
|
59
|
-
|
43
|
+
def lint_and_report(paths = nil)
|
44
|
+
command = 'coffeelint -c --reporter raw'
|
45
|
+
command += "-f #{@config_file}" if @config_file
|
46
|
+
command += if paths && paths.length > 0
|
47
|
+
" #{paths.join ' '}"
|
48
|
+
else
|
49
|
+
' .'
|
50
|
+
end
|
60
51
|
|
61
|
-
|
62
|
-
errors = JSON.parse(`coffeelint --reporter raw -f #{@config_file} #{path}`).values.first
|
52
|
+
results = `#{command} 2>&1`
|
63
53
|
|
64
|
-
|
65
|
-
|
54
|
+
begin
|
55
|
+
results = JSON.parse(results)
|
56
|
+
rescue JSON::ParserError
|
57
|
+
UI.error "Error linting #{paths}"
|
58
|
+
return
|
59
|
+
end
|
66
60
|
|
61
|
+
results.each do |file, errors|
|
67
62
|
errors.each do |error|
|
68
|
-
|
63
|
+
error_letter = error['level'].chars.first.upcase
|
64
|
+
error_letter = case error_letter
|
65
|
+
when 'E' then error_letter.red
|
66
|
+
when 'W' then error_letter.yellow
|
67
|
+
else error_letter
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "#{file.cyan}:#{error['lineNumber']}:#{error_letter}" \
|
71
|
+
": #{error['name']}: #{error['message']}. #{error['context']}"
|
69
72
|
end
|
70
|
-
|
71
73
|
end
|
72
74
|
|
73
|
-
|
75
|
+
file_count = results.size
|
76
|
+
error_count = results.map { |_, e| e.size }.reduce(:+)
|
77
|
+
puts "\n" + summary(file_count, error_count, color: true)
|
78
|
+
|
79
|
+
notify file_count, error_count
|
80
|
+
|
81
|
+
throw :task_has_failed unless error_count == 0
|
74
82
|
end
|
75
83
|
|
84
|
+
def summary(file_count, error_count, color: false)
|
85
|
+
summary = "#{file_count} files scanned, "
|
86
|
+
summary << if error_count > 0
|
87
|
+
s = "#{error_count} errors"
|
88
|
+
color ? s.red : s
|
89
|
+
else
|
90
|
+
s = "No errors"
|
91
|
+
color ? s.green : s
|
92
|
+
end
|
93
|
+
summary << " found."
|
94
|
+
end
|
76
95
|
end
|
77
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-coffeelint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Eagar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: colorize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.4.5
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Guard plugin for Coffeelint
|
109
109
|
test_files: []
|
110
|
-
has_rdoc:
|