Class: Middleman::PreviewServer::ServerUrl
- Inherits:
-
Object
- Object
- Middleman::PreviewServer::ServerUrl
- Defined in:
- lib/middleman-core/preview_server/server_url.rb
Overview
This builds the server urls for the preview server
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ 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(opts = {}) ⇒ ServerUrl
Returns a new instance of ServerUrl.
13 14 15 16 17 18 |
# File 'lib/middleman-core/preview_server/server_url.rb', line 13 def initialize(opts={}) @hosts = opts.fetch(:hosts) @port = opts.fetch(:port) @https = opts.fetch(:https, false) @format_output = opts.fetch(:format_output, true) end |
Instance Method Details
#to_bind_addresses ⇒ Array
Return bind addresses
24 25 26 27 28 29 30 |
# File 'lib/middleman-core/preview_server/server_url.rb', line 24 def to_bind_addresses if format_output hosts.map { |l| format('"%s:%s"', l.to_s, port) } else hosts.map { |l| format('%s:%s', l.to_s, port) } end end |
#to_config_urls ⇒ Array
Return server config urls
48 49 50 51 52 53 54 |
# File 'lib/middleman-core/preview_server/server_url.rb', line 48 def to_config_urls if format_output hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) } else hosts.map { |l| format('%s://%s:%s/__middleman', https? ? 'https' : 'http', l.to_browser, port) } end end |
#to_urls ⇒ Array
Return server urls
36 37 38 39 40 41 42 |
# File 'lib/middleman-core/preview_server/server_url.rb', line 36 def to_urls if format_output hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) } else hosts.map { |l| format('%s://%s:%s', https? ? 'https' : 'http', l.to_browser, port) } end end |