Class: Guard::Motion
- Defined in:
- lib/guard/motion.rb,
lib/guard/motion/runner.rb,
lib/guard/motion/inspector.rb,
lib/guard/motion/results_parser.rb
Defined Under Namespace
Classes: Inspector, ResultsParser, Runner
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Motion
constructor
Initialize a Guard.
-
#reload ⇒ Object
Called when ‘reload|r|z + enter` is pressed.
-
#run_all ⇒ Object
Called when just ‘enter` is pressed This method should be principally used for long action like running all specs/tests/…
-
#run_on_changes(paths) ⇒ Object
Called on file(s) modifications that the Guard watches.
-
#start ⇒ Object
Call once when Guard starts.
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Motion
Initialize a Guard.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/guard/motion.rb', line 15 def initialize(watchers = [], = {}) super = { :all_after_pass => true, :all_on_start => true, :keep_failed => true, :spec_paths => ["spec"] }.merge() @last_failed = false @failed_paths = [] @runner = Runner.new() @inspector = Inspector.new() end |
Instance Method Details
#reload ⇒ Object
Called when ‘reload|r|z + enter` is pressed. This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/…
40 41 42 |
# File 'lib/guard/motion.rb', line 40 def reload @failed_paths = [] end |
#run_all ⇒ Object
Called when just ‘enter` is pressed This method should be principally used for long action like running all specs/tests/…
47 48 49 50 51 52 53 54 55 |
# File 'lib/guard/motion.rb', line 47 def run_all passed = @runner.run unless @last_failed = !passed @failed_paths = [] else throw :task_has_failed end end |
#run_on_changes(paths) ⇒ Object
Called on file(s) modifications that the Guard watches.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/guard/motion.rb', line 60 def run_on_changes(paths) paths += @failed_paths if [:keep_failed] paths = @inspector.clean(paths).uniq if passed = @runner.run(paths) remove_failed(paths) # run all the specs if the run before this one failed if @last_failed && [:all_after_pass] @last_failed = false run_all end else @last_failed = true add_failed(paths) throw :task_has_failed end end |
#start ⇒ Object
Call once when Guard starts. Please override initialize method to init stuff.
32 33 34 35 |
# File 'lib/guard/motion.rb', line 32 def start UI.info "Guard::Motion is running" run_all if [:all_on_start] end |