rspactor 0.0.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,21 @@ require 'timeout'
2
2
 
3
3
  class Interactor
4
4
 
5
- def wait_for_enter_key(seconds_to_wait)
5
+ def initialize
6
+ ticker
7
+ end
8
+
9
+ def wait_for_enter_key(msg, seconds_to_wait)
6
10
  begin
7
11
  Timeout::timeout(seconds_to_wait) do
8
- loop do
9
- sleep 0.2
10
- return true if $stdin.gets
11
- end
12
+ ticker(:start => true, :msg => msg)
13
+ $stdin.gets
14
+ return true
12
15
  end
13
16
  rescue Timeout::Error
14
17
  false
18
+ ensure
19
+ ticker(:stop => true)
15
20
  end
16
21
  end
17
22
 
@@ -21,8 +26,7 @@ class Interactor
21
26
  loop do
22
27
  sleep 0.5
23
28
  if $stdin.gets
24
- puts "** Running all specs.. Hit <enter> twice to exit RSpactor."
25
- if wait_for_enter_key(1)
29
+ if wait_for_enter_key("** Running all specs.. Hit <enter> again to exit RSpactor", 3)
26
30
  @main_thread.exit
27
31
  exit
28
32
  end
@@ -31,4 +35,29 @@ class Interactor
31
35
  end
32
36
  end
33
37
  end
38
+
39
+
40
+ private
41
+
42
+ def ticker(opts = {})
43
+ if opts[:stop]
44
+ $stdout.puts "\n"
45
+ @pointer_running = false
46
+ elsif opts[:start]
47
+ @pointer_running = true
48
+ write(opts[:msg]) if opts[:msg]
49
+ else
50
+ Thread.new do
51
+ loop do
52
+ write('.') if @pointer_running == true
53
+ sleep 1.0
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ def write(msg)
60
+ $stdout.print(msg)
61
+ $stdout.flush
62
+ end
34
63
  end
@@ -41,7 +41,7 @@ class RSpactorFormatter
41
41
  end
42
42
 
43
43
  def growl(title, msg, img, pri = 0)
44
- %x(growlnotify -w -n rspactor --image #{img} -p #{pri} -m #{msg.inspect} #{title})
44
+ system("growlnotify -w -n rspactor --image #{img} -p #{pri} -m #{msg.inspect} #{title} &")
45
45
  end
46
46
  end
47
47
 
@@ -4,11 +4,15 @@ class Runner
4
4
  @inspector = Inspector.new
5
5
  @interactor = Interactor.new
6
6
 
7
- puts ">> RSpactor is now watching at '#{Dir.pwd}'"
7
+ puts "** RSpactor is now watching at '#{Dir.pwd}'"
8
8
 
9
- run_all_specs unless initial_spec_run_abort
9
+ if initial_spec_run_abort
10
+ @interactor.start_termination_handler
11
+ else
12
+ @interactor.start_termination_handler
13
+ run_all_specs
14
+ end
10
15
 
11
- @interactor.start_termination_handler
12
16
  Listener.new do |files|
13
17
  files_to_spec = []
14
18
  files.each do |file|
@@ -63,8 +67,7 @@ class Runner
63
67
  end
64
68
 
65
69
  def self.initial_spec_run_abort
66
- puts "** Hit <enter> to skip initial spec run.."
67
- @interactor.wait_for_enter_key(2)
70
+ @interactor.wait_for_enter_key("** Hit <enter> to skip initial spec run", 3)
68
71
  end
69
72
 
70
73
  def self.script_runner(file)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Wolff