Class: Guard::Cane
- Inherits:
-
Plugin
- Object
- Plugin
- Guard::Cane
- Defined in:
- lib/guard/cane.rb
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(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.
13 14 15 |
# File 'lib/guard/cane.rb', line 13 def last_result @last_result end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/guard/cane.rb', line 13 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) Compat::UI.info "Running Cane: #{command}" result = system command if result Compat::UI.notify(*SUCCESS) if last_result == false else Compat::UI.notify(*FAILED) end @last_result = result result end |
#run_all ⇒ Object
27 28 29 |
# File 'lib/guard/cane.rb', line 27 def run_all cane end |
#run_on_modifications(paths) ⇒ Object
31 32 33 34 |
# File 'lib/guard/cane.rb', line 31 def run_on_modifications(paths) passed = cane paths run_all if [:all_after_pass] && passed end |
#start ⇒ Object
21 22 23 24 25 |
# File 'lib/guard/cane.rb', line 21 def start Compat::UI.info "Guard::Cane is running" run_all if [:run_all_on_start] end |