Class: RSpactor::Interactor

Inherits:
Object
  • Object
show all
Defined in:
lib/rspactor/interactor.rb

Instance Method Summary collapse

Constructor Details

#initializeInteractor

Returns a new instance of Interactor.



5
6
7
# File 'lib/rspactor/interactor.rb', line 5

def initialize
  ticker
end

Instance Method Details

#start_termination_handlerObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rspactor/interactor.rb', line 23

def start_termination_handler
  @main_thread = Thread.current
  Thread.new do
    loop do
      sleep 0.5
      if $stdin.gets
        if wait_for_enter_key("** Running all specs.. Hit <enter> again to exit RSpactor", 3)
          @main_thread.exit
          exit
        end
        Runner.run_all_specs
      end
    end
  end
end

#wait_for_enter_key(msg, seconds_to_wait) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rspactor/interactor.rb', line 9

def wait_for_enter_key(msg, seconds_to_wait)
  begin
    Timeout::timeout(seconds_to_wait) do
      ticker(:start => true, :msg => msg)
      $stdin.gets
      return true
    end
  rescue Timeout::Error
    false
  ensure
    ticker(:stop => true)
  end
end