Class: Guard::Spring::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



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

def initialize(options = {})
  @options = options
  @spring_cmd = get_spring_cmd
  UI.info 'Guard::Spring Initialized'
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#kill_springObject



19
20
21
# File 'lib/guard/spring/runner.rb', line 19

def kill_spring
  stop_spring
end

#launch_spring(action) ⇒ Object



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

def launch_spring(action)
  UI.info "#{action}ing Spring", :reset => true
  start_spring
end

#run(paths) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/guard/spring/runner.rb', line 23

def run(paths)
  existing_paths = paths.uniq.select { |path| File.exist? "#{Dir.pwd}/#{path}" }
  rspec_paths = existing_paths.select { |path| path =~ /spec(\/\w+)*(\/\w+_spec\.rb)?/ }
  run_command "#@spring_cmd rspec", existing_paths.join(' ') unless rspec_paths.empty?

  # TBD: # testunit_paths = existing_paths.select { |path| path =~ /test(.*\.rb)?/ }
  # TBD: # run_command 'spring testunit', existing_paths.join(' ') unless testunit_paths.empty?
end

#run_allObject



32
33
34
35
36
37
38
# File 'lib/guard/spring/runner.rb', line 32

def run_all
  if rspec?
    run(%w(spec))
  elsif test_unit?
    run(Dir['test/**/*_test.rb']+Dir['test/**/test_*.rb'])
  end
end