roda 3.17.0 → 3.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +48 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +22 -4
- data/doc/release_notes/3.18.0.txt +170 -0
- data/lib/roda.rb +249 -26
- data/lib/roda/plugins/_after_hook.rb +4 -26
- data/lib/roda/plugins/_before_hook.rb +30 -2
- data/lib/roda/plugins/branch_locals.rb +2 -2
- data/lib/roda/plugins/class_level_routing.rb +9 -7
- data/lib/roda/plugins/default_headers.rb +15 -1
- data/lib/roda/plugins/default_status.rb +9 -10
- data/lib/roda/plugins/direct_call.rb +38 -0
- data/lib/roda/plugins/error_email.rb +1 -1
- data/lib/roda/plugins/error_handler.rb +37 -11
- data/lib/roda/plugins/hooks.rb +28 -30
- data/lib/roda/plugins/mail_processor.rb +16 -11
- data/lib/roda/plugins/mailer.rb +1 -1
- data/lib/roda/plugins/middleware.rb +13 -3
- data/lib/roda/plugins/multi_route.rb +3 -3
- data/lib/roda/plugins/named_templates.rb +4 -4
- data/lib/roda/plugins/path.rb +13 -8
- data/lib/roda/plugins/render.rb +2 -2
- data/lib/roda/plugins/route_block_args.rb +4 -3
- data/lib/roda/plugins/route_csrf.rb +9 -4
- data/lib/roda/plugins/sessions.rb +2 -1
- data/lib/roda/plugins/shared_vars.rb +1 -1
- data/lib/roda/plugins/static_routing.rb +7 -17
- data/lib/roda/plugins/status_handler.rb +5 -3
- data/lib/roda/plugins/view_options.rb +2 -2
- data/lib/roda/version.rb +1 -1
- data/spec/define_roda_method_spec.rb +257 -0
- data/spec/plugin/class_level_routing_spec.rb +0 -27
- data/spec/plugin/default_headers_spec.rb +7 -0
- data/spec/plugin/default_status_spec.rb +31 -1
- data/spec/plugin/direct_call_spec.rb +28 -0
- data/spec/plugin/error_handler_spec.rb +27 -0
- data/spec/plugin/hooks_spec.rb +21 -0
- data/spec/plugin/middleware_spec.rb +108 -36
- data/spec/plugin/multi_route_spec.rb +12 -0
- data/spec/plugin/route_csrf_spec.rb +27 -0
- data/spec/plugin/sessions_spec.rb +26 -1
- data/spec/plugin/static_routing_spec.rb +25 -3
- data/spec/plugin/status_handler_spec.rb +17 -0
- data/spec/route_spec.rb +39 -0
- data/spec/spec_helper.rb +2 -2
- metadata +9 -3
@@ -86,6 +86,28 @@ describe "static_routing plugin" do
|
|
86
86
|
a.must_equal [1,3,2]
|
87
87
|
end
|
88
88
|
|
89
|
+
it "supports overridding static routes" do
|
90
|
+
app(:static_routing) do |r|
|
91
|
+
end
|
92
|
+
app.static_route('/foo'){'bar'}
|
93
|
+
body('/foo').must_equal 'bar'
|
94
|
+
app.static_route('/foo'){'baz'}
|
95
|
+
body('/foo').must_equal 'baz'
|
96
|
+
end
|
97
|
+
|
98
|
+
it "keeps existing routes when loading the plugin" do
|
99
|
+
app(:bare) do
|
100
|
+
plugin :static_routing
|
101
|
+
static_route "/foo" do |r|
|
102
|
+
"#{r.path}:#{r.remaining_path}"
|
103
|
+
end
|
104
|
+
plugin :static_routing
|
105
|
+
|
106
|
+
route{}
|
107
|
+
end
|
108
|
+
body('/foo').must_equal '/foo:'
|
109
|
+
end
|
110
|
+
|
89
111
|
it "does not allow placeholders in static routes" do
|
90
112
|
app(:bare) do
|
91
113
|
plugin :static_routing
|
@@ -133,15 +155,15 @@ describe "static_routing plugin" do
|
|
133
155
|
it "freezes static routes when app is frozen" do
|
134
156
|
app(:bare) do
|
135
157
|
plugin :static_routing
|
136
|
-
static_route
|
158
|
+
static_route("/foo"){}
|
137
159
|
freeze
|
138
160
|
|
139
161
|
proc do
|
140
|
-
static_get
|
162
|
+
static_get("/foo"){}
|
141
163
|
end.must_raise
|
142
164
|
|
143
165
|
proc do
|
144
|
-
static_route
|
166
|
+
static_route("/bar"){}
|
145
167
|
end.must_raise
|
146
168
|
end
|
147
169
|
end
|
@@ -22,6 +22,23 @@ describe "status_handler plugin" do
|
|
22
22
|
status("/a").must_equal 200
|
23
23
|
end
|
24
24
|
|
25
|
+
it "passes request if block accepts argument" do
|
26
|
+
app(:bare) do
|
27
|
+
plugin :status_handler
|
28
|
+
|
29
|
+
status_handler(404) do |r|
|
30
|
+
r.path + 'foo'
|
31
|
+
end
|
32
|
+
|
33
|
+
route do |r|
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
body('/').must_equal '/foo'
|
38
|
+
body("/a").must_equal '/afoo'
|
39
|
+
status("/").must_equal 404
|
40
|
+
end
|
41
|
+
|
25
42
|
it "allows overriding status inside status_handler" do
|
26
43
|
app(:bare) do
|
27
44
|
plugin :status_handler
|
data/spec/route_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
describe "Roda.route" do
|
4
|
+
it "should set the route block" do
|
5
|
+
pr = proc{'123'}
|
6
|
+
app.route(&pr)
|
7
|
+
app.route_block.must_equal pr
|
8
|
+
body.must_equal '123'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should work if called in subclass and parent class later frozen" do
|
12
|
+
a = app
|
13
|
+
@app = Class.new(a)
|
14
|
+
@app.route{|r| "OK"}
|
15
|
+
body.must_equal "OK"
|
16
|
+
a.freeze
|
17
|
+
body.must_equal "OK"
|
18
|
+
app.freeze
|
19
|
+
body.must_equal "OK"
|
20
|
+
end
|
21
|
+
|
22
|
+
deprecated "should support #call being overridden" do
|
23
|
+
app.class_eval do
|
24
|
+
def call; super end
|
25
|
+
end
|
26
|
+
app.route{'123'}
|
27
|
+
body.must_equal '123'
|
28
|
+
end
|
29
|
+
|
30
|
+
deprecated "should support #_call" do
|
31
|
+
pr = proc{env['PATH_INFO']}
|
32
|
+
app{_call(&pr)}
|
33
|
+
body.must_equal '/'
|
34
|
+
end
|
35
|
+
|
36
|
+
deprecated "should be callable without a block" do
|
37
|
+
app.route.must_be_nil
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -77,7 +77,7 @@ class Minitest::Spec
|
|
77
77
|
def app(type=nil, &block)
|
78
78
|
case type
|
79
79
|
when :new
|
80
|
-
@app = _app{route(&block)}
|
80
|
+
@app = _app{route(&block) if block}
|
81
81
|
when :bare
|
82
82
|
@app = _app(&block)
|
83
83
|
when Symbol
|
@@ -89,7 +89,7 @@ class Minitest::Spec
|
|
89
89
|
if block
|
90
90
|
@app = _app{route(&block)}
|
91
91
|
else
|
92
|
-
@app ||= _app{
|
92
|
+
@app ||= _app{}
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -214,6 +214,7 @@ extra_rdoc_files:
|
|
214
214
|
- doc/release_notes/3.15.0.txt
|
215
215
|
- doc/release_notes/3.16.0.txt
|
216
216
|
- doc/release_notes/3.17.0.txt
|
217
|
+
- doc/release_notes/3.18.0.txt
|
217
218
|
files:
|
218
219
|
- CHANGELOG
|
219
220
|
- MIT-LICENSE
|
@@ -266,6 +267,7 @@ files:
|
|
266
267
|
- doc/release_notes/3.15.0.txt
|
267
268
|
- doc/release_notes/3.16.0.txt
|
268
269
|
- doc/release_notes/3.17.0.txt
|
270
|
+
- doc/release_notes/3.18.0.txt
|
269
271
|
- doc/release_notes/3.2.0.txt
|
270
272
|
- doc/release_notes/3.3.0.txt
|
271
273
|
- doc/release_notes/3.4.0.txt
|
@@ -297,6 +299,7 @@ files:
|
|
297
299
|
- lib/roda/plugins/delay_build.rb
|
298
300
|
- lib/roda/plugins/delegate.rb
|
299
301
|
- lib/roda/plugins/delete_empty_headers.rb
|
302
|
+
- lib/roda/plugins/direct_call.rb
|
300
303
|
- lib/roda/plugins/disallow_file_uploads.rb
|
301
304
|
- lib/roda/plugins/drop_body.rb
|
302
305
|
- lib/roda/plugins/early_hints.rb
|
@@ -377,6 +380,7 @@ files:
|
|
377
380
|
- spec/assets/css/raw.css
|
378
381
|
- spec/assets/js/head/app.js
|
379
382
|
- spec/composition_spec.rb
|
383
|
+
- spec/define_roda_method_spec.rb
|
380
384
|
- spec/env_spec.rb
|
381
385
|
- spec/freeze_spec.rb
|
382
386
|
- spec/integration_spec.rb
|
@@ -402,6 +406,7 @@ files:
|
|
402
406
|
- spec/plugin/delay_build_spec.rb
|
403
407
|
- spec/plugin/delegate_spec.rb
|
404
408
|
- spec/plugin/delete_empty_headers_spec.rb
|
409
|
+
- spec/plugin/direct_call_spec.rb
|
405
410
|
- spec/plugin/disallow_file_uploads_spec.rb
|
406
411
|
- spec/plugin/drop_body_spec.rb
|
407
412
|
- spec/plugin/early_hints_spec.rb
|
@@ -478,6 +483,7 @@ files:
|
|
478
483
|
- spec/redirect_spec.rb
|
479
484
|
- spec/request_spec.rb
|
480
485
|
- spec/response_spec.rb
|
486
|
+
- spec/route_spec.rb
|
481
487
|
- spec/session_middleware_spec.rb
|
482
488
|
- spec/session_spec.rb
|
483
489
|
- spec/spec_helper.rb
|
@@ -525,7 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
525
531
|
- !ruby/object:Gem::Version
|
526
532
|
version: '0'
|
527
533
|
requirements: []
|
528
|
-
rubygems_version: 3.0.
|
534
|
+
rubygems_version: 3.0.3
|
529
535
|
signing_key:
|
530
536
|
specification_version: 4
|
531
537
|
summary: Routing tree web toolkit
|