Class: Guard::Konacha::Runner

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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={})
  @options = DEFAULT_OPTIONS.merge(options)
  UI.info "Guard::Konacha Initialized"
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/guard/konacha/runner.rb', line 14

def options
  @options
end

Instance Method Details

#kill_konachaObject



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_allObject



45
46
47
48
# File 'lib/guard/konacha/runner.rb', line 45

def run_all
  return unless @options[:run_all]
  run
end