roda 3.48.0 → 3.49.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 +6 -0
- data/README.rdoc +2 -1
- data/doc/release_notes/3.49.0.txt +18 -0
- data/lib/roda/plugins/_optimized_matching.rb +40 -2
- data/lib/roda/plugins/content_for.rb +2 -2
- data/lib/roda/plugins/content_security_policy.rb +2 -2
- data/lib/roda/plugins/module_include.rb +1 -1
- data/lib/roda/plugins/multi_route.rb +1 -1
- data/lib/roda/plugins/multi_run.rb +1 -1
- data/lib/roda/plugins/run_handler.rb +1 -1
- data/lib/roda/plugins/shared_vars.rb +1 -1
- data/lib/roda/plugins/sinatra_helpers.rb +1 -1
- data/lib/roda/plugins/typecast_params.rb +2 -2
- data/lib/roda/request.rb +1 -1
- 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: 2d3b9688bae8b0013acedfc6a5bcb45c374e0a73fd30e56985f0ebeee942ef8c
|
4
|
+
data.tar.gz: acb8215250d1615f007a2ec01d2b6546376414d2fea23a4f2341af9efd951110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a5434bdcb6926d6c5e656c25b46e16b035ad54d74ed16bdc1cf46005b8ef605b3371a628cae52d65803064aa3d2eac8a56c2e8e1e55b6f3a82c04a74c636855
|
7
|
+
data.tar.gz: 9dc3773fae04325373adb8a7a57d52166bb65c238b959999adf6f6f17a3be29fcdedcea677eeeaaa84f6a01b5accb4aff2594817165b8a77a45106a3d4a9dea3
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
= 3.49.0 (2021-10-13)
|
2
|
+
|
3
|
+
* Switch block_given? to defined?(yield) (jeremyevans)
|
4
|
+
|
5
|
+
* Automatically optimize remaining r.is/r.get/r.post calls with a single argument (jeremyevans)
|
6
|
+
|
1
7
|
= 3.48.0 (2021-09-13)
|
2
8
|
|
3
9
|
* Extract named_routes plugin from multi_route plugin (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -1109,7 +1109,8 @@ Roda's plugin system is based on the plugin system used by
|
|
1109
1109
|
Roda fully supports the currently supported versions of Ruby (MRI) and JRuby. It may
|
1110
1110
|
support unsupported versions of Ruby or JRuby, but such support may be dropped in any
|
1111
1111
|
minor version if keeping it becomes a support issue. The minimum Ruby version
|
1112
|
-
required to run the current version of Roda is 1.9.2
|
1112
|
+
required to run the current version of Roda is 1.9.2, and the minimum JRuby version is
|
1113
|
+
9.0.0.0.
|
1113
1114
|
|
1114
1115
|
== License
|
1115
1116
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
= Improvements
|
2
|
+
|
3
|
+
* The r.is optimization added in 3.46.0 has been extended to optimize
|
4
|
+
all single argument calls. This results in the following speedups
|
5
|
+
based on argument type:
|
6
|
+
|
7
|
+
* Hash/Class matching: 20%
|
8
|
+
* Symbol matching: 25%
|
9
|
+
* Array matching: 35%
|
10
|
+
* Proc matching: 50%
|
11
|
+
* false/nil matching: 65%
|
12
|
+
|
13
|
+
* Roda now uses defined?(yield) instead of block_given? internally
|
14
|
+
for better performance on CRuby. defined?(yield) is faster as it is
|
15
|
+
built into the VM, while block_given? is a regular method and has
|
16
|
+
the overhead of calling a regular method. Note that defined?(yield)
|
17
|
+
is not implemented correctly on JRuby before 9.0.0.0, so this
|
18
|
+
release of Roda drops support for JRuby versions before 9.0.0.0.
|
@@ -156,7 +156,21 @@ class Roda
|
|
156
156
|
always{yield(matchdata[1].to_i)}
|
157
157
|
end
|
158
158
|
else
|
159
|
-
|
159
|
+
path = @remaining_path
|
160
|
+
captures = @captures.clear
|
161
|
+
meth = :"_match_class_#{matcher}"
|
162
|
+
if respond_to?(meth, true)
|
163
|
+
# Allow calling private methods, as match methods are generally private
|
164
|
+
if send(meth, &block) && @remaining_path.empty?
|
165
|
+
block_result(yield(*captures))
|
166
|
+
throw :halt, response.finish
|
167
|
+
else
|
168
|
+
@remaining_path = path
|
169
|
+
false
|
170
|
+
end
|
171
|
+
else
|
172
|
+
unsupported_matcher(matcher)
|
173
|
+
end
|
160
174
|
end
|
161
175
|
when Regexp
|
162
176
|
if (matchdata = self.class.cached_matcher(matcher){matcher}.match(@remaining_path)) && matchdata.post_match.empty?
|
@@ -165,8 +179,32 @@ class Roda
|
|
165
179
|
end
|
166
180
|
when true
|
167
181
|
always(&block) if @remaining_path.empty?
|
182
|
+
when false, nil
|
183
|
+
# nothing
|
168
184
|
else
|
169
|
-
|
185
|
+
path = @remaining_path
|
186
|
+
captures = @captures.clear
|
187
|
+
|
188
|
+
matched = case matcher
|
189
|
+
when Array
|
190
|
+
_match_array(matcher)
|
191
|
+
when Hash
|
192
|
+
_match_hash(matcher)
|
193
|
+
when Symbol
|
194
|
+
_match_symbol(matcher)
|
195
|
+
when Proc
|
196
|
+
matcher.call
|
197
|
+
else
|
198
|
+
unsupported_matcher(matcher)
|
199
|
+
end
|
200
|
+
|
201
|
+
if matched && @remaining_path.empty?
|
202
|
+
block_result(yield(*captures))
|
203
|
+
throw :halt, response.finish
|
204
|
+
else
|
205
|
+
@remaining_path = path
|
206
|
+
false
|
207
|
+
end
|
170
208
|
end
|
171
209
|
end
|
172
210
|
end
|
@@ -75,8 +75,8 @@ class Roda
|
|
75
75
|
def content_for(key, value=nil)
|
76
76
|
append = opts[:append_content_for]
|
77
77
|
|
78
|
-
if
|
79
|
-
if
|
78
|
+
if defined?(yield) || value
|
79
|
+
if defined?(yield)
|
80
80
|
outvar = render_opts[:template_opts][:outvar]
|
81
81
|
buf_was = instance_variable_get(outvar)
|
82
82
|
|
@@ -278,7 +278,7 @@ class Roda
|
|
278
278
|
Policy.new
|
279
279
|
end
|
280
280
|
|
281
|
-
yield policy if
|
281
|
+
yield policy if defined?(yield)
|
282
282
|
policy.freeze
|
283
283
|
end
|
284
284
|
|
@@ -287,7 +287,7 @@ class Roda
|
|
287
287
|
# current content security policy.
|
288
288
|
def content_security_policy
|
289
289
|
policy = @_response.content_security_policy
|
290
|
-
yield policy if
|
290
|
+
yield policy if defined?(yield)
|
291
291
|
policy
|
292
292
|
end
|
293
293
|
end
|
@@ -72,7 +72,7 @@ class Roda
|
|
72
72
|
end
|
73
73
|
|
74
74
|
if mod
|
75
|
-
raise RodaError, "can't provide both argument and block to response_module" if
|
75
|
+
raise RodaError, "can't provide both argument and block to response_module" if defined?(yield)
|
76
76
|
klass.send(:include, mod)
|
77
77
|
else
|
78
78
|
if instance_variable_defined?(iv)
|
@@ -384,7 +384,7 @@ class Roda
|
|
384
384
|
|
385
385
|
# Set or retrieve the response body. When a block is given,
|
386
386
|
# evaluation is deferred until the body is needed.
|
387
|
-
def body(value = (return @body unless
|
387
|
+
def body(value = (return @body unless defined?(yield); nil), &block)
|
388
388
|
if block
|
389
389
|
@body = DelayedBody.new(&block)
|
390
390
|
else
|
@@ -564,7 +564,7 @@ class Roda
|
|
564
564
|
end
|
565
565
|
|
566
566
|
v = @obj[key]
|
567
|
-
v = yield if v.nil? &&
|
567
|
+
v = yield if v.nil? && defined?(yield)
|
568
568
|
|
569
569
|
begin
|
570
570
|
sub = self.class.nest(v, Array(@nesting) + [key])
|
@@ -580,7 +580,7 @@ class Roda
|
|
580
580
|
# Return the nested value for key. If there is no nested_value for +key+,
|
581
581
|
# calls the block to return the value, or returns nil if there is no block given.
|
582
582
|
def fetch(key)
|
583
|
-
send(:[], key){return(yield if
|
583
|
+
send(:[], key){return(yield if defined?(yield))}
|
584
584
|
end
|
585
585
|
|
586
586
|
# Captures conversions inside the given block, and returns a hash of all conversions,
|
data/lib/roda/request.rb
CHANGED
@@ -520,7 +520,7 @@ class Roda
|
|
520
520
|
if matchdata = pattern.match(@remaining_path)
|
521
521
|
@remaining_path = matchdata.post_match
|
522
522
|
captures = matchdata.captures
|
523
|
-
captures = yield(*captures) if
|
523
|
+
captures = yield(*captures) if defined?(yield)
|
524
524
|
@captures.concat(captures)
|
525
525
|
end
|
526
526
|
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.49.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: 2021-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -219,6 +219,7 @@ extra_rdoc_files:
|
|
219
219
|
- doc/release_notes/3.46.0.txt
|
220
220
|
- doc/release_notes/3.47.0.txt
|
221
221
|
- doc/release_notes/3.48.0.txt
|
222
|
+
- doc/release_notes/3.49.0.txt
|
222
223
|
- doc/release_notes/3.5.0.txt
|
223
224
|
- doc/release_notes/3.6.0.txt
|
224
225
|
- doc/release_notes/3.7.0.txt
|
@@ -274,6 +275,7 @@ files:
|
|
274
275
|
- doc/release_notes/3.46.0.txt
|
275
276
|
- doc/release_notes/3.47.0.txt
|
276
277
|
- doc/release_notes/3.48.0.txt
|
278
|
+
- doc/release_notes/3.49.0.txt
|
277
279
|
- doc/release_notes/3.5.0.txt
|
278
280
|
- doc/release_notes/3.6.0.txt
|
279
281
|
- doc/release_notes/3.7.0.txt
|