roda 3.28.0 → 3.29.0

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 (188) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +10 -0
  3. data/README.rdoc +10 -0
  4. data/doc/release_notes/3.29.0.txt +15 -0
  5. data/lib/roda.rb +1 -0
  6. data/lib/roda/plugins/caching.rb +2 -0
  7. data/lib/roda/plugins/common_logger.rb +1 -1
  8. data/lib/roda/plugins/exception_page.rb +7 -1
  9. data/lib/roda/plugins/indifferent_params.rb +2 -0
  10. data/lib/roda/version.rb +1 -1
  11. metadata +4 -214
  12. data/Rakefile +0 -108
  13. data/doc/release_notes/1.0.0.txt +0 -329
  14. data/doc/release_notes/1.1.0.txt +0 -226
  15. data/doc/release_notes/1.2.0.txt +0 -406
  16. data/doc/release_notes/1.3.0.txt +0 -109
  17. data/doc/release_notes/2.0.0.txt +0 -75
  18. data/doc/release_notes/2.1.0.txt +0 -124
  19. data/doc/release_notes/2.10.0.txt +0 -27
  20. data/doc/release_notes/2.11.0.txt +0 -70
  21. data/doc/release_notes/2.12.0.txt +0 -40
  22. data/doc/release_notes/2.13.0.txt +0 -10
  23. data/doc/release_notes/2.14.0.txt +0 -44
  24. data/doc/release_notes/2.15.0.txt +0 -53
  25. data/doc/release_notes/2.16.0.txt +0 -48
  26. data/doc/release_notes/2.17.0.txt +0 -62
  27. data/doc/release_notes/2.18.0.txt +0 -69
  28. data/doc/release_notes/2.19.0.txt +0 -30
  29. data/doc/release_notes/2.2.0.txt +0 -97
  30. data/doc/release_notes/2.20.0.txt +0 -5
  31. data/doc/release_notes/2.21.0.txt +0 -17
  32. data/doc/release_notes/2.22.0.txt +0 -41
  33. data/doc/release_notes/2.23.0.txt +0 -29
  34. data/doc/release_notes/2.24.0.txt +0 -65
  35. data/doc/release_notes/2.25.0.txt +0 -14
  36. data/doc/release_notes/2.26.0.txt +0 -13
  37. data/doc/release_notes/2.27.0.txt +0 -56
  38. data/doc/release_notes/2.28.0.txt +0 -17
  39. data/doc/release_notes/2.29.0.txt +0 -156
  40. data/doc/release_notes/2.3.0.txt +0 -109
  41. data/doc/release_notes/2.4.0.txt +0 -55
  42. data/doc/release_notes/2.5.0.txt +0 -23
  43. data/doc/release_notes/2.5.1.txt +0 -4
  44. data/doc/release_notes/2.6.0.txt +0 -21
  45. data/doc/release_notes/2.7.0.txt +0 -75
  46. data/doc/release_notes/2.8.0.txt +0 -44
  47. data/doc/release_notes/2.9.0.txt +0 -6
  48. data/spec/all.rb +0 -1
  49. data/spec/assets/css/app.scss +0 -1
  50. data/spec/assets/css/no_access.css +0 -1
  51. data/spec/assets/css/raw.css +0 -1
  52. data/spec/assets/js/head/app.js +0 -1
  53. data/spec/composition_spec.rb +0 -31
  54. data/spec/define_roda_method_spec.rb +0 -274
  55. data/spec/env_spec.rb +0 -11
  56. data/spec/freeze_spec.rb +0 -37
  57. data/spec/integration_spec.rb +0 -209
  58. data/spec/matchers_spec.rb +0 -832
  59. data/spec/opts_spec.rb +0 -42
  60. data/spec/plugin/_after_hook_spec.rb +0 -19
  61. data/spec/plugin/all_verbs_spec.rb +0 -29
  62. data/spec/plugin/assets_preloading_spec.rb +0 -98
  63. data/spec/plugin/assets_spec.rb +0 -745
  64. data/spec/plugin/backtracking_array_spec.rb +0 -42
  65. data/spec/plugin/branch_locals_spec.rb +0 -106
  66. data/spec/plugin/caching_spec.rb +0 -337
  67. data/spec/plugin/chunked_spec.rb +0 -201
  68. data/spec/plugin/class_level_routing_spec.rb +0 -164
  69. data/spec/plugin/class_matchers_spec.rb +0 -40
  70. data/spec/plugin/common_logger_spec.rb +0 -85
  71. data/spec/plugin/content_for_spec.rb +0 -162
  72. data/spec/plugin/content_security_policy_spec.rb +0 -175
  73. data/spec/plugin/cookies_spec.rb +0 -51
  74. data/spec/plugin/csrf_spec.rb +0 -111
  75. data/spec/plugin/default_headers_spec.rb +0 -82
  76. data/spec/plugin/default_status_spec.rb +0 -95
  77. data/spec/plugin/delay_build_spec.rb +0 -23
  78. data/spec/plugin/delegate_spec.rb +0 -23
  79. data/spec/plugin/delete_empty_headers_spec.rb +0 -27
  80. data/spec/plugin/direct_call_spec.rb +0 -28
  81. data/spec/plugin/disallow_file_uploads_spec.rb +0 -25
  82. data/spec/plugin/drop_body_spec.rb +0 -24
  83. data/spec/plugin/early_hints_spec.rb +0 -19
  84. data/spec/plugin/empty_root_spec.rb +0 -14
  85. data/spec/plugin/environments_spec.rb +0 -42
  86. data/spec/plugin/error_email_spec.rb +0 -97
  87. data/spec/plugin/error_handler_spec.rb +0 -216
  88. data/spec/plugin/error_mail_spec.rb +0 -93
  89. data/spec/plugin/exception_page_spec.rb +0 -168
  90. data/spec/plugin/flash_spec.rb +0 -121
  91. data/spec/plugin/h_spec.rb +0 -11
  92. data/spec/plugin/halt_spec.rb +0 -119
  93. data/spec/plugin/hash_matcher_spec.rb +0 -27
  94. data/spec/plugin/hash_routes_spec.rb +0 -535
  95. data/spec/plugin/head_spec.rb +0 -52
  96. data/spec/plugin/header_matchers_spec.rb +0 -98
  97. data/spec/plugin/heartbeat_spec.rb +0 -74
  98. data/spec/plugin/hooks_spec.rb +0 -152
  99. data/spec/plugin/indifferent_params_spec.rb +0 -14
  100. data/spec/plugin/json_parser_spec.rb +0 -141
  101. data/spec/plugin/json_spec.rb +0 -83
  102. data/spec/plugin/mail_processor_spec.rb +0 -451
  103. data/spec/plugin/mailer_spec.rb +0 -282
  104. data/spec/plugin/match_affix_spec.rb +0 -43
  105. data/spec/plugin/match_hook_spec.rb +0 -79
  106. data/spec/plugin/middleware_spec.rb +0 -237
  107. data/spec/plugin/middleware_stack_spec.rb +0 -81
  108. data/spec/plugin/module_include_spec.rb +0 -48
  109. data/spec/plugin/multi_route_spec.rb +0 -268
  110. data/spec/plugin/multi_run_spec.rb +0 -87
  111. data/spec/plugin/multi_view_spec.rb +0 -50
  112. data/spec/plugin/multibyte_string_matcher_spec.rb +0 -44
  113. data/spec/plugin/named_templates_spec.rb +0 -96
  114. data/spec/plugin/not_allowed_spec.rb +0 -69
  115. data/spec/plugin/not_found_spec.rb +0 -128
  116. data/spec/plugin/optimized_string_matchers_spec.rb +0 -43
  117. data/spec/plugin/padrino_render_spec.rb +0 -34
  118. data/spec/plugin/param_matchers_spec.rb +0 -69
  119. data/spec/plugin/params_capturing_spec.rb +0 -33
  120. data/spec/plugin/partials_spec.rb +0 -43
  121. data/spec/plugin/pass_spec.rb +0 -29
  122. data/spec/plugin/path_matchers_spec.rb +0 -42
  123. data/spec/plugin/path_rewriter_spec.rb +0 -45
  124. data/spec/plugin/path_spec.rb +0 -222
  125. data/spec/plugin/placeholder_string_matchers_spec.rb +0 -126
  126. data/spec/plugin/precompile_templates_spec.rb +0 -61
  127. data/spec/plugin/public_spec.rb +0 -85
  128. data/spec/plugin/render_each_spec.rb +0 -82
  129. data/spec/plugin/render_locals_spec.rb +0 -114
  130. data/spec/plugin/render_spec.rb +0 -912
  131. data/spec/plugin/request_aref_spec.rb +0 -51
  132. data/spec/plugin/request_headers_spec.rb +0 -39
  133. data/spec/plugin/response_request_spec.rb +0 -43
  134. data/spec/plugin/route_block_args_spec.rb +0 -86
  135. data/spec/plugin/route_csrf_spec.rb +0 -305
  136. data/spec/plugin/run_append_slash_spec.rb +0 -77
  137. data/spec/plugin/run_handler_spec.rb +0 -53
  138. data/spec/plugin/sessions_spec.rb +0 -452
  139. data/spec/plugin/shared_vars_spec.rb +0 -45
  140. data/spec/plugin/sinatra_helpers_spec.rb +0 -537
  141. data/spec/plugin/slash_path_empty_spec.rb +0 -22
  142. data/spec/plugin/static_routing_spec.rb +0 -192
  143. data/spec/plugin/static_spec.rb +0 -30
  144. data/spec/plugin/status_303_spec.rb +0 -28
  145. data/spec/plugin/status_handler_spec.rb +0 -158
  146. data/spec/plugin/streaming_spec.rb +0 -246
  147. data/spec/plugin/strip_path_prefix_spec.rb +0 -24
  148. data/spec/plugin/symbol_matchers_spec.rb +0 -51
  149. data/spec/plugin/symbol_status_spec.rb +0 -25
  150. data/spec/plugin/symbol_views_spec.rb +0 -32
  151. data/spec/plugin/timestamp_public_spec.rb +0 -85
  152. data/spec/plugin/type_routing_spec.rb +0 -348
  153. data/spec/plugin/typecast_params_spec.rb +0 -1370
  154. data/spec/plugin/unescape_path_spec.rb +0 -22
  155. data/spec/plugin/view_options_spec.rb +0 -170
  156. data/spec/plugin_spec.rb +0 -71
  157. data/spec/redirect_spec.rb +0 -41
  158. data/spec/request_spec.rb +0 -97
  159. data/spec/response_spec.rb +0 -199
  160. data/spec/route_spec.rb +0 -39
  161. data/spec/session_middleware_spec.rb +0 -129
  162. data/spec/session_spec.rb +0 -37
  163. data/spec/spec_helper.rb +0 -137
  164. data/spec/version_spec.rb +0 -14
  165. data/spec/views/_test.erb +0 -1
  166. data/spec/views/a.erb +0 -1
  167. data/spec/views/a.rdoc +0 -2
  168. data/spec/views/about.erb +0 -1
  169. data/spec/views/about.str +0 -1
  170. data/spec/views/about/_test.css.gz +0 -0
  171. data/spec/views/about/_test.erb +0 -1
  172. data/spec/views/about/_test.erb.gz +0 -0
  173. data/spec/views/about/comp_test.erb +0 -1
  174. data/spec/views/b.erb +0 -1
  175. data/spec/views/c.erb +0 -1
  176. data/spec/views/comp_layout.erb +0 -1
  177. data/spec/views/comp_test.erb +0 -1
  178. data/spec/views/content-yield.erb +0 -1
  179. data/spec/views/each.str +0 -1
  180. data/spec/views/home.erb +0 -2
  181. data/spec/views/home.str +0 -2
  182. data/spec/views/iv.erb +0 -1
  183. data/spec/views/layout-alternative.erb +0 -2
  184. data/spec/views/layout-yield.erb +0 -3
  185. data/spec/views/layout.erb +0 -2
  186. data/spec/views/layout.str +0 -2
  187. data/spec/views/multiple-layout.erb +0 -1
  188. data/spec/views/multiple.erb +0 -1
@@ -1,329 +0,0 @@
1
- = New Plugins
2
-
3
- * A csrf plugin has been added for CSRF prevention, using
4
- Rack::Csrf. It also adds helper methods for views such as
5
- csrf_tag.
6
-
7
- * A symbol_matchers plugin has been added, for customizing
8
- the regexps used per symbol. This also affects the use
9
- of embedded colons in strings. This supports the following
10
- symbol regexps by default:
11
-
12
- :d :: (\d+), a decimal segment
13
- :format :: (?:\.(\w+))?, an optional format/extension
14
- :opt :: (?:\/([^\/]+))?, an optional segment
15
- :optd :: (?:\/(\d+))?, an optional decimal segment
16
- :rest :: (.*), all remaining characters, if any
17
- :w :: (\w+), a alphanumeric segment
18
-
19
- This allows you to write code such as:
20
-
21
- plugin :symbol_matchers
22
-
23
- route do |r|
24
- r.is "track/:d" do
25
- end
26
- end
27
-
28
- And have it only match routes such as /track/123, not
29
- /track/abc.
30
-
31
- Note that :opt, :optd, and :format are only going to make sense
32
- when used as embedded colons in strings, due to how segment matching
33
- works.
34
-
35
- You can add your own symbol matchers using the symbol_matcher
36
- class method:
37
-
38
- plugin :symbol_matchers
39
- symbol_matcher :slug, /([\w-]+)/
40
-
41
- route do |r|
42
- r.on :slug do
43
- end
44
- end
45
-
46
- * A symbol_views plugin has been added, which allows match blocks to
47
- return symbols, which are interpreted as template names:
48
-
49
- plugin :symbol_views
50
-
51
- route do |r|
52
- :template_name # same as view :template_name
53
- end
54
-
55
- * A json plugin has been added, which allows match blocks to return
56
- arrays or hashes, and uses a JSON version of them as the response
57
- body:
58
-
59
- plugin :json
60
-
61
- route do |r|
62
- {'a'=>[1,2,3]} # response: {"a":[1,2,3]}
63
- end
64
-
65
- This also sets the Content-Type of the response to application/json.
66
-
67
- To convert additional object types to JSON, you can modify
68
- json_response_classes:
69
-
70
- plugin :json
71
- json_response_classes << Sequel::Model
72
-
73
- * A view_subdirs plugin has been added for setting a default
74
- subdirectory to use for views:
75
-
76
- Roda.route do |r|
77
- r.on "admin" do
78
- set_view_subdir "admin"
79
-
80
- r.is do
81
- view "index" # uses admin/index view
82
- end
83
- end
84
- end
85
-
86
- * A render_each plugin has been added, for rendering the same
87
- template for multiple objects, and returning the concatenation
88
- of all of the output:
89
-
90
- <%= render_each([1,2,3], 'number') %>
91
-
92
- This renders the number template 3 times. Each time the template
93
- is rendered, a local variable named number will be present with
94
- the current entry in the enumerable. You can control the name of
95
- the local variable using the :local option:
96
-
97
- <%= render_each([1,2,3], 'number', :local=>:n) %>
98
-
99
- * A content_for plugin has been added, for storing content in one
100
- template and retrieving that content in a different template (such
101
- as the layout). To set content, you call content_for with a block:
102
-
103
- <% content_for :foo do %>
104
- content for foo
105
- <% end %>
106
-
107
- To retrieve content, you call content_for without a block:
108
-
109
- <%= content_for :foo %>
110
-
111
- This plugin probably only works when using erb templates.
112
-
113
- * A not_allowed plugin has been added, for automatically returning 405
114
- Method Not Allowed responses when a route is handled for a different
115
- request method than the one used. For this routing tree:
116
-
117
- plugin :not_allowed
118
-
119
- route do |r|
120
- r.get "foo" do
121
- end
122
- end
123
-
124
- If you submit a POST /foo request, it will return a 405 error
125
- instead of a 404 error.
126
-
127
- This also handles cases when multiple methods are supported for
128
- a single path, so for this routing tree:
129
-
130
- route do |r|
131
- r.is "foo" do
132
- r.get do
133
- end
134
- r.post do
135
- end
136
- end
137
- end
138
-
139
- If you submit a DELETE /foo request, it will return a 405 error
140
- instead of a 404 error.
141
-
142
- * A head plugin has been added, automatically handling HEAD requests
143
- the same as GET requests, except returning an empty body. So for
144
- this routing tree:
145
-
146
- plugin :head
147
-
148
- route do |r|
149
- r.get "foo" do
150
- end
151
- end
152
-
153
- A request for HEAD /foo will return a 200 result instead of a 404
154
- error.
155
-
156
- * A backtracking_array plugin has been added, which makes matching
157
- backtrack to the next entry in an array if a later matcher fails.
158
- For example, the following code does not match /foo/bar by
159
- default in Roda:
160
-
161
- r.is ['foo', 'foo/bar'] do
162
- end
163
-
164
- This is because the 'foo' entry in the array matches, so the
165
- array matches. However, after the array is matched, the terminal
166
- matcher added by r.is fails to match. That causes the routing
167
- method not to match the request, so the match block is not called.
168
-
169
- With the backtracking_array plugin, failures of later matchers after
170
- an array matcher backtrack so the next entry in the array is tried.
171
-
172
- * A per_thread_caching plugin has been added, allowing you to change
173
- from a thread-safe shared cache to a per-thread cache, which may
174
- be faster on alternative ruby implementations, at the cost of
175
- additional memory usage.
176
-
177
- = New Features
178
-
179
- * The hash_matcher class method has been added to make it easier to
180
- define custom hash matchers:
181
-
182
- hash_matcher(:foo) do |v|
183
- self['foo'] == v
184
- end
185
-
186
- route do |r|
187
- r.on :foo=>'bar' do
188
- # matches when param foo has value bar
189
- end
190
- end
191
-
192
- * An r.root routing method has been added for handling GET
193
- requests where the current path is /. This is basically
194
- a faster and simpler version of r.get "", except it does
195
- not consume the / from the path.
196
-
197
- * The r.halt method now works without an argument, in which
198
- case it uses the current response.
199
-
200
- * The r.redirect method now works without an argument for non-GET
201
- requests, redirecting to the current path.
202
-
203
- * An :all hash matcher has been added, which takes an array and
204
- matches only if all of the elements match. This is mainly
205
- designed for usage inside an array matcher, so:
206
-
207
- r.on ["foo", {:all=>["bar", :id]}] do
208
- end
209
-
210
- will match either /foo or /bar/123, but not /bar.
211
-
212
- * The render plugin's view method now accepts a :content option,
213
- in which case it uses the content directly without running it
214
- through the template engine. This is useful if you have
215
- arbitrary content you want rendered inside the layout.
216
-
217
- * The render plugin now accepts an :escape option, in which case
218
- it will automatically set the default :engine_class for erb
219
- templates to an Erubis::EscapedEruby subclass. This changes the
220
- behavior of erb templates such that:
221
-
222
- <%= '<escaped>' %> # &lt;escaped&gt;
223
- <%== '<not escaped>' %> # <not escaped>
224
-
225
- This makes it easier to protect against XSS attacks in your
226
- templates, as long as you only use <%== %> for content that has
227
- already been escaped.
228
-
229
- Note that similar behavior is available in Erubis by default,
230
- using the :opts=>{:escape_html=>true} render option, but that
231
- doesn't handle postfix conditionals in <%= %> tags.
232
-
233
- * The multi_route plugin now has an r.multi_route method, which
234
- will attempt to dispatch to one of the named routes based on
235
- first segment in the path. So this routing tree:
236
-
237
- plugin :multi_route
238
-
239
- route "a" do |r|
240
- r.is "c" do
241
- "e"
242
- end
243
- end
244
- route "b" do |r|
245
- r.is "d" do
246
- "f"
247
- end
248
- end
249
-
250
- route do |r|
251
- r.multi_route
252
- end
253
-
254
- will return "e" for /a/c and "f" for /b/d.
255
-
256
- * Plugins can now override request and response class methods
257
- using RequestClassMethods and ResponseClassMethods modules.
258
-
259
- = Optimizations
260
-
261
- * String, hash, and symbol matchers are now much faster by caching
262
- the underlying regexp.
263
-
264
- * String, hash, and symbol matchers are now faster by using a
265
- regexp positive lookahead assertion instead of an additional
266
- capture.
267
-
268
- * Terminal matching in the r.is, r.get, and r.post routing methods
269
- is now faster, as it does not use a hash matcher internally.
270
-
271
- * The routing methods are now faster by reducing the number of
272
- Array objects created.
273
-
274
- * Calling routing methods without arguments is now faster.
275
-
276
- * The r.get method is now faster by reducing the number of string
277
- allocations.
278
-
279
- * Many request methods are faster by reducing the number of
280
- method calls used.
281
-
282
- * Template caching no longer uses a mutex on MRI, since one is
283
- not needed for thread safety there.
284
-
285
- = Other Improvements
286
-
287
- * The flash plugin now implements its own flash hash instead of
288
- using sinatra-flash. It is now slightly faster and handles nil
289
- keys in #keep and #discard.
290
-
291
- * Roda's version is now stored in roda/version.rb so that it can be
292
- required without requiring Roda itself.
293
-
294
- = Backwards Compatibility
295
-
296
- * The multi_route plugin's route instance method has been changed
297
- to a request method. So the new usage is:
298
-
299
- plugin :multi_route
300
-
301
- route "a" do |r|
302
- end
303
-
304
- route do |r|
305
- r.route "a" # instead of: route "a"
306
- end
307
-
308
- * The session key used for the flash hash in the flash plugin is
309
- now :_flash, not :flash.
310
-
311
- * The :extension matcher now longer forces a terminal match, use
312
- one of the routing methods that forces a terminal match if you
313
- want that behavior.
314
-
315
- * The :term hash matcher has been removed.
316
-
317
- * The r.consume private method now takes the exact regexp to use
318
- to search the current path, it no longer enforces a preceeding
319
- slash and that the match end on a segment boundary.
320
-
321
- * Dynamically constructing match patterns is now a potential
322
- memory leak due to them being cached. So you shouldn't do
323
- things like:
324
-
325
- r.on r['param'] do
326
- end
327
-
328
- * Many private routing methods were changed or removed, if you were
329
- using them, you'll probably need to update your code.
@@ -1,226 +0,0 @@
1
- = New Plugins
2
-
3
- * An assets plugin has been added, for rendering your CSS and
4
- javascript asset files on the fly in development, and compiling
5
- them to a single, compressed file in production.
6
-
7
- When loading the plugin, you just specify the assets to use via :css
8
- and/or :js options:
9
-
10
- plugin :assets, :css=>'some_file.scss', :js=>'some_file.coffee'
11
-
12
- Inside your Roda.route block, you call r.assets to serve the assets:
13
-
14
- route do |r|
15
- r.assets
16
- end
17
-
18
- In your views, you can call the assets method, which returns strings
19
- containing link/script tags for your assets:
20
-
21
- <%= assets(:css) %>
22
- <%= assets(:js) %>
23
-
24
- In production mode, you call compile_assets after loading the
25
- plugin, and it will compile all of the asset files into a single
26
- file per type, optionally compress it (using yuicompressor), and
27
- write the file to the public folder where it can be served by the
28
- webserver. In compiled mode, calling assets in your views will
29
- reference the compiled file.
30
-
31
- It's possible to precompile your assets before application boot, so
32
- they don't need to be compiled every time your application boots.
33
-
34
- The assets plugin also supports asset groups, useful when different
35
- sections of your application use different sets of assets.
36
-
37
- * A chunked plugin has been added, for streaming template rendering
38
- using Transfer-Encoding: chunked. By default, this flushes the
39
- rendering of the top part of the layout template before rendering
40
- the content template, allowing the client to load the assets
41
- necessary to fully render the page while the content template is
42
- still being rendered on the server. This can significantly decrease
43
- client rendering times.
44
-
45
- To use chunked encoding for a response, just call the chunked method
46
- instead of view:
47
-
48
- r.root do
49
- chunked(:index)
50
- end
51
-
52
- If you want to execute code after flushing the top part of the layout
53
- template, but before rendering the content template, pass a block to
54
- chunked:
55
-
56
- r.root do
57
- chunked(:index) do
58
- # expensive calculation here
59
- end
60
- end
61
-
62
- If you want to use chunked encoding for all responses, pass the
63
- :chunk_by_default option when loading the plugin:
64
-
65
- plugin :chunked, :chunk_by_default => true
66
-
67
- Inside your layout or content templates, you can call the flush method
68
- to flush the current result of the template to the user, useful for
69
- streaming large datasets.
70
-
71
- <% (1..100).each do |i| %>
72
- <%= i %>
73
- <% sleep 0.1 %>
74
- <% flush %>
75
- <% end %>
76
-
77
- * A caching plugin has been added, for simple HTTP caching support.
78
- The implementation is based on Sinatra's, and offers
79
- r.last_modifed and r.etag methods for conditional responses:
80
-
81
- r.get '/albums/:d' do |album_id|
82
- @album = Album[album_id]
83
- r.last_modified @album.updated_at
84
- r.etag @album.sha1
85
- view('album')
86
- end
87
-
88
- This also adds response.cache_control and response.expires methods
89
- for setting the Cache-Control/Expires headers for the response.
90
-
91
- * A path plugin has been added for simple support for named paths:
92
-
93
- plugin :path
94
- path :foo, '/foo' # foo_path => '/foo'
95
- path :bar do |bar| # bar_path(bar) => '/bar/1'
96
- "/bar/#{bar.id}"
97
- end
98
-
99
- * An error_email plugin has been added, for easily emailing error
100
- notifications for an exception. This is designed for use with
101
- the error_handler plugin, and should only be used in low-traffic
102
- environments:
103
-
104
- plugin :error_email, :to=>'to@example.com',
105
- :from=>'from@example.com'
106
- plugin :error_handler do |e|
107
- error_email(e)
108
- 'Internal Server Error'
109
- end
110
-
111
- = multi_route Plugin Improvements
112
-
113
- * The multi_route plugin now supports namespaces, allowing it to
114
- support routing trees of arbitrary complexity. Previously, only
115
- a single namespace was supported. For example, if you want
116
- to store your named routes in a directory tree:
117
-
118
- /routes/foo.rb
119
- /routes/foo/baz.rb
120
- /routes/foo/quux.rb
121
- /routes/bar.rb
122
- /routes/bar/baz.rb
123
- /routes/bar/quux.rb
124
-
125
- You can load all of the routing files in the routes subdirectory
126
- tree, and structure your routing tree as follows:
127
-
128
- # app.rb
129
- route do |r|
130
- r.multi_route
131
- end
132
-
133
- # routes/foo.rb
134
- route('foo') do |r|
135
- check_foo_access!
136
- r.multi_route('foo')
137
- end
138
-
139
- # routes/bar.rb
140
- route('bar') do |r|
141
- check_bar_access!
142
- r.multi_route('bar')
143
- end
144
-
145
- # routes/foo/baz.rb
146
- route('baz', 'foo') do
147
- # ...
148
- end
149
-
150
- * Newly added named routes are now picked up while running, useful in
151
- development when using code reloading.
152
-
153
- * r.multi_route now ignores non-String named routes, allowing you to
154
- only dispatch to the String named routes. Previously, calling
155
- r.multi_route when any non-String names routes were present resulted
156
- in an error.
157
-
158
- * r.multi_route now prefers longer routes to shorter routes if
159
- routes have the same prefix. This can fix behavior if you have
160
- named routes such as "foo" and "foo/bar".
161
-
162
- * If you don't pass a block to r.multi_route, it will use the
163
- return value of the named route as the block value to return,
164
- instead of always returning nil.
165
-
166
- = Optimizations
167
-
168
- * Dispatch speed is slightly improved by using allocate instead of
169
- new to create new instances.
170
-
171
- * Hash allocations in the render plugin have been reduced.
172
-
173
- = Other Improvements
174
-
175
- * The Roda.route block is now inherited when subclassing, making
176
- it possible to subclass a Roda application and have the subclass
177
- work without adding a route block.
178
-
179
- * Middleware added to a Roda app after the Roda.route method is
180
- called are now used instead of being ignored.
181
-
182
- * A response.finish_with_body method has been added, for overriding
183
- the response body to use. This is useful if you want to support
184
- arbitrary response bodies.
185
-
186
- * The render plugin now defaults the locals argument to an empty
187
- frozen hash instead of nil when rendering templates via tilt.
188
- This is faster as it avoids a hash allocation inside tilt, and
189
- also works with broken external tilt templates that require that
190
- the locals argument be a hash.
191
-
192
- * Plugins that ship with Roda no longer set constants inside
193
- InstanceMethods. Instead, the constants are set at the plugin
194
- module level. This is done to avoid polluting the namespace of
195
- the application with the constants. Roda's policy is that all
196
- internal constants inside the Roda namespace are prefixed with
197
- Roda, so they don't pollute the user's namespace, and setting
198
- these constants inside InstanceMethods in plugins violated that
199
- policy.
200
-
201
- = Backwards Compatibility
202
-
203
- * response.write no longer sets a Content-Length header. Instead,
204
- response.finish sets it. This is faster if you call
205
- response.write multiple times, and more correct if you call
206
- response.finish without calling response.write.
207
-
208
- * In the render plugin, modifying render_opts directly is now
209
- deprecated and will raise an error in the next major release (the
210
- hash will be frozen). Instead, users should call plugin :render
211
- again with a new hash, which will be merged into the existing
212
- render_opts hash.
213
-
214
- * Moving plugin's constants from InstanceMethods to the plugin level
215
- can break applications where the constant was referenced directly.
216
- For example, if you were doing:
217
-
218
- Roda::SESSION_KEY
219
-
220
- to get the constant for the session key, you would now need to use:
221
-
222
- Roda::RodaPlugins::Base::SESSION_KEY
223
-
224
- In general, it is recommended to not reference such constants at
225
- all. If you think there should be a general reason to access them,
226
- request that a method is added that returns them.