roda 3.75.0 → 3.76.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 +8 -0
- data/doc/release_notes/3.76.0.txt +18 -0
- data/lib/roda/plugins/break.rb +43 -0
- data/lib/roda/plugins/error_email.rb +10 -1
- data/lib/roda/plugins/error_mail.rb +13 -2
- data/lib/roda/plugins/middleware.rb +3 -0
- data/lib/roda/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f4eee948a9994645560f635fd228d2f46f3f466da782a476d7046b2b0b9f026
|
4
|
+
data.tar.gz: 4abb6bed043b264c59e17b1120771822a26292f24037a283c08003168c72e602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 112d90a74ed25ae0bb608a2e89d2f6fa757912287feb3a68d312ef4b8fd317bdb8f04eb76f529090d14a92c322d869ededa831f8db5d20bce8a66cd973a71584
|
7
|
+
data.tar.gz: 22ddb0a055b5849c6dcd3ec93426e495198434cf1e9cf9adbae1c22ece9b788c0ea7332122b9ad525954e2b946b0eef873de3b0466fe5b844407dec6c9844c84
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
= 3.76.0 (2024-01-12)
|
2
|
+
|
3
|
+
* Support :filter plugin option in error_mail and error_email for filtering parameters, environment variables, and session values (jeremyevans) (#346)
|
4
|
+
|
5
|
+
* Set temporary name on Ruby 3.3 in middleware plugin for middleware class created (janko) (#344)
|
6
|
+
|
7
|
+
* Add break plugin, for using break inside a routing block to return from the block and keep routing (jeremyevans)
|
8
|
+
|
1
9
|
= 3.75.0 (2023-12-14)
|
2
10
|
|
3
11
|
* Add cookie_flags plugin, for overriding, warning, or raising for incorrect cookie flags (jeremyevans)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A break plugin has been added, allowing you to use break from
|
4
|
+
inside a routing block and continue routing after the block. This
|
5
|
+
offers the same feature as the pass plugin, but using the standard
|
6
|
+
break keyword instead of the r.pass method.
|
7
|
+
|
8
|
+
* The error_mail and error_email features now both accept a :filter
|
9
|
+
plugin option. The value should respond to call with two arguments.
|
10
|
+
The first arguments is the key, and the second is the value, and
|
11
|
+
should return a truthy value if the value should be filtered. This
|
12
|
+
will be used for filtering parameter values, ENV values, and session
|
13
|
+
values in the generated emails.
|
14
|
+
|
15
|
+
= Other Improvements
|
16
|
+
|
17
|
+
* On Ruby 3.3+, the middleware plugin sets a temporary class name for
|
18
|
+
the created middleware, based on the class name of the Roda app.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
class Roda
|
5
|
+
module RodaPlugins
|
6
|
+
# The break plugin supports calling break inside a match block, to
|
7
|
+
# return from the block and continue in the routing tree, restoring
|
8
|
+
# the remaining path so that future matchers operating on the path
|
9
|
+
# operate as expected.
|
10
|
+
#
|
11
|
+
# plugin :break
|
12
|
+
#
|
13
|
+
# route do |r|
|
14
|
+
# r.on "foo", :bar do |bar|
|
15
|
+
# break if bar == 'baz'
|
16
|
+
# "/foo/#{bar} (not baz)"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# r.on "foo/baz" do
|
20
|
+
# "/foo/baz"
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# This provides the same basic feature as the pass plugin, but
|
25
|
+
# uses Ruby's standard control flow primative instead of a
|
26
|
+
# separate method.
|
27
|
+
module Break
|
28
|
+
module RequestMethods
|
29
|
+
private
|
30
|
+
|
31
|
+
# Handle break inside match blocks, restoring remaining path.
|
32
|
+
def if_match(_)
|
33
|
+
rp = @remaining_path
|
34
|
+
super
|
35
|
+
ensure
|
36
|
+
@remaining_path = rp
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
register_plugin(:break, Break)
|
42
|
+
end
|
43
|
+
end
|
@@ -21,6 +21,9 @@ class Roda
|
|
21
21
|
#
|
22
22
|
# Options:
|
23
23
|
#
|
24
|
+
# :filter :: Callable called with the key and value for each parameter, environment
|
25
|
+
# variable, and session value. If it returns true, the value of the
|
26
|
+
# parameter is filtered in the email.
|
24
27
|
# :from :: The From address to use in the email (required)
|
25
28
|
# :headers :: A hash of additional headers to use in the email (default: empty hash)
|
26
29
|
# :host :: The SMTP server to use to send the email (default: localhost)
|
@@ -38,6 +41,7 @@ class Roda
|
|
38
41
|
# use an error reporting service instead of this plugin.
|
39
42
|
module ErrorEmail
|
40
43
|
DEFAULTS = {
|
44
|
+
:filter=>lambda{|k,v| false},
|
41
45
|
:headers=>OPTS,
|
42
46
|
:host=>'localhost',
|
43
47
|
# :nocov:
|
@@ -52,7 +56,12 @@ class Roda
|
|
52
56
|
{'From'=>h[:from], 'To'=>h[:to], 'Subject'=>"#{h[:prefix]}#{subject}"}
|
53
57
|
end,
|
54
58
|
:body=>lambda do |s, e|
|
55
|
-
|
59
|
+
filter = s.opts[:error_email][:filter]
|
60
|
+
format = lambda do |h|
|
61
|
+
h = h.map{|k, v| "#{k.inspect} => #{filter.call(k, v) ? 'FILTERED' : v.inspect}"}
|
62
|
+
h.sort!
|
63
|
+
h.join("\n")
|
64
|
+
end
|
56
65
|
|
57
66
|
begin
|
58
67
|
params = s.request.params
|
@@ -21,6 +21,9 @@ class Roda
|
|
21
21
|
#
|
22
22
|
# Options:
|
23
23
|
#
|
24
|
+
# :filter :: Callable called with the key and value for each parameter, environment
|
25
|
+
# variable, and session value. If it returns true, the value of the
|
26
|
+
# parameter is filtered in the email.
|
24
27
|
# :from :: The From address to use in the email (required)
|
25
28
|
# :headers :: A hash of additional headers to use in the email (default: empty hash)
|
26
29
|
# :prefix :: A prefix to use in the email's subject line (default: no prefix)
|
@@ -36,9 +39,12 @@ class Roda
|
|
36
39
|
# for low traffic web applications. For high traffic web applications,
|
37
40
|
# use an error reporting service instead of this plugin.
|
38
41
|
module ErrorMail
|
42
|
+
DEFAULT_FILTER = lambda{|k,v| false}
|
43
|
+
private_constant :DEFAULT_FILTER
|
44
|
+
|
39
45
|
# Set default opts for plugin. See ErrorEmail module RDoc for options.
|
40
46
|
def self.configure(app, opts=OPTS)
|
41
|
-
app.opts[:error_mail] = email_opts = (app.opts[:error_mail] ||
|
47
|
+
app.opts[:error_mail] = email_opts = (app.opts[:error_mail] || {:filter=>DEFAULT_FILTER}).merge(opts).freeze
|
42
48
|
unless email_opts[:to] && email_opts[:from]
|
43
49
|
raise RodaError, "must provide :to and :from options to error_mail plugin"
|
44
50
|
end
|
@@ -68,8 +74,13 @@ class Roda
|
|
68
74
|
e.to_s
|
69
75
|
end
|
70
76
|
subject = "#{email_opts[:prefix]}#{subject}"
|
77
|
+
filter = email_opts[:filter]
|
71
78
|
|
72
|
-
format = lambda
|
79
|
+
format = lambda do |h|
|
80
|
+
h = h.map{|k, v| "#{k.inspect} => #{filter.call(k, v) ? 'FILTERED' : v.inspect}"}
|
81
|
+
h.sort!
|
82
|
+
h.join("\n")
|
83
|
+
end
|
73
84
|
|
74
85
|
begin
|
75
86
|
params = request.params
|
@@ -134,6 +134,9 @@ class Roda
|
|
134
134
|
# and store +app+ as the next middleware to call.
|
135
135
|
def initialize(mid, app, *args, &block)
|
136
136
|
@mid = Class.new(mid)
|
137
|
+
# :nocov:
|
138
|
+
@mid.set_temporary_name("#{mid.name}(middleware)") if mid.name && RUBY_VERSION >= "3.3"
|
139
|
+
# :nocov:
|
137
140
|
if @mid.opts[:middleware_next_if_not_found]
|
138
141
|
@mid.plugin(:not_found, &NEXT_PROC)
|
139
142
|
end
|
data/lib/roda/version.rb
CHANGED
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.76.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:
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -249,6 +249,7 @@ extra_rdoc_files:
|
|
249
249
|
- doc/release_notes/3.73.0.txt
|
250
250
|
- doc/release_notes/3.74.0.txt
|
251
251
|
- doc/release_notes/3.75.0.txt
|
252
|
+
- doc/release_notes/3.76.0.txt
|
252
253
|
- doc/release_notes/3.8.0.txt
|
253
254
|
- doc/release_notes/3.9.0.txt
|
254
255
|
files:
|
@@ -331,6 +332,7 @@ files:
|
|
331
332
|
- doc/release_notes/3.73.0.txt
|
332
333
|
- doc/release_notes/3.74.0.txt
|
333
334
|
- doc/release_notes/3.75.0.txt
|
335
|
+
- doc/release_notes/3.76.0.txt
|
334
336
|
- doc/release_notes/3.8.0.txt
|
335
337
|
- doc/release_notes/3.9.0.txt
|
336
338
|
- lib/roda.rb
|
@@ -351,6 +353,7 @@ files:
|
|
351
353
|
- lib/roda/plugins/autoload_named_routes.rb
|
352
354
|
- lib/roda/plugins/backtracking_array.rb
|
353
355
|
- lib/roda/plugins/branch_locals.rb
|
356
|
+
- lib/roda/plugins/break.rb
|
354
357
|
- lib/roda/plugins/caching.rb
|
355
358
|
- lib/roda/plugins/capture_erb.rb
|
356
359
|
- lib/roda/plugins/chunked.rb
|
@@ -494,7 +497,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
494
497
|
- !ruby/object:Gem::Version
|
495
498
|
version: '0'
|
496
499
|
requirements: []
|
497
|
-
rubygems_version: 3.
|
500
|
+
rubygems_version: 3.5.3
|
498
501
|
signing_key:
|
499
502
|
specification_version: 4
|
500
503
|
summary: Routing tree web toolkit
|