diff --git a/.rubocop.yml b/.rubocop.yml index d7a8c488..cdfb67d2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -59,8 +59,6 @@ Style/MethodMissingSuper: Enabled: false Style/FrozenStringLiteralComment: Enabled: false -Style/FormatStringToken: - Enabled: false Style/EvalWithLocation: Enabled: false Style/Lambda: diff --git a/middleman-core/lib/middleman-core/preview_server.rb b/middleman-core/lib/middleman-core/preview_server.rb index 22ff0c23..93331642 100644 --- a/middleman-core/lib/middleman-core/preview_server.rb +++ b/middleman-core/lib/middleman-core/preview_server.rb @@ -42,9 +42,9 @@ module Middleman app.logger.debug %(== Server information is provided by #{server_information.handler}) app.logger.debug %(== The Middleman is running in "#{environment}" environment) - app.logger.debug format('== The Middleman preview server is bound to %s', ServerUrl.new(hosts: server_information.listeners, port: server_information.port, https: server_information.https?).to_bind_addresses.join(', ')) - app.logger.info format('== View your site at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_urls.join(', ')) - app.logger.info format('== Inspect your site configuration at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_config_urls.join(', ')) + app.logger.debug format('== The Middleman preview server is bound to %s', url: ServerUrl.new(hosts: server_information.listeners, port: server_information.port, https: server_information.https?).to_bind_addresses.join(', ')) + app.logger.info format('== View your site at %s', url: ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_urls.join(', ')) + app.logger.info format('== Inspect your site configuration at %s', url: ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_config_urls.join(', ')) @initialized ||= false return if @initialized @@ -187,7 +187,13 @@ module Middleman server_name: possible_from_cli(:server_name, app.config), https: possible_from_cli(:https, app.config)) - app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless server_information.port == configured_port + unless server_information.port == configured_port + app.logger.warn format( + '== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', + new_port: server_information.port, + old_port: configured_port + ) + end @environment = possible_from_cli(:environment, app.config) diff --git a/middleman-core/lib/middleman-core/preview_server/checks.rb b/middleman-core/lib/middleman-core/preview_server/checks.rb index a8f1a9f4..6f36b79b 100644 --- a/middleman-core/lib/middleman-core/preview_server/checks.rb +++ b/middleman-core/lib/middleman-core/preview_server/checks.rb @@ -34,7 +34,11 @@ module Middleman return if resolver.ips_for(information.server_name).include? information.bind_address information.valid = false - information.reason = format('Server name "%s" does not resolve to bind address "%s"', information.server_name, information.bind_address) + information.reason = format( + 'Server name "%s" does not resolve to bind address "%s"', + name: information.server_name, + addr: information.bind_address + ) end end @@ -49,7 +53,11 @@ module Middleman return if information.bind_address.blank? || information.local_network_interfaces.include?(information.bind_address.to_s) || %w[0.0.0.0 ::].any? { |b| information.bind_address == b } || IPAddr.new('127.0.0.0/8').include?(information.bind_address.to_s) information.valid = false - information.reason = format('Bind address "%s" is not available on your system. Please use one of %s', information.bind_address, information.local_network_interfaces.map { |i| %("#{i}") }.join(', ')) + information.reason = format( + 'Bind address "%s" is not available on your system. Please use one of %s', + bad_addr: information.bind_address, + good_addrs: information.local_network_interfaces.map { |i| %("#{i}") }.join(', ') + ) end end @@ -61,7 +69,10 @@ module Middleman return unless information.bind_address.blank? information.valid = false - information.reason = format('Server name "%s" does not resolve to an ip address', information.server_name) + information.reason = format( + 'Server name "%s" does not resolve to an ip address', + name: information.server_name + ) end end diff --git a/middleman-core/lib/middleman-core/preview_server/server_ip_address.rb b/middleman-core/lib/middleman-core/preview_server/server_ip_address.rb index 55a83db5..7d3c290c 100644 --- a/middleman-core/lib/middleman-core/preview_server/server_ip_address.rb +++ b/middleman-core/lib/middleman-core/preview_server/server_ip_address.rb @@ -32,7 +32,7 @@ module Middleman end def to_browser - format('[%s]', to_s) + format('[%s]', addr: to_s) end if RUBY_VERSION < '2' diff --git a/middleman-core/lib/middleman-core/preview_server/server_url.rb b/middleman-core/lib/middleman-core/preview_server/server_url.rb index a3bd7757..f77adc7c 100644 --- a/middleman-core/lib/middleman-core/preview_server/server_url.rb +++ b/middleman-core/lib/middleman-core/preview_server/server_url.rb @@ -23,9 +23,9 @@ module Middleman # List of bind addresses of format host:port def to_bind_addresses if format_output - hosts.map { |l| format('"%s:%s"', l.to_s, port) } + hosts.map { |l| format('"%s:%s"', host: l.to_s, port: port) } else - hosts.map { |l| format('%s:%s', l.to_s, port) } + hosts.map { |l| format('%s:%s', host: l.to_s, port: port) } end end @@ -35,9 +35,23 @@ module Middleman # List of urls of format http://host:port def to_urls if format_output - hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) } + hosts.map do |l| + format( + '"%s://%s:%s"', + protocol: https? ? 'https' : 'http', + host: l.to_browser, + port: port + ) + end else - hosts.map { |l| format('%s://%s:%s', https? ? 'https' : 'http', l.to_browser, port) } + hosts.map do |l| + format( + '%s://%s:%s', + protocol: https? ? 'https' : 'http', + host: l.to_browser, + port: port + ) + end end end @@ -47,9 +61,23 @@ module Middleman # List of urls of format http://host:port/__middleman def to_config_urls if format_output - hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) } + hosts.map do |l| + format( + '"%s://%s:%s/__middleman"', + protocol: https? ? 'https' : 'http', + host: l.to_browser, + port: port + ) + end else - hosts.map { |l| format('%s://%s:%s/__middleman', https? ? 'https' : 'http', l.to_browser, port) } + hosts.map do |l| + format( + '%s://%s:%s/__middleman', + protocol: https? ? 'https' : 'http', + host: l.to_browser, + port: port + ) + end end end