Class: Everdeen::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/everdeen/server.rb

Constant Summary collapse

StartTimeout =
Class.new(StandardError)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_pathObject (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_pathObject (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_portObject (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_portObject (readonly)

Returns the value of attribute proxy_port.



13
14
15
# File 'lib/everdeen/server.rb', line 13

def proxy_port
  @proxy_port
end

#stderrObject (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

#pingObject



45
46
47
# File 'lib/everdeen/server.rb', line 45

def ping
  client.ping
end

#registered_expectationsObject



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

#startObject



23
24
25
26
27
# File 'lib/everdeen/server.rb', line 23

def start
  pid = spawn_process.pid
  wait_until_ready
  pid
end

#stopObject



41
42
43
# File 'lib/everdeen/server.rb', line 41

def stop
  Process.kill(:INT, @pipe.pid)
end