Class: Guard::Cane
Overview
Defines the guard, which is automatically seen by Guard
Constant Summary collapse
- DEFAULTS =
{ run_all_on_start: true }
- SUCCESS =
["Passed", { title: "Cane", image: :success }]
- FAILED =
["Failed", { title: "Cane", 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.
Instance Method Summary collapse
- #build_command(paths) ⇒ Object
- #cane(paths = []) ⇒ Object
-
#initialize(watchers = [], options = {}) ⇒ Cane
constructor
A new instance of Cane.
- #run_all ⇒ Object
- #run_on_modifications(paths) ⇒ Object
- #start ⇒ Object
Constructor Details
Instance Attribute Details
#last_result ⇒ Object (readonly)
Returns the value of attribute last_result.
14 15 16 |
# File 'lib/guard/cane.rb', line 14 def last_result @last_result end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/guard/cane.rb', line 14 def @options end |
Instance Method Details
#build_command(paths) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/guard/cane.rb', line 54 def build_command(paths) command = [] command << ([:command] || "cane") if paths.any? joined_paths = paths.join(',') command << "--all '{#{joined_paths}}'" end command << [:cli] command.compact.join(" ") end |
#cane(paths = []) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/guard/cane.rb', line 36 def cane(paths = []) command = build_command(paths) UI.info "Running Cane: #{command}" result = system command if result Notifier.notify(*SUCCESS) if last_result == false else Notifier.notify(*FAILED) end @last_result = result result end |
#run_all ⇒ Object
28 29 30 |
# File 'lib/guard/cane.rb', line 28 def run_all cane end |
#run_on_modifications(paths) ⇒ Object
32 33 34 |
# File 'lib/guard/cane.rb', line 32 def run_on_modifications(paths) cane paths end |
#start ⇒ Object
22 23 24 25 26 |
# File 'lib/guard/cane.rb', line 22 def start UI.info "Guard::Cane is running" run_all if [:run_all_on_start] end |