roda 2.29.0 → 3.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG +52 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +51 -109
- data/Rakefile +7 -14
- data/doc/conventions.rdoc +4 -4
- data/doc/release_notes/1.2.0.txt +1 -1
- data/doc/release_notes/3.0.0.txt +84 -0
- data/lib/roda.rb +25 -79
- data/lib/roda/plugins/assets.rb +25 -58
- data/lib/roda/plugins/assets_preloading.rb +0 -5
- data/lib/roda/plugins/backtracking_array.rb +0 -5
- data/lib/roda/plugins/branch_locals.rb +3 -3
- data/lib/roda/plugins/caching.rb +5 -38
- data/lib/roda/plugins/chunked.rb +7 -25
- data/lib/roda/plugins/class_level_routing.rb +2 -2
- data/lib/roda/plugins/content_for.rb +7 -10
- data/lib/roda/plugins/cookies.rb +3 -3
- data/lib/roda/plugins/csrf.rb +2 -2
- data/lib/roda/plugins/delegate.rb +3 -3
- data/lib/roda/plugins/drop_body.rb +0 -7
- data/lib/roda/plugins/empty_root.rb +0 -3
- data/lib/roda/plugins/error_email.rb +4 -6
- data/lib/roda/plugins/error_handler.rb +1 -2
- data/lib/roda/plugins/error_mail.rb +3 -6
- data/lib/roda/plugins/flash.rb +0 -4
- data/lib/roda/plugins/h.rb +5 -0
- data/lib/roda/plugins/hash_matcher.rb +4 -2
- data/lib/roda/plugins/head.rb +5 -7
- data/lib/roda/plugins/header_matchers.rb +12 -33
- data/lib/roda/plugins/heartbeat.rb +2 -7
- data/lib/roda/plugins/indifferent_params.rb +2 -2
- data/lib/roda/plugins/json.rb +6 -14
- data/lib/roda/plugins/json_parser.rb +2 -13
- data/lib/roda/plugins/mailer.rb +29 -39
- data/lib/roda/plugins/match_affix.rb +0 -5
- data/lib/roda/plugins/middleware.rb +10 -15
- data/lib/roda/plugins/multi_route.rb +8 -5
- data/lib/roda/plugins/multi_run.rb +1 -0
- data/lib/roda/plugins/named_templates.rb +2 -2
- data/lib/roda/plugins/optimized_string_matchers.rb +0 -3
- data/lib/roda/plugins/padrino_render.rb +6 -9
- data/lib/roda/plugins/param_matchers.rb +6 -6
- data/lib/roda/plugins/params_capturing.rb +15 -35
- data/lib/roda/plugins/partials.rb +3 -8
- data/lib/roda/plugins/path.rb +5 -5
- data/lib/roda/plugins/path_matchers.rb +3 -3
- data/lib/roda/plugins/path_rewriter.rb +4 -9
- data/lib/roda/plugins/placeholder_string_matchers.rb +1 -1
- data/lib/roda/plugins/precompile_templates.rb +10 -20
- data/lib/roda/plugins/public.rb +6 -9
- data/lib/roda/plugins/render.rb +50 -171
- data/lib/roda/plugins/render_each.rb +4 -7
- data/lib/roda/plugins/render_locals.rb +6 -20
- data/lib/roda/plugins/request_headers.rb +2 -4
- data/lib/roda/plugins/run_append_slash.rb +1 -4
- data/lib/roda/plugins/run_handler.rb +4 -7
- data/lib/roda/plugins/shared_vars.rb +3 -6
- data/lib/roda/plugins/sinatra_helpers.rb +11 -40
- data/lib/roda/plugins/slash_path_empty.rb +0 -3
- data/lib/roda/plugins/static.rb +2 -2
- data/lib/roda/plugins/static_routing.rb +2 -3
- data/lib/roda/plugins/streaming.rb +15 -108
- data/lib/roda/plugins/strip_path_prefix.rb +1 -1
- data/lib/roda/plugins/symbol_matchers.rb +7 -23
- data/lib/roda/plugins/type_routing.rb +4 -9
- data/lib/roda/plugins/view_options.rb +10 -66
- data/lib/roda/version.rb +2 -2
- data/spec/all.rb +0 -2
- data/spec/composition_spec.rb +1 -1
- data/spec/env_spec.rb +1 -1
- data/spec/freeze_spec.rb +1 -1
- data/spec/integration_spec.rb +1 -1
- data/spec/matchers_spec.rb +26 -70
- data/spec/opts_spec.rb +1 -1
- data/spec/plugin/all_verbs_spec.rb +1 -1
- data/spec/plugin/assets_preloading_spec.rb +1 -1
- data/spec/plugin/assets_spec.rb +43 -27
- data/spec/plugin/backtracking_array_spec.rb +1 -1
- data/spec/plugin/branch_locals_spec.rb +1 -1
- data/spec/plugin/caching_spec.rb +1 -1
- data/spec/plugin/chunked_spec.rb +1 -1
- data/spec/plugin/class_level_routing_spec.rb +1 -1
- data/spec/plugin/class_matchers_spec.rb +1 -1
- data/spec/plugin/content_for_spec.rb +2 -7
- data/spec/plugin/cookies_spec.rb +1 -1
- data/spec/plugin/csrf_spec.rb +1 -1
- data/spec/plugin/default_headers_spec.rb +1 -1
- data/spec/plugin/default_status_spec.rb +1 -1
- data/spec/plugin/delay_build_spec.rb +1 -1
- data/spec/plugin/delegate_spec.rb +1 -1
- data/spec/plugin/delete_empty_headers_spec.rb +1 -1
- data/spec/plugin/disallow_file_uploads_spec.rb +2 -2
- data/spec/plugin/drop_body_spec.rb +1 -1
- data/spec/plugin/empty_root_spec.rb +1 -1
- data/spec/plugin/environments_spec.rb +1 -1
- data/spec/plugin/error_email_spec.rb +1 -1
- data/spec/plugin/error_handler_spec.rb +1 -1
- data/spec/plugin/error_mail_spec.rb +2 -2
- data/spec/plugin/flash_spec.rb +1 -1
- data/spec/plugin/h_spec.rb +1 -1
- data/spec/plugin/halt_spec.rb +2 -2
- data/spec/plugin/hash_matcher_spec.rb +1 -1
- data/spec/plugin/head_spec.rb +1 -1
- data/spec/plugin/header_matchers_spec.rb +4 -47
- data/spec/plugin/heartbeat_spec.rb +1 -1
- data/spec/plugin/hooks_spec.rb +1 -1
- data/spec/plugin/indifferent_params_spec.rb +1 -1
- data/spec/plugin/json_parser_spec.rb +12 -1
- data/spec/plugin/json_spec.rb +8 -1
- data/spec/plugin/mailer_spec.rb +1 -1
- data/spec/plugin/match_affix_spec.rb +1 -1
- data/spec/plugin/middleware_spec.rb +15 -1
- data/spec/plugin/module_include_spec.rb +1 -1
- data/spec/plugin/multi_route_spec.rb +5 -3
- data/spec/plugin/multi_run_spec.rb +1 -1
- data/spec/plugin/multi_view_spec.rb +1 -1
- data/spec/plugin/named_templates_spec.rb +1 -1
- data/spec/plugin/not_allowed_spec.rb +1 -1
- data/spec/plugin/not_found_spec.rb +1 -1
- data/spec/plugin/optimized_string_matchers_spec.rb +1 -1
- data/spec/plugin/padrino_render_spec.rb +1 -1
- data/spec/plugin/param_matchers_spec.rb +1 -1
- data/spec/plugin/params_capturing_spec.rb +6 -22
- data/spec/plugin/partials_spec.rb +1 -1
- data/spec/plugin/pass_spec.rb +1 -1
- data/spec/plugin/path_matchers_spec.rb +1 -1
- data/spec/plugin/path_rewriter_spec.rb +1 -1
- data/spec/plugin/path_spec.rb +1 -1
- data/spec/plugin/placeholder_string_matchers_spec.rb +3 -36
- data/spec/plugin/precompile_templates_spec.rb +1 -17
- data/spec/plugin/public_spec.rb +3 -4
- data/spec/plugin/render_each_spec.rb +1 -1
- data/spec/plugin/render_locals_spec.rb +1 -1
- data/spec/plugin/render_spec.rb +28 -114
- data/spec/plugin/request_headers_spec.rb +1 -1
- data/spec/plugin/response_request_spec.rb +1 -1
- data/spec/plugin/run_append_slash_spec.rb +1 -1
- data/spec/plugin/run_handler_spec.rb +1 -1
- data/spec/plugin/shared_vars_spec.rb +1 -1
- data/spec/plugin/sinatra_helpers_spec.rb +1 -1
- data/spec/plugin/slash_path_empty_spec.rb +1 -1
- data/spec/plugin/static_routing_spec.rb +1 -1
- data/spec/plugin/static_spec.rb +1 -1
- data/spec/plugin/status_303_spec.rb +1 -1
- data/spec/plugin/status_handler_spec.rb +1 -1
- data/spec/plugin/streaming_spec.rb +1 -106
- data/spec/plugin/strip_path_prefix_spec.rb +1 -1
- data/spec/plugin/symbol_matchers_spec.rb +1 -77
- data/spec/plugin/symbol_status_spec.rb +1 -1
- data/spec/plugin/symbol_views_spec.rb +1 -1
- data/spec/plugin/type_routing_spec.rb +1 -1
- data/spec/plugin/unescape_path_spec.rb +1 -1
- data/spec/plugin/view_options_spec.rb +16 -110
- data/spec/plugin_spec.rb +1 -1
- data/spec/redirect_spec.rb +1 -1
- data/spec/request_spec.rb +1 -1
- data/spec/response_spec.rb +1 -1
- data/spec/session_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -3
- data/spec/version_spec.rb +1 -1
- metadata +6 -26
- data/lib/roda/plugins/_erubis_escaping.rb +0 -59
- data/lib/roda/plugins/per_thread_caching.rb +0 -71
- data/lib/roda/plugins/static_path_info.rb +0 -12
- data/lib/roda/plugins/view_subdirs.rb +0 -7
- data/lib/roda/plugins/websockets.rb +0 -107
- data/spec/plugin/_erubis_escaping_spec.rb +0 -97
- data/spec/plugin/per_thread_caching_spec.rb +0 -28
- data/spec/plugin/websockets_spec.rb +0 -84
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7717dcab195a4aa608a95fe1b957a4e70e46eb1
|
|
4
|
+
data.tar.gz: a183e023f32c278e5ddce68390775ef396472d44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0aded27e4b6f521e554f49d14e805fe3bdf03265f3cb4b4437145bc8767ef4b07ced8e267caaee331dc8fba84cb706c166776dd507e5ff254238c9b39984a94a
|
|
7
|
+
data.tar.gz: 79cc0eeea440e916f31b5312c0005e06a543f29204b6ec4b3a34340a221708fb5779b85b38d1242bca29d9b86e789803336e502621bec68034e08e583e1df2b1
|
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
= 3.0.0 (2017-09-15)
|
|
2
|
+
|
|
3
|
+
* Make defined symbol_matcher and hash_matcher match methods private (jeremyevans)
|
|
4
|
+
|
|
5
|
+
* Use public_send instead of send unless calling private methods is expected (jeremyevans)
|
|
6
|
+
|
|
7
|
+
* Compute multi_run regexp when freezing app to avoid thread safety issues at runtime (jeremyevans)
|
|
8
|
+
|
|
9
|
+
* Remove deprecated support for using undefined multi_route namespaces when routing (jeremyevans)
|
|
10
|
+
|
|
11
|
+
* Make it possible to reset :include_request options to false for json and json_parser plugins (jeremyevans)
|
|
12
|
+
|
|
13
|
+
* Deprecate RodaRequest#placeholder_string_matcher? private method (jeremyevans)
|
|
14
|
+
|
|
15
|
+
* Deprecate Roda.thread_safe_cache, use RodaCache directly (jeremyevans)
|
|
16
|
+
|
|
17
|
+
* Make using an app as middleware always create a subclass of the app (jeremyevans)
|
|
18
|
+
|
|
19
|
+
* Enable SHA256 subresource integrity by default in assets plugin (jeremyevans)
|
|
20
|
+
|
|
21
|
+
* Make subclassing a roda app always inherit the render cache (jeremyevans)
|
|
22
|
+
|
|
23
|
+
* Make :cache=>nil render plugin option still allow caching via :cache render method option (jeremyevans)
|
|
24
|
+
|
|
25
|
+
* Make content_for plugin append to existing content by default (jeremyevans)
|
|
26
|
+
|
|
27
|
+
* Make :host matcher in the header_matchers plugin always yield captures if given a regexp (jeremyevans)
|
|
28
|
+
|
|
29
|
+
* Make :header matcher in the header_matchers plugin now always prefix header with HTTP_ (jeremyevans)
|
|
30
|
+
|
|
31
|
+
* Remove deprecated support for locals handling at the plugin level in the render plugin (jeremyevans)
|
|
32
|
+
|
|
33
|
+
* Remove deprecated support for handling locals in the view_options plugin (jeremyevans)
|
|
34
|
+
|
|
35
|
+
* Remove deprecated support for :ext option in render plugin (jeremyevans)
|
|
36
|
+
|
|
37
|
+
* Remove deprecated view_subdirs alias for view_options plugin (jeremyevans)
|
|
38
|
+
|
|
39
|
+
* Remove deprecated support for EventMachine and Stream#callback method in the streaming plugin (jeremyevans)
|
|
40
|
+
|
|
41
|
+
* Drop support for ruby 1.8.7 (jeremyevans)
|
|
42
|
+
|
|
43
|
+
* Make using an unsupported matcher raise error by default (jeremyevans)
|
|
44
|
+
|
|
45
|
+
* Make having a match/route block return an unsupported value raise error by default (jeremyevans)
|
|
46
|
+
|
|
47
|
+
* Remove deprecated :format, :opt, and :optd symbol matchers in symbol_matchers plugin (jeremyevans)
|
|
48
|
+
|
|
49
|
+
* Remove deprecated support for placeholders in string matchers (jeremyevans)
|
|
50
|
+
|
|
51
|
+
* Remove deprecated constants and plugins (jeremyevans)
|
|
52
|
+
|
|
1
53
|
= 2.29.0 (2017-08-16)
|
|
2
54
|
|
|
3
55
|
* Deprecate accessing multi_route namespace when there are no routes (jeremyevans)
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
|
@@ -131,10 +131,11 @@ allowing for code such as <tt>r.redirect(path) if some_condition</tt>.
|
|
|
131
131
|
If +r.redirect+ is called without arguments
|
|
132
132
|
and the current request method is not +GET+, it redirects to the current path.
|
|
133
133
|
|
|
134
|
-
The +.freeze.app+ at the end is optional. Freezing the app
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
The +.app+ is an optimization, which saves a few method calls
|
|
134
|
+
The +.freeze.app+ at the end is optional. Freezing the app makes modifying
|
|
135
|
+
app-level settings raise an error, alerting you to possible thread-safety issues
|
|
136
|
+
in your application. It is recommended to freeze the app in production and
|
|
137
|
+
during testing. The +.app+ is an optimization, which saves a few method calls
|
|
138
|
+
for every request.
|
|
138
139
|
|
|
139
140
|
== The Routing Tree
|
|
140
141
|
|
|
@@ -232,7 +233,7 @@ Here's an example showcasing how different matchers work:
|
|
|
232
233
|
end
|
|
233
234
|
|
|
234
235
|
# GET /username/foobar branch
|
|
235
|
-
r.on "username", String, :
|
|
236
|
+
r.on "username", String, method: :get do |username|
|
|
236
237
|
user = User.find_by_username(username)
|
|
237
238
|
|
|
238
239
|
# GET /username/foobar/posts
|
|
@@ -249,7 +250,7 @@ Here's an example showcasing how different matchers work:
|
|
|
249
250
|
|
|
250
251
|
# /search?q=barbaz
|
|
251
252
|
r.get "search" do
|
|
252
|
-
"Searched for #{r['q']}" #=> "Searched for barbaz"
|
|
253
|
+
"Searched for #{r.params['q']}" #=> "Searched for barbaz"
|
|
253
254
|
end
|
|
254
255
|
|
|
255
256
|
r.is "login" do
|
|
@@ -260,7 +261,7 @@ Here's an example showcasing how different matchers work:
|
|
|
260
261
|
|
|
261
262
|
# POST /login?user=foo&password=baz
|
|
262
263
|
r.post do
|
|
263
|
-
"#{r['user']}:#{r['password']}" #=> "foo:baz"
|
|
264
|
+
"#{r.params['user']}:#{r.params['password']}" #=> "foo:baz"
|
|
264
265
|
end
|
|
265
266
|
end
|
|
266
267
|
end
|
|
@@ -285,41 +286,15 @@ If a string contains any slashes, it matches one additional segment for each sla
|
|
|
285
286
|
"foo/bar" # matches "/foo/bar"
|
|
286
287
|
"foo/bar" # does not match "/foo/bard"
|
|
287
288
|
|
|
288
|
-
While deprecated by default, if a string contains a colon followed by any
|
|
289
|
-
<tt>\\w</tt> characters, the colon and remaining <tt>\\w</tt> characters match any
|
|
290
|
-
nonempty segment that contains at least one character:
|
|
291
|
-
|
|
292
|
-
"foo/:id" # matches "/foo/bar", "/foo/baz", etc.
|
|
293
|
-
"foo/:id" # does not match "/fo/bar"
|
|
294
|
-
|
|
295
|
-
You can use multiple colons in a string:
|
|
296
|
-
|
|
297
|
-
":x/:y" # matches "/foo/bar", "/bar/foo" etc.
|
|
298
|
-
":x/:y" # does not match "/foo", "/bar/"
|
|
299
|
-
|
|
300
|
-
Note that instead of using colons in strings, it is recommended to use separate
|
|
301
|
-
symbol arguments, as it is faster and simpler:
|
|
302
|
-
|
|
303
|
-
"foo", String # instead of "foo/:id"
|
|
304
|
-
String, String # instead of ":x/:y"
|
|
305
|
-
|
|
306
|
-
You can load the placeholder_string_matchers plugin to allow placeholders in
|
|
307
|
-
strings without a deprecation warning. The deprecated default handling of placeholders
|
|
308
|
-
in strings will be removed in Roda 3.
|
|
309
|
-
|
|
310
|
-
Note that other than colons followed by a <tt>\\w</tt> character, strings do no
|
|
311
|
-
handle regular expression syntax, they are matched verbatim:
|
|
312
|
-
|
|
313
|
-
"\\d+(/\\w+)?" # matches "/\d+(/\w+)?"
|
|
314
|
-
"\\d+(/\\w+)?" # does not match "/123/abc"
|
|
315
|
-
|
|
316
289
|
=== Regexp
|
|
317
290
|
|
|
318
291
|
Regexps match one or more segments by looking for the pattern,
|
|
319
|
-
preceded by a slash:
|
|
292
|
+
preceded by a slash, and followed by a slash or the end of the path:
|
|
320
293
|
|
|
321
294
|
/foo\w+/ # matches "/foobar"
|
|
322
295
|
/foo\w+/ # does not match "/foo/bar"
|
|
296
|
+
/foo/i # matches "/foo", "/Foo/"
|
|
297
|
+
/foo/i # does not match "/food"
|
|
323
298
|
|
|
324
299
|
If any patterns are captured by the Regexp, they are yielded:
|
|
325
300
|
|
|
@@ -331,7 +306,8 @@ If any patterns are captured by the Regexp, they are yielded:
|
|
|
331
306
|
There are two classes that are supported as matchers, String
|
|
332
307
|
and Integer.
|
|
333
308
|
|
|
334
|
-
String :: matches any non-empty segment
|
|
309
|
+
String :: matches any non-empty segment, yielding the segment except for
|
|
310
|
+
the preceding slash
|
|
335
311
|
Integer :: matches any segment of 0-9, returns matched values as integers
|
|
336
312
|
|
|
337
313
|
Using String and Integer is the recommended way to handle
|
|
@@ -396,7 +372,7 @@ allows for easily defining your own:
|
|
|
396
372
|
end
|
|
397
373
|
|
|
398
374
|
route do |r|
|
|
399
|
-
r.on :
|
|
375
|
+
r.on foo: 'bar' do
|
|
400
376
|
# ...
|
|
401
377
|
end
|
|
402
378
|
end
|
|
@@ -406,7 +382,7 @@ allows for easily defining your own:
|
|
|
406
382
|
|
|
407
383
|
The +:all+ matcher matches if all of the entries in the given array match, so
|
|
408
384
|
|
|
409
|
-
r.on :
|
|
385
|
+
r.on all: [String, String] do
|
|
410
386
|
# ...
|
|
411
387
|
end
|
|
412
388
|
|
|
@@ -419,7 +395,7 @@ is the same as:
|
|
|
419
395
|
The reason it also exists as a separate hash matcher
|
|
420
396
|
is so you can use it inside an array matcher, so:
|
|
421
397
|
|
|
422
|
-
r.on ['foo', {:
|
|
398
|
+
r.on ['foo', {all: ['foos', Integer]}] do
|
|
423
399
|
end
|
|
424
400
|
|
|
425
401
|
would match +/foo+ and +/foos/10+, but not +/foos+.
|
|
@@ -429,8 +405,8 @@ would match +/foo+ and +/foos/10+, but not +/foos+.
|
|
|
429
405
|
The +:method+ matcher matches the method of the request.
|
|
430
406
|
You can provide an array to specify multiple request methods and match on any of them:
|
|
431
407
|
|
|
432
|
-
{:
|
|
433
|
-
{:
|
|
408
|
+
{method: :post} # matches POST
|
|
409
|
+
{method: ['post', 'patch']} # matches POST and PATCH
|
|
434
410
|
|
|
435
411
|
=== false, nil
|
|
436
412
|
|
|
@@ -438,8 +414,8 @@ If +false+ or +nil+ is given directly as a matcher, it doesn't match anything.
|
|
|
438
414
|
|
|
439
415
|
=== Everything else
|
|
440
416
|
|
|
441
|
-
Everything else
|
|
442
|
-
|
|
417
|
+
Everything else raises an error, unless support is specifically added for it
|
|
418
|
+
(some plugins add support for additional matcher types).
|
|
443
419
|
|
|
444
420
|
== Optional segments
|
|
445
421
|
|
|
@@ -450,11 +426,11 @@ the item's id, and 456 being some optional data.
|
|
|
450
426
|
The simplest way to handle this is by treating this as two separate routes with a
|
|
451
427
|
shared branch:
|
|
452
428
|
|
|
453
|
-
r.on "items",
|
|
429
|
+
r.on "items", Integer do |item_id|
|
|
454
430
|
# Shared code for branch here
|
|
455
431
|
|
|
456
432
|
# /items/123/456
|
|
457
|
-
r.is
|
|
433
|
+
r.is Integer do |optional_data|
|
|
458
434
|
end
|
|
459
435
|
|
|
460
436
|
# /items/123
|
|
@@ -495,8 +471,7 @@ or route block return value is inspected:
|
|
|
495
471
|
|
|
496
472
|
String :: used as the response body
|
|
497
473
|
nil, false :: ignored
|
|
498
|
-
everything else ::
|
|
499
|
-
error starting in Roda 3
|
|
474
|
+
everything else :: raises an error
|
|
500
475
|
|
|
501
476
|
Plugins can add support for additional match block and route block return
|
|
502
477
|
values. One example of this is the json plugin, which allows returning
|
|
@@ -574,7 +549,7 @@ If you want to match the request method
|
|
|
574
549
|
and do only a partial match on the request path,
|
|
575
550
|
you need to use +r.on+ with the <tt>:method</tt> hash matcher:
|
|
576
551
|
|
|
577
|
-
r.on "foo", :
|
|
552
|
+
r.on "foo", method: :get do # Matches GET /foo(/.*)?
|
|
578
553
|
end
|
|
579
554
|
|
|
580
555
|
== Root Method
|
|
@@ -588,7 +563,7 @@ Unlike the other matching methods, +r.root+ takes no arguments.
|
|
|
588
563
|
|
|
589
564
|
Note that +r.root+ does not match if the path is empty;
|
|
590
565
|
you should use <tt>r.get true</tt> for that.
|
|
591
|
-
If you want to match either the
|
|
566
|
+
If you want to match either the empty path or +/+,
|
|
592
567
|
you can use <tt>r.get ["", true]</tt>, or use the slash_path_empty
|
|
593
568
|
plugin.
|
|
594
569
|
|
|
@@ -694,7 +669,7 @@ The default Rake task will run the specs for Roda.
|
|
|
694
669
|
== Settings
|
|
695
670
|
|
|
696
671
|
Each Roda app can store settings in the +opts+ hash.
|
|
697
|
-
The settings are inherited
|
|
672
|
+
The settings are inherited by subclasses.
|
|
698
673
|
|
|
699
674
|
Roda.opts[:layout] = "guest"
|
|
700
675
|
|
|
@@ -726,22 +701,6 @@ The following options are respected by the default library or multiple plugins:
|
|
|
726
701
|
:freeze_middleware :: Whether to freeze all middleware when building the rack app.
|
|
727
702
|
:root :: Set the root path for the app. This defaults to the current working
|
|
728
703
|
directory of the process.
|
|
729
|
-
:unsupported_block_result :: If set to :raise, raises an error if a match or
|
|
730
|
-
route block returns an object that is not handled.
|
|
731
|
-
By default, String, nil, and false are handled,
|
|
732
|
-
and other types can be handled via plugins. Setting
|
|
733
|
-
this option can alert you to possible issues in your
|
|
734
|
-
application.
|
|
735
|
-
:unsupported_matcher :: If set to :raise, raises an error if a matcher is used that
|
|
736
|
-
is not handled. By default, String, Symbol, Regexp, Hash,
|
|
737
|
-
Array, Proc, true, false, and nil are handled. Setting
|
|
738
|
-
this option can alert you to possible issues in your
|
|
739
|
-
application.
|
|
740
|
-
:verbatim_string_matcher :: If set to true, makes all string matchers match
|
|
741
|
-
verbatim strings, disallowing the use of colons
|
|
742
|
-
for placeholders. In general, it is recommended
|
|
743
|
-
to use separate symbol matchers instead of
|
|
744
|
-
embedding placeholders in string matchers.
|
|
745
704
|
|
|
746
705
|
There may be other options supported by individual plugins, if so it will be
|
|
747
706
|
mentioned in the documentation for the plugin.
|
|
@@ -769,7 +728,7 @@ By default, +view+ will render the template inside the default layout template;
|
|
|
769
728
|
r.get "render" do
|
|
770
729
|
# Renders the views/home.erb template, which will have access to
|
|
771
730
|
# the instance variable @var, as well as local variable content.
|
|
772
|
-
render("home", :
|
|
731
|
+
render("home", locals: {content: "hello, world"})
|
|
773
732
|
end
|
|
774
733
|
|
|
775
734
|
r.get "view" do
|
|
@@ -788,12 +747,10 @@ You can override the default rendering options by passing a hash to the plugin:
|
|
|
788
747
|
|
|
789
748
|
class App < Roda
|
|
790
749
|
plugin :render,
|
|
791
|
-
:
|
|
792
|
-
|
|
793
|
-
:
|
|
794
|
-
:
|
|
795
|
-
:ext=>'html.erb'}, # Default layout template options
|
|
796
|
-
:template_opts => {:default_encoding=>'UTF-8'} # Default template options
|
|
750
|
+
escape: true, # Automatically escape output in erb templates using Erubi's escaping support
|
|
751
|
+
views: 'admin_views', # Default views directory
|
|
752
|
+
layout_opts: {template: 'admin_layout', engine: 'html.erb'}, # Default layout options
|
|
753
|
+
template_opts: {default_encoding: 'UTF-8'} # Default template options
|
|
797
754
|
end
|
|
798
755
|
|
|
799
756
|
== Sessions
|
|
@@ -806,7 +763,7 @@ that comes with Rack:
|
|
|
806
763
|
require "roda"
|
|
807
764
|
|
|
808
765
|
class App < Roda
|
|
809
|
-
use Rack::Session::Cookie, :
|
|
766
|
+
use Rack::Session::Cookie, secret: ENV['SECRET']
|
|
810
767
|
end
|
|
811
768
|
|
|
812
769
|
== Security
|
|
@@ -853,14 +810,7 @@ are not escaping the output of the content template:
|
|
|
853
810
|
|
|
854
811
|
<%== yield %> # not <%= yield %>
|
|
855
812
|
|
|
856
|
-
|
|
857
|
-
make <tt><%= %></tt> not escape certain string subclasses, useful
|
|
858
|
-
if you have helpers that already return escaped output using a
|
|
859
|
-
string subclass instance.
|
|
860
|
-
|
|
861
|
-
This support requires {Erubis}[http://www.kuwata-lab.com/erubis/].
|
|
862
|
-
You can use <tt>:escape=>:erubi</tt> to use {Erubi}[https://github.com/jeremyevans/erubi],
|
|
863
|
-
a simplified fork of Erubis.
|
|
813
|
+
This support requires {Erubi}[https://github.com/jeremyevans/erubi].
|
|
864
814
|
|
|
865
815
|
=== Security Related HTTP Headers
|
|
866
816
|
|
|
@@ -890,36 +840,21 @@ Example:
|
|
|
890
840
|
|
|
891
841
|
=== Rendering Templates Derived From User Input
|
|
892
842
|
|
|
893
|
-
Roda's rendering plugin
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
843
|
+
Roda's rendering plugin by default checks that rendered templates are inside the views
|
|
844
|
+
directory. This is because rendering templates outside the views directory is not
|
|
845
|
+
commonly needed, and it prevents a common attack (which is especially severe if there is any
|
|
846
|
+
location on the file system that users can write files to).
|
|
897
847
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
view(r['page'])
|
|
902
|
-
end
|
|
903
|
-
end
|
|
904
|
-
|
|
905
|
-
Then attackers can submit a <tt>page</tt> parameter such as <tt>'../../../../tmp/upload'</tt>
|
|
906
|
-
to render the <tt>/tmp/upload.erb</tt> file. If you have another part of your system that
|
|
907
|
-
allows users to create files with arbitrary extensions (even temporary files), then it may
|
|
908
|
-
be possible to combine these two issues into a remote code execution exploit.
|
|
909
|
-
|
|
910
|
-
To mitigate against this issue, you can use the <tt>:check_paths => true</tt> render
|
|
911
|
-
option, which will check that the full path of the template to be rendered begins with the
|
|
912
|
-
+:views+ directory, and raises an exception if not. You can also use the +:allowed_paths+
|
|
913
|
-
render option to specify which paths are allowed. While
|
|
914
|
-
<tt>:check_paths => true</tt> is not currently the default, it will become the default in
|
|
915
|
-
Roda 3. Note that when specifying the +:path+ option when rendering a template, Roda will
|
|
848
|
+
You can specify which directories are allowed using the +:allowed_paths+ render plugin
|
|
849
|
+
option. If you really want to turn path checking off, you can do so via the
|
|
850
|
+
<tt>check_paths: false</tt> render plugin option.
|
|
916
851
|
not check paths, as it assumes that users and libraries that use this option will be checking
|
|
917
852
|
such paths manually.
|
|
918
853
|
|
|
919
854
|
== Code Reloading
|
|
920
855
|
|
|
921
|
-
Roda does not ship with integrated support for code reloading,
|
|
922
|
-
|
|
856
|
+
Roda does not ship with integrated support for code reloading, but there are rack-based
|
|
857
|
+
reloaders that will work with Roda apps.
|
|
923
858
|
|
|
924
859
|
For most applications, {rack-unreloader}[https://github.com/jeremyevans/rack-unreloader]
|
|
925
860
|
is probably the fastest approach to reloading while still being fairly safe, as it
|
|
@@ -954,7 +889,7 @@ It's fast but may cause issues in cases where you remove classes, constants, or
|
|
|
954
889
|
or when you are not clearing out cached data manually when files are reloaded.
|
|
955
890
|
|
|
956
891
|
There is no one reloading solution that is the best for all applications and development
|
|
957
|
-
approaches. Consider your needs and the
|
|
892
|
+
approaches. Consider your needs and the tradeoffs of each of the reloading approaches,
|
|
958
893
|
and pick the one you think will work best.
|
|
959
894
|
|
|
960
895
|
If you are unsure where to start, it may be best to start with rerun or shotgun
|
|
@@ -1060,9 +995,16 @@ It started out as a fork of Cuba, from which it borrows the idea of using a rout
|
|
|
1060
995
|
(which Cuba in turn took from {Rum}[https://github.com/chneukirchen/rum]).
|
|
1061
996
|
From Sinatra, it takes the ideas that route blocks should return the request bodies
|
|
1062
997
|
and that routes should be canonical.
|
|
1063
|
-
|
|
998
|
+
Roda's plugin system is based on the plugin system used by
|
|
1064
999
|
{Sequel}[http://sequel.jeremyevans.net].
|
|
1065
1000
|
|
|
1001
|
+
== Ruby Support Policy
|
|
1002
|
+
|
|
1003
|
+
Roda fully supports the currently supported versions of Ruby (MRI) and JRuby. It may
|
|
1004
|
+
support unsupported versions of Ruby or JRuby, but such support may be dropped in any
|
|
1005
|
+
minor version of keeping it becomes a support issue. The minimum Ruby version
|
|
1006
|
+
required to run the current version of Roda is 1.9.2.
|
|
1007
|
+
|
|
1066
1008
|
== License
|
|
1067
1009
|
|
|
1068
1010
|
MIT
|
data/Rakefile
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
require "rake"
|
|
2
2
|
require "rake/clean"
|
|
3
|
+
require "rdoc/task"
|
|
3
4
|
|
|
4
5
|
NAME = 'roda'
|
|
5
6
|
VERS = lambda do
|
|
6
|
-
|
|
7
|
+
require_relative 'lib/roda/version'
|
|
7
8
|
Roda::RodaVersion
|
|
8
9
|
end
|
|
9
10
|
CLEAN.include ["#{NAME}-*.gem", "rdoc", "coverage", "www/public/*.html", "www/public/rdoc", "spec/assets/app.*.css", "spec/assets/app.*.js", "spec/assets/app.*.css.gz", "spec/assets/app.*.js.gz"]
|
|
@@ -17,32 +18,24 @@ end
|
|
|
17
18
|
|
|
18
19
|
### RDoc
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
RDOC_OPTS = ["--line-numbers", "--inline-source", '--title', 'Roda: Routing tree web toolkit']
|
|
21
22
|
|
|
22
23
|
begin
|
|
23
24
|
gem 'hanna-nouveau'
|
|
24
|
-
|
|
25
|
+
RDOC_OPTS.concat(['-f', 'hanna'])
|
|
25
26
|
rescue Gem::LoadError
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
require "rdoc/task"
|
|
30
|
-
RDoc::Task
|
|
31
|
-
rescue LoadError
|
|
32
|
-
require "rake/rdoctask"
|
|
33
|
-
Rake::RDocTask
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc']
|
|
29
|
+
RDOC_OPTS.concat(['--main', 'README.rdoc'])
|
|
37
30
|
RDOC_FILES = %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb" + Dir["doc/*.rdoc"] + Dir['doc/release_notes/*.txt']
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
RDoc::Task.new do |rdoc|
|
|
40
33
|
rdoc.rdoc_dir = "rdoc"
|
|
41
34
|
rdoc.options += RDOC_OPTS
|
|
42
35
|
rdoc.rdoc_files.add RDOC_FILES
|
|
43
36
|
end
|
|
44
37
|
|
|
45
|
-
|
|
38
|
+
RDoc::Task.new(:website_rdoc) do |rdoc|
|
|
46
39
|
rdoc.rdoc_dir = "www/public/rdoc"
|
|
47
40
|
rdoc.options += RDOC_OPTS
|
|
48
41
|
rdoc.rdoc_files.add RDOC_FILES
|