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
-
#ca_cert_path ⇒ Object
readonly
Returns the value of attribute ca_cert_path.
-
#ca_key_path ⇒ Object
readonly
Returns the value of attribute ca_key_path.
-
#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 20 21 |
# 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")) @ca_cert_path = opts.fetch(:ca_cert_path, nil) @ca_key_path = opts.fetch(:ca_key_path, nil) end |
Instance Attribute Details
#ca_cert_path ⇒ Object (readonly)
Returns the value of attribute ca_cert_path.
13 14 15 |
# File 'lib/everdeen/server.rb', line 13 def ca_cert_path @ca_cert_path end |
#ca_key_path ⇒ Object (readonly)
Returns the value of attribute ca_key_path.
13 14 15 |
# File 'lib/everdeen/server.rb', line 13 def ca_key_path @ca_key_path end |
#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
29 30 31 |
# File 'lib/everdeen/server.rb', line 29 def create_expectations(expectations) client.create_expectations(expectations).collect { |exp| Expectation.new(exp) } end |
#ping ⇒ Object
45 46 47 |
# File 'lib/everdeen/server.rb', line 45 def ping client.ping end |
#registered_expectations ⇒ Object
33 34 35 |
# File 'lib/everdeen/server.rb', line 33 def registered_expectations client.registered_expectations end |
#requests(expectation_id) ⇒ Object
37 38 39 |
# File 'lib/everdeen/server.rb', line 37 def requests(expectation_id) client.requests(expectation_id)['requests'].collect { |req| Request.new(req) } end |
#start ⇒ Object
23 24 25 26 27 |
# File 'lib/everdeen/server.rb', line 23 def start pid = spawn_process.pid wait_until_ready pid end |
#stop ⇒ Object
41 42 43 |
# File 'lib/everdeen/server.rb', line 41 def stop Process.kill(:INT, @pipe.pid) end |