Class: Guard::Bacon
Constant Summary
Constants included from Guard
Instance Method Summary collapse
- #file_changed(path) ⇒ Object
-
#initialize(watchers = [], options = {}) ⇒ Bacon
constructor
A new instance of Bacon.
-
#reload ⇒ Object
Called on Ctrl-Z signal.
-
#run_all ⇒ Object
Called on Ctrl-\ signal This method should be principally used for long action like running all specs/tests/…
-
#run_on_changes(paths) ⇒ Object
Called on file(s) modifications.
- #run_spec(path) ⇒ Object
- #start ⇒ Object
-
#stop ⇒ Object
Called on Ctrl-C signal (when Guard quits).
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Bacon
Returns a new instance of Bacon.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/guard/bacon.rb', line 12 def initialize(watchers= [], = {}) @last_run_spec = nil super if [:output] puts "Bacon: Using output #{[:output]}." ::Bacon.extend(::Bacon::const_get([:output])) end if [:backtrace] puts "Bacon: Limiting backtrace to #{[:backtrace]} lines." ::Bacon.backtrace_size = [:backtrace] end end |
Instance Method Details
#file_changed(path) ⇒ Object
88 89 90 91 |
# File 'lib/guard/bacon.rb', line 88 def file_changed(path) run_spec(path) puts "" end |
#reload ⇒ Object
Called on Ctrl-Z signal
37 38 39 |
# File 'lib/guard/bacon.rb', line 37 def reload true end |
#run_all ⇒ Object
Called on Ctrl-\ signal This method should be principally used for long action like running all specs/tests/…
43 44 45 46 47 48 49 |
# File 'lib/guard/bacon.rb', line 43 def run_all Dir["specs/**/*_spec.rb"].each do |path| run_spec(path) end true end |
#run_on_changes(paths) ⇒ Object
Called on file(s) modifications
94 95 96 97 98 |
# File 'lib/guard/bacon.rb', line 94 def run_on_changes(paths) paths.each do |path| file_changed(path) end end |
#run_spec(path) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/guard/bacon.rb', line 51 def run_spec(path) if !File.exists?(path) && @last_run_spec puts "spec not found: #{path}" puts "running last one." path = @last_run_spec end if File.exists?(path) @last_run_spec = path pid = Kernel.fork do puts "\n●●➤ Running spec: #{path}" counters = ::Bacon.run_file(path) # system "bundle exec bacon -o TestUnit #{path}" # {:installed_summary=>1, :specifications=>19, :depth=>0, :requirements=>30, :failed=>2, :errors => 1} all_specs = counters[:specifications] failed = counters[:failed].to_i + counters[:errors].to_i if failed > 0 Notifier.notify("Specs: #{failed} Failures (#{all_specs} specs)", :image => :failed, :title => File.basename(path) ) else Notifier.notify("Specs: OK (#{all_specs} specs)", :image => :success, :title => File.basename(path) ) end end Process.wait(pid) else puts "spec not found: #{path}" end end |
#start ⇒ Object
26 27 28 29 |
# File 'lib/guard/bacon.rb', line 26 def start puts "Guard::Bacon started." true end |
#stop ⇒ Object
Called on Ctrl-C signal (when Guard quits)
32 33 34 |
# File 'lib/guard/bacon.rb', line 32 def stop true end |