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
# 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_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



27
28
29
# File 'lib/everdeen/server.rb', line 27

def create_expectations(expectations)
  client.create_expectations(expectations).collect { |exp| Expectation.new(exp) }
end

#pingObject



43
44
45
# File 'lib/everdeen/server.rb', line 43

def ping
  client.ping
end

#registered_expectationsObject



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

#startObject



21
22
23
24
25
# File 'lib/everdeen/server.rb', line 21

def start
  pid = spawn_process.pid
  wait_until_ready
  pid
end

#stopObject



39
40
41
# File 'lib/everdeen/server.rb', line 39

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