class Middleman::PreviewServer::ServerInformation

Furthermore it probes for a free tcp port, if the default one 4567 is not available.
* port
* bind address
* server name
This class holds all information which the preview server needs to setup a listener

def bind_address

Returns:
  • (String) -
def bind_address
  information.bind_address
end

def handler

Returns:
  • (String) -
def handler
  information.class.to_s
end

def https?

Is https enabled?
def https?
  @https == true
end

def information

Is cached

The information
def information
  return @information if @information
  # The `DefaultInformation`-class always returns `true`, so there's
  # always a klass available and find will never return nil
  listener_klass = informations.find { |l| l.matches? bind_address: @bind_address, server_name: @server_name }
  @information = listener_klass.new(bind_address: @bind_address, server_name: @server_name)
  @information.show_me_network_interfaces(network_interface_inventory)
  @information.resolve_me(resolver)
  @information.port = tcp_port_prober.port(@port)
  @information.validate_me(validator)
  @information
end

def initialize(opts={})

def initialize(opts={})
  @resolver     = opts.fetch(:resolver, DnsResolver.new)
  @validator    = opts.fetch(:validator, ServerInformationValidator.new)
  @network_interface_inventory = opts.fetch(:network_interface_inventory, NetworkInterfaceInventory.new)
  @tcp_port_prober = opts.fetch(:tcp_port_prober, TcpPortProber.new)
  @informations = []
  @informations << AllInterfaces
  @informations << AllIpv4Interfaces
  @informations << AllIpv6Interfaces
  @informations << ServerNameIsIpInformation
  @informations << ServerNameInformation
  @informations << BindAddressInformation
  @informations << BindAddressAndServerNameInformation
  @informations << DefaultInformation
end

def listeners

Returns:
  • (Array) -
def listeners
  information.listeners
end

def port

Returns:
  • (Integer) -
def port
  information.port
end

def reason

Returns:
  • (String) -
def reason
  information.reason
end

def server_name

Returns:
  • (String) -
def server_name
  information.server_name
end

def site_addresses

Returns:
  • (Array) -
def site_addresses
  information.site_addresses
end

def use(config)

Parameters:
  • config (#[]) --
def use(config)
  @bind_address = config[:bind_address]
  @port         = config[:port]
  @server_name  = config[:server_name]
  @https        = config[:https]
  config[:bind_address] = bind_address
  config[:port]         = port
  config[:server_name]  = server_name
  config[:https]        = https?
end

def valid?

Returns:
  • (TrueClass, FalseClass) -
def valid?
  information.valid?
end