Class: Middleman::PreviewServer::BasicInformation

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

Overview

Basic information class to wrap common behaviour

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options_hash = ::Middleman::EMPTY_HASH) ⇒ BasicInformation

Create instance


29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 29

def initialize(options_hash = ::Middleman::EMPTY_HASH)
  @bind_address = ServerIpAddress.new(options_hash[:bind_address])
  @server_name  = ServerHostname.new(options_hash[:server_name])
  @port         = options_hash[: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

Instance Attribute Details

#bind_addressObject

Returns the value of attribute bind_address


16
17
18
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 16

def bind_address
  @bind_address
end

#listenersObject (readonly)

Returns the value of attribute listeners


17
18
19
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 17

def listeners
  @listeners
end

#portObject

Returns the value of attribute port


16
17
18
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 16

def port
  @port
end

#reasonObject

Returns the value of attribute reason


16
17
18
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 16

def reason
  @reason
end

#server_nameObject

Returns the value of attribute server_name


16
17
18
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 16

def server_name
  @server_name
end

#site_addressesObject (readonly)

Returns the value of attribute site_addresses


17
18
19
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 17

def site_addresses
  @site_addresses
end

#validObject

Returns the value of attribute valid


16
17
18
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 16

def valid
  @valid
end

Instance Method Details

#local_network_interfacesObject

Default is to get all network interfaces


70
71
72
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 70

def local_network_interfaces
  network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:all)
end

#resolve_meObject

Raises:

  • (NoMethodError)

57
58
59
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 57

def resolve_me(*)
  raise NoMethodError
end

#show_me_network_interfaces(inventory) ⇒ Object

Get network information


65
66
67
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 65

def show_me_network_interfaces(inventory)
  @network_interfaces_inventory = inventory
end

#valid?Boolean

Is the given information valid?


45
46
47
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 45

def valid?
  valid == true
end

#validate_me(validator) ⇒ Object

Pass "self" to validator


53
54
55
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 53

def validate_me(validator)
  validator.validate self, checks
end