Class: Guard::Spork::Runner

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/guard/spork/runner.rb', line 9

def initialize(options={})
  options[:wait]           ||= 30 # seconds
  options[:retry_delay]    ||= 2 * options[:wait] # seconds
  options[:test_unit_port] ||= 8988
  options[:cucumber_port]  ||= 8990
  options[:rspec_port]     ||= 8989
  options[:minitest_port]  ||= 8988
  options[:rspec_env]      ||= {}
  options[:test_unit_env]  ||= {}
  options[:cucumber_env]   ||= {}
  options[:minitest_env]   ||= {}
  options[:minitest]       ||= false
  options[:aggressive_kill]  = true unless options[:aggressive_kill] == false
  options[:foreman]        ||= false
  options[:quiet]          ||= false
  @options  = options
  initialize_spork_instances
end

Instance Attribute Details

#options ⇒ Object

Returns the value of attribute options.



6
7
8
# File 'lib/guard/spork/runner.rb', line 6

def options
  @options
end

#spork_instances ⇒ Object (readonly)

Returns the value of attribute spork_instances.



7
8
9
# File 'lib/guard/spork/runner.rb', line 7

def spork_instances
  @spork_instances
end

Class Method Details

.windows? ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/guard/spork/runner.rb', line 50

def self.windows?
  ENV['OS'] == 'Windows_NT'
end

Instance Method Details

#kill_global_sporks ⇒ Object



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

def kill_global_sporks
  if options[:aggressive_kill]
    kill_pids self.class.spork_instance_class.spork_pids
  end
end

#kill_sporks(type = nil) ⇒ Object



38
39
40
41
42
# File 'lib/guard/spork/runner.rb', line 38

def kill_sporks(type = nil)
  alive = find_instances(type).select(&:alive?)
  Compat::UI.debug "Killing Spork servers with PID: #{alive.map(&:pid).join(', ')}"
  alive.each(&:stop)
end

#launch_sporks(action, type = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/guard/spork/runner.rb', line 28

def launch_sporks(action, type = nil)
  instances = find_instances(type)
  Compat::UI.info "#{action.capitalize}ing Spork for #{instances.join(', ')}", :reset => true
  if options[:notify_on_start]
    Notifier.notify "#{action.capitalize}ing #{instances.join(', ')}", :title => "Spork", :image => :success
  end
  instances.each(&:start)
  verify_launches(action, instances)
end