class Viter::DevServer
Constants
- DEFAULT_ENV_PREFIX
Attributes
config[R]
Configure dev server connection timeout (in seconds), default: 0.01 Webpacker.server.connect_timeout = 1
cattr_accessor(:connect_timeout) { 0.01 }
Public Class Methods
new(config)
click to toggle source
# File lib/viter/dev_server.rb, line 10 def initialize(config) @config = config end
Public Instance Methods
env_prefix()
click to toggle source
# File lib/viter/dev_server.rb, line 54 def env_prefix config.server.fetch(:env_prefix, DEFAULT_ENV_PREFIX) end
host()
click to toggle source
# File lib/viter/dev_server.rb, line 25 def host fetch(:host) end
host_with_port()
click to toggle source
# File lib/viter/dev_server.rb, line 46 def host_with_port "#{host}:#{port}" end
https?()
click to toggle source
# File lib/viter/dev_server.rb, line 33 def https? case fetch(:https) when true, 'true', Hash true else false end end
port()
click to toggle source
# File lib/viter/dev_server.rb, line 29 def port fetch(:port) end
pretty?()
click to toggle source
# File lib/viter/dev_server.rb, line 50 def pretty? fetch(:pretty) end
protocol()
click to toggle source
# File lib/viter/dev_server.rb, line 42 def protocol https? ? 'https' : 'http' end
running?()
click to toggle source
# File lib/viter/dev_server.rb, line 14 def running? if config.server.present? Socket.tcp(host, port, connect_timeout: connect_timeout).close true else false end rescue false end
Private Instance Methods
defaults()
click to toggle source
# File lib/viter/dev_server.rb, line 63 def defaults config.send(:defaults)[:server] || {} end
fetch(key)
click to toggle source
# File lib/viter/dev_server.rb, line 59 def fetch(key) ENV["#{env_prefix}_#{key.upcase}"] || config.server.fetch(key, defaults[key]) end