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.
- checksums.yaml +4 -4
- data/cucumber.yml +2 -2
- data/features/builder.feature +1 -1
- data/features/chained_templates.feature +0 -7
- data/features/coffee-script.feature +1 -1
- data/features/collections.feature +2 -2
- data/features/console.feature +1 -1
- data/features/data.feature +31 -0
- data/features/extension_api_deprecations.feature +3 -1
- data/features/extension_hooks.feature +3 -1
- data/features/helpers_external.feature +1 -17
- data/features/i18n_link_to.feature +0 -23
- data/features/i18n_mixed_sources.feature +0 -8
- data/features/i18n_preview.feature +1 -30
- data/features/ignore.feature +11 -67
- data/features/ignore_already_minified.feature +1 -1
- data/features/markdown.feature +1 -0
- data/features/minify_javascript.feature +35 -35
- data/features/mount_rack.feature +0 -1
- data/features/page-id.feature +2 -2
- data/features/partials.feature +1 -1
- data/features/relative_assets_helpers_only.feature +6 -4
- data/features/scss-support.feature +6 -1
- data/features/support/env.rb +5 -5
- data/features/tilde_directories.feature +2 -0
- data/features/unicode_filenames.feature +1 -1
- data/fixtures/asset-hash-app/config.rb +1 -0
- data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
- data/fixtures/asset-hash-minified-app/config.rb +1 -1
- data/fixtures/asset-hash-prefix/config.rb +2 -1
- data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
- data/fixtures/asset-hash-source-map/config.rb +1 -0
- data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
- data/fixtures/asset-host-app/config.rb +1 -1
- data/fixtures/auto-css-app/config.rb +2 -2
- data/fixtures/auto-js-app/config.rb +2 -2
- data/fixtures/auto-js-directory-index-app/config.rb +1 -1
- data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
- data/fixtures/basic-data-app/config.rb +2 -2
- data/fixtures/capture-html-app/config.rb +4 -4
- data/fixtures/clean-app/config-complications.rb +6 -6
- data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
- data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
- data/fixtures/clean-app/config.rb +6 -6
- data/fixtures/clean-dir-app/config.rb +1 -0
- data/fixtures/clean-nested-app/config.rb +1 -1
- data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
- data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
- data/fixtures/content-for-app/config.rb +4 -4
- data/fixtures/dynamic-pages-app/config.rb +26 -25
- data/fixtures/ember-cli-app/config.rb +4 -4
- data/fixtures/env-app/environments/development.rb +1 -1
- data/fixtures/env-app/environments/production.rb +1 -1
- data/fixtures/env-app/source/stylesheets/site.css.scss +1 -1
- data/fixtures/extension-hooks-app/config.rb +8 -8
- data/fixtures/external-helpers/config.rb +2 -2
- data/fixtures/external-helpers/helpers/derp.rb +1 -3
- data/fixtures/external-helpers/helpers/four_helpers.rb +1 -3
- data/fixtures/external-helpers/helpers/one_helper.rb +1 -3
- data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -3
- data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
- data/fixtures/external-pipeline-error/config.rb +4 -4
- data/fixtures/feature-params-app/config.rb +1 -1
- data/fixtures/frontmatter-app/config.rb +1 -1
- data/fixtures/generator-test/config.rb +15 -1
- data/fixtures/glob-app/config.rb +1 -1
- data/fixtures/i-8859-1-app/config.rb +1 -1
- data/fixtures/i18n-force-locale/config.rb +4 -4
- data/fixtures/i18n-mixed-sources/config.rb +1 -1
- data/fixtures/i18n-test-app/locales/en.yml +1 -7
- data/fixtures/i18n-test-app/locales/es.yml +1 -2
- data/fixtures/import-app/config.rb +3 -3
- data/fixtures/indexable-app/config.rb +3 -3
- data/fixtures/large-build-app/config.rb +1 -1
- data/fixtures/manual-layout-override/config.rb +1 -1
- data/fixtures/missing-tilt-library-app/config.rb +2 -2
- data/fixtures/more-traversal-app/config.rb +4 -4
- data/fixtures/multiple-data-sources-app/config.rb +1 -1
- data/fixtures/multiple-sources-app/config.rb +1 -1
- data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
- data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
- data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
- data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
- data/fixtures/padrino-helpers-app/config.rb +1 -1
- data/fixtures/page-classes-app/config.rb +2 -2
- data/fixtures/page-helper-layout-block-app/config.rb +1 -1
- data/fixtures/page-id-app/config-proc.rb +4 -4
- data/fixtures/page-id-app/config.rb +3 -3
- data/fixtures/page-id-app/source/{forty-two.html.erb → fourty-two.html.erb} +0 -0
- data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
- data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
- data/fixtures/partials-app/source/_locals.erb +1 -1
- data/fixtures/partials-app/source/locals.html.erb +1 -1
- data/fixtures/proxy-pages-app/config.rb +14 -13
- data/fixtures/sass-assets-path-app/config.rb +2 -2
- data/fixtures/scss-app/source/stylesheets/error.css.sass +1 -0
- data/fixtures/sinatra-app/config.rb +6 -6
- data/fixtures/traversal-app/config.rb +4 -4
- data/fixtures/v4-extension-callbacks/config.rb +2 -2
- data/fixtures/wildcard-app/config.rb +1 -1
- data/fixtures/wildcard-directory-index-app/config.rb +1 -1
- data/lib/middleman/rack.rb +7 -0
- data/lib/middleman-core/application.rb +9 -10
- data/lib/middleman-core/builder.rb +21 -50
- data/lib/middleman-core/callback_manager.rb +1 -1
- data/lib/middleman-core/config_context.rb +2 -2
- data/lib/middleman-core/configuration.rb +5 -5
- data/lib/middleman-core/contracts.rb +2 -2
- data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
- data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
- data/lib/middleman-core/core_extensions/collections.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +11 -11
- data/lib/middleman-core/core_extensions/default_helpers.rb +29 -26
- data/lib/middleman-core/core_extensions/external_helpers.rb +1 -1
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
- data/lib/middleman-core/core_extensions/i18n.rb +23 -44
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +7 -10
- data/lib/middleman-core/core_extensions/routing.rb +1 -1
- data/lib/middleman-core/core_extensions.rb +2 -2
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
- data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
- data/lib/middleman-core/dns_resolver.rb +1 -1
- data/lib/middleman-core/extension.rb +32 -34
- data/lib/middleman-core/extension_manager.rb +2 -6
- data/lib/middleman-core/extensions/asset_hash.rb +22 -24
- data/lib/middleman-core/extensions/asset_host.rb +10 -10
- data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
- data/lib/middleman-core/extensions/cache_buster.rb +2 -2
- data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +9 -14
- data/lib/middleman-core/extensions/gzip.rb +6 -8
- data/lib/middleman-core/extensions/lorem.rb +9 -9
- data/lib/middleman-core/extensions/minify_css.rb +16 -14
- data/lib/middleman-core/extensions/minify_javascript.rb +13 -13
- data/lib/middleman-core/extensions/relative_assets.rb +8 -8
- data/lib/middleman-core/extensions.rb +7 -8
- data/lib/middleman-core/file_renderer.rb +6 -7
- data/lib/middleman-core/load_paths.rb +10 -13
- data/lib/middleman-core/logger.rb +4 -3
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
- data/lib/middleman-core/meta_pages.rb +1 -1
- data/lib/middleman-core/preview_server/checks.rb +1 -1
- data/lib/middleman-core/preview_server/information.rb +13 -13
- data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
- data/lib/middleman-core/preview_server/server_information.rb +1 -1
- data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +1 -1
- data/lib/middleman-core/preview_server/server_url.rb +1 -1
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
- data/lib/middleman-core/preview_server.rb +25 -25
- data/lib/middleman-core/rack.rb +1 -1
- data/lib/middleman-core/renderers/coffee_script.rb +2 -2
- data/lib/middleman-core/renderers/haml.rb +4 -8
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +2 -3
- data/lib/middleman-core/renderers/markdown.rb +7 -7
- data/lib/middleman-core/renderers/redcarpet.rb +2 -2
- data/lib/middleman-core/renderers/sass.rb +23 -26
- data/lib/middleman-core/renderers/sass_functions.rb +14 -17
- data/lib/middleman-core/renderers/slim.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -2
- data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/proxies.rb +1 -2
- data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/traversal.rb +25 -80
- data/lib/middleman-core/sitemap/resource.rb +20 -21
- data/lib/middleman-core/sitemap/store.rb +6 -6
- data/lib/middleman-core/sources/source_watcher.rb +11 -17
- data/lib/middleman-core/sources.rb +12 -12
- data/lib/middleman-core/step_definitions/builder_steps.rb +12 -38
- data/lib/middleman-core/step_definitions/commandline_steps.rb +6 -6
- data/lib/middleman-core/step_definitions/middleman_steps.rb +14 -13
- data/lib/middleman-core/step_definitions/server_steps.rb +16 -18
- data/lib/middleman-core/template_context.rb +10 -17
- data/lib/middleman-core/template_renderer.rb +33 -35
- data/lib/middleman-core/util/binary.rb +1 -3
- data/lib/middleman-core/util/data.rb +22 -12
- data/lib/middleman-core/util/files.rb +3 -3
- data/lib/middleman-core/util/paths.rb +44 -47
- data/lib/middleman-core/util/rack.rb +3 -3
- data/lib/middleman-core/util/uri_templates.rb +0 -1
- data/lib/middleman-core/util.rb +2 -2
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +3 -3
- data/middleman-core.gemspec +13 -12
- data/spec/middleman-core/callbacks_spec.rb +14 -15
- data/spec/middleman-core/core_extensions/data_spec.rb +74 -70
- data/spec/middleman-core/dns_resolver_spec.rb +6 -6
- data/spec/middleman-core/util_spec.rb +86 -81
- data/spec/spec_helper.rb +6 -1
- data/spec/support/given.rb +15 -11
- metadata +59 -76
- data/features/multiple-sources-reload.feature +0 -40
- data/fixtures/chained-app/source/stylesheets/main.css.scss.erb +0 -3
- data/fixtures/chained-app/source/stylesheets/sub.scss +0 -1
- data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +0 -1
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +0 -2
- data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +0 -1
- data/fixtures/i18n-default-app/source/name.html.erb +0 -1
- data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +0 -9
- data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +0 -9
- data/fixtures/i18n-test-app/source/localizable/tac.html.erb +0 -1
- data/fixtures/multiple-sources-with-destination-dir/config.rb +0 -2
- data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +0 -1
- data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/config.rb +0 -1
- data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +0 -1
- 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
|
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
|
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
|
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
|
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[
|
241
|
+
@_lookup_by_path[resource.path] = resource
|
242
242
|
end
|
243
243
|
|
244
244
|
@resources.each do |resource|
|
245
|
-
@_lookup_by_destination_path[
|
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.
|
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
|
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
|
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
|
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
|
360
|
+
listener_running = @listener && @listener.processing?
|
367
361
|
|
368
362
|
stop_listener! if listener_running
|
369
363
|
|
370
364
|
yield
|
371
365
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
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 =
|
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
|
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
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
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
|
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
|
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 %
|
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 %
|
18
|
-
step %
|
19
|
-
step %
|
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 %
|
30
|
-
step %
|
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 %
|
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 %
|
44
|
-
step %
|
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 |
|
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(
|
3
|
+
Timeout.timeout(exit_timeout) do
|
4
4
|
loop do
|
5
|
-
|
5
|
+
fail "You need to start middleman interactively first." unless @interactive
|
6
6
|
|
7
|
-
if
|
8
|
-
|
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
|
-
|
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 |
|
4
|
-
|
5
|
-
|
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 %
|
11
|
-
step %
|
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(
|
21
|
+
next if File.basename(expand_path(".")) == path
|
21
22
|
|
22
|
-
step %
|
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 %
|
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 %
|
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(
|
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(
|
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(
|
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
|
-
|
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 <<
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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 %
|
65
|
-
step %
|
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 %
|
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
|
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(
|
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
|
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
|
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
|
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
|