middleman-core 3.0.0 → 3.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/.cane +2 -0
  2. data/.cane-exclusions.yml +5 -0
  3. data/Rakefile +1 -1
  4. data/bin/middleman +9 -55
  5. data/features/cli_extension.feature +1 -0
  6. data/features/frontmatter_page_settings.feature +11 -1
  7. data/features/instance_vars.feature +9 -0
  8. data/features/step_definitions/page_layout_steps.rb +3 -3
  9. data/features/strip_url.feature +40 -0
  10. data/features/support/env.rb +1 -1
  11. data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
  12. data/fixtures/basic-data-app/config.rb +1 -1
  13. data/fixtures/build-with-errors-app/config.rb +1 -1
  14. data/fixtures/clean-app/config-complications.rb +1 -1
  15. data/fixtures/clean-app/config.rb +1 -1
  16. data/fixtures/current-page-app/config.rb +1 -1
  17. data/fixtures/custom-layout-app/config.rb +1 -1
  18. data/fixtures/data-app/config.rb +1 -1
  19. data/fixtures/external-helpers/config.rb +1 -1
  20. data/fixtures/external-helpers/helpers/derp.rb +1 -1
  21. data/fixtures/external-helpers/helpers/four_helpers.rb +1 -1
  22. data/fixtures/external-helpers/helpers/one_helper.rb +1 -1
  23. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -1
  24. data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
  25. data/fixtures/feature-params-app/config.rb +1 -1
  26. data/fixtures/frontmatter-settings-app/config.rb +3 -1
  27. data/fixtures/frontmatter-settings-app/source/layouts/override.erb +2 -0
  28. data/fixtures/frontmatter-settings-app/source/override_layout.html.erb +4 -0
  29. data/fixtures/frontmatter-settings-app/source/page_mentioned.html.erb +4 -0
  30. data/fixtures/generator-test/config.rb +10 -10
  31. data/fixtures/glob-app/config.rb +1 -1
  32. data/fixtures/instance-vars-app/config.rb +7 -0
  33. data/fixtures/instance-vars-app/source/content.html.erb +2 -0
  34. data/fixtures/instance-vars-app/source/layout.erb +1 -0
  35. data/fixtures/large-build-app/config.rb +1 -1
  36. data/fixtures/large-build-app/source/images/Child folder/regular_file(example).txt +1 -1
  37. data/fixtures/large-build-app/source/images/Read me (example).txt +1 -1
  38. data/fixtures/manual-layout-missing/config.rb +1 -1
  39. data/fixtures/manual-layout-override/config.rb +1 -1
  40. data/fixtures/manual-layout/config.rb +1 -1
  41. data/fixtures/page-helper-layout-block-app/config.rb +1 -1
  42. data/fixtures/sinatra-app/config.rb +1 -1
  43. data/fixtures/strip-url-app/config.rb +0 -0
  44. data/fixtures/strip-url-app/source/index.html.erb +1 -0
  45. data/fixtures/strip-url-app/source/other.html.erb +1 -0
  46. data/fixtures/strip-url-app/source/subdir/index.html.erb +1 -0
  47. data/fixtures/traversal-app/config.rb +1 -1
  48. data/fixtures/wildcard-app/config.rb +1 -1
  49. data/lib/middleman-core.rb +3 -3
  50. data/lib/middleman-core/application.rb +12 -11
  51. data/lib/middleman-core/cli.rb +23 -10
  52. data/lib/middleman-core/cli/build.rb +65 -54
  53. data/lib/middleman-core/cli/bundler.rb +7 -7
  54. data/lib/middleman-core/cli/extension.rb +25 -12
  55. data/lib/middleman-core/cli/init.rb +19 -19
  56. data/lib/middleman-core/cli/server.rb +25 -16
  57. data/lib/middleman-core/core_extensions/builder.rb +3 -3
  58. data/lib/middleman-core/core_extensions/data.rb +28 -28
  59. data/lib/middleman-core/core_extensions/extensions.rb +24 -25
  60. data/lib/middleman-core/core_extensions/external_helpers.rb +7 -7
  61. data/lib/middleman-core/core_extensions/file_watcher.rb +41 -38
  62. data/lib/middleman-core/core_extensions/front_matter.rb +36 -33
  63. data/lib/middleman-core/core_extensions/rendering.rb +49 -46
  64. data/lib/middleman-core/core_extensions/request.rb +34 -33
  65. data/lib/middleman-core/core_extensions/routing.rb +17 -17
  66. data/lib/middleman-core/core_extensions/ruby_encoding.rb +1 -1
  67. data/lib/middleman-core/core_extensions/show_exceptions.rb +5 -5
  68. data/lib/middleman-core/extensions.rb +4 -4
  69. data/lib/middleman-core/load_paths.rb +56 -0
  70. data/lib/middleman-core/logger.rb +29 -0
  71. data/lib/middleman-core/preview_server.rb +35 -34
  72. data/lib/middleman-core/profiling.rb +58 -0
  73. data/lib/middleman-core/renderers/coffee_script.rb +8 -6
  74. data/lib/middleman-core/renderers/erb.rb +5 -5
  75. data/lib/middleman-core/renderers/haml.rb +5 -5
  76. data/lib/middleman-core/renderers/less.rb +14 -10
  77. data/lib/middleman-core/renderers/liquid.rb +7 -7
  78. data/lib/middleman-core/renderers/markdown.rb +13 -14
  79. data/lib/middleman-core/renderers/redcarpet.rb +31 -11
  80. data/lib/middleman-core/renderers/sass.rb +38 -22
  81. data/lib/middleman-core/renderers/slim.rb +15 -7
  82. data/lib/middleman-core/sitemap.rb +25 -28
  83. data/lib/middleman-core/sitemap/extensions/ignores.rb +13 -13
  84. data/lib/middleman-core/sitemap/extensions/on_disk.rb +12 -12
  85. data/lib/middleman-core/sitemap/extensions/proxies.rb +26 -20
  86. data/lib/middleman-core/sitemap/extensions/traversal.rb +10 -10
  87. data/lib/middleman-core/sitemap/resource.rb +47 -50
  88. data/lib/middleman-core/sitemap/store.rb +38 -36
  89. data/lib/middleman-core/step_definitions.rb +1 -1
  90. data/lib/middleman-core/step_definitions/builder_steps.rb +1 -1
  91. data/lib/middleman-core/step_definitions/middleman_steps.rb +3 -3
  92. data/lib/middleman-core/step_definitions/server_steps.rb +5 -5
  93. data/lib/middleman-core/templates.rb +12 -12
  94. data/lib/middleman-core/templates/default.rb +11 -11
  95. data/lib/middleman-core/templates/extension/Gemfile +14 -1
  96. data/lib/middleman-core/templates/extension/Rakefile +3 -1
  97. data/lib/middleman-core/templates/extension/features/support/env.rb +1 -1
  98. data/lib/middleman-core/templates/extension/gitignore +2 -0
  99. data/lib/middleman-core/templates/extension/lib/lib.rb +11 -11
  100. data/lib/middleman-core/templates/extension/lib/middleman_extension.rb +1 -1
  101. data/lib/middleman-core/templates/html5.rb +10 -10
  102. data/lib/middleman-core/templates/html5/source/humans.txt +0 -0
  103. data/lib/middleman-core/templates/html5/source/robots.txt +0 -0
  104. data/lib/middleman-core/templates/local.rb +4 -4
  105. data/lib/middleman-core/templates/mobile.rb +3 -3
  106. data/lib/middleman-core/templates/mobile/source/humans.txt +0 -0
  107. data/lib/middleman-core/templates/mobile/source/robots.txt +0 -0
  108. data/lib/middleman-core/templates/shared/config.ru +1 -1
  109. data/lib/middleman-core/templates/shared/config.tt +10 -10
  110. data/lib/middleman-core/util.rb +30 -6
  111. data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb +19 -19
  112. data/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +2 -2
  113. data/lib/middleman-core/vendor/hooks-0.2.0/test/hooks_test.rb +29 -29
  114. data/lib/middleman-core/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +11 -11
  115. data/lib/middleman-core/version.rb +1 -1
  116. data/lib/middleman/rack.rb +4 -0
  117. data/middleman-core-x86-mingw32.gemspec +38 -0
  118. data/middleman-core.gemspec +3 -2
  119. metadata +72 -11
@@ -2,32 +2,33 @@ require "middleman-core/sitemap/extensions/traversal"
2
2
 
3
3
  module Middleman
4
4
 
5
- # Sitemap namespace
5
+ # Sitemap namespace
6
6
  module Sitemap
7
-
7
+
8
8
  # Sitemap Resource class
9
9
  class Resource
10
10
  include Middleman::Sitemap::Extensions::Traversal
11
-
11
+
12
12
  # @return [Middleman::Application]
13
13
  attr_reader :app
14
-
14
+ delegate :logger, :instrument, :to => :app
15
+
15
16
  # @return [Middleman::Sitemap::Store]
16
17
  attr_reader :store
17
-
18
+
18
19
  # The source path of this resource (relative to the source directory,
19
20
  # without template extensions)
20
21
  # @return [String]
21
22
  attr_reader :path
22
-
23
+
23
24
  # Set the on-disk source file for this resource
24
25
  # @return [String]
25
26
  # attr_reader :source_file
26
-
27
+
27
28
  def source_file
28
29
  @source_file || get_source_file
29
30
  end
30
-
31
+
31
32
  # Initialize resource with parent store and URL
32
33
  # @param [Middleman::Sitemap::Store] store
33
34
  # @param [String] path
@@ -37,40 +38,38 @@ module Middleman
37
38
  @app = @store.app
38
39
  @path = path
39
40
  @source_file = source_file
40
-
41
+
41
42
  @destination_paths = [@path]
42
43
 
43
44
  @local_metadata = { :options => {}, :locals => {}, :page => {}, :blocks => [] }
44
45
  end
45
-
46
+
46
47
  # Whether this resource has a template file
47
48
  # @return [Boolean]
48
49
  def template?
49
50
  return false if source_file.nil?
50
51
  !::Tilt[source_file].nil?
51
52
  end
52
-
53
+
53
54
  # Get the metadata for both the current source_file and the current path
54
55
  # @return [Hash]
55
56
  def metadata
56
- result = store.metadata_for_file(source_file).dup
57
+ result = store.metadata_for_path(path).dup
57
58
 
58
- path_meta = store.metadata_for_path(path).dup
59
- if path_meta.has_key?(:blocks)
60
- result[:blocks] << path_meta[:blocks]
61
- path_meta.delete(:blocks)
59
+ file_meta = store.metadata_for_file(source_file).dup
60
+ if file_meta.has_key?(:blocks)
61
+ result[:blocks] << file_meta.delete(:blocks)
62
62
  end
63
- result.deep_merge!(path_meta)
63
+ result.deep_merge!(file_meta)
64
64
 
65
65
  local_meta = @local_metadata.dup
66
66
  if local_meta.has_key?(:blocks)
67
- result[:blocks] << local_meta[:blocks]
68
- local_meta.delete(:blocks)
67
+ result[:blocks] << local_meta.delete(:blocks)
69
68
  end
70
69
  result.deep_merge!(local_meta)
71
70
 
72
71
  result[:blocks] = result[:blocks].flatten.compact
73
-
72
+
74
73
  result
75
74
  end
76
75
 
@@ -78,74 +77,72 @@ module Middleman
78
77
  # @param [Hash] metadata A metadata block like provides_metadata_for_path takes
79
78
  def add_metadata(metadata={}, &block)
80
79
  if metadata.has_key?(:blocks)
81
- @local_metadata[:blocks] << metadata[:blocks]
82
- metadata.delete(:blocks)
80
+ @local_metadata[:blocks] << metadata.delete(:blocks)
83
81
  end
84
82
  @local_metadata.deep_merge!(metadata)
85
83
  @local_metadata[:blocks] << block if block_given?
86
84
  end
87
-
85
+
88
86
  # Get the output/preview URL for this resource
89
87
  # @return [String]
90
88
  def destination_path
91
89
  @destination_paths.last
92
90
  end
93
-
91
+
94
92
  # Set the output/preview URL for this resource
95
93
  # @param [String] path
96
94
  # @return [void]
97
95
  def destination_path=(path)
98
96
  @destination_paths << path
99
97
  end
100
-
98
+
101
99
  # Extension of the path (i.e. '.js')
102
100
  # @return [String]
103
101
  def ext
104
102
  File.extname(path)
105
103
  end
106
-
104
+
107
105
  # Mime type of the path
108
106
  # @return [String]
109
107
  def mime_type
110
108
  app.mime_type ext
111
109
  end
112
-
110
+
113
111
  # Render this resource
114
112
  # @return [String]
115
113
  def render(opts={}, locs={}, &block)
116
114
  return File.open(source_file).read unless template?
117
-
118
- start_time = Time.now
119
- puts "== Render Start: #{source_file}" if app.logging?
120
115
 
121
- md = metadata.dup
122
- opts = md[:options].deep_merge(opts)
123
- locs = md[:locals].deep_merge(locs)
116
+ relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))
124
117
 
125
- # Forward remaining data to helpers
126
- if md.has_key?(:page)
127
- app.data.store("page", md[:page])
128
- end
118
+ instrument "render.resource", :path => relative_source do
119
+ md = metadata.dup
120
+ opts = md[:options].deep_merge(opts)
121
+ locs = md[:locals].deep_merge(locs)
129
122
 
130
- md[:blocks].each do |aBlock|
131
- app.instance_eval(&aBlock)
132
- end
133
-
134
- app.instance_eval(&block) if block_given?
135
-
136
- app.current_path ||= self.destination_path
137
- result = app.render_template(source_file, locs, opts)
123
+ # Forward remaining data to helpers
124
+ if md.has_key?(:page)
125
+ app.data.store("page", md[:page])
126
+ end
138
127
 
139
- puts "== Render End: #{source_file} (#{(Time.now - start_time).round(2)}s)" if app.logging?
140
- result
128
+ blocks = md[:blocks].dup rescue []
129
+ blocks << block if block_given?
130
+
131
+ app.current_path ||= self.destination_path
132
+ app.render_template(source_file, locs, opts, blocks)
133
+ end
141
134
  end
142
-
135
+
143
136
  # A path without the directory index - so foo/index.html becomes
144
137
  # just foo. Best for linking.
145
138
  # @return [String]
146
139
  def url
147
- File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/',
148
- destination_path.sub(/\/#{Regexp.escape(app.index_file)}$/, '/'))
140
+ url_path = destination_path
141
+ if app.strip_index_file
142
+ url_path = url_path.sub(/(^|\/)#{Regexp.escape(app.index_file)}$/,
143
+ app.trailing_slash ? '/' : '')
144
+ end
145
+ File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/', url_path)
149
146
  end
150
147
  end
151
148
  end
@@ -2,10 +2,10 @@
2
2
  require "active_support/core_ext/hash/deep_merge"
3
3
 
4
4
  module Middleman
5
-
5
+
6
6
  # Sitemap namespace
7
7
  module Sitemap
8
-
8
+
9
9
  # The Store class
10
10
  #
11
11
  # The Store manages a collection of Resource objects, which represent
@@ -13,10 +13,10 @@ module Middleman
13
13
  # which is the path relative to the source directory, minus any template
14
14
  # extensions. All "path" parameters used in this class are source paths.
15
15
  class Store
16
-
16
+
17
17
  # @return [Middleman::Application]
18
18
  attr_accessor :app
19
-
19
+
20
20
  # Initialize with parent app
21
21
  # @param [Middleman::Application] app
22
22
  def initialize(app)
@@ -25,10 +25,10 @@ module Middleman
25
25
  @_cached_metadata = {}
26
26
  @_lookup_cache = { :path => {}, :destination_path => {} }
27
27
  @resource_list_manipulators = []
28
-
28
+
29
29
  # Register classes which can manipulate the main site map list
30
30
  register_resource_list_manipulator(:on_disk, Middleman::Sitemap::Extensions::OnDisk.new(self), false)
31
-
31
+
32
32
  # Proxies
33
33
  register_resource_list_manipulator(:proxies, @app.proxy_manager, false)
34
34
  end
@@ -42,22 +42,24 @@ module Middleman
42
42
  @resource_list_manipulators << [name, inst]
43
43
  rebuild_resource_list!(:registered_new) if immediately_rebuild
44
44
  end
45
-
45
+
46
46
  # Rebuild the list of resources from scratch, using registed manipulators
47
47
  # @return [void]
48
48
  def rebuild_resource_list!(reason=nil)
49
49
  @resources = @resource_list_manipulators.inject([]) do |result, (_, inst)|
50
- inst.manipulate_resource_list(result)
51
- end
52
-
53
- # Reset lookup cache
54
- @_lookup_cache = { :path => {}, :destination_path => {} }
55
- @resources.each do |resource|
56
- @_lookup_cache[:path][resource.path] = resource
57
- @_lookup_cache[:destination_path][resource.destination_path] = resource
50
+ newres = inst.manipulate_resource_list(result)
51
+
52
+ # Reset lookup cache
53
+ @_lookup_cache = { :path => {}, :destination_path => {} }
54
+ newres.each do |resource|
55
+ @_lookup_cache[:path][resource.path] = resource
56
+ @_lookup_cache[:destination_path][resource.destination_path] = resource
57
+ end
58
+
59
+ newres
58
60
  end
59
61
  end
60
-
62
+
61
63
  # Find a resource given its original path
62
64
  # @param [String] request_path The original path of a resource.
63
65
  # @return [Middleman::Sitemap::Resource]
@@ -65,7 +67,7 @@ module Middleman
65
67
  request_path = ::Middleman::Util.normalize_path(request_path)
66
68
  @_lookup_cache[:path][request_path]
67
69
  end
68
-
70
+
69
71
  # Find a resource given its destination path
70
72
  # @param [String] request_path The destination (output) path of a resource.
71
73
  # @return [Middleman::Sitemap::Resource]
@@ -73,7 +75,7 @@ module Middleman
73
75
  request_path = ::Middleman::Util.normalize_path(request_path)
74
76
  @_lookup_cache[:destination_path][request_path]
75
77
  end
76
-
78
+
77
79
  # Get the array of all resources
78
80
  # @param [Boolean] include_ignored Whether to include ignored resources
79
81
  # @return [Array<Middleman::Sitemap::Resource>]
@@ -84,7 +86,7 @@ module Middleman
84
86
  @resources.reject(&:ignored?)
85
87
  end
86
88
  end
87
-
89
+
88
90
  # Register a handler to provide metadata on a file path
89
91
  # @param [Regexp] matcher
90
92
  # @return [Array<Array<Proc, Regexp>>]
@@ -93,16 +95,16 @@ module Middleman
93
95
  @_provides_metadata << [block, matcher] if block_given?
94
96
  @_provides_metadata
95
97
  end
96
-
98
+
97
99
  # Get the metadata for a specific file
98
100
  # @param [String] source_file
99
101
  # @return [Hash]
100
102
  def metadata_for_file(source_file)
101
103
  blank_metadata = { :options => {}, :locals => {}, :page => {}, :blocks => [] }
102
-
104
+
103
105
  provides_metadata.inject(blank_metadata) do |result, (callback, matcher)|
104
106
  next result if !matcher.nil? && !source_file.match(matcher)
105
-
107
+
106
108
  metadata = callback.call(source_file)
107
109
 
108
110
  if metadata.has_key?(:blocks)
@@ -113,10 +115,10 @@ module Middleman
113
115
  result.deep_merge(metadata)
114
116
  end
115
117
  end
116
-
118
+
117
119
  # Register a handler to provide metadata on a url path
118
120
  # @param [Regexp] matcher
119
- # @param [Symbol] origin an indicator of where this metadata came from - only one
121
+ # @param [Symbol] origin an indicator of where this metadata came from - only one
120
122
  # block per [matcher, origin] pair may exist.
121
123
  # @return [Array<Array<Proc, Regexp>>]
122
124
  def provides_metadata_for_path(matcher=nil, origin=nil, &block)
@@ -136,7 +138,7 @@ module Middleman
136
138
  end
137
139
  @_provides_metadata_for_path
138
140
  end
139
-
141
+
140
142
  # Get the metadata for a specific URL
141
143
  # @param [String] request_path
142
144
  # @return [Hash]
@@ -144,7 +146,7 @@ module Middleman
144
146
  return @_cached_metadata[request_path] if @_cached_metadata[request_path]
145
147
 
146
148
  blank_metadata = { :options => {}, :locals => {}, :page => {}, :blocks => [] }
147
-
149
+
148
150
  @_cached_metadata[request_path] = provides_metadata_for_path.inject(blank_metadata) do |result, (callback, matcher)|
149
151
  case matcher
150
152
  when Regexp
@@ -152,9 +154,9 @@ module Middleman
152
154
  when String
153
155
  next result unless File.fnmatch("/" + matcher.sub(%r{^/}, ''), "/#{request_path}")
154
156
  end
155
-
157
+
156
158
  metadata = callback.call(request_path)
157
-
159
+
158
160
  if metadata.has_key?(:blocks)
159
161
  result[:blocks] << metadata[:blocks]
160
162
  metadata.delete(:blocks)
@@ -163,26 +165,26 @@ module Middleman
163
165
  result.deep_merge(metadata)
164
166
  end
165
167
  end
166
-
168
+
167
169
  # Get the URL path for an on-disk file
168
170
  # @param [String] file
169
171
  # @return [String]
170
172
  def file_to_path(file)
171
173
  file = File.expand_path(file, @app.root)
172
-
174
+
173
175
  prefix = @app.source_dir.sub(/\/$/, "") + "/"
174
- return false unless file.include?(prefix)
175
-
176
+ return false unless file.start_with?(prefix)
177
+
176
178
  path = file.sub(prefix, "")
177
-
179
+
178
180
  # Replace a file name containing automatic_directory_matcher with a folder
179
181
  unless @app.automatic_directory_matcher.nil?
180
182
  path = path.gsub(@app.automatic_directory_matcher, "/")
181
183
  end
182
-
184
+
183
185
  extensionless_path(path)
184
186
  end
185
-
187
+
186
188
  # Get a path without templating extensions
187
189
  # @param [String] file
188
190
  # @return [String]
@@ -214,4 +216,4 @@ module Middleman
214
216
  end
215
217
  end
216
218
  end
217
- end
219
+ end
@@ -9,4 +9,4 @@ require "middleman-core/step_definitions/server_steps"
9
9
 
10
10
  Before do
11
11
  @aruba_timeout_seconds = 30
12
- end
12
+ end
@@ -21,7 +21,7 @@ Given /^a fixture app "([^\"]*)"$/ do |path|
21
21
 
22
22
  target_path = File.join(PROJECT_ROOT_PATH, "fixtures", path)
23
23
  FileUtils.cp_r(target_path, current_dir)
24
-
24
+
25
25
  step %Q{I cd to "#{path}"}
26
26
  end
27
27
 
@@ -9,9 +9,9 @@ Then /^the file "([^\"]*)" is removed$/ do |path|
9
9
  end
10
10
 
11
11
  Then /^the file "([^\"]*)" did change$/ do |path|
12
- @server_inst.files.did_change(@server_inst.root_path + path)
12
+ @server_inst.files.did_change(path)
13
13
  end
14
14
 
15
15
  Then /^the file "([^\"]*)" did delete$/ do |path|
16
- @server_inst.files.did_delete(@server_inst.root_path + path)
17
- end
16
+ @server_inst.files.did_delete(path)
17
+ end
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
10
10
  @initialize_commands ||= []
11
-
11
+
12
12
  if state == "enabled"
13
13
  @initialize_commands << lambda { activate(feature.to_sym) }
14
14
  end
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  Given /^"([^\"]*)" feature is "enabled" with "([^\"]*)"$/ do |feature, options_str|
18
18
  @initialize_commands ||= []
19
-
19
+
20
20
  options = eval("{#{options_str}}")
21
21
 
22
22
  @initialize_commands << lambda { activate(feature.to_sym, options) }
@@ -39,20 +39,20 @@ Given /^the Server is running$/ do
39
39
  else
40
40
  ENV["MM_SOURCE"] = ""
41
41
  end
42
-
42
+
43
43
  initialize_commands = @initialize_commands || []
44
44
  initialize_commands.unshift lambda {
45
45
  set :root, root_dir
46
46
  set :environment, @current_env || :development
47
47
  set :show_exceptions, false
48
48
  }
49
-
49
+
50
50
  @server_inst = Middleman::Application.server.inst do
51
51
  initialize_commands.each do |p|
52
52
  instance_exec(&p)
53
53
  end
54
54
  end
55
-
55
+
56
56
  app_rack = @server_inst.class.to_rack_app
57
57
  @browser = ::Rack::Test::Session.new(::Rack::MockSession.new(app_rack))
58
58
  end