Class: Guard::Konacha::Runner
- Inherits:
-
Object
- Object
- Guard::Konacha::Runner
- Defined in:
- lib/guard/konacha/runner.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :bundler => true, :spec_dir => 'spec/javascripts', :run_all => true, :notification => true }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #kill_konacha ⇒ Object
- #launch_konacha(action) ⇒ Object
- #run(paths = []) ⇒ Object
- #run_all ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
16 17 18 19 |
# File 'lib/guard/konacha/runner.rb', line 16 def initialize(={}) @options = DEFAULT_OPTIONS.merge() UI.info "Guard::Konacha Initialized" end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/guard/konacha/runner.rb', line 14 def @options end |
Instance Method Details
#kill_konacha ⇒ Object
26 27 28 29 30 31 |
# File 'lib/guard/konacha/runner.rb', line 26 def kill_konacha if @process @process.stop(5) UI.info "Konacha Stopped", :reset => true end end |
#launch_konacha(action) ⇒ Object
21 22 23 24 |
# File 'lib/guard/konacha/runner.rb', line 21 def launch_konacha(action) UI.info "#{action}ing Konacha", :reset => true spawn_konacha end |
#run(paths = []) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/guard/konacha/runner.rb', line 33 def run(paths=[]) UI.info "Konacha Running: #{paths.join(' ')}" result = run_command(konacha_command(paths)) if @options[:notification] last_line = result.split("\n").last examples, failures = last_line.scan(/\d+/).map { |s| s.to_i } image = failures > 0 ? :failed : :success ::Guard::Notifier.notify(last_line, :title => 'Konacha Specs', :image => image ) end end |
#run_all ⇒ Object
45 46 47 48 |
# File 'lib/guard/konacha/runner.rb', line 45 def run_all return unless @options[:run_all] run end |