class ParallelTests::Pids
Attributes
Public Class Methods
Source
# File lib/parallel_tests/pids.rb, line 8 def initialize(file_path) @file_path = file_path @mutex = Mutex.new end
Public Instance Methods
Source
# File lib/parallel_tests/pids.rb, line 18 def delete(pid) pids.delete(pid.to_i) save end
Private Instance Methods
Source
# File lib/parallel_tests/pids.rb, line 44 def read sync do contents = File.read(file_path) return if contents.empty? @pids = JSON.parse(contents) end end
Source
# File lib/parallel_tests/pids.rb, line 52 def save sync { File.write(file_path, pids.to_json) } end
Source
# File lib/parallel_tests/pids.rb, line 56 def sync(&block) mutex.synchronize(&block) end