rspec_runner 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6537a01d0edf8244bee0f8e8c1561950e92260a2
4
- data.tar.gz: a6b5dde3a76f11d61f30b2f593ff3a8dc9674e31
3
+ metadata.gz: 068cee9187e40f7479ace40250ecfea90a7977ba
4
+ data.tar.gz: c637235611c38bd7bdc9b817c47b11ff1c2d8368
5
5
  SHA512:
6
- metadata.gz: 8d260b1df5d8ffc2ff71d0df28a912ac37b532a220c15315cbbbbc6afa23aff2eb7776f4cc388f65b8e1bc23d8ffefea67353a4674d067f949f4213e2dbfdb5e
7
- data.tar.gz: 6b4aee0adc08c8b15f80bfa52066be7c2dc73b29935e8c8cd8c57822eab882d9e15335754861fd48000e1bbce3cd32b8cd2955ffeb2d71c61cee0b751ba2cfcd
6
+ metadata.gz: 76d15ffba43111a859ef7646b4d6c4e8f5ed61481764cb20602a061c054646f17637a5cb0f6208c978cb450e46b8bcba5ba70edb10f853dac143f747bba4d7f7
7
+ data.tar.gz: b7d6cecf3503bdec8bc90b357f47bfbf7f3bd5503ebdca64bbae429929ebaf12a942451b44879f0662ed1449609a12f814357d2ce745ab3674c7803478c645f8
data/bin/rspec_runner CHANGED
@@ -5,7 +5,7 @@ cmd = ARGV[0]
5
5
  case cmd
6
6
  when 'monitor'.freeze
7
7
  require 'rspec_runner/monitor'
8
- RspecRunner::Monitor.run
8
+ RspecRunner::Monitor.start
9
9
  else
10
10
  require 'rspec_runner/client'
11
11
  RspecRunner::Client.execute(cmd)
@@ -1,20 +1,17 @@
1
- require 'open3'
2
1
  require 'rspec_runner/server'
3
2
  require 'rspec_runner/watcher'
4
3
 
5
4
  module RspecRunner
6
5
  class Monitor
7
- CMD = 'bundle exec rspec_runner start'.freeze
8
-
9
6
  class << self
10
- def run
11
- start
7
+ def start
8
+ RspecRunner::Server.start
12
9
 
13
- at_exit { die }
10
+ at_exit { stop }
14
11
 
15
- watcher_thread = Watcher.run do |changes|
12
+ watcher_thread = Watcher.start do |changes|
16
13
  puts 'Restarting...'
17
- restart
14
+ RspecRunner::Server.restart
18
15
  end
19
16
 
20
17
  watcher_thread.join
@@ -23,32 +20,10 @@ module RspecRunner
23
20
 
24
21
  private
25
22
 
26
- def start
27
- @pid = fork { RspecRunner::Server.run }
28
- Process.detach(@pid) # so if the child exits, it dies
29
- end
30
-
31
23
  def stop
32
- if @pid && @pid != 0
33
- # TODO: try to kill without -9
34
- send_signal('KILL')
35
- RspecRunner::Server.stop
36
- end
37
- end
38
-
39
- def send_signal(signal)
40
- Process.kill(signal, @pid)
41
- end
42
-
43
- def die
44
- stop
24
+ RspecRunner::Server.stop
45
25
  exit 0
46
26
  end
47
-
48
- def restart
49
- stop
50
- start
51
- end
52
27
  end
53
28
  end
54
29
  end
@@ -5,19 +5,32 @@ require 'rspec_runner/configuration'
5
5
  module RspecRunner
6
6
  class Server
7
7
  class << self
8
- def run
9
- puts 'Loading dependencies...'
8
+ def start
9
+ puts 'Preloading gems...'
10
+ require 'rubygems'
11
+ require 'bundler'
12
+
13
+ Bundler.load.dependencies.reject! do |d|
14
+ spec = d.to_spec
15
+
16
+ if spec.gem_dir == Dir.pwd
17
+ @gem_name = spec.name
18
+ else
19
+ spec.name == 'rspec_runner'
20
+ end
21
+ end
22
+
23
+ if gem?
24
+ Bundler.require(:default, :development)
25
+ else
26
+ Bundler.require(:default, :test)
27
+ end
10
28
 
11
29
  $LOAD_PATH.unshift File.expand_path("#{Dir.pwd}/spec")
12
- require 'rspec'
13
- require 'spec_helper.rb'
14
30
 
15
- DRb.start_service(assign_uri, self)
16
- puts 'Server started!'
31
+ fork_process
17
32
 
18
33
  at_exit { stop }
19
-
20
- DRb.thread.join
21
34
  end
22
35
 
23
36
  def execute(path)
@@ -27,12 +40,44 @@ module RspecRunner
27
40
  reset_rspec!
28
41
  end
29
42
 
43
+ def restart
44
+ stop
45
+ fork_process
46
+ end
47
+
30
48
  def stop
49
+ if @pid && @pid != 0
50
+ # TODO: try to kill without -9
51
+ send_signal('KILL')
52
+ end
31
53
  File.delete(RspecRunner.configuration.uri_filepath) if File.exist?(RspecRunner.configuration.uri_filepath)
32
54
  end
33
55
 
34
56
  private
35
57
 
58
+ def gem?
59
+ !!@gem_name
60
+ end
61
+
62
+ def fork_process
63
+ @pid = fork do
64
+ puts 'Preloading dependencies...'
65
+ require @gem_name if gem?
66
+ require 'spec_helper.rb'
67
+
68
+ DRb.start_service(assign_uri, self)
69
+ puts 'Server started!'
70
+
71
+ DRb.thread.join
72
+ end
73
+
74
+ Process.detach(@pid) # so if the child exits, it dies
75
+ end
76
+
77
+ def send_signal(signal)
78
+ Process.kill(signal, @pid)
79
+ end
80
+
36
81
  def assign_uri
37
82
  socket = Socket.new(:INET, :STREAM, 0)
38
83
  socket.bind(Addrinfo.tcp('127.0.0.1'.freeze, 0))
@@ -1,3 +1,3 @@
1
1
  module RspecRunner
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -4,7 +4,7 @@ require 'rspec_runner/configuration'
4
4
  module RspecRunner
5
5
  class Watcher
6
6
  class << self
7
- def run(&block)
7
+ def start(&block)
8
8
  if @thread then
9
9
  raise RuntimeError, "already started"
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - exAspArk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2016-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec