Class: Webpack::DevServer::Process
- Inherits:
-
Object
- Object
- Webpack::DevServer::Process
show all
- Defined in:
- lib/webpack/dev_server/process.rb
Defined Under Namespace
Classes: UnsupportedAddressError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(address, timeout: 0.01) ⇒ Process
Returns a new instance of Process.
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/webpack/dev_server/process.rb', line 12
def initialize(address, timeout: 0.01)
uri = URI.parse(address.to_s)
case uri
when URI::HTTP, URI::HTTPS
@uri = uri
else
raise UnsupportedAddressError, "`#{address}` is unsupported address."
end
@timeout = timeout
end
|
Instance Attribute Details
#timeout ⇒ Object
Returns the value of attribute timeout.
10
11
12
|
# File 'lib/webpack/dev_server/process.rb', line 10
def timeout
@timeout
end
|
#uri ⇒ Object
Returns the value of attribute uri.
10
11
12
|
# File 'lib/webpack/dev_server/process.rb', line 10
def uri
@uri
end
|
Instance Method Details
#host ⇒ Object
32
33
34
|
# File 'lib/webpack/dev_server/process.rb', line 32
def host
uri.host
end
|
#host_with_port ⇒ Object
40
41
42
|
# File 'lib/webpack/dev_server/process.rb', line 40
def host_with_port
"#{host}:#{port}"
end
|
#https? ⇒ Boolean
28
29
30
|
# File 'lib/webpack/dev_server/process.rb', line 28
def https?
protocol == "https"
end
|
#port ⇒ Object
36
37
38
|
# File 'lib/webpack/dev_server/process.rb', line 36
def port
uri.port
end
|
#protocol ⇒ Object
24
25
26
|
# File 'lib/webpack/dev_server/process.rb', line 24
def protocol
uri.scheme
end
|
#running? ⇒ Boolean
44
45
46
47
48
49
|
# File 'lib/webpack/dev_server/process.rb', line 44
def running?
Socket.tcp(host, port, connect_timeout: timeout).close
true
rescue StandardError
false
end
|