Class: Middleman::PreviewServer::BasicInformation
- Inherits:
-
Object
- Object
- Middleman::PreviewServer::BasicInformation
- Defined in:
- middleman-core/lib/middleman-core/preview_server/information.rb
Overview
Basic information class to wrap common behaviour
Direct Known Subclasses
AllInterfaces, BindAddressAndServerNameInformation, BindAddressInformation, DefaultInformation, ServerNameInformation, ServerNameIsIpInformation
Instance Attribute Summary collapse
-
#bind_address ⇒ Object
Returns the value of attribute bind_address.
-
#listeners ⇒ Object
readonly
Returns the value of attribute listeners.
-
#port ⇒ Object
Returns the value of attribute port.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#server_name ⇒ Object
Returns the value of attribute server_name.
-
#site_addresses ⇒ Object
readonly
Returns the value of attribute site_addresses.
-
#valid ⇒ Object
Returns the value of attribute valid.
Instance Method Summary collapse
-
#initialize(options_hash = ::Middleman::EMPTY_HASH) ⇒ BasicInformation
constructor
Create instance.
-
#local_network_interfaces ⇒ Object
Default is to get all network interfaces.
- #resolve_me ⇒ Object
-
#show_me_network_interfaces(inventory) ⇒ Object
Get network information.
-
#valid? ⇒ Boolean
Is the given information valid?.
-
#validate_me(validator) ⇒ Object
Pass "self" to validator.
Constructor Details
#initialize(options_hash = ::Middleman::EMPTY_HASH) ⇒ BasicInformation
Create instance
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 31 def initialize( = ::Middleman::EMPTY_HASH) @bind_address = ServerIpAddress.new([:bind_address]) @server_name = ServerHostname.new([:server_name]) @port = [: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_address ⇒ Object
Returns the value of attribute bind_address.
18 19 20 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 18 def bind_address @bind_address end |
#listeners ⇒ Object (readonly)
Returns the value of attribute listeners.
19 20 21 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 19 def listeners @listeners end |
#port ⇒ Object
Returns the value of attribute port.
18 19 20 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 18 def port @port end |
#reason ⇒ Object
Returns the value of attribute reason.
18 19 20 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 18 def reason @reason end |
#server_name ⇒ Object
Returns the value of attribute server_name.
18 19 20 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 18 def server_name @server_name end |
#site_addresses ⇒ Object (readonly)
Returns the value of attribute site_addresses.
19 20 21 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 19 def site_addresses @site_addresses end |
#valid ⇒ Object
Returns the value of attribute valid.
18 19 20 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 18 def valid @valid end |
Instance Method Details
#local_network_interfaces ⇒ Object
Default is to get all network interfaces
72 73 74 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 72 def local_network_interfaces network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:all) end |
#resolve_me ⇒ Object
59 60 61 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 59 def resolve_me(*) raise NoMethodError end |
#show_me_network_interfaces(inventory) ⇒ Object
Get network information
67 68 69 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 67 def show_me_network_interfaces(inventory) @network_interfaces_inventory = inventory end |
#valid? ⇒ Boolean
Is the given information valid?
47 48 49 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 47 def valid? valid == true end |
#validate_me(validator) ⇒ Object
Pass "self" to validator
55 56 57 |
# File 'middleman-core/lib/middleman-core/preview_server/information.rb', line 55 def validate_me(validator) validator.validate self, checks end |