Class: Webpacker::DevServer
- Inherits:
-
Object
- Object
- Webpacker::DevServer
- Defined in:
- lib/webpacker/dev_server.rb
Constant Summary collapse
- DEFAULT_ENV_PREFIX =
"WEBPACKER_DEV_SERVER".freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #env_prefix ⇒ Object
- #hmr? ⇒ Boolean
- #host ⇒ Object
- #host_with_port ⇒ Object
- #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.
10 11 12 |
# File 'lib/webpacker/dev_server.rb', line 10 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/webpacker/dev_server.rb', line 8 def config @config end |
Instance Method Details
#env_prefix ⇒ Object
58 59 60 |
# File 'lib/webpacker/dev_server.rb', line 58 def env_prefix config.dev_server.fetch(:env_prefix, DEFAULT_ENV_PREFIX) end |
#hmr? ⇒ Boolean
54 55 56 |
# File 'lib/webpacker/dev_server.rb', line 54 def hmr? fetch(:hmr) end |
#host ⇒ Object
25 26 27 |
# File 'lib/webpacker/dev_server.rb', line 25 def host fetch(:host) end |
#host_with_port ⇒ Object
46 47 48 |
# File 'lib/webpacker/dev_server.rb', line 46 def host_with_port "#{host}:#{port}" end |
#https? ⇒ Boolean
33 34 35 36 37 38 39 40 |
# File 'lib/webpacker/dev_server.rb', line 33 def https? case fetch(:https) when true, "true", Hash true else false end end |
#port ⇒ Object
29 30 31 |
# File 'lib/webpacker/dev_server.rb', line 29 def port fetch(:port) end |
#pretty? ⇒ Boolean
50 51 52 |
# File 'lib/webpacker/dev_server.rb', line 50 def pretty? fetch(:pretty) end |
#protocol ⇒ Object
42 43 44 |
# File 'lib/webpacker/dev_server.rb', line 42 def protocol https? ? "https" : "http" end |
#running? ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/webpacker/dev_server.rb', line 14 def running? if config.dev_server.present? Socket.tcp(host, port, connect_timeout: connect_timeout).close true else false end rescue false end |