Class: Everdeen::Server
- Inherits:
-
Object
- Object
- Everdeen::Server
- Defined in:
- lib/everdeen/server.rb
Constant Summary collapse
- StartTimeout =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#control_port ⇒ Object
readonly
Returns the value of attribute control_port.
-
#proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
Class Method Summary collapse
Instance Method Summary collapse
- #create_expectations(expectations) ⇒ Object
-
#initialize(opts = {}) ⇒ Server
constructor
A new instance of Server.
- #ping ⇒ Object
- #registered_expectations ⇒ Object
- #requests(expectation_id) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Server
Returns a new instance of Server.
15 16 17 18 19 |
# File 'lib/everdeen/server.rb', line 15 def initialize(opts = {}) @proxy_port = opts.fetch(:proxy_port) @control_port = opts.fetch(:control_port) @stderr = opts.fetch(:stderr, Tempfile.new("everdeen")) end |
Instance Attribute Details
#control_port ⇒ Object (readonly)
Returns the value of attribute control_port.
13 14 15 |
# File 'lib/everdeen/server.rb', line 13 def control_port @control_port end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
13 14 15 |
# File 'lib/everdeen/server.rb', line 13 def proxy_port @proxy_port end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
13 14 15 |
# File 'lib/everdeen/server.rb', line 13 def stderr @stderr end |
Class Method Details
.start(opts = {}) ⇒ Object
7 8 9 10 11 |
# File 'lib/everdeen/server.rb', line 7 def self.start(opts = {}) server = new(opts) server.start server end |
Instance Method Details
#create_expectations(expectations) ⇒ Object
27 28 29 |
# File 'lib/everdeen/server.rb', line 27 def create_expectations(expectations) client.create_expectations(expectations).collect { |exp| Expectation.new(exp) } end |
#ping ⇒ Object
43 44 45 |
# File 'lib/everdeen/server.rb', line 43 def ping client.ping end |
#registered_expectations ⇒ Object
31 32 33 |
# File 'lib/everdeen/server.rb', line 31 def registered_expectations client.registered_expectations end |
#requests(expectation_id) ⇒ Object
35 36 37 |
# File 'lib/everdeen/server.rb', line 35 def requests(expectation_id) client.requests(expectation_id)['requests'].collect { |req| Request.new(req) } end |
#start ⇒ Object
21 22 23 24 25 |
# File 'lib/everdeen/server.rb', line 21 def start pid = spawn_process.pid wait_until_ready pid end |
#stop ⇒ Object
39 40 41 |
# File 'lib/everdeen/server.rb', line 39 def stop Process.kill(:INT, @pipe.pid) end |