merb-core 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/Rakefile +61 -11
  2. data/bin/merb +5 -1
  3. data/lib/merb-core.rb +202 -25
  4. data/lib/merb-core/autoload.rb +19 -17
  5. data/lib/merb-core/bootloader.rb +84 -71
  6. data/lib/merb-core/config.rb +19 -14
  7. data/lib/merb-core/controller/abstract_controller.rb +16 -17
  8. data/lib/merb-core/controller/exceptions.rb +115 -70
  9. data/lib/merb-core/controller/merb_controller.rb +62 -38
  10. data/lib/merb-core/controller/mime.rb +1 -1
  11. data/lib/merb-core/controller/mixins/authentication.rb +87 -0
  12. data/lib/merb-core/controller/mixins/controller.rb +16 -15
  13. data/lib/merb-core/controller/mixins/render.rb +113 -19
  14. data/lib/merb-core/controller/mixins/responder.rb +8 -2
  15. data/lib/merb-core/controller/template.rb +1 -1
  16. data/lib/merb-core/core_ext.rb +1 -0
  17. data/lib/merb-core/core_ext/class.rb +113 -6
  18. data/lib/merb-core/core_ext/hash.rb +43 -39
  19. data/lib/merb-core/core_ext/kernel.rb +75 -38
  20. data/lib/merb-core/core_ext/mash.rb +4 -4
  21. data/lib/merb-core/core_ext/object.rb +18 -7
  22. data/lib/merb-core/core_ext/set.rb +9 -4
  23. data/lib/merb-core/core_ext/string.rb +29 -9
  24. data/lib/merb-core/core_ext/time.rb +13 -0
  25. data/lib/merb-core/dispatch/cookies.rb +1 -2
  26. data/lib/merb-core/dispatch/dispatcher.rb +18 -10
  27. data/lib/merb-core/dispatch/exceptions.html.erb +1 -1
  28. data/lib/merb-core/dispatch/request.rb +3 -0
  29. data/lib/merb-core/dispatch/router.rb +10 -7
  30. data/lib/merb-core/dispatch/router/behavior.rb +36 -27
  31. data/lib/merb-core/dispatch/router/route.rb +7 -2
  32. data/lib/merb-core/dispatch/session/cookie.rb +4 -4
  33. data/lib/merb-core/dispatch/session/memcached.rb +17 -5
  34. data/lib/merb-core/logger.rb +2 -2
  35. data/lib/merb-core/plugins.rb +16 -4
  36. data/lib/merb-core/rack/adapter/ebb.rb +4 -1
  37. data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -0
  38. data/lib/merb-core/rack/adapter/fcgi.rb +1 -0
  39. data/lib/merb-core/rack/adapter/mongrel.rb +1 -0
  40. data/lib/merb-core/rack/adapter/runner.rb +1 -0
  41. data/lib/merb-core/rack/adapter/thin.rb +3 -1
  42. data/lib/merb-core/rack/adapter/webrick.rb +1 -0
  43. data/lib/merb-core/rack/application.rb +17 -1
  44. data/lib/merb-core/server.rb +78 -28
  45. data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -3
  46. data/lib/merb-core/test/helpers/request_helper.rb +81 -27
  47. data/lib/merb-core/test/helpers/view_helper.rb +1 -1
  48. data/lib/merb-core/test/matchers/controller_matchers.rb +55 -5
  49. data/lib/merb-core/test/matchers/route_matchers.rb +8 -17
  50. data/lib/merb-core/test/matchers/view_matchers.rb +53 -11
  51. data/lib/merb-core/test/run_specs.rb +22 -14
  52. data/lib/merb-core/test/tasks/spectasks.rb +54 -33
  53. data/lib/merb-core/vendor/facets/inflect.rb +91 -2
  54. data/lib/merb-core/version.rb +2 -2
  55. data/spec/private/config/config_spec.rb +54 -26
  56. data/spec/private/core_ext/class_spec.rb +22 -0
  57. data/spec/private/core_ext/hash_spec.rb +70 -54
  58. data/spec/private/core_ext/kernel_spec.rb +149 -14
  59. data/spec/private/core_ext/object_spec.rb +92 -10
  60. data/spec/private/core_ext/string_spec.rb +162 -4
  61. data/spec/private/core_ext/time_spec.rb +16 -0
  62. data/spec/private/dispatch/bootloader_spec.rb +24 -0
  63. data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +1 -1
  64. data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +1 -1
  65. data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +1 -1
  66. data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +1 -1
  67. data/spec/private/dispatch/fixture/config/black_hole.rb +12 -0
  68. data/spec/private/dispatch/fixture/log/merb_test.log +138 -0
  69. data/spec/private/plugins/plugin_spec.rb +79 -8
  70. data/spec/private/rack/application_spec.rb +1 -1
  71. data/spec/public/abstract_controller/controllers/filters.rb +26 -0
  72. data/spec/public/abstract_controller/controllers/helpers.rb +2 -2
  73. data/spec/public/abstract_controller/controllers/partial.rb +2 -2
  74. data/spec/public/abstract_controller/controllers/render.rb +16 -4
  75. data/spec/public/abstract_controller/filter_spec.rb +8 -0
  76. data/spec/public/abstract_controller/render_spec.rb +12 -0
  77. data/spec/public/controller/authentication_spec.rb +103 -0
  78. data/spec/public/controller/base_spec.rb +4 -3
  79. data/spec/public/controller/controllers/authentication.rb +47 -0
  80. data/spec/public/controller/controllers/base.rb +1 -0
  81. data/spec/public/controller/controllers/display.rb +30 -0
  82. data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +1 -0
  83. data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +1 -0
  84. data/spec/public/controller/display_spec.rb +17 -0
  85. data/spec/public/controller/spec_helper.rb +1 -0
  86. data/spec/public/controller/url_spec.rb +25 -7
  87. data/spec/public/core/merb_core_spec.rb +34 -0
  88. data/spec/public/directory_structure/directory/app/controllers/custom.rb +2 -2
  89. data/spec/public/directory_structure/directory/log/merb_test.log +48 -0
  90. data/spec/public/logger/logger_spec.rb +10 -4
  91. data/spec/public/reloading/directory/app/controllers/reload.rb +1 -1
  92. data/spec/public/reloading/directory/log/merb_test.log +13 -0
  93. data/spec/public/reloading/reload_spec.rb +23 -22
  94. data/spec/public/request/request_spec.rb +2 -0
  95. data/spec/public/router/nested_resources_spec.rb +7 -0
  96. data/spec/public/router/resources_spec.rb +46 -1
  97. data/spec/public/router/special_spec.rb +5 -1
  98. data/spec/public/test/controller_matchers_spec.rb +25 -1
  99. data/spec/public/test/controllers/spec_helper_controller.rb +8 -0
  100. data/spec/public/test/request_helper_spec.rb +52 -1
  101. data/spec/public/test/route_matchers_spec.rb +27 -25
  102. data/spec/public/test/view_helper_spec.rb +1 -1
  103. data/spec/public/test/view_matchers_spec.rb +148 -72
  104. metadata +23 -3
@@ -9,7 +9,7 @@ module Kernel
9
9
  def dependency(name, *ver)
10
10
  Merb::BootLoader::Dependencies.dependencies << [name, ver]
11
11
  end
12
-
12
+
13
13
  # Loads the given string as a gem.
14
14
  #
15
15
  # ==== Parameters
@@ -28,21 +28,21 @@ module Kernel
28
28
  try_framework = Merb.frozen?
29
29
  begin
30
30
  # If this is a piece of merb, and we're frozen, try to require
31
- # first, so we can pick it up from framework/,
31
+ # first, so we can pick it up from framework/,
32
32
  # otherwise try activating the gem
33
33
  if name =~ /^merb/ && try_framework
34
34
  require name
35
35
  else
36
36
  gem(name, *ver) if ver
37
37
  require name
38
- Merb.logger.info!("loading gem '#{name}' from #{__app_file_trace__.first} ...")
38
+ Merb.logger.info!("loading gem '#{name}' ...")
39
39
  end
40
40
  rescue LoadError
41
41
  if try_framework
42
42
  try_framework = false
43
43
  retry
44
44
  else
45
- Merb.logger.info!("loading gem '#{name}' from #{__app_file_trace__.first} ...")
45
+ Merb.logger.info!("loading gem '#{name}' ...")
46
46
  # Failed requiring as a gem, let's try loading with a normal require.
47
47
  require name
48
48
  end
@@ -63,7 +63,7 @@ module Kernel
63
63
  end
64
64
  end
65
65
  end
66
-
66
+
67
67
  # Loads both gem and library dependencies that are passed in as arguments.
68
68
  #
69
69
  # ==== Parameters
@@ -89,7 +89,7 @@ module Kernel
89
89
  end
90
90
  end
91
91
  end
92
-
92
+
93
93
  # Does a basic require, and prints a message if an error occurs.
94
94
  #
95
95
  # ==== Parameters
@@ -100,7 +100,7 @@ module Kernel
100
100
  rescue LoadError, RuntimeError
101
101
  Merb.logger.error!(message) if message
102
102
  end
103
-
103
+
104
104
  # Used in Merb.root/config/init.rb to tell Merb which ORM (Object Relational
105
105
  # Mapper) you wish to use. Currently Merb has plugins to support
106
106
  # ActiveRecord, DataMapper, and Sequel.
@@ -115,20 +115,46 @@ module Kernel
115
115
  # # This will use the DataMapper generator for your ORM
116
116
  # $ ruby script/generate model MyModel
117
117
  def use_orm(orm)
118
- if !Merb.generator_scope.include?(:merb_default) && !Merb.generator_scope.include?(orm.to_sym)
119
- raise "Don't call use_orm more than once"
120
- end
118
+ raise "Don't call use_orm more than once" if registred_orm?(orm)
119
+
121
120
  begin
122
121
  Merb.generator_scope.delete(:merb_default)
123
- orm_plugin = orm.to_s.match(/^merb_/) ? orm.to_s : "merb_#{orm}"
124
- Merb.generator_scope.unshift(orm.to_sym) unless Merb.generator_scope.include?(orm.to_sym)
122
+ register_orm(orm)
123
+ orm_plugin = "merb_#{orm}"
125
124
  Kernel.dependency(orm_plugin)
126
125
  rescue LoadError => e
127
126
  Merb.logger.warn!("The #{orm_plugin} gem was not found. You may need to install it.")
128
127
  raise e
129
128
  end
130
129
  end
131
-
130
+
131
+ # Use to check whether given ORM already registred at generator scope
132
+ #
133
+ # ==== Parameters
134
+ # orm<~to_sym>::
135
+ # ORM alias, like :activerecord, :datamapper or :sequel.
136
+ #
137
+ # ==== Returns
138
+ # Boolean::
139
+ # true if ORM is already registred, false otherwise
140
+ #
141
+ #--
142
+ # @semi-public
143
+ def registred_orm?(orm)
144
+ !Merb.generator_scope.include?(:merb_default) && !Merb.generator_scope.include?(orm.to_sym)
145
+ end
146
+
147
+ # Registers ORM at generator scope.
148
+ #
149
+ # ==== Parameters
150
+ # orm<~to_sym>::
151
+ # ORM alias, like :activerecord, :datamapper or :sequel.
152
+ #--
153
+ # @private
154
+ def register_orm(orm)
155
+ Merb.generator_scope.unshift(orm.to_sym) unless Merb.generator_scope.include?(orm.to_sym)
156
+ end
157
+
132
158
  # Used in Merb.root/config/init.rb to tell Merb which testing framework to
133
159
  # use. Currently Merb has plugins to support RSpec and Test::Unit.
134
160
  #
@@ -143,24 +169,35 @@ module Kernel
143
169
  # # This will now use the RSpec generator for tests
144
170
  # $ ruby script/generate controller MyController
145
171
  def use_test(test_framework, *test_dependencies)
146
- raise "use_test only supports :rspec and :test_unit currently" unless
147
- [:rspec, :test_unit].include?(test_framework.to_sym)
172
+ raise "use_test only supports :rspec and :test_unit currently" unless supported_test_framework?(test_framework)
173
+ register_test_framework(test_framework)
174
+
175
+ dependencies test_dependencies if Merb.env == "test" || Merb.env.nil?
176
+ end
177
+
178
+ # Check whether Merb supports test framework. Currently Merb has plugins to support RSpec and Test::Unit.
179
+ #
180
+ # ==== Parameters
181
+ # test_framework<Symbol>::
182
+ # The test framework to check. Currently only supports :rspec and :test_unit.
183
+ #--
184
+ # @semi-public
185
+ def supported_test_framework?(test_framework)
186
+ [:rspec, :test_unit].include?(test_framework.to_sym)
187
+ end
188
+
189
+ # Register test framework at generator scope. Currently Merb has plugins to support RSpec and Test::Unit.
190
+ #
191
+ # ==== Parameters
192
+ # test_framework<Symbol>::
193
+ # The test framework to check. Currently only supports :rspec and :test_unit but the check is performed before registration if you use API.
194
+ #--
195
+ # @private
196
+ def register_test_framework(test_framework)
148
197
  Merb.generator_scope.delete(:rspec)
149
198
  Merb.generator_scope.delete(:test_unit)
199
+
150
200
  Merb.generator_scope.push(test_framework.to_sym)
151
-
152
- dependencies test_dependencies if Merb.env == "test" || Merb.env.nil?
153
- end
154
-
155
- # ==== Returns
156
- # Array[String]:: A stack trace of the applications files.
157
- def __app_file_trace__
158
- caller.select do |call|
159
- call.include?(Merb.root) && !call.include?(Merb.root + "/framework")
160
- end.map do |call|
161
- file, line = call.scan(Regexp.new("#{Merb.root}/(.*):(.*)")).first
162
- "#{file}:#{line}"
163
- end
164
201
  end
165
202
 
166
203
  # ==== Parameters
@@ -219,9 +256,9 @@ module Kernel
219
256
 
220
257
  area
221
258
  end
222
-
223
- # Takes a block, profiles the results of running the block 100 times and
224
- # writes out the results in a file.
259
+
260
+ # Takes a block, profiles the results of running the block
261
+ # specified number of times and generates HTML report.
225
262
  #
226
263
  # ==== Parameters
227
264
  # name<~to_s>::
@@ -244,8 +281,8 @@ module Kernel
244
281
  # end
245
282
  #
246
283
  # Assuming that the total time taken for #puts calls was less than 5% of the
247
- # total time to run, #puts won't appear in the profile report.
248
- # The code block will be run 30 times.
284
+ # total time to run, #puts won't appear in the profile report.
285
+ # The code block will be run 30 times in the example above.
249
286
  def __profile__(name, min=1, iter=100)
250
287
  require 'ruby-prof' unless defined?(RubyProf)
251
288
  return_result = ''
@@ -259,8 +296,8 @@ module Kernel
259
296
  :print_file => true})
260
297
  end
261
298
  return_result
262
- end
263
-
299
+ end
300
+
264
301
  # Extracts an options hash if it is the last item in the args array. Used
265
302
  # internally in methods that take *args.
266
303
  #
@@ -275,7 +312,7 @@ module Kernel
275
312
  def extract_options_from_args!(args)
276
313
  args.pop if Hash === args.last
277
314
  end
278
-
315
+
279
316
  # Checks that the given objects quack like the given conditions.
280
317
  #
281
318
  # ==== Parameters
@@ -290,13 +327,13 @@ module Kernel
290
327
  raise ArgumentError, "#{k.inspect} doesn't quack like #{v.inspect}" unless k.quacks_like?(v)
291
328
  end
292
329
  end
293
-
330
+
294
331
  unless Kernel.respond_to?(:debugger)
295
332
 
296
333
  # Define debugger method so that code even works if debugger was not
297
334
  # requested. Drops a note to the logs that Debugger was not available.
298
335
  def debugger
299
- Merb.logger.info! "\n***** Debugger requested, but was not " +
336
+ Merb.logger.info! "\n***** Debugger requested, but was not " +
300
337
  "available: Start server with --debugger " +
301
338
  "to enable *****\n"
302
339
  end
@@ -9,7 +9,7 @@ class Mash < Hash
9
9
  # ==== Alternatives
10
10
  # If constructor is a Hash, a new mash will be created based on the keys of
11
11
  # the hash and no default value will be set.
12
- def initialize(constructor = {})
12
+ def initialize(constructor = {})
13
13
  if constructor.is_a?(Hash)
14
14
  super()
15
15
  update(constructor)
@@ -72,7 +72,7 @@ class Mash < Hash
72
72
  alias_method :member?, :key?
73
73
 
74
74
  # ==== Parameters
75
- # key<Object>:: The key to fetch. This willbe run through convert_key.
75
+ # key<Object>:: The key to fetch. This will be run through convert_key.
76
76
  # extras:: Default value.
77
77
  #
78
78
  # ==== Returns
@@ -83,7 +83,7 @@ class Mash < Hash
83
83
 
84
84
  # ==== Parameters
85
85
  # indices<Array>::
86
- # The keys to retrieve values for. These will be run through convert_key.
86
+ # The keys to retrieve values for. These will be run through +convert_key+.
87
87
  def values_at(*indices)
88
88
  indices.collect {|key| self[convert_key(key)]}
89
89
  end
@@ -146,7 +146,7 @@ class Mash < Hash
146
146
  when Hash
147
147
  value.to_mash
148
148
  when Array
149
- value.collect { |e| e.is_a?(Hash) ? e.to_mash : e }
149
+ value.collect { |e| convert_value(e) }
150
150
  else
151
151
  value
152
152
  end
@@ -18,7 +18,7 @@ class Object
18
18
  # puts self
19
19
  # end
20
20
  # end
21
- #
21
+ #
22
22
  # def String.add_meta_var(var)
23
23
  # self.meta_class.instance_eval do
24
24
  # define_method var do
@@ -67,7 +67,7 @@ class Object
67
67
  # false.blank? #=> true
68
68
  # "".blank? #=> true
69
69
  # " ".blank? #=> true
70
- # " hey ho ".blank? #=> false
70
+ # " hey ho ".blank? #=> false
71
71
  def blank?
72
72
  if respond_to?(:empty?) && respond_to?(:strip)
73
73
  empty? or strip.empty?
@@ -89,8 +89,9 @@ class Object
89
89
  list.each {|x| obj = obj.const_get(x) }
90
90
  obj
91
91
  end
92
-
93
- # Makes a module from a string (e.g. Foo::Bar::Baz)
92
+
93
+ # Defines module from a string name (e.g. Foo::Bar::Baz)
94
+ # If method already exists, no exception raised.
94
95
  #
95
96
  # ==== Parameters
96
97
  # name<String>:: The name of the full module name to make
@@ -106,7 +107,7 @@ class Object
106
107
  #{ender}
107
108
  HERE
108
109
  end
109
-
110
+
110
111
  # ==== Parameters
111
112
  # duck<Symbol, Class, Array>:: The thing to compare the object to.
112
113
  #
@@ -132,5 +133,15 @@ class Object
132
133
  false
133
134
  end
134
135
  end
135
-
136
- end
136
+
137
+ # ==== Parameters
138
+ # arrayish<Array>:: Container to check, to see if it includes the object.
139
+ # more<Objects>:: additional args, will be flattened into arrayish
140
+ #
141
+ # ==== Returns
142
+ # Boolean: True if the object is included in arrayish (+ more)
143
+ def in?(arrayish,*more)
144
+ arrayish = more.unshift(arrayish) unless more.empty?
145
+ arrayish.include?(self)
146
+ end
147
+ end
@@ -1,4 +1,9 @@
1
1
  module Merb
2
+ # Simple set implementation
3
+ # on top of Hash with mergins support.
4
+ #
5
+ # In particular this is used to store
6
+ # a set of callable actions of controller.
2
7
  class SimpleSet < Hash
3
8
 
4
9
  # ==== Parameters
@@ -33,9 +38,9 @@ module Merb
33
38
  def inspect
34
39
  "#<SimpleSet: {#{keys.map {|x| x.inspect}.join(", ")}}>"
35
40
  end
36
-
41
+
37
42
  # def to_a
38
43
  alias_method :to_a, :keys
39
-
40
- end
41
- end
44
+
45
+ end # SimpleSet
46
+ end # Merb
@@ -1,25 +1,36 @@
1
1
  require "pathname"
2
2
 
3
3
  class String
4
-
5
- class InvalidPathConversion < Exception; end
6
4
 
7
5
  # ==== Returns
8
6
  # String:: The string with all regexp special characters escaped.
9
7
  #
10
8
  # ==== Examples
11
- # "\*?{}.".escape_regexp #=> "\\*\\?\\{\\}\\."
9
+ # "*?{}.".escape_regexp #=> "\\*\\?\\{\\}\\."
12
10
  def escape_regexp
13
11
  Regexp.escape self
14
12
  end
15
-
13
+
14
+ # ==== Returns
15
+ # String:: The string with all regexp special characters unescaped.
16
+ #
17
+ # ==== Examples
18
+ # "\\*\\?\\{\\}\\.".unescape_regexp #=> "*?{}."
19
+ def unescape_regexp
20
+ self.gsub(/\\([\.\?\|\(\)\[\]\{\}\^\$\*\+\-])/, '\1')
21
+ end
22
+
16
23
  # ==== Returns
17
24
  # String:: The string converted to snake case.
18
25
  #
19
26
  # ==== Examples
20
27
  # "FooBar".snake_case #=> "foo_bar"
28
+ # "HeadlineCNNNews".snake_case #=> "headline_cnn_news"
29
+ # "CNN".snake_case #=> "cnn"
21
30
  def snake_case
22
- gsub(/\B[A-Z]/, '_\&').downcase
31
+ return self.downcase if self =~ /^[A-Z]+$/
32
+ self.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/
33
+ return $+.downcase
23
34
  end
24
35
 
25
36
  # ==== Returns
@@ -28,9 +39,10 @@ class String
28
39
  # ==== Examples
29
40
  # "foo_bar".camel_case #=> "FooBar"
30
41
  def camel_case
42
+ return self if self !~ /_/ && self =~ /[A-Z]+.*/
31
43
  split('_').map{|e| e.capitalize}.join
32
44
  end
33
-
45
+
34
46
  # ==== Returns
35
47
  # String:: The path string converted to a constant name.
36
48
  #
@@ -39,7 +51,7 @@ class String
39
51
  def to_const_string
40
52
  gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
41
53
  end
42
-
54
+
43
55
  # ==== Returns
44
56
  # String::
45
57
  # The path that is associated with the constantized string, assuming a
@@ -62,8 +74,16 @@ class String
62
74
  def /(o)
63
75
  File.join(self, o.to_s)
64
76
  end
65
-
77
+
78
+ # ==== Parameters ====
79
+ # other<String>:: Base path to calculate against
80
+ #
81
+ # ==== Returns ====
82
+ # String:: Relative path from between the two
83
+ #
84
+ # ==== Example ====
85
+ # "/opt/local/lib".relative_path_from("/opt/local/lib/ruby/site_ruby") # => "../.."
66
86
  def relative_path_from(other)
67
87
  Pathname.new(self).relative_path_from(Pathname.new(other)).to_s
68
88
  end
69
- end
89
+ end
@@ -0,0 +1,13 @@
1
+ class Time
2
+
3
+ # ==== Returns
4
+ # String::
5
+ # ISO 8601 compatible rendering of the Time object's properties.
6
+ #
7
+ # ==== Examples
8
+ # Time.now.to_json # => "\"2008-03-28T17:54:20-05:00\""
9
+ def to_json
10
+ self.xmlschema.to_json
11
+ end
12
+
13
+ end
@@ -69,8 +69,7 @@ module Merb
69
69
  Merb.logger.info("Cookie deleted: #{name} => #{cookie.inspect}")
70
70
  cookie
71
71
  end
72
-
73
- private
72
+
74
73
  # ==== Parameters
75
74
  # name<~to_s>:: Name of the cookie.
76
75
  # value<~to_s>:: Value of the cookie.
@@ -35,9 +35,7 @@ class Merb::Dispatcher
35
35
  end
36
36
  request.route_params = route_params
37
37
  request.params.merge! route_params
38
-
39
- Merb.logger.info("Params: #{request.params.inspect}")
40
-
38
+
41
39
  controller_name = (route_params[:namespace] ? route_params[:namespace] + '/' : '') + route_params[:controller]
42
40
 
43
41
  unless controller_name
@@ -61,11 +59,19 @@ class Merb::Dispatcher
61
59
  raise Merb::ControllerExceptions::NotFound
62
60
  end
63
61
 
62
+ Merb.logger.info("Params: #{klass._filter_params(request.params).inspect}")
63
+
64
64
  action = route_params[:action]
65
65
 
66
+ if route_index && route = Merb::Router.routes[route_index]
67
+ #Fixate the session ID if it is enabled on the route
68
+ if route.allow_fixation? && request.params.key?(Merb::Controller._session_id_key)
69
+ request.cookies[Merb::Controller._session_id_key] = request.params[Merb::Controller._session_id_key]
70
+ end
71
+ end
72
+
66
73
  controller = dispatch_action(klass, action, request)
67
- controller._benchmarks[:dispatch_time] = Time.now - start
68
- controller.route = Merb::Router.routes[route_index] if route_index
74
+ controller._benchmarks[:dispatch_time] = Time.now - start
69
75
  Merb.logger.info controller._benchmarks.inspect
70
76
  Merb.logger.flush
71
77
 
@@ -156,9 +162,9 @@ Stacktrace:
156
162
  request.params[:original_cookies] = request.cookies.dup rescue {}
157
163
  request.params[:exception] = exception
158
164
  request.params[:action] = exception_klass.name
159
-
160
- dispatch_action(klass, exception_klass.name, request, exception.class::STATUS)
161
- rescue => dispatch_issue
165
+
166
+ dispatch_action(klass, exception_klass.name, request, exception.class.status)
167
+ rescue => dispatch_issue
162
168
  dispatch_issue = controller_exception(dispatch_issue)
163
169
  # when no action/template exist for an exception, or an
164
170
  # exception occurs on an InternalServerError the message is
@@ -174,7 +180,9 @@ Stacktrace:
174
180
  retry
175
181
  else
176
182
  dispatch_default_exception(klass, request, exception)
177
- end
183
+ end
184
+ elsif request.params[:exception].is_a?(dispatch_issue.class)
185
+ dispatch_default_exception(klass, request, dispatch_issue)
178
186
  elsif dispatch_issue.is_a?(Merb::ControllerExceptions::InternalServerError)
179
187
  dispatch_default_exception(klass, request, dispatch_issue)
180
188
  else
@@ -202,7 +210,7 @@ Stacktrace:
202
210
  # An array containing the Merb::Controller that was dispatched to and the
203
211
  # error's name. For instance, a NotFound error's name is "not_found".
204
212
  def dispatch_default_exception(klass, request, e)
205
- controller = klass.new(request, e.class::STATUS)
213
+ controller = klass.new(request, e.class.status)
206
214
  if e.is_a? Merb::ControllerExceptions::Redirection
207
215
  controller.headers.merge!('Location' => e.message)
208
216
  controller.body = %{ } #fix