Class: Middleman::PreviewServer::ServerNameInformation

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

Overview

Use if server name is given and bind address 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) ⇒ ServerNameInformation

Returns a new instance of ServerNameInformation


206
207
208
209
210
211
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 206

def initialize(*args)
  super

  @checks << Checks::RequiresBindAddressIfServerNameIsGiven.new
  @site_addresses << server_name
end

Class Method Details

.matches?(options_hash = ::Middleman::EMPTY_HASH) ⇒ Boolean

Returns:

  • (Boolean)

224
225
226
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 224

def self.matches?(options_hash = ::Middleman::EMPTY_HASH)
  options_hash[:bind_address].blank? && !options_hash[:server_name].blank?
end

Instance Method Details

#resolve_me(resolver) ⇒ Object


213
214
215
216
217
218
219
220
221
222
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 213

def resolve_me(resolver)
  @bind_address = ServerIpAddress.new(resolver.ips_for(server_name).first)

  unless bind_address.blank?
    @listeners << bind_address
    @site_addresses << bind_address
  end

  self
end