Class: Middleman::PreviewServer::ServerNameIsIpInformation

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

Overview

If the server name is either an ipv4 or ipv6 address, e.g. 127.0.0.1 or ::1, use this one

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(_options_hash = ::Middleman::EMPTY_HASH) ⇒ ServerNameIsIpInformation

Returns a new instance of ServerNameIsIpInformation



252
253
254
255
256
257
258
259
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 252

def initialize(_options_hash = ::Middleman::EMPTY_HASH)
  super

  ip = ServerIpAddress.new(server_name.to_s)

  @listeners << ip
  @site_addresses << ip
end

Class Method Details

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

Returns:

  • (Boolean)


263
264
265
266
267
268
269
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 263

def self.matches?(options_hash = ::Middleman::EMPTY_HASH)
  ip = IPAddr.new(options_hash[:server_name])

  ip.ipv4? || ip.ipv6?
rescue StandardError
  false
end

Instance Method Details

#resolve_meObject



261
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 261

def resolve_me(*); end