Class: Middleman::PreviewServer::BasicInformation
- Inherits:
-
Object
- Object
- Middleman::PreviewServer::BasicInformation
- Defined in:
- 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(opts = {}) ⇒ 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(opts = {}) ⇒ BasicInformation
Create instance
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/middleman-core/preview_server/information.rb', line 30 def initialize(opts={}) @bind_address = ServerIpAddress.new(opts[:bind_address]) @server_name = ServerHostname.new(opts[:server_name]) @port = opts[: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.
17 18 19 |
# File 'lib/middleman-core/preview_server/information.rb', line 17 def bind_address @bind_address end |
#listeners ⇒ Object (readonly)
Returns the value of attribute listeners.
18 19 20 |
# File 'lib/middleman-core/preview_server/information.rb', line 18 def listeners @listeners end |
#port ⇒ Object
Returns the value of attribute port.
17 18 19 |
# File 'lib/middleman-core/preview_server/information.rb', line 17 def port @port end |
#reason ⇒ Object
Returns the value of attribute reason.
17 18 19 |
# File 'lib/middleman-core/preview_server/information.rb', line 17 def reason @reason end |
#server_name ⇒ Object
Returns the value of attribute server_name.
17 18 19 |
# File 'lib/middleman-core/preview_server/information.rb', line 17 def server_name @server_name end |
#site_addresses ⇒ Object (readonly)
Returns the value of attribute site_addresses.
18 19 20 |
# File 'lib/middleman-core/preview_server/information.rb', line 18 def site_addresses @site_addresses end |
#valid ⇒ Object
Returns the value of attribute valid.
17 18 19 |
# File 'lib/middleman-core/preview_server/information.rb', line 17 def valid @valid end |
Instance Method Details
#local_network_interfaces ⇒ Object
Default is to get all network interfaces
71 72 73 |
# File 'lib/middleman-core/preview_server/information.rb', line 71 def local_network_interfaces network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:all) end |
#resolve_me ⇒ Object
58 59 60 |
# File 'lib/middleman-core/preview_server/information.rb', line 58 def resolve_me(*) fail NoMethodError end |
#show_me_network_interfaces(inventory) ⇒ Object
Get network information
66 67 68 |
# File 'lib/middleman-core/preview_server/information.rb', line 66 def show_me_network_interfaces(inventory) @network_interfaces_inventory = inventory end |
#valid? ⇒ Boolean
Is the given information valid?
46 47 48 |
# File 'lib/middleman-core/preview_server/information.rb', line 46 def valid? valid == true end |
#validate_me(validator) ⇒ Object
Pass "self" to validator
54 55 56 |
# File 'lib/middleman-core/preview_server/information.rb', line 54 def validate_me(validator) validator.validate self, checks end |