Class: RSpec::Parallel::Master
- Inherits:
-
Object
- Object
- RSpec::Parallel::Master
- Defined in:
- lib/rspec/parallel/master.rb
Instance Attribute Summary collapse
- #args ⇒ Object readonly
Instance Method Summary collapse
- #close ⇒ void
-
#initialize(args) ⇒ Master
constructor
A new instance of Master.
- #run ⇒ void
-
#socket_builder ⇒ RSpec::Parallel::SocketBuilder
Create a socket builder which builds a socket to connect with the master process.
Constructor Details
#initialize(args) ⇒ Master
Note:
RSpec must be configured ahead
Returns a new instance of Master.
18 19 20 21 22 23 |
# File 'lib/rspec/parallel/master.rb', line 18 def initialize(args) @args = args @path = "/tmp/parallel-rspec-#{$PID}.sock" @files_to_run = ::RSpec.configuration.files_to_run.uniq @server = ::UNIXServer.new(@path) end |
Instance Attribute Details
#args ⇒ Object (readonly)
14 15 16 |
# File 'lib/rspec/parallel/master.rb', line 14 def args @args end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
26 27 28 |
# File 'lib/rspec/parallel/master.rb', line 26 def close server.close end |
#run ⇒ void
This method returns an undefined value.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rspec/parallel/master.rb', line 31 def run until files_to_run.empty? rs, _ws, _es = IO.select([server]) rs.each do |s| socket = s.accept method, _data = socket.gets.strip.split("\t", 2) case method when Protocol::POP path = files_to_run.pop RSpec::Parallel.configuration.logger.info("Deliver #{path}") socket.write(path) when Protocol::PING socket.write("ok") end socket.close end end close remove_socket_file end |
#socket_builder ⇒ RSpec::Parallel::SocketBuilder
Create a socket builder which builds a socket to connect with the master process.
56 57 58 |
# File 'lib/rspec/parallel/master.rb', line 56 def socket_builder SocketBuilder.new(path) end |