Class: Guard::Gotest::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/gotest/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
10
11
12
# File 'lib/guard/gotest/runner.rb', line 6

def initialize(options = {})
  @options = {
    :env          => nil,
    :notification => true,
    :sleep_time   => 1
  }.merge(options)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/guard/gotest/runner.rb', line 4

def options
  @options
end

Instance Method Details

#run(paths, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/guard/gotest/runner.rb', line 14

def run(paths, options = {})
  return false if paths.empty?

  message = options[:message] || "Running: #{paths.join(' ')}"
  UI.info(message, :reset => true)

  options = @options.merge(options)
  success = system(gotest_command(paths, options))

  if @options[:notification] && !success
    Notifier.notify('Failed', :title => 'Gotest results', :image => :failed, :priority => 2)
  end

  success
end

#stopObject



30
31
32
33
34
35
36
37
# File 'lib/guard/gotest/runner.rb', line 30

def stop
  ps_go_pid.each do |pid|
    system %{kill -KILL #{pid}}
  end
  while ps_go_pid.count > 0
    sleep @options[:sleep_time].to_f || 1
  end
end