Class: RSpecRayo::RayoDriver
- Inherits:
-
Object
- Object
- RSpecRayo::RayoDriver
- Defined in:
- lib/rspec-rayo/driver.rb
Instance Attribute Summary collapse
-
#call_queue ⇒ Object
readonly
Returns the value of attribute call_queue.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
Instance Method Summary collapse
- #cleanup_calls ⇒ Object
- #dial(options) ⇒ Object
- #get_call ⇒ Object
-
#initialize(options) ⇒ RayoDriver
constructor
A new instance of RayoDriver.
- #wait_for_connection(timeout = nil) ⇒ Object
Constructor Details
#initialize(options) ⇒ RayoDriver
Returns a new instance of RayoDriver.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rspec-rayo/driver.rb', line 7 def initialize() @calls = {} @call_queue = Queue.new @queue_timeout = .delete(:queue_timeout) || 5 @write_timeout = .delete(:write_timeout) || 5 @threads = [] @connection_latch = CountDownLatch.new 1 initialize_punchblock end |
Instance Attribute Details
#call_queue ⇒ Object (readonly)
Returns the value of attribute call_queue.
5 6 7 |
# File 'lib/rspec-rayo/driver.rb', line 5 def call_queue @call_queue end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
5 6 7 |
# File 'lib/rspec-rayo/driver.rb', line 5 def calls @calls end |
Instance Method Details
#cleanup_calls ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rspec-rayo/driver.rb', line 26 def cleanup_calls @calls.each_pair do |call_id, call| call.hangup unless call.status == :finished end @calls = {} end |
#dial(options) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rspec-rayo/driver.rb', line 33 def dial() new_call.tap do |call| dial = call.dial call.call_id = dial.call_id @calls[call.call_id] = call end end |
#get_call ⇒ Object
22 23 24 |
# File 'lib/rspec-rayo/driver.rb', line 22 def get_call Timeout::timeout(@queue_timeout) { @call_queue.pop } end |
#wait_for_connection(timeout = nil) ⇒ Object
18 19 20 |
# File 'lib/rspec-rayo/driver.rb', line 18 def wait_for_connection(timeout = nil) @connection_latch.wait timeout end |