Class: Middleman::PreviewServer::AllInterfaces
- Inherits:
-
BasicInformation
- Object
- BasicInformation
- Middleman::PreviewServer::AllInterfaces
- Defined in:
- lib/middleman-core/preview_server/information.rb
Overview
This one is used if no bind address and no server name is given
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasicInformation
#bind_address, #listeners, #port, #reason, #server_name, #site_addresses, #valid
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ AllInterfaces
constructor
A new instance of AllInterfaces.
-
#resolve_me(resolver) ⇒ Object
Resolve ips.
Methods inherited from BasicInformation
#local_network_interfaces, #show_me_network_interfaces, #valid?, #validate_me
Constructor Details
#initialize(*args) ⇒ AllInterfaces
Returns a new instance of AllInterfaces.
97 98 99 100 101 |
# File 'lib/middleman-core/preview_server/information.rb', line 97 def initialize(*args) super after_init end |
Class Method Details
.matches?(opts = {}) ⇒ Boolean
103 104 105 |
# File 'lib/middleman-core/preview_server/information.rb', line 103 def self.matches?(opts={}) opts[:bind_address].blank? && opts[:server_name].blank? end |
Instance Method Details
#resolve_me(resolver) ⇒ Object
Resolve ips
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/middleman-core/preview_server/information.rb', line 108 def resolve_me(resolver) hostname = ServerHostname.new(Socket.gethostname) hostname_ips = resolver.ips_for(hostname) network_interface = ServerIpAddress.new(Array(local_network_interfaces).first) resolved_name = ServerHostname.new(resolver.names_for(network_interface).first) if includes_array? local_network_interfaces, hostname_ips @server_name = hostname @site_addresses << hostname network_interface = ServerIpAddress.new((local_network_interfaces & hostname_ips).first) elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ @server_name = hostname @site_addresses << hostname elsif !resolved_name.blank? @server_name = resolved_name @site_addresses << resolved_name else @server_name = network_interface end @site_addresses << network_interface self end |