Class: BrowserMob::Proxy::Server
- Inherits:
-
Object
- Object
- BrowserMob::Proxy::Server
show all
- Defined in:
- lib/browsermob/proxy/server.rb
Defined Under Namespace
Classes: ServerDiedError, TimeoutError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path, opts = {}) ⇒ Server
Create a new server instance
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/browsermob/proxy/server.rb', line 20
def initialize(path, opts = {})
assert_executable path
@path = path
@port = Integer(opts[:port] || 8080)
@timeout = Integer(opts[:timeout] || 10)
@log = !!opts[:log]
@process = create_process
end
|
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
8
9
10
|
# File 'lib/browsermob/proxy/server.rb', line 8
def port
@port
end
|
Instance Method Details
#create_proxy(port = nil) ⇒ Object
46
47
48
|
# File 'lib/browsermob/proxy/server.rb', line 46
def create_proxy(port = nil)
Client.from url, port
end
|
#start ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/browsermob/proxy/server.rb', line 31
def start
@process.start
wait_for_startup
pid = Process.pid
at_exit { stop if Process.pid == pid }
self
end
|
#stop ⇒ Object
50
51
52
|
# File 'lib/browsermob/proxy/server.rb', line 50
def stop
@process.stop if @process.alive?
end
|
#url ⇒ Object
42
43
44
|
# File 'lib/browsermob/proxy/server.rb', line 42
def url
"http://localhost:#{port}"
end
|