middleman-core 4.3.0.rc.4 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/cucumber.yml +2 -2
  3. data/features/builder.feature +1 -1
  4. data/features/chained_templates.feature +0 -7
  5. data/features/coffee-script.feature +1 -1
  6. data/features/collections.feature +2 -2
  7. data/features/console.feature +1 -1
  8. data/features/data.feature +31 -0
  9. data/features/extension_api_deprecations.feature +3 -1
  10. data/features/extension_hooks.feature +3 -1
  11. data/features/helpers_external.feature +1 -17
  12. data/features/i18n_link_to.feature +0 -23
  13. data/features/i18n_mixed_sources.feature +0 -8
  14. data/features/i18n_preview.feature +1 -30
  15. data/features/ignore.feature +11 -67
  16. data/features/ignore_already_minified.feature +1 -1
  17. data/features/markdown.feature +1 -0
  18. data/features/minify_javascript.feature +35 -35
  19. data/features/mount_rack.feature +0 -1
  20. data/features/page-id.feature +2 -2
  21. data/features/partials.feature +1 -1
  22. data/features/relative_assets_helpers_only.feature +6 -4
  23. data/features/scss-support.feature +6 -1
  24. data/features/support/env.rb +5 -5
  25. data/features/tilde_directories.feature +2 -0
  26. data/features/unicode_filenames.feature +1 -1
  27. data/fixtures/asset-hash-app/config.rb +1 -0
  28. data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
  29. data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
  30. data/fixtures/asset-hash-minified-app/config.rb +1 -1
  31. data/fixtures/asset-hash-prefix/config.rb +2 -1
  32. data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
  33. data/fixtures/asset-hash-source-map/config.rb +1 -0
  34. data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
  35. data/fixtures/asset-host-app/config.rb +1 -1
  36. data/fixtures/auto-css-app/config.rb +2 -2
  37. data/fixtures/auto-js-app/config.rb +2 -2
  38. data/fixtures/auto-js-directory-index-app/config.rb +1 -1
  39. data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
  40. data/fixtures/basic-data-app/config.rb +2 -2
  41. data/fixtures/capture-html-app/config.rb +4 -4
  42. data/fixtures/clean-app/config-complications.rb +6 -6
  43. data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
  44. data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
  45. data/fixtures/clean-app/config.rb +6 -6
  46. data/fixtures/clean-dir-app/config.rb +1 -0
  47. data/fixtures/clean-nested-app/config.rb +1 -1
  48. data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
  49. data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
  50. data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
  51. data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
  52. data/fixtures/content-for-app/config.rb +4 -4
  53. data/fixtures/dynamic-pages-app/config.rb +26 -25
  54. data/fixtures/ember-cli-app/config.rb +4 -4
  55. data/fixtures/env-app/environments/development.rb +1 -1
  56. data/fixtures/env-app/environments/production.rb +1 -1
  57. data/fixtures/env-app/source/stylesheets/site.css.scss +1 -1
  58. data/fixtures/extension-hooks-app/config.rb +8 -8
  59. data/fixtures/external-helpers/config.rb +2 -2
  60. data/fixtures/external-helpers/helpers/derp.rb +1 -3
  61. data/fixtures/external-helpers/helpers/four_helpers.rb +1 -3
  62. data/fixtures/external-helpers/helpers/one_helper.rb +1 -3
  63. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -3
  64. data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
  65. data/fixtures/external-pipeline-error/config.rb +4 -4
  66. data/fixtures/feature-params-app/config.rb +1 -1
  67. data/fixtures/frontmatter-app/config.rb +1 -1
  68. data/fixtures/generator-test/config.rb +15 -1
  69. data/fixtures/glob-app/config.rb +1 -1
  70. data/fixtures/i-8859-1-app/config.rb +1 -1
  71. data/fixtures/i18n-force-locale/config.rb +4 -4
  72. data/fixtures/i18n-mixed-sources/config.rb +1 -1
  73. data/fixtures/i18n-test-app/locales/en.yml +1 -7
  74. data/fixtures/i18n-test-app/locales/es.yml +1 -2
  75. data/fixtures/import-app/config.rb +3 -3
  76. data/fixtures/indexable-app/config.rb +3 -3
  77. data/fixtures/large-build-app/config.rb +1 -1
  78. data/fixtures/manual-layout-override/config.rb +1 -1
  79. data/fixtures/missing-tilt-library-app/config.rb +2 -2
  80. data/fixtures/more-traversal-app/config.rb +4 -4
  81. data/fixtures/multiple-data-sources-app/config.rb +1 -1
  82. data/fixtures/multiple-sources-app/config.rb +1 -1
  83. data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
  84. data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
  85. data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
  86. data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
  87. data/fixtures/padrino-helpers-app/config.rb +1 -1
  88. data/fixtures/page-classes-app/config.rb +2 -2
  89. data/fixtures/page-helper-layout-block-app/config.rb +1 -1
  90. data/fixtures/page-id-app/config-proc.rb +4 -4
  91. data/fixtures/page-id-app/config.rb +3 -3
  92. data/fixtures/page-id-app/source/{forty-two.html.erb → fourty-two.html.erb} +0 -0
  93. data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
  94. data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
  95. data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
  96. data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
  97. data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
  98. data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
  99. data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
  100. data/fixtures/partials-app/source/_locals.erb +1 -1
  101. data/fixtures/partials-app/source/locals.html.erb +1 -1
  102. data/fixtures/proxy-pages-app/config.rb +14 -13
  103. data/fixtures/sass-assets-path-app/config.rb +2 -2
  104. data/fixtures/scss-app/source/stylesheets/error.css.sass +1 -0
  105. data/fixtures/sinatra-app/config.rb +6 -6
  106. data/fixtures/traversal-app/config.rb +4 -4
  107. data/fixtures/v4-extension-callbacks/config.rb +2 -2
  108. data/fixtures/wildcard-app/config.rb +1 -1
  109. data/fixtures/wildcard-directory-index-app/config.rb +1 -1
  110. data/lib/middleman/rack.rb +7 -0
  111. data/lib/middleman-core/application.rb +9 -10
  112. data/lib/middleman-core/builder.rb +21 -50
  113. data/lib/middleman-core/callback_manager.rb +1 -1
  114. data/lib/middleman-core/config_context.rb +2 -2
  115. data/lib/middleman-core/configuration.rb +5 -5
  116. data/lib/middleman-core/contracts.rb +2 -2
  117. data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
  118. data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
  119. data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
  120. data/lib/middleman-core/core_extensions/collections.rb +1 -1
  121. data/lib/middleman-core/core_extensions/data.rb +11 -11
  122. data/lib/middleman-core/core_extensions/default_helpers.rb +29 -26
  123. data/lib/middleman-core/core_extensions/external_helpers.rb +1 -1
  124. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
  125. data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
  126. data/lib/middleman-core/core_extensions/i18n.rb +23 -44
  127. data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +7 -10
  128. data/lib/middleman-core/core_extensions/routing.rb +1 -1
  129. data/lib/middleman-core/core_extensions.rb +2 -2
  130. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
  131. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
  132. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
  133. data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
  134. data/lib/middleman-core/dns_resolver.rb +1 -1
  135. data/lib/middleman-core/extension.rb +32 -34
  136. data/lib/middleman-core/extension_manager.rb +2 -6
  137. data/lib/middleman-core/extensions/asset_hash.rb +22 -24
  138. data/lib/middleman-core/extensions/asset_host.rb +10 -10
  139. data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
  140. data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
  141. data/lib/middleman-core/extensions/cache_buster.rb +2 -2
  142. data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
  143. data/lib/middleman-core/extensions/external_pipeline.rb +9 -14
  144. data/lib/middleman-core/extensions/gzip.rb +6 -8
  145. data/lib/middleman-core/extensions/lorem.rb +9 -9
  146. data/lib/middleman-core/extensions/minify_css.rb +16 -14
  147. data/lib/middleman-core/extensions/minify_javascript.rb +13 -13
  148. data/lib/middleman-core/extensions/relative_assets.rb +8 -8
  149. data/lib/middleman-core/extensions.rb +7 -8
  150. data/lib/middleman-core/file_renderer.rb +6 -7
  151. data/lib/middleman-core/load_paths.rb +10 -13
  152. data/lib/middleman-core/logger.rb +4 -3
  153. data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
  154. data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
  155. data/lib/middleman-core/meta_pages.rb +1 -1
  156. data/lib/middleman-core/preview_server/checks.rb +1 -1
  157. data/lib/middleman-core/preview_server/information.rb +13 -13
  158. data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
  159. data/lib/middleman-core/preview_server/server_information.rb +1 -1
  160. data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +1 -1
  161. data/lib/middleman-core/preview_server/server_url.rb +1 -1
  162. data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
  163. data/lib/middleman-core/preview_server.rb +25 -25
  164. data/lib/middleman-core/rack.rb +1 -1
  165. data/lib/middleman-core/renderers/coffee_script.rb +2 -2
  166. data/lib/middleman-core/renderers/haml.rb +4 -8
  167. data/lib/middleman-core/renderers/less.rb +1 -1
  168. data/lib/middleman-core/renderers/liquid.rb +2 -3
  169. data/lib/middleman-core/renderers/markdown.rb +7 -7
  170. data/lib/middleman-core/renderers/redcarpet.rb +2 -2
  171. data/lib/middleman-core/renderers/sass.rb +23 -26
  172. data/lib/middleman-core/renderers/sass_functions.rb +14 -17
  173. data/lib/middleman-core/renderers/slim.rb +2 -2
  174. data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -2
  175. data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
  176. data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
  177. data/lib/middleman-core/sitemap/extensions/proxies.rb +1 -2
  178. data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
  179. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
  180. data/lib/middleman-core/sitemap/extensions/traversal.rb +25 -80
  181. data/lib/middleman-core/sitemap/resource.rb +20 -21
  182. data/lib/middleman-core/sitemap/store.rb +6 -6
  183. data/lib/middleman-core/sources/source_watcher.rb +11 -17
  184. data/lib/middleman-core/sources.rb +12 -12
  185. data/lib/middleman-core/step_definitions/builder_steps.rb +12 -38
  186. data/lib/middleman-core/step_definitions/commandline_steps.rb +6 -6
  187. data/lib/middleman-core/step_definitions/middleman_steps.rb +14 -13
  188. data/lib/middleman-core/step_definitions/server_steps.rb +16 -18
  189. data/lib/middleman-core/template_context.rb +10 -17
  190. data/lib/middleman-core/template_renderer.rb +33 -35
  191. data/lib/middleman-core/util/binary.rb +1 -3
  192. data/lib/middleman-core/util/data.rb +22 -12
  193. data/lib/middleman-core/util/files.rb +3 -3
  194. data/lib/middleman-core/util/paths.rb +44 -47
  195. data/lib/middleman-core/util/rack.rb +3 -3
  196. data/lib/middleman-core/util/uri_templates.rb +0 -1
  197. data/lib/middleman-core/util.rb +2 -2
  198. data/lib/middleman-core/version.rb +1 -1
  199. data/lib/middleman-core.rb +3 -3
  200. data/middleman-core.gemspec +13 -12
  201. data/spec/middleman-core/callbacks_spec.rb +14 -15
  202. data/spec/middleman-core/core_extensions/data_spec.rb +74 -70
  203. data/spec/middleman-core/dns_resolver_spec.rb +6 -6
  204. data/spec/middleman-core/util_spec.rb +86 -81
  205. data/spec/spec_helper.rb +6 -1
  206. data/spec/support/given.rb +15 -11
  207. metadata +59 -76
  208. data/features/multiple-sources-reload.feature +0 -40
  209. data/fixtures/chained-app/source/stylesheets/main.css.scss.erb +0 -3
  210. data/fixtures/chained-app/source/stylesheets/sub.scss +0 -1
  211. data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +0 -1
  212. data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +0 -2
  213. data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +0 -1
  214. data/fixtures/i18n-default-app/source/name.html.erb +0 -1
  215. data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +0 -9
  216. data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +0 -9
  217. data/fixtures/i18n-test-app/source/localizable/tac.html.erb +0 -1
  218. data/fixtures/multiple-sources-with-destination-dir/config.rb +0 -2
  219. data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +0 -1
  220. data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +0 -1
  221. data/fixtures/multiple-sources-without-destination-dir/config.rb +0 -1
  222. data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +0 -1
  223. data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +0 -1
@@ -88,7 +88,7 @@ module Middleman
88
88
  end
89
89
 
90
90
  Contract Symbol, RespondTo[:manipulate_resource_list], Maybe[Or[Num, ArrayOf[Num]]], Maybe[Symbol] => Any
91
- def register_resource_list_manipulators(name, manipulator, priority = 50, custom_name = nil)
91
+ def register_resource_list_manipulators(name, manipulator, priority=50, custom_name=nil)
92
92
  Array(priority || 50).each do |p|
93
93
  register_resource_list_manipulator(name, manipulator, p, custom_name)
94
94
  end
@@ -103,7 +103,7 @@ module Middleman
103
103
  # @param [Symbol] custom_name The method name to execute.
104
104
  # @return [void]
105
105
  Contract Symbol, RespondTo[:manipulate_resource_list], Maybe[Num, Bool], Maybe[Symbol] => Any
106
- def register_resource_list_manipulator(name, manipulator, priority = 50, custom_name = nil)
106
+ def register_resource_list_manipulator(name, manipulator, priority=50, custom_name=nil)
107
107
  # The third argument used to be a boolean - handle those who still pass one
108
108
  priority = 50 unless priority.is_a? Numeric
109
109
  @resource_list_manipulators = @resource_list_manipulators.push(
@@ -121,7 +121,7 @@ module Middleman
121
121
  rebuild_resource_list!(:"registered_new_manipulator_#{name}")
122
122
  end
123
123
 
124
- # Rebuild the list of resources from scratch, using registered manipulators
124
+ # Rebuild the list of resources from scratch, using registed manipulators
125
125
  # @return [void]
126
126
  Contract Symbol => Any
127
127
  def rebuild_resource_list!(name)
@@ -171,7 +171,7 @@ module Middleman
171
171
  # @param [Boolean] include_ignored Whether to include ignored resources
172
172
  # @return [Array<Middleman::Sitemap::Resource>]
173
173
  Contract Bool => ResourceList
174
- def resources(include_ignored = false)
174
+ def resources(include_ignored=false)
175
175
  @lock.synchronize do
176
176
  ensure_resource_list_updated!
177
177
  if include_ignored
@@ -238,11 +238,11 @@ module Middleman
238
238
 
239
239
  # Rebuild cache
240
240
  @resources.each do |resource|
241
- @_lookup_by_path[::Middleman::Util.normalize_path(resource.path)] = resource
241
+ @_lookup_by_path[resource.path] = resource
242
242
  end
243
243
 
244
244
  @resources.each do |resource|
245
- @_lookup_by_destination_path[::Middleman::Util.normalize_path(resource.destination_path)] = resource
245
+ @_lookup_by_destination_path[resource.destination_path] = resource
246
246
  end
247
247
 
248
248
  # NB: This needs to be done after the previous two steps,
@@ -15,7 +15,7 @@ module Listen
15
15
  # return true unless only_patterns.any? { |pattern| path =~ pattern }
16
16
  # end
17
17
 
18
- return only_patterns.none? { |pattern| path =~ pattern } if only_patterns
18
+ return !only_patterns.any? { |pattern| path =~ pattern } if only_patterns
19
19
 
20
20
  ignore_patterns.any? { |pattern| path =~ pattern }
21
21
  end
@@ -50,7 +50,7 @@ module Middleman
50
50
  # Reference to lower level listener
51
51
  attr_reader :listener
52
52
 
53
- IGNORED_DIRECTORIES = Set.new(%w[.git node_modules .sass-cache vendor/bundle .bundle])
53
+ IGNORED_DIRECTORIES = Set.new(%w(.git node_modules .sass-cache vendor/bundle .bundle))
54
54
 
55
55
  # Construct a new SourceWatcher
56
56
  #
@@ -59,7 +59,7 @@ module Middleman
59
59
  # @param [String] directory The on-disk path to watch.
60
60
  # @param [Hash] options Configuration options.
61
61
  Contract IsA['Middleman::Sources'], Symbol, String, Hash => Any
62
- def initialize(parent, type, directory, options = {})
62
+ def initialize(parent, type, directory, options={})
63
63
  @parent = parent
64
64
  @options = options
65
65
 
@@ -103,7 +103,7 @@ module Middleman
103
103
  poll_once!
104
104
  end
105
105
 
106
- def update_config(options = {})
106
+ def update_config(options={})
107
107
  without_listener_running do
108
108
  @disable_watcher = options.fetch(:disable_watcher, false)
109
109
  @force_polling = options.fetch(:force_polling, false)
@@ -134,19 +134,13 @@ module Middleman
134
134
  # @param [Boolean] glob If the path contains wildcard characters.
135
135
  # @return [Middleman::SourceFile, nil]
136
136
  Contract Or[String, Pathname], Maybe[Bool] => Maybe[IsA['Middleman::SourceFile']]
137
- def find(path, glob = false)
137
+ def find(path, glob=false)
138
138
  path = path.to_s.encode!('UTF-8', 'UTF-8-MAC') if RUBY_PLATFORM =~ /darwin/
139
139
 
140
140
  p = Pathname(path)
141
141
 
142
142
  return nil if p.absolute? && !p.to_s.start_with?(@directory.to_s)
143
143
 
144
- destination_dir = @options[:destination_dir]
145
- if destination_dir.present? && p.to_s.start_with?(destination_dir)
146
- path_without_destination_dir = p.to_s[destination_dir.to_s.length + 1..-1]
147
- p = Pathname(path_without_destination_dir)
148
- end
149
-
150
144
  p = @directory + p if p.relative?
151
145
 
152
146
  if glob
@@ -301,7 +295,7 @@ module Middleman
301
295
  [valid_updates, valid_removes]
302
296
  end
303
297
 
304
- # Convert a path to a file representation.
298
+ # Convert a path to a file resprentation.
305
299
  #
306
300
  # @param [Pathname] path The path.
307
301
  # @return [Middleman::SourceFile]
@@ -363,16 +357,16 @@ module Middleman
363
357
  private
364
358
 
365
359
  def without_listener_running
366
- listener_running = @listener&.processing?
360
+ listener_running = @listener && @listener.processing?
367
361
 
368
362
  stop_listener! if listener_running
369
363
 
370
364
  yield
371
365
 
372
- return unless listener_running
373
-
374
- poll_once!
375
- listen!
366
+ if listener_running
367
+ poll_once!
368
+ listen!
369
+ end
376
370
  end
377
371
  end
378
372
  end
@@ -24,7 +24,7 @@ module Middleman
24
24
  include Contracts
25
25
 
26
26
  # Types which could cause output to change.
27
- OUTPUT_TYPES = %i[source locales data].freeze
27
+ OUTPUT_TYPES = [:source, :locales, :data].freeze
28
28
 
29
29
  # Types which require a reload to eval ruby
30
30
  CODE_TYPES = [:reload].freeze
@@ -56,7 +56,7 @@ module Middleman
56
56
  # @param [Hash] options Global options.
57
57
  # @param [Array] watchers Default watchers.
58
58
  Contract IsA['Middleman::Application'], Maybe[Hash], Maybe[Array] => Any
59
- def initialize(app, _options = {}, watchers = [])
59
+ def initialize(app, _options={}, watchers=[])
60
60
  @app = app
61
61
  @watchers = watchers
62
62
  @sorted_watchers = @watchers.dup.freeze
@@ -88,7 +88,7 @@ module Middleman
88
88
  # @param [Proc] block Ignore by block evaluation.
89
89
  # @return [void]
90
90
  Contract Symbol, Symbol, Or[Regexp, Proc] => Any
91
- def ignore(name, type, regex = nil, &block)
91
+ def ignore(name, type, regex=nil, &block)
92
92
  @ignores = @ignores.put(name, type: type,
93
93
  validator: (block_given? ? block : regex))
94
94
 
@@ -116,13 +116,13 @@ module Middleman
116
116
  # @param [Hash] options The watcher options.
117
117
  # @return [#changed, #deleted]
118
118
  Contract Or[Symbol, HANDLER], Maybe[Hash] => HANDLER
119
- def watch(type_or_handler, options = {})
119
+ def watch(type_or_handler, options={})
120
120
  handler = if type_or_handler.is_a? Symbol
121
- path = File.expand_path(options.delete(:path), app.root)
122
- SourceWatcher.new(self, type_or_handler, path, options)
123
- else
124
- type_or_handler
125
- end
121
+ path = File.expand_path(options.delete(:path), app.root)
122
+ SourceWatcher.new(self, type_or_handler, path, options)
123
+ else
124
+ type_or_handler
125
+ end
126
126
 
127
127
  @watchers << handler
128
128
 
@@ -188,7 +188,7 @@ module Middleman
188
188
  # @param [Boolean] glob If the path contains wildcard or glob characters.
189
189
  # @return [Middleman::SourceFile, nil]
190
190
  Contract Or[Symbol, ArrayOf[Symbol], SetOf[Symbol]], Or[Pathname, String], Maybe[Bool] => Maybe[SourceFile]
191
- def find(types, path, glob = false)
191
+ def find(types, path, glob=false)
192
192
  array_of_types = Array(types)
193
193
 
194
194
  watchers
@@ -277,7 +277,7 @@ module Middleman
277
277
  #
278
278
  # @param [nil,Regexp] matcher A Regexp to match the change path against
279
279
  Contract Maybe[Matcher] => Any
280
- def changed(matcher = nil, &_block)
280
+ def changed(matcher=nil, &_block)
281
281
  on_change OUTPUT_TYPES do |updated, _removed|
282
282
  updated
283
283
  .select { |f| matcher.nil? ? true : matches?(matcher, f) }
@@ -289,7 +289,7 @@ module Middleman
289
289
  #
290
290
  # @param [nil,Regexp] matcher A Regexp to match the change path against
291
291
  Contract Maybe[Matcher] => Any
292
- def deleted(matcher = nil, &_block)
292
+ def deleted(matcher=nil, &_block)
293
293
  on_change OUTPUT_TYPES do |_updated, removed|
294
294
  removed
295
295
  .select { |f| matcher.nil? ? true : matches?(matcher, f) }
@@ -1,57 +1,31 @@
1
1
  require 'fileutils'
2
2
 
3
3
  Before do
4
- @modification_times = {}
4
+ @modification_times = Hash.new
5
5
  end
6
6
 
7
7
  Given /^a built app at "([^\"]*)"$/ do |path|
8
- step %(a fixture app "#{path}")
9
-
10
- cwd = File.expand_path(aruba.current_directory)
11
- step %(I set the environment variable "MM_ROOT" to "#{cwd}")
12
-
13
- step %(I run `middleman build --verbose`)
8
+ step %Q{a fixture app "#{path}"}
9
+ step %Q{I run `middleman build --verbose`}
14
10
  end
15
11
 
16
12
  Given /^was successfully built$/ do
17
- step %(the output should contain "Project built successfully.")
18
- step %(the exit status should be 0)
19
- step %(a directory named "build" should exist)
20
- end
21
-
22
- Given /^was not successfully built$/ do
23
- step %(the output should not contain "Project built successfully.")
24
- step %(the exit status should be 1)
25
- step %(a directory named "build" should not exist)
13
+ step %Q{the output should contain "Project built successfully."}
14
+ step %Q{the exit status should be 0}
15
+ step %Q{a directory named "build" should exist}
26
16
  end
27
17
 
28
18
  Given /^a successfully built app at "([^\"]*)"$/ do |path|
29
- step %(a built app at "#{path}")
30
- step %(was successfully built)
19
+ step %Q{a built app at "#{path}"}
20
+ step %Q{was successfully built}
31
21
  end
32
22
 
33
23
  Given /^a built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags|
34
- step %(a fixture app "#{path}")
35
-
36
- cwd = File.expand_path(aruba.current_directory)
37
- step %(I set the environment variable "MM_ROOT" to "#{cwd}")
38
-
39
- step %(I run `middleman build #{flags}`)
24
+ step %Q{a fixture app "#{path}"}
25
+ step %Q{I run `middleman build #{flags}`}
40
26
  end
41
27
 
42
28
  Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path, flags|
43
- step %(a built app at "#{path}" with flags "#{flags}")
44
- step %(was successfully built)
45
- end
46
-
47
- Given /^I run the interactive middleman console$/ do
48
- cwd = File.expand_path(aruba.current_directory)
49
- step %(I set the environment variable "MM_ROOT" to "#{cwd}")
50
- step %(I run `middleman console` interactively)
51
- end
52
-
53
- Given /^I run the interactive middleman server$/ do
54
- cwd = File.expand_path(aruba.current_directory)
55
- step %(I set the environment variable "MM_ROOT" to "#{cwd}")
56
- step %(I run `middleman server` interactively)
29
+ step %Q{a built app at "#{path}" with flags "#{flags}"}
30
+ step %Q{was successfully built}
57
31
  end
@@ -1,11 +1,11 @@
1
- When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |_last_command, expected|
1
+ When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
2
2
  begin
3
- Timeout.timeout(aruba.config.exit_timeout) do
3
+ Timeout.timeout(exit_timeout) do
4
4
  loop do
5
- raise 'You need to start middleman interactively first.' unless @interactive
5
+ fail "You need to start middleman interactively first." unless @interactive
6
6
 
7
- if sanitize_text(@interactive.output)&.match?(Regexp.new(sanitize_text(expected)))
8
- all_commands.each(&:terminate)
7
+ if unescape(@interactive.output) =~ Regexp.new(unescape(expected))
8
+ only_processes.each { |p| p.terminate }
9
9
  break
10
10
  end
11
11
 
@@ -80,7 +80,7 @@ end
80
80
 
81
81
  # Make sure each and every process is really dead
82
82
  After do
83
- all_commands.each(&:terminate)
83
+ only_processes.each { |p| p.terminate }
84
84
  end
85
85
 
86
86
  Before '@ruby-2.1' do
@@ -1,14 +1,15 @@
1
1
  require 'fileutils'
2
2
 
3
- Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |_path, config_name|
4
- config_path = File.join(expand_path('.'), "config-#{config_name}.rb")
5
- config_dest = File.join(expand_path('.'), 'config.rb')
3
+ Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
4
+ target = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
5
+ config_path = File.join(expand_path("."), "config-#{config_name}.rb")
6
+ config_dest = File.join(expand_path("."), 'config.rb')
6
7
  FileUtils.cp(config_path, config_dest)
7
8
  end
8
9
 
9
10
  Given /^an empty app$/ do
10
- step %(a directory named "empty_app")
11
- step %(I cd to "empty_app")
11
+ step %Q{a directory named "empty_app"}
12
+ step %Q{I cd to "empty_app"}
12
13
  ENV['MM_ROOT'] = nil
13
14
  end
14
15
 
@@ -17,14 +18,14 @@ Given /^a fixture app "([^\"]*)"$/ do |path|
17
18
 
18
19
  # This step can be reentered from several places but we don't want
19
20
  # to keep re-copying and re-cd-ing into ever-deeper directories
20
- next if File.basename(expand_path('.')) == path
21
+ next if File.basename(expand_path(".")) == path
21
22
 
22
- step %(a directory named "#{path}")
23
+ step %Q{a directory named "#{path}"}
23
24
 
24
25
  target_path = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
25
- FileUtils.cp_r(target_path, expand_path('.'))
26
+ FileUtils.cp_r(target_path, expand_path("."))
26
27
 
27
- step %(I cd to "#{path}")
28
+ step %Q{I cd to "#{path}"}
28
29
  end
29
30
 
30
31
  Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
@@ -34,18 +35,18 @@ Then /^the file "([^\"]*)" has the contents$/ do |path, contents|
34
35
  end
35
36
 
36
37
  Then /^the file "([^\"]*)" is removed$/ do |path|
37
- step %(I remove the file "#{path}")
38
+ step %Q{I remove the file "#{path}"}
38
39
 
39
40
  @server_inst.files.poll_once!
40
41
  end
41
42
 
42
43
  Given /^a modification time for a file named "([^\"]*)"$/ do |file|
43
- target = File.join(expand_path('.'), file)
44
+ target = File.join(expand_path("."), file)
44
45
  @modification_times[target] = File.mtime(target)
45
46
  end
46
47
 
47
48
  Then /^the file "([^\"]*)" should not have been updated$/ do |file|
48
- target = File.join(expand_path('.'), file)
49
+ target = File.join(expand_path("."), file)
49
50
  expect(File.mtime(target)).to eq(@modification_times[target])
50
51
  end
51
52
 
@@ -55,5 +56,5 @@ Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
55
56
  end
56
57
 
57
58
  And /the file "(.*)" should be gzipped/ do |file|
58
- expect(File.binread(File.join(expand_path('.'), file), 2)).to eq(['1F8B'].pack('H*'))
59
+ expect(File.binread(File.join(expand_path("."), file), 2)).to eq(['1F8B'].pack('H*'))
59
60
  end
@@ -10,7 +10,9 @@ end
10
10
  Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
11
11
  @activation_commands ||= []
12
12
 
13
- @activation_commands << -> { activate(feature.to_sym) } if state == 'enabled'
13
+ if state == 'enabled'
14
+ @activation_commands << lambda { activate(feature.to_sym) }
15
+ end
14
16
  end
15
17
 
16
18
  Given /^"([^\"]*)" feature is "enabled" with "([^\"]*)"$/ do |feature, options_str|
@@ -18,7 +20,7 @@ Given /^"([^\"]*)" feature is "enabled" with "([^\"]*)"$/ do |feature, options_s
18
20
 
19
21
  options = eval("{#{options_str}}")
20
22
 
21
- @activation_commands << -> { activate(feature.to_sym, options) }
23
+ @activation_commands << lambda { activate(feature.to_sym, options) }
22
24
  end
23
25
 
24
26
  Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
@@ -29,13 +31,13 @@ Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
29
31
  end
30
32
 
31
33
  Given /^the Server is running$/ do
32
- root_dir = File.expand_path(expand_path('.'))
34
+ root_dir = File.expand_path(expand_path("."))
33
35
 
34
- ENV['MM_SOURCE'] = if File.exist?(File.join(root_dir, 'source'))
35
- 'source'
36
- else
37
- ''
38
- end
36
+ if File.exists?(File.join(root_dir, 'source'))
37
+ ENV['MM_SOURCE'] = 'source'
38
+ else
39
+ ENV['MM_SOURCE'] = ''
40
+ end
39
41
 
40
42
  ENV['MM_ROOT'] = root_dir
41
43
 
@@ -52,7 +54,7 @@ Given /^the Server is running$/ do
52
54
 
53
55
  app.after_configuration_eval do
54
56
  activation_commands.each do |p|
55
- instance_exec(&p)
57
+ config_context.instance_exec(&p)
56
58
  end
57
59
  end
58
60
  end
@@ -61,16 +63,12 @@ Given /^the Server is running$/ do
61
63
  end
62
64
 
63
65
  Given /^the Server is running at "([^\"]*)"$/ do |app_path|
64
- step %(a fixture app "#{app_path}")
65
- step %(the Server is running)
66
- end
67
-
68
- When /^the Server is reloaded$/ do
69
- step %(the Server is running)
66
+ step %Q{a fixture app "#{app_path}"}
67
+ step %Q{the Server is running}
70
68
  end
71
69
 
72
70
  Given /^a template named "([^\"]*)" with:$/ do |name, string|
73
- step %(a file named "source/#{name}" with:), string
71
+ step %Q{a file named "source/#{name}" with:}, string
74
72
  end
75
73
 
76
74
  When /^I go to "([^\"]*)"$/ do |url|
@@ -78,7 +76,7 @@ When /^I go to "([^\"]*)"$/ do |url|
78
76
  end
79
77
 
80
78
  Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
81
- expect { visit(URI.encode(url).to_s) }.to_not raise_exception
79
+ expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
82
80
  end
83
81
 
84
82
  Then /^the content type should be "([^\"]*)"$/ do |expected|
@@ -122,5 +120,5 @@ Then /^the status code should be "([^\"]*)"$/ do |expected|
122
120
  end
123
121
 
124
122
  Then /^I should see "([^\"]*)" lines$/ do |lines|
125
- expect(page.body.chomp.split($INPUT_RECORD_SEPARATOR).length).to eq lines.to_i
123
+ expect(page.body.chomp.split($/).length).to eq lines.to_i
126
124
  end
@@ -30,7 +30,7 @@ module Middleman
30
30
  # @param [Middleman::Application] app
31
31
  # @param [Hash] locs
32
32
  # @param [Hash] opts
33
- def initialize(app, locs = {}, opts = {})
33
+ def initialize(app, locs={}, opts={})
34
34
  @app = app
35
35
  @locs = locs
36
36
  @opts = opts
@@ -42,8 +42,7 @@ module Middleman
42
42
  # @api private
43
43
  # @return [String] The old buffer.
44
44
  def save_buffer
45
- buf_was = @_out_buf
46
- @_out_buf = ''
45
+ @_out_buf, buf_was = '', @_out_buf
47
46
  buf_was
48
47
  end
49
48
 
@@ -101,7 +100,7 @@ module Middleman
101
100
  # @param [Proc] block A block will be evaluated to return internal contents.
102
101
  # @return [String]
103
102
  Contract Any, Or[Symbol, String], Hash => String, Maybe[Proc] => String
104
- def render(_, name, options = {}, &block)
103
+ def render(_, name, options={}, &block)
105
104
  name = name.to_s
106
105
 
107
106
  partial_file = locate_partial(name, false) || locate_partial(name, true)
@@ -127,35 +126,30 @@ module Middleman
127
126
  # @param [String] partial_path
128
127
  # @return [String]
129
128
  Contract String, Maybe[Bool] => Maybe[IsA['Middleman::SourceFile']]
130
- def locate_partial(partial_path, try_static = true)
129
+ def locate_partial(partial_path, try_static=true)
131
130
  partial_file = nil
132
131
  lookup_stack = []
133
132
  non_root = partial_path.to_s.sub(/^\//, '')
134
133
  non_root_no_underscore = non_root.sub(/^_/, '').sub(/\/_/, '/')
135
134
 
136
- if current_resource
137
- resource = current_resource
135
+ if resource = current_resource
138
136
  current_dir = resource.file_descriptor[:relative_path].dirname
139
137
  relative_dir = current_dir + Pathname(non_root)
140
138
  relative_dir_no_underscore = current_dir + Pathname(non_root_no_underscore)
141
-
142
- if relative_dir
143
- lookup_stack.push [relative_dir.to_s,
144
- { preferred_engine: resource.file_descriptor[:relative_path]
145
- .extname[1..-1].to_sym }]
146
- end
147
139
  end
148
140
 
141
+ if relative_dir
142
+ lookup_stack.push [relative_dir.to_s,
143
+ { preferred_engine: resource.file_descriptor[:relative_path]
144
+ .extname[1..-1].to_sym }]
145
+ end
149
146
  lookup_stack.push [non_root]
150
-
151
147
  lookup_stack.push [non_root,
152
148
  { try_static: try_static }]
153
-
154
149
  if relative_dir_no_underscore
155
150
  lookup_stack.push [relative_dir_no_underscore.to_s,
156
151
  { try_static: try_static }]
157
152
  end
158
-
159
153
  lookup_stack.push [non_root_no_underscore,
160
154
  { try_static: try_static }]
161
155
 
@@ -175,7 +169,6 @@ module Middleman
175
169
  # @return [Middleman::Sitemap::Resource]
176
170
  def current_resource
177
171
  return nil unless current_path
178
-
179
172
  sitemap.find_resource_by_destination_path(current_path)
180
173
  end
181
174
  alias current_page current_resource