Class: Webpacker::DevServer
- Inherits:
-
Object
- Object
- Webpacker::DevServer
- Defined in:
- lib/webpacker/dev_server.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #host ⇒ Object
- #host_with_port ⇒ Object
- #hot_module_replacing? ⇒ Boolean
- #https? ⇒ Boolean
-
#initialize(config) ⇒ DevServer
constructor
A new instance of DevServer.
- #port ⇒ Object
- #pretty? ⇒ Boolean
- #protocol ⇒ Object
- #running? ⇒ Boolean
Constructor Details
#initialize(config) ⇒ DevServer
Returns a new instance of DevServer.
8 9 10 |
# File 'lib/webpacker/dev_server.rb', line 8 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/webpacker/dev_server.rb', line 6 def config @config end |
Instance Method Details
#host ⇒ Object
32 33 34 |
# File 'lib/webpacker/dev_server.rb', line 32 def host fetch(:host) end |
#host_with_port ⇒ Object
53 54 55 |
# File 'lib/webpacker/dev_server.rb', line 53 def host_with_port "#{host}:#{port}" end |
#hot_module_replacing? ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/webpacker/dev_server.rb', line 23 def hot_module_replacing? case fetch(:hmr) when true, "true" true else false end end |
#https? ⇒ Boolean
40 41 42 43 44 45 46 47 |
# File 'lib/webpacker/dev_server.rb', line 40 def https? case fetch(:https) when true, "true" true else false end end |
#port ⇒ Object
36 37 38 |
# File 'lib/webpacker/dev_server.rb', line 36 def port fetch(:port) end |
#pretty? ⇒ Boolean
57 58 59 |
# File 'lib/webpacker/dev_server.rb', line 57 def pretty? fetch(:pretty) end |
#protocol ⇒ Object
49 50 51 |
# File 'lib/webpacker/dev_server.rb', line 49 def protocol https? ? "https" : "http" end |
#running? ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/webpacker/dev_server.rb', line 12 def running? if config.dev_server.present? Socket.tcp(host, port, connect_timeout: connect_timeout).close true else false end rescue false end |