middleman-core 4.3.0.rc.1 → 4.3.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +0 -1
  3. data/cucumber.yml +2 -2
  4. data/features/asset_hash.feature +2 -2
  5. data/features/collections.feature +2 -2
  6. data/features/i18n_mixed_sources.feature +8 -0
  7. data/features/markdown.feature +0 -1
  8. data/features/multiple-sources-reload.feature +40 -0
  9. data/features/partials.feature +1 -1
  10. data/features/support/env.rb +4 -1
  11. data/features/tilde_directories.feature +0 -2
  12. data/features/unicode_filenames.feature +1 -1
  13. data/fixtures/asset-hash-app/config.rb +0 -1
  14. data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
  15. data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
  16. data/fixtures/asset-hash-prefix/config.rb +1 -2
  17. data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
  18. data/fixtures/asset-hash-source-map/config.rb +0 -1
  19. data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
  20. data/fixtures/asset-host-app/config.rb +1 -1
  21. data/fixtures/auto-css-app/config.rb +2 -2
  22. data/fixtures/auto-js-app/config.rb +2 -2
  23. data/fixtures/auto-js-directory-index-app/config.rb +1 -1
  24. data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
  25. data/fixtures/basic-data-app/config.rb +2 -2
  26. data/fixtures/capture-html-app/config.rb +4 -4
  27. data/fixtures/clean-app/config-complications.rb +6 -6
  28. data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
  29. data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
  30. data/fixtures/clean-app/config.rb +6 -6
  31. data/fixtures/clean-dir-app/config.rb +0 -1
  32. data/fixtures/clean-nested-app/config.rb +1 -1
  33. data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
  34. data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
  35. data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
  36. data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
  37. data/fixtures/content-for-app/config.rb +4 -4
  38. data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +1 -0
  39. data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +2 -0
  40. data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +1 -0
  41. data/fixtures/dynamic-pages-app/config.rb +25 -26
  42. data/fixtures/ember-cli-app/config.rb +4 -4
  43. data/fixtures/env-app/environments/development.rb +1 -1
  44. data/fixtures/env-app/environments/production.rb +1 -1
  45. data/fixtures/extension-hooks-app/config.rb +8 -8
  46. data/fixtures/external-helpers/config.rb +2 -2
  47. data/fixtures/external-helpers/helpers/derp.rb +3 -1
  48. data/fixtures/external-helpers/helpers/four_helpers.rb +3 -1
  49. data/fixtures/external-helpers/helpers/one_helper.rb +3 -1
  50. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +3 -1
  51. data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
  52. data/fixtures/external-pipeline-error/config.rb +4 -4
  53. data/fixtures/feature-params-app/config.rb +1 -1
  54. data/fixtures/frontmatter-app/config.rb +1 -1
  55. data/fixtures/glob-app/config.rb +1 -1
  56. data/fixtures/i-8859-1-app/config.rb +1 -1
  57. data/fixtures/i18n-force-locale/config.rb +4 -4
  58. data/fixtures/i18n-mixed-sources/config.rb +1 -1
  59. data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +9 -0
  60. data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +9 -0
  61. data/fixtures/import-app/config.rb +3 -3
  62. data/fixtures/indexable-app/config.rb +3 -3
  63. data/fixtures/large-build-app/config.rb +1 -1
  64. data/fixtures/manual-layout-override/config.rb +1 -1
  65. data/fixtures/missing-tilt-library-app/config.rb +2 -2
  66. data/fixtures/more-traversal-app/config.rb +4 -4
  67. data/fixtures/multiple-data-sources-app/config.rb +1 -1
  68. data/fixtures/multiple-sources-app/config.rb +1 -1
  69. data/fixtures/multiple-sources-with-destination-dir/config.rb +2 -0
  70. data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +1 -0
  71. data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +1 -0
  72. data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
  73. data/fixtures/multiple-sources-without-destination-dir/config.rb +1 -0
  74. data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +1 -0
  75. data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +1 -0
  76. data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
  77. data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
  78. data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
  79. data/fixtures/padrino-helpers-app/config.rb +1 -1
  80. data/fixtures/page-classes-app/config.rb +2 -2
  81. data/fixtures/page-helper-layout-block-app/config.rb +1 -1
  82. data/fixtures/page-id-app/config-proc.rb +4 -4
  83. data/fixtures/page-id-app/config.rb +3 -3
  84. data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
  85. data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
  86. data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
  87. data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
  88. data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
  89. data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
  90. data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
  91. data/fixtures/partials-app/source/_locals.erb +1 -1
  92. data/fixtures/partials-app/source/locals.html.erb +1 -1
  93. data/fixtures/proxy-pages-app/config.rb +13 -14
  94. data/fixtures/sass-assets-path-app/config.rb +2 -2
  95. data/fixtures/sinatra-app/config.rb +6 -6
  96. data/fixtures/traversal-app/config.rb +4 -4
  97. data/fixtures/v4-extension-callbacks/config.rb +2 -2
  98. data/fixtures/wildcard-app/config.rb +1 -1
  99. data/fixtures/wildcard-directory-index-app/config.rb +1 -1
  100. data/lib/middleman-core.rb +3 -3
  101. data/lib/middleman-core/application.rb +5 -5
  102. data/lib/middleman-core/builder.rb +20 -20
  103. data/lib/middleman-core/callback_manager.rb +1 -1
  104. data/lib/middleman-core/config_context.rb +2 -2
  105. data/lib/middleman-core/configuration.rb +5 -5
  106. data/lib/middleman-core/contracts.rb +2 -2
  107. data/lib/middleman-core/core_extensions/collections.rb +1 -1
  108. data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
  109. data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
  110. data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
  111. data/lib/middleman-core/core_extensions/data.rb +10 -10
  112. data/lib/middleman-core/core_extensions/default_helpers.rb +26 -22
  113. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
  114. data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
  115. data/lib/middleman-core/core_extensions/i18n.rb +24 -24
  116. data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +10 -7
  117. data/lib/middleman-core/core_extensions/routing.rb +1 -1
  118. data/lib/middleman-core/dns_resolver.rb +1 -1
  119. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
  120. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
  121. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
  122. data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
  123. data/lib/middleman-core/extension.rb +26 -25
  124. data/lib/middleman-core/extension_manager.rb +1 -1
  125. data/lib/middleman-core/extensions.rb +8 -7
  126. data/lib/middleman-core/extensions/asset_hash.rb +24 -22
  127. data/lib/middleman-core/extensions/asset_host.rb +10 -10
  128. data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
  129. data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
  130. data/lib/middleman-core/extensions/cache_buster.rb +2 -2
  131. data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
  132. data/lib/middleman-core/extensions/external_pipeline.rb +14 -9
  133. data/lib/middleman-core/extensions/gzip.rb +7 -5
  134. data/lib/middleman-core/extensions/lorem.rb +9 -9
  135. data/lib/middleman-core/extensions/minify_css.rb +9 -9
  136. data/lib/middleman-core/extensions/minify_javascript.rb +10 -10
  137. data/lib/middleman-core/extensions/relative_assets.rb +8 -8
  138. data/lib/middleman-core/file_renderer.rb +6 -5
  139. data/lib/middleman-core/load_paths.rb +10 -10
  140. data/lib/middleman-core/logger.rb +2 -3
  141. data/lib/middleman-core/meta_pages.rb +1 -1
  142. data/lib/middleman-core/preview_server.rb +21 -22
  143. data/lib/middleman-core/preview_server/checks.rb +1 -1
  144. data/lib/middleman-core/preview_server/information.rb +13 -13
  145. data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
  146. data/lib/middleman-core/preview_server/server_information.rb +1 -1
  147. data/lib/middleman-core/preview_server/server_url.rb +1 -1
  148. data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
  149. data/lib/middleman-core/rack.rb +1 -1
  150. data/lib/middleman-core/renderers/coffee_script.rb +2 -2
  151. data/lib/middleman-core/renderers/haml.rb +1 -4
  152. data/lib/middleman-core/renderers/less.rb +1 -1
  153. data/lib/middleman-core/renderers/liquid.rb +2 -1
  154. data/lib/middleman-core/renderers/markdown.rb +7 -7
  155. data/lib/middleman-core/renderers/redcarpet.rb +2 -2
  156. data/lib/middleman-core/renderers/sass.rb +5 -5
  157. data/lib/middleman-core/renderers/sass_functions.rb +5 -5
  158. data/lib/middleman-core/renderers/slim.rb +2 -2
  159. data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -4
  160. data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
  161. data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
  162. data/lib/middleman-core/sitemap/extensions/proxies.rb +2 -1
  163. data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
  164. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
  165. data/lib/middleman-core/sitemap/extensions/traversal.rb +80 -25
  166. data/lib/middleman-core/sitemap/resource.rb +21 -20
  167. data/lib/middleman-core/sitemap/store.rb +3 -3
  168. data/lib/middleman-core/sources.rb +12 -12
  169. data/lib/middleman-core/sources/source_watcher.rb +16 -10
  170. data/lib/middleman-core/step_definitions/builder_steps.rb +23 -23
  171. data/lib/middleman-core/step_definitions/commandline_steps.rb +5 -5
  172. data/lib/middleman-core/step_definitions/middleman_steps.rb +13 -14
  173. data/lib/middleman-core/step_definitions/server_steps.rb +14 -16
  174. data/lib/middleman-core/template_context.rb +17 -10
  175. data/lib/middleman-core/template_renderer.rb +34 -32
  176. data/lib/middleman-core/util.rb +2 -2
  177. data/lib/middleman-core/util/binary.rb +3 -1
  178. data/lib/middleman-core/util/data.rb +2 -2
  179. data/lib/middleman-core/util/files.rb +2 -2
  180. data/lib/middleman-core/util/paths.rb +47 -44
  181. data/lib/middleman-core/util/rack.rb +3 -3
  182. data/lib/middleman-core/util/uri_templates.rb +1 -0
  183. data/lib/middleman-core/version.rb +1 -1
  184. data/middleman-core.gemspec +3 -2
  185. data/spec/middleman-core/callbacks_spec.rb +15 -14
  186. data/spec/middleman-core/core_extensions/data_spec.rb +70 -74
  187. data/spec/middleman-core/dns_resolver_spec.rb +6 -6
  188. data/spec/middleman-core/util_spec.rb +81 -86
  189. data/spec/support/given.rb +11 -15
  190. metadata +44 -6
@@ -1,8 +1,6 @@
1
1
  # Use the Ruby/Rails logger
2
2
  require 'active_support/notifications'
3
3
  require 'active_support/logger'
4
- require 'thread'
5
-
6
4
  module Middleman
7
5
  # The Middleman Logger
8
6
  class Logger < ActiveSupport::Logger
@@ -17,7 +15,7 @@ module Middleman
17
15
  @_logger
18
16
  end
19
17
 
20
- def initialize(log_level=1, is_instrumenting=false, target=$stdout)
18
+ def initialize(log_level = 1, is_instrumenting = false, target = $stdout)
21
19
  super(target)
22
20
 
23
21
  self.level = log_level
@@ -41,6 +39,7 @@ module Middleman
41
39
 
42
40
  evt = ::ActiveSupport::Notifications::Event.new(message, *args)
43
41
  return unless evt.duration > 30
42
+
44
43
  info "== Instrument (#{evt.name.sub(/.middleman$/, '')}): #{evt.duration}ms\n#{args.last}"
45
44
  end
46
45
  end
@@ -93,7 +93,7 @@ module Middleman
93
93
  private
94
94
 
95
95
  # Render a template with the given name and locals
96
- def template(template_name, locals={})
96
+ def template(template_name, locals = {})
97
97
  template_path = File.join(File.dirname(__FILE__), 'meta_pages', 'templates', template_name)
98
98
  content = Tilt.new(template_path).render(::Object.new, locals)
99
99
  response(content)
@@ -8,7 +8,6 @@ require 'middleman-core/preview_server/server_information'
8
8
  require 'middleman-core/preview_server/server_url'
9
9
  require 'middleman-core/preview_server/server_information_callback_proxy'
10
10
 
11
- # rubocop:disable GlobalVars
12
11
  module Middleman
13
12
  class PreviewServer
14
13
  class << self
@@ -18,7 +17,7 @@ module Middleman
18
17
 
19
18
  # Start an instance of Middleman::Application
20
19
  # @return [void]
21
- def start(opts={}, cli_options={})
20
+ def start(opts = {}, cli_options = {})
22
21
  # Do not buffer output, otherwise testing of output does not work
23
22
  $stdout.sync = true
24
23
  $stderr.sync = true
@@ -35,7 +34,7 @@ module Middleman
35
34
 
36
35
  # And now comes the check
37
36
  unless server_information.valid?
38
- $stderr.puts %(== Running Middleman failed: #{server_information.reason}. Please fix that and try again.)
37
+ warn %(== Running Middleman failed: #{server_information.reason}. Please fix that and try again.)
39
38
  exit 1
40
39
  end
41
40
 
@@ -49,6 +48,7 @@ module Middleman
49
48
 
50
49
  @initialized ||= false
51
50
  return if @initialized
51
+
52
52
  @initialized = true
53
53
 
54
54
  register_signal_handlers
@@ -61,7 +61,9 @@ module Middleman
61
61
 
62
62
  if @options[:daemon]
63
63
  # To output the child PID, let's make preview server a daemon by hand
64
- if child_pid = fork
64
+ child_pid = fork
65
+
66
+ if child_pid
65
67
  app.logger.info "== Middleman preview server is running in background with PID #{child_pid}"
66
68
  Process.detach child_pid
67
69
  exit 0
@@ -91,7 +93,7 @@ module Middleman
91
93
  def stop
92
94
  begin
93
95
  app.logger.info '== The Middleman is shutting down'
94
- rescue
96
+ rescue StandardError
95
97
  # if the user closed their terminal STDOUT/STDERR won't exist
96
98
  end
97
99
 
@@ -107,8 +109,8 @@ module Middleman
107
109
 
108
110
  begin
109
111
  app = initialize_new_app
110
- rescue => e
111
- $stderr.puts "Error reloading Middleman: #{e}\n#{e.backtrace.join("\n")}"
112
+ rescue StandardError => e
113
+ warn "Error reloading Middleman: #{e}\n#{e.backtrace.join("\n")}"
112
114
  app.logger.info '== The Middleman is still running the application from before the error'
113
115
  return
114
116
  end
@@ -149,7 +151,7 @@ module Middleman
149
151
  ready do
150
152
  unless config[:watcher_disable]
151
153
  match_against = [
152
- %r{^config\.rb$},
154
+ /^config\.rb$/,
153
155
  %r{^environments/[^\.](.*)\.rb$},
154
156
  %r{^lib/[^\.](.*)\.rb$},
155
157
  %r{^#{config[:helpers_dir]}/[^\.](.*)\.rb$}
@@ -207,17 +209,13 @@ module Middleman
207
209
  end
208
210
 
209
211
  def possible_from_cli(key, config)
210
- if @cli_options[key]
211
- @cli_options[key]
212
- else
213
- config[key]
214
- end
212
+ @cli_options[key] || config[key]
215
213
  end
216
214
 
217
215
  # Trap some interupt signals and shut down smoothly
218
216
  # @return [void]
219
217
  def register_signal_handlers
220
- %w(INT HUP TERM QUIT).each do |sig|
218
+ %w[INT HUP TERM QUIT].each do |sig|
221
219
  next unless Signal.list[sig]
222
220
 
223
221
  Signal.trap(sig) do
@@ -245,13 +243,14 @@ module Middleman
245
243
 
246
244
  if ssl_certificate || ssl_private_key
247
245
  raise 'You must provide both :ssl_certificate and :ssl_private_key' unless ssl_private_key && ssl_certificate
246
+
248
247
  http_opts[:SSLCertificate] = OpenSSL::X509::Certificate.new ::File.read ssl_certificate
249
248
  http_opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new ::File.read ssl_private_key
250
249
  else
251
250
  # use a generated self-signed cert
252
251
  http_opts[:SSLCertName] = [
253
- %w(CN localhost),
254
- %w(CN #{host})
252
+ %w[CN localhost],
253
+ ['CN', host]
255
254
  ].uniq
256
255
  cert, key = create_self_signed_cert(1024, [['CN', server_information.server_name]], server_information.site_addresses, 'Middleman Preview Server')
257
256
  http_opts[:SSLCertificate] = cert
@@ -260,16 +259,16 @@ module Middleman
260
259
  end
261
260
 
262
261
  http_opts[:Logger] = if is_logging
263
- FilteredWebrickLog.new
264
- else
265
- ::WEBrick::Log.new(nil, 0)
266
- end
262
+ FilteredWebrickLog.new
263
+ else
264
+ ::WEBrick::Log.new(nil, 0)
265
+ end
267
266
 
268
267
  begin
269
268
  ::WEBrick::HTTPServer.new(http_opts)
270
269
  rescue Errno::EADDRINUSE
271
270
  port = http_opts[:Port]
272
- $stderr.puts %(== Port #{port} is already in use. This could mean another instance of middleman is already running. Please make sure port #{port} is free and start `middleman server` again, or choose another port by running `middleman server —-port=#{port + 1}` instead.)
271
+ warn %(== Port #{port} is already in use. This could mean another instance of middleman is already running. Please make sure port #{port} is free and start `middleman server` again, or choose another port by running `middleman server —-port=#{port + 1}` instead.)
273
272
  end
274
273
  end
275
274
 
@@ -332,7 +331,7 @@ module Middleman
332
331
 
333
332
  class FilteredWebrickLog < ::WEBrick::Log
334
333
  def log(level, data)
335
- super(level, data) unless data =~ %r{Could not determine content-length of response body.}
334
+ super(level, data) unless data =~ /Could not determine content-length of response body./
336
335
  end
337
336
  end
338
337
  end
@@ -46,7 +46,7 @@ module Middleman
46
46
  # @param [Information] information
47
47
  # The information to be validated
48
48
  def validate(information)
49
- 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)
49
+ 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)
50
50
 
51
51
  information.valid = false
52
52
  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(', '))
@@ -27,7 +27,7 @@ module Middleman
27
27
  #
28
28
  # @param [Integer] port
29
29
  # The port to listen on
30
- def initialize(opts={})
30
+ def initialize(opts = {})
31
31
  @bind_address = ServerIpAddress.new(opts[:bind_address])
32
32
  @server_name = ServerHostname.new(opts[:server_name])
33
33
  @port = opts[:port]
@@ -56,7 +56,7 @@ module Middleman
56
56
  end
57
57
 
58
58
  def resolve_me(*)
59
- fail NoMethodError
59
+ raise NoMethodError
60
60
  end
61
61
 
62
62
  # Get network information
@@ -100,7 +100,7 @@ module Middleman
100
100
  after_init
101
101
  end
102
102
 
103
- def self.matches?(opts={})
103
+ def self.matches?(opts = {})
104
104
  opts[:bind_address].blank? && opts[:server_name].blank?
105
105
  end
106
106
 
@@ -116,7 +116,7 @@ module Middleman
116
116
  @site_addresses << hostname
117
117
 
118
118
  network_interface = ServerIpAddress.new((local_network_interfaces & hostname_ips).first)
119
- elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
119
+ elsif /mswin|mingw|cygwin/.match?(RbConfig::CONFIG['host_os'])
120
120
  @server_name = hostname
121
121
  @site_addresses << hostname
122
122
  elsif !resolved_name.blank?
@@ -146,7 +146,7 @@ module Middleman
146
146
  # This is used if bind address is 0.0.0.0, the server name needs to be
147
147
  # blank
148
148
  class AllIpv4Interfaces < AllInterfaces
149
- def self.matches?(opts={})
149
+ def self.matches?(opts = {})
150
150
  opts[:bind_address] == '0.0.0.0' && opts[:server_name].blank?
151
151
  end
152
152
 
@@ -164,7 +164,7 @@ module Middleman
164
164
 
165
165
  # This is used if bind address is ::, the server name needs to be blank
166
166
  class AllIpv6Interfaces < AllInterfaces
167
- def self.matches?(opts={})
167
+ def self.matches?(opts = {})
168
168
  opts[:bind_address] == '::' && opts[:server_name].blank?
169
169
  end
170
170
 
@@ -189,7 +189,7 @@ module Middleman
189
189
  @site_addresses << bind_address
190
190
  end
191
191
 
192
- def self.matches?(opts={})
192
+ def self.matches?(opts = {})
193
193
  !opts[:bind_address].blank? && opts[:server_name].blank?
194
194
  end
195
195
 
@@ -222,7 +222,7 @@ module Middleman
222
222
  self
223
223
  end
224
224
 
225
- def self.matches?(opts={})
225
+ def self.matches?(opts = {})
226
226
  opts[:bind_address].blank? && !opts[:server_name].blank?
227
227
  end
228
228
  end
@@ -240,8 +240,8 @@ module Middleman
240
240
  @checks << Checks::ServerNameResolvesToBindAddress.new
241
241
  end
242
242
 
243
- def self.matches?(opts={})
244
- !opts[:bind_address].blank? && !opts[:server_name].blank? && !%w(:: 0.0.0.0).include?(opts[:bind_address])
243
+ def self.matches?(opts = {})
244
+ !opts[:bind_address].blank? && !opts[:server_name].blank? && !%w[:: 0.0.0.0].include?(opts[:bind_address])
245
245
  end
246
246
 
247
247
  def resolve_me(*); end
@@ -250,7 +250,7 @@ module Middleman
250
250
  # If the server name is either an ipv4 or ipv6 address, e.g. 127.0.0.1 or
251
251
  # ::1, use this one
252
252
  class ServerNameIsIpInformation < BasicInformation
253
- def initialize(opts={})
253
+ def initialize(opts = {})
254
254
  super
255
255
 
256
256
  ip = ServerIpAddress.new(server_name.to_s)
@@ -261,11 +261,11 @@ module Middleman
261
261
 
262
262
  def resolve_me(*); end
263
263
 
264
- def self.matches?(opts={})
264
+ def self.matches?(opts = {})
265
265
  ip = IPAddr.new(opts[:server_name])
266
266
 
267
267
  ip.ipv4? || ip.ipv6?
268
- rescue
268
+ rescue StandardError
269
269
  false
270
270
  end
271
271
  end
@@ -25,7 +25,7 @@ module Middleman
25
25
  end
26
26
 
27
27
  def self.match?(type)
28
- :ipv4 == type
28
+ type == :ipv4
29
29
  end
30
30
  end
31
31
 
@@ -36,7 +36,7 @@ module Middleman
36
36
  end
37
37
 
38
38
  def self.match?(type)
39
- :ipv6 == type
39
+ type == :ipv6
40
40
  end
41
41
  end
42
42
 
@@ -57,7 +57,7 @@ module Middleman
57
57
  #
58
58
  # @param [Symbol] type
59
59
  # The type of interface which should be returned
60
- def network_interfaces(type=:all)
60
+ def network_interfaces(type = :all)
61
61
  types.find { |t| t.match? type.to_sym }.new.network_interfaces
62
62
  end
63
63
  end
@@ -22,7 +22,7 @@ module Middleman
22
22
 
23
23
  attr_writer :https
24
24
 
25
- def initialize(opts={})
25
+ def initialize(opts = {})
26
26
  @resolver = opts.fetch(:resolver, DnsResolver.new)
27
27
  @validator = opts.fetch(:validator, ServerInformationValidator.new)
28
28
  @network_interface_inventory = opts.fetch(:network_interface_inventory, NetworkInterfaceInventory.new)
@@ -10,7 +10,7 @@ module Middleman
10
10
 
11
11
  public
12
12
 
13
- def initialize(opts={})
13
+ def initialize(opts = {})
14
14
  @hosts = opts.fetch(:hosts)
15
15
  @port = opts.fetch(:port)
16
16
  @https = opts.fetch(:https, false)
@@ -17,7 +17,7 @@ module Middleman
17
17
  server.close
18
18
 
19
19
  try_port
20
- rescue
20
+ rescue StandardError
21
21
  server = TCPServer.open(0)
22
22
  port = server.addr[1]
23
23
  server.close
@@ -143,7 +143,7 @@ module Middleman
143
143
  response = file.serving(env)
144
144
  end
145
145
  status = response[0]
146
- response[1]['Content-Encoding'] = 'gzip' if %w(.svgz .gz).include?(resource.ext)
146
+ response[1]['Content-Encoding'] = 'gzip' if %w[.svgz .gz].include?(resource.ext)
147
147
  # Do not set Content-Type if status is 1xx, 204, 205 or 304, otherwise
148
148
  # Rack will throw an error (500)
149
149
  if !(100..199).cover?(status) && ![204, 205, 304].include?(status)
@@ -6,7 +6,7 @@ module Middleman
6
6
  # CoffeeScript Renderer
7
7
  class CoffeeScript < ::Middleman::Extension
8
8
  # Setup extension
9
- def initialize(app, options={}, &block)
9
+ def initialize(app, options = {}, &block)
10
10
  super
11
11
 
12
12
  # Tell Tilt to use it as well (for inline scss blocks)
@@ -32,7 +32,7 @@ module Middleman
32
32
  super
33
33
  rescue ::ExecJS::RuntimeError => e
34
34
  e.to_s
35
- rescue => e
35
+ rescue StandardError => e
36
36
  e.to_s
37
37
  end
38
38
  end
@@ -43,7 +43,7 @@ module Middleman
43
43
 
44
44
  # Haml Renderer
45
45
  class Haml < ::Middleman::Extension
46
- def initialize(app, options={}, &block)
46
+ def initialize(app, options = {}, &block)
47
47
  super
48
48
 
49
49
  ::Haml::Options.defaults[:context] = nil
@@ -51,8 +51,6 @@ module Middleman
51
51
  if defined?(::Haml::TempleEngine)
52
52
  ::Haml::TempleEngine.define_options context: nil
53
53
  end
54
-
55
- # rubocop:disable NestedMethodDefinition
56
54
  [::Haml::Filters::Sass, ::Haml::Filters::Scss, ::Haml::Filters::Markdown].each do |f|
57
55
  f.class_exec do
58
56
  def self.render_with_options(text, compiler_options)
@@ -64,7 +62,6 @@ module Middleman
64
62
  end
65
63
  end
66
64
  end
67
- # rubocop:enable NestedMethodDefinition
68
65
 
69
66
  ::Tilt.prefer(::Middleman::Renderers::HamlTemplate, :haml)
70
67
 
@@ -6,7 +6,7 @@ module Middleman
6
6
  class Less < ::Middleman::Extension
7
7
  define_setting :less, {}, 'LESS compiler options'
8
8
 
9
- def initialize(app, options={}, &block)
9
+ def initialize(app, options = {}, &block)
10
10
  super
11
11
 
12
12
  # Tell Tilt to use it as well (for inline sass blocks)
@@ -14,6 +14,7 @@ module Middleman
14
14
  def read_template_file(template_path)
15
15
  file = app.files.find(:source, "_#{template_path}.liquid")
16
16
  raise ::Liquid::FileSystemError, "No such template '#{template_path}'" unless file
17
+
17
18
  file.read
18
19
  end
19
20
 
@@ -24,7 +25,7 @@ module Middleman
24
25
 
25
26
  resources.each do |resource|
26
27
  next if resource.file_descriptor.nil?
27
- next unless resource.file_descriptor[:full_path].to_s =~ %r{\.liquid$}
28
+ next unless resource.file_descriptor[:full_path].to_s =~ /\.liquid$/
28
29
 
29
30
  # Convert data object into a hash for liquid
30
31
  resource.add_metadata locals: {
@@ -7,7 +7,7 @@ module Middleman
7
7
 
8
8
  # Once configuration is parsed
9
9
  def after_configuration
10
- markdown_exts = %w(markdown mdown md mkd mkdn)
10
+ markdown_exts = %w[markdown mdown md mkd mkdn]
11
11
 
12
12
  begin
13
13
  # Look for the user's preferred engine
@@ -20,12 +20,12 @@ module Middleman
20
20
  elsif app.config[:markdown_engine]
21
21
  # Map symbols to classes
22
22
  markdown_engine_klass = if app.config[:markdown_engine].is_a? Symbol
23
- engine = app.config[:markdown_engine].to_s
24
- engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize
25
- app.config[:markdown_engine_prefix].const_get("#{engine}Template")
26
- else
27
- app.config[:markdown_engine_prefix]
28
- end
23
+ engine = app.config[:markdown_engine].to_s
24
+ engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize
25
+ app.config[:markdown_engine_prefix].const_get("#{engine}Template")
26
+ else
27
+ app.config[:markdown_engine_prefix]
28
+ end
29
29
 
30
30
  # Tell tilt to use that engine
31
31
  ::Tilt.prefer(markdown_engine_klass, *markdown_exts)