Class: Guard::Reek
Overview
Guard::Reek class, it implements an guard for reek task
Constant Summary collapse
- SUCCESS =
["Passed", { title: "Passed", image: :success }]
- FAILED =
["Failed", { title: "Failed", image: :failed }]
Instance Attribute Summary collapse
-
#last_result ⇒ Object
readonly
Returns the value of attribute last_result.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Reek
constructor
A new instance of Reek.
- #run_all ⇒ Object
- #run_on_changes(path) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Reek
Returns a new instance of Reek.
12 13 14 15 16 17 18 19 |
# File 'lib/guard/reek.rb', line 12 def initialize(watchers = [], = {}) super = @files = Dir["**/*"] @files.select! do |file| watchers.reduce(false) { |res, watcher| res || watcher.match(file) } end end |
Instance Attribute Details
#last_result ⇒ Object (readonly)
Returns the value of attribute last_result.
10 11 12 |
# File 'lib/guard/reek.rb', line 10 def last_result @last_result end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/guard/reek.rb', line 10 def end |
Class Method Details
.command(paths) ⇒ Object
44 45 46 |
# File 'lib/guard/reek.rb', line 44 def self.command paths "reek -n #{paths.uniq.join(' ')}" end |
.notify(result) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/guard/reek.rb', line 48 def self.notify result if result Notifier.notify(*SUCCESS) else Notifier.notify(*FAILED) end end |
.reek(paths) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/guard/reek.rb', line 36 def self.reek(paths) result = system command(paths) notify(result) @last_result = result result end |
Instance Method Details
#run_all ⇒ Object
26 27 28 29 |
# File 'lib/guard/reek.rb', line 26 def run_all UI.info('Guard::Reek is running on all files') self.class.reek @files end |
#run_on_changes(path) ⇒ Object
31 32 33 34 |
# File 'lib/guard/reek.rb', line 31 def run_on_changes path UI.info("Guard::Reek is running on #{path.to_s}") self.class.reek path end |
#start ⇒ Object
21 22 23 24 |
# File 'lib/guard/reek.rb', line 21 def start UI.info('Guard::Reek is starting') run_all end |