Class: Middleman::PreviewServer::BindAddressInformation

Inherits:
BasicInformation show all
Defined in:
middleman-core/lib/middleman-core/preview_server/information.rb

Overview

Used if a bind address is given and the server name is blank

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

Methods inherited from BasicInformation

#local_network_interfaces, #show_me_network_interfaces, #valid?, #validate_me

Constructor Details

#initialize(*args) ⇒ BindAddressInformation

Returns a new instance of BindAddressInformation



185
186
187
188
189
190
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 185

def initialize(*args)
  super

  @listeners << bind_address
  @site_addresses << bind_address
end

Class Method Details

.matches?(opts = {}) ⇒ Boolean

Returns:

  • (Boolean)


192
193
194
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 192

def self.matches?(opts={})
  !opts[:bind_address].blank? && opts[:server_name].blank?
end

Instance Method Details

#resolve_me(resolver) ⇒ Object

Resolv



197
198
199
200
201
202
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 197

def resolve_me(resolver)
  @server_name = ServerHostname.new(resolver.names_for(bind_address).first)
  @site_addresses << @server_name unless @server_name.blank?

  self
end