roda 3.68.0 → 3.69.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/doc/release_notes/3.69.0.txt +33 -0
- data/lib/roda/plugins/class_matchers.rb +1 -1
- data/lib/roda/plugins/symbol_matchers.rb +36 -5
- data/lib/roda/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2871ec8db3a18a77238fdae1aeb786c7a7eb93f14b0827428fab1b07f6e7bee8
|
4
|
+
data.tar.gz: 75db2ec79978055f407c2270cfd9119782322402c2c536a504fbfc08f4fedac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca4fdcac9bcba88309b8ccb4315ea2243530b08313135f97a643b81600b98821521fbbe08e9c7ab757732887326e8af492f0f3e883a3f54e7be73f0811d19e6
|
7
|
+
data.tar.gz: 6b313eecbd4f62d07bca53fa23db2325b4f53f3faf55344c86d8f543ff92c5dcba94235f963582ce227d3602e3ea8633e981393ef6aedcbe20fb8152e6409c08
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
= 3.69.0 (2023-06-13)
|
2
|
+
|
3
|
+
* Allow symbol_matcher in symbol_matchers plugin to take a block to allow type conversion (jeremyevans)
|
4
|
+
|
1
5
|
= 3.68.0 (2023-05-11)
|
2
6
|
|
3
7
|
* Make Roda.run in multi_run plugin accept blocks to allow autoloading the apps to dispatch to (jeremyevans)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
= New Feature
|
2
|
+
|
3
|
+
* The symbol_matcher method in the symbol_matchers plugin now
|
4
|
+
supports a block to allow for type conversion of matched
|
5
|
+
segments:
|
6
|
+
|
7
|
+
symbol_matcher(:date, /(\d\d\d\d)-(\d\d)-(\d\d)/) do |y, m, d|
|
8
|
+
[Date.new(y.to_i, m.to_i, d.to_i)]
|
9
|
+
end
|
10
|
+
|
11
|
+
route do |r|
|
12
|
+
r.on :date do |date|
|
13
|
+
# date is an instance of Date
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
As shown above, the block should return an array of objects to yield
|
18
|
+
to the match block.
|
19
|
+
|
20
|
+
If you have a segment match the passed regexp, but decide during block
|
21
|
+
processing that you do not want to treat it as a match, you can have the
|
22
|
+
block return nil or false. This is useful if you want to make sure you
|
23
|
+
are using valid data:
|
24
|
+
|
25
|
+
symbol_matcher(:date, /(\d\d\d\d)-(\d\d)-(\d\d)/) do |y, m, d|
|
26
|
+
y = y.to_i
|
27
|
+
m = m.to_i
|
28
|
+
d = d.to_i
|
29
|
+
[Date.new(y, m, d)] if Date.valid_date?(y, m, d)
|
30
|
+
end
|
31
|
+
|
32
|
+
When providing a block when using the symbol_matchers method, that
|
33
|
+
symbol may not work with the params_capturing plugin.
|
@@ -33,7 +33,7 @@ class Roda
|
|
33
33
|
# block return nil or false. This is useful if you want to make sure you
|
34
34
|
# are using valid data:
|
35
35
|
#
|
36
|
-
# class_matcher(Date, /(\
|
36
|
+
# class_matcher(Date, /(\d\d\d\d)-(\d\d)-(\d\d)/) do |y, m, d|
|
37
37
|
# y = y.to_i
|
38
38
|
# m = m.to_i
|
39
39
|
# d = d.to_i
|
@@ -37,6 +37,35 @@ class Roda
|
|
37
37
|
#
|
38
38
|
# If using this plugin with the params_capturing plugin, this plugin should
|
39
39
|
# be loaded first.
|
40
|
+
#
|
41
|
+
# You can provide a block when calling +symbol_matcher+, and it will be called
|
42
|
+
# for all matches to allow for type conversion. The block must return an
|
43
|
+
# array:
|
44
|
+
#
|
45
|
+
# symbol_matcher(:date, /(\d\d\d\d)-(\d\d)-(\d\d)/) do |y, m, d|
|
46
|
+
# [Date.new(y.to_i, m.to_i, d.to_i)]
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# route do |r|
|
50
|
+
# r.on :date do |date|
|
51
|
+
# # date is an instance of Date
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# If you have a segment match the passed regexp, but decide during block
|
56
|
+
# processing that you do not want to treat it as a match, you can have the
|
57
|
+
# block return nil or false. This is useful if you want to make sure you
|
58
|
+
# are using valid data:
|
59
|
+
#
|
60
|
+
# symbol_matcher(:date, /(\d\d\d\d)-(\d\d)-(\d\d)/) do |y, m, d|
|
61
|
+
# y = y.to_i
|
62
|
+
# m = m.to_i
|
63
|
+
# d = d.to_i
|
64
|
+
# [Date.new(y, m, d)] if Date.valid_date?(y, m, d)
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# However, if providing a block to the symbol_matchers plugin, the symbol may
|
68
|
+
# not work with the params_capturing plugin.
|
40
69
|
module SymbolMatchers
|
41
70
|
def self.load_dependencies(app)
|
42
71
|
app.plugin :_symbol_regexp_matchers
|
@@ -50,9 +79,10 @@ class Roda
|
|
50
79
|
|
51
80
|
module ClassMethods
|
52
81
|
# Set the regexp to use for the given symbol, instead of the default.
|
53
|
-
def symbol_matcher(s, re)
|
82
|
+
def symbol_matcher(s, re, &block)
|
54
83
|
meth = :"match_symbol_#{s}"
|
55
|
-
|
84
|
+
array = [re, block].freeze
|
85
|
+
self::RodaRequest.send(:define_method, meth){array}
|
56
86
|
self::RodaRequest.send(:private, meth)
|
57
87
|
end
|
58
88
|
end
|
@@ -67,8 +97,8 @@ class Roda
|
|
67
97
|
meth = :"match_symbol_#{s}"
|
68
98
|
if respond_to?(meth, true)
|
69
99
|
# Allow calling private match methods
|
70
|
-
re = send(meth)
|
71
|
-
consume(self.class.cached_matcher(re){re})
|
100
|
+
re, block = send(meth)
|
101
|
+
consume(self.class.cached_matcher(re){re}, &block)
|
72
102
|
else
|
73
103
|
super
|
74
104
|
end
|
@@ -80,7 +110,8 @@ class Roda
|
|
80
110
|
meth = :"match_symbol_#{s}"
|
81
111
|
if respond_to?(meth, true)
|
82
112
|
# Allow calling private match methods
|
83
|
-
send(meth)
|
113
|
+
re, = send(meth)
|
114
|
+
re
|
84
115
|
else
|
85
116
|
super
|
86
117
|
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.69.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: 2023-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -241,6 +241,7 @@ extra_rdoc_files:
|
|
241
241
|
- doc/release_notes/3.66.0.txt
|
242
242
|
- doc/release_notes/3.67.0.txt
|
243
243
|
- doc/release_notes/3.68.0.txt
|
244
|
+
- doc/release_notes/3.69.0.txt
|
244
245
|
- doc/release_notes/3.7.0.txt
|
245
246
|
- doc/release_notes/3.8.0.txt
|
246
247
|
- doc/release_notes/3.9.0.txt
|
@@ -316,6 +317,7 @@ files:
|
|
316
317
|
- doc/release_notes/3.66.0.txt
|
317
318
|
- doc/release_notes/3.67.0.txt
|
318
319
|
- doc/release_notes/3.68.0.txt
|
320
|
+
- doc/release_notes/3.69.0.txt
|
319
321
|
- doc/release_notes/3.7.0.txt
|
320
322
|
- doc/release_notes/3.8.0.txt
|
321
323
|
- doc/release_notes/3.9.0.txt
|