class Middleman::PreviewServer::BasicInformation
Basic information class to wrap common behaviour
Attributes
bind_address[RW]
checks[R]
listeners[R]
network_interfaces_inventory[R]
port[RW]
reason[RW]
server_name[RW]
site_addresses[R]
valid[RW]
Public Class Methods
new(opts={})
click to toggle source
Create instance
@param [String] bind_address
The bind address of the server
@param [String] server_name
The name of the server
@param [Integer] port
The port to listen on
# File lib/middleman-core/preview_server/information.rb, line 30 def initialize(opts={}) @bind_address = ServerIpAddress.new(opts[:bind_address]) @server_name = ServerHostname.new(opts[:server_name]) @port = opts[:port] @valid = true @site_addresses = [] @listeners = [] @checks = [] # This needs to be check for each use case. Otherwise `Webrick` will # complain about that. @checks << Checks::InterfaceIsAvailableOnSystem.new end
Public Instance Methods
local_network_interfaces()
click to toggle source
Default is to get all network interfaces
# File lib/middleman-core/preview_server/information.rb, line 71 def local_network_interfaces network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:all) end
resolve_me(*)
click to toggle source
# File lib/middleman-core/preview_server/information.rb, line 58 def resolve_me(*) fail NoMethodError end
show_me_network_interfaces(inventory)
click to toggle source
Get network information
@param [#network_interfaces] inventory
Get list of available network interfaces
# File lib/middleman-core/preview_server/information.rb, line 66 def show_me_network_interfaces(inventory) @network_interfaces_inventory = inventory end
valid?()
click to toggle source
Is the given information valid?
# File lib/middleman-core/preview_server/information.rb, line 46 def valid? valid == true end
validate_me(validator)
click to toggle source
Pass “self” to validator
@param [#validate] validator
The validator
# File lib/middleman-core/preview_server/information.rb, line 54 def validate_me(validator) validator.validate self, checks end