Class: Middleman::PreviewServer::ServerUrl
- Inherits:
-
Object
- Object
- Middleman::PreviewServer::ServerUrl
- Defined in:
- middleman-core/lib/middleman-core/preview_server/server_url.rb
Overview
This builds the server urls for the preview server
Instance Method Summary collapse
-
#initialize(options_hash = ::Middleman::EMPTY_HASH) ⇒ ServerUrl
constructor
A new instance of ServerUrl.
-
#to_bind_addresses ⇒ Array
Return bind addresses.
-
#to_config_urls ⇒ Array
Return server config urls.
-
#to_urls ⇒ Array
Return server urls.
Constructor Details
#initialize(options_hash = ::Middleman::EMPTY_HASH) ⇒ ServerUrl
Returns a new instance of ServerUrl.
15 16 17 18 19 20 |
# File 'middleman-core/lib/middleman-core/preview_server/server_url.rb', line 15 def initialize( = ::Middleman::EMPTY_HASH) @hosts = .fetch(:hosts) @port = .fetch(:port) @https = .fetch(:https, false) @format_output = .fetch(:format_output, true) end |
Instance Method Details
#to_bind_addresses ⇒ Array
Return bind addresses
26 27 28 29 30 31 32 |
# File 'middleman-core/lib/middleman-core/preview_server/server_url.rb', line 26 def to_bind_addresses if format_output hosts.map { |l| format('"%<host>s:%<port>s"', host: l.to_s, port: port) } else hosts.map { |l| format('%<host>s:%<port>s', host: l.to_s, port: port) } end end |
#to_config_urls ⇒ Array
Return server config urls
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'middleman-core/lib/middleman-core/preview_server/server_url.rb', line 64 def to_config_urls if format_output hosts.map do |l| format( '"%<protocol>s://%<host>s:%<port>s/__middleman"', protocol: https? ? 'https' : 'http', host: l.to_browser, port: port ) end else hosts.map do |l| format( '%<protocol>s://%<host>s:%<port>s/__middleman', protocol: https? ? 'https' : 'http', host: l.to_browser, port: port ) end end end |
#to_urls ⇒ Array
Return server urls
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'middleman-core/lib/middleman-core/preview_server/server_url.rb', line 38 def to_urls if format_output hosts.map do |l| format( '"%<protocol>s://%<host>s:%<port>s"', protocol: https? ? 'https' : 'http', host: l.to_browser, port: port ) end else hosts.map do |l| format( '%<protocol>s://%<host>s:%<port>s', protocol: https? ? 'https' : 'http', host: l.to_browser, port: port ) end end end |