guard-brakeman 0.1.7 → 0.1.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.
- data/README.md +3 -2
- data/lib/guard/brakeman.rb +25 -16
- metadata +4 -4
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Guard::Brakeman [](http://travis-ci.org/oreoshake/guard-brakeman)
|
2
2
|
|
3
|
-
Guard::Brakeman allows you to automatically run Brakeman tests when files are modified.
|
3
|
+
Guard::Brakeman allows you to automatically run [Brakeman](http://brakemanscanner.org/) tests when files are modified.
|
4
4
|
|
5
5
|
|
6
6
|
## Install
|
@@ -46,7 +46,8 @@ Please read the [Guard documentation](http://github.com/guard/guard#readme) for
|
|
46
46
|
### List of available options
|
47
47
|
|
48
48
|
```ruby
|
49
|
-
|
49
|
+
:notifications => false # display Growl notifications, defaults to true
|
50
|
+
:run_on_start => true # run all checks on startup, defaults to false
|
50
51
|
```
|
51
52
|
|
52
53
|
## Brakeman configuration
|
data/lib/guard/brakeman.rb
CHANGED
@@ -12,7 +12,8 @@ module Guard
|
|
12
12
|
def initialize(watchers = [], options = { })
|
13
13
|
super
|
14
14
|
@options = {
|
15
|
-
:notifications => true
|
15
|
+
:notifications => true,
|
16
|
+
:run_on_start => false
|
16
17
|
}.update(options)
|
17
18
|
end
|
18
19
|
|
@@ -21,9 +22,11 @@ module Guard
|
|
21
22
|
# @raise [:task_has_failed] when stop has failed
|
22
23
|
#
|
23
24
|
def start
|
24
|
-
|
25
|
-
@scanner = ::Brakeman::Scanner.new(
|
25
|
+
scanner_opts = ::Brakeman::set_options(:app_path => '.')
|
26
|
+
@scanner = ::Brakeman::Scanner.new(scanner_opts)
|
26
27
|
@tracker = @scanner.process
|
28
|
+
|
29
|
+
run_all if @options[:run_on_start]
|
27
30
|
end
|
28
31
|
|
29
32
|
# Gets called when all checks should be run.
|
@@ -31,7 +34,7 @@ module Guard
|
|
31
34
|
# @raise [:task_has_failed] when stop has failed
|
32
35
|
#
|
33
36
|
def run_all
|
34
|
-
|
37
|
+
UI.info 'running all'
|
35
38
|
@tracker.run_checks
|
36
39
|
print_failed(@tracker.checks)
|
37
40
|
throw :task_has_failed if @tracker.checks.all_warnings.any?
|
@@ -45,7 +48,7 @@ module Guard
|
|
45
48
|
def run_on_change(paths)
|
46
49
|
return run_all unless @tracker.checks
|
47
50
|
|
48
|
-
|
51
|
+
UI.info "rescanning #{paths}, running all checks"
|
49
52
|
report = ::Brakeman::rescan(@tracker, paths)
|
50
53
|
print_changed(report)
|
51
54
|
throw :task_has_failed if report.any_warnings?
|
@@ -54,37 +57,43 @@ module Guard
|
|
54
57
|
private
|
55
58
|
|
56
59
|
def print_failed report
|
57
|
-
UI.
|
60
|
+
UI.info "\n------ brakeman warnings --------\n"
|
58
61
|
|
59
|
-
|
62
|
+
icon = report.all_warnings.count > 0 ? :success : :pending
|
63
|
+
|
64
|
+
Notifier.notify("#{report.all_warnings.count} brakeman findings", :title => "Brakeman results", :image => icon) if @options[:notifications]
|
60
65
|
puts report.all_warnings.sort_by { |w| w.confidence }
|
61
66
|
end
|
62
67
|
|
63
68
|
def print_changed report
|
64
69
|
UI.info "\n------ brakeman warnings --------\n"
|
70
|
+
|
71
|
+
message = ""
|
65
72
|
|
66
73
|
unless report.fixed_warnings.empty?
|
67
|
-
message
|
68
|
-
|
69
|
-
UI.info(message
|
74
|
+
message += "#{report.fixed_warnings.length} fixed warning(s)\n"
|
75
|
+
icon = :success
|
76
|
+
UI.info(UI.send(:color, message, 'green')) # janky
|
70
77
|
puts report.fixed_warnings.sort_by { |w| w.confidence }
|
71
78
|
puts
|
72
79
|
end
|
73
80
|
|
74
81
|
unless report.new_warnings.empty?
|
75
|
-
message
|
76
|
-
|
77
|
-
UI.
|
82
|
+
message += "#{report.new_warnings.length} new warning(s)\n"
|
83
|
+
icon = :failed
|
84
|
+
UI.error message
|
78
85
|
puts report.new_warnings.sort_by { |w| w.confidence }
|
79
86
|
puts
|
80
87
|
end
|
81
88
|
|
82
89
|
unless report.existing_warnings.empty?
|
83
|
-
|
84
|
-
|
85
|
-
UI.warning message
|
90
|
+
icon ||= :pending
|
91
|
+
message += "#{report.existing_warnings.length} previous warning(s)\n"
|
92
|
+
UI.warning message
|
86
93
|
puts report.existing_warnings.sort_by { |w| w.confidence }
|
87
94
|
end
|
95
|
+
|
96
|
+
Notifier.notify(message.chomp, :title => "Brakeman results", :image => icon) if @options[:notifications]
|
88
97
|
end
|
89
98
|
end
|
90
99
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-brakeman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Neil Matatall
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01
|
18
|
+
date: 2012-02-01 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|