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 |
# File 'lib/guard/bacon.rb', line 12 def initialize(watchers= [], = {}) 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
80 81 82 83 |
# File 'lib/guard/bacon.rb', line 80 def file_changed(path) run_spec(path) puts "" end |
#reload ⇒ Object
Called on Ctrl-Z signal
36 37 38 |
# File 'lib/guard/bacon.rb', line 36 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/…
42 43 44 45 46 47 48 |
# File 'lib/guard/bacon.rb', line 42 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
86 87 88 89 90 |
# File 'lib/guard/bacon.rb', line 86 def run_on_changes(paths) paths.each do |path| file_changed(path) end end |
#run_spec(path) ⇒ Object
50 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 |
# File 'lib/guard/bacon.rb', line 50 def run_spec(path) if File.exists?(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
25 26 27 28 |
# File 'lib/guard/bacon.rb', line 25 def start puts "Guard::Bacon started." true end |
#stop ⇒ Object
Called on Ctrl-C signal (when Guard quits)
31 32 33 |
# File 'lib/guard/bacon.rb', line 31 def stop true end |