roda 3.62.0 → 3.63.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/doc/release_notes/3.63.0.txt +36 -0
- data/lib/roda/plugins/autoload_hash_branches.rb +67 -0
- data/lib/roda/plugins/mailer.rb +9 -3
- 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: 6e19674abcd02c79572ada44fe13fc8188a4cc91b780a3fbaa39da206cf7457f
|
4
|
+
data.tar.gz: ffd0e850b4aab5e82b3f5cf307145853df9d420389ff8eb6170ec53d3e29ca57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d91087a996b037de3c0ecc3ca5e029f6b4bb40c5da1618048d70c0aa42ac5dcc581b6ed67e55cd9236da5463c3c224c62b09f85797daeffcb9a8fb98a16bca03
|
7
|
+
data.tar.gz: 62d2e2fdb0efa867299a764d4f7b36fc1a1e680147d32703d29451e29d2e3090a0f337c2c87ac46929a5a504b6461f92d18b50a14c62f422de4c114e43892c91
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
= 3.63.0 (2022-12-16)
|
2
|
+
|
3
|
+
* Make mailer plugin set configured content type for body part for emails with attachments when using mail 2.8+ (jeremyevans)
|
4
|
+
|
5
|
+
* Add autoload_hash_branches plugin for autoloading file for a hash branch when there is a request for that branch (jeremyevans)
|
6
|
+
|
7
|
+
* Add mailer plugin :terminal option to make r.mail use a terminal match when provided arguments (jeremyevans)
|
8
|
+
|
1
9
|
= 3.62.0 (2022-11-14)
|
2
10
|
|
3
11
|
* Add typecast_params_sized_integers plugin for converting parameters to sized integers (jeremyevans)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An autoload_hash_branches plugin has been added for autoloading
|
4
|
+
route files for each hash branch, instead of requiring the route
|
5
|
+
files be loaded up front. For example, to automatically load a
|
6
|
+
route file for a hash branch on the first request to that branch:
|
7
|
+
|
8
|
+
plugin :autoload_hash_branches
|
9
|
+
autoload_hash_branch('branch_name', '/path/to/file')
|
10
|
+
autoload_hash_branch('namespace', 'branch_name', '/path/to/file')
|
11
|
+
|
12
|
+
The route file loaded should define the expected hash branch.
|
13
|
+
|
14
|
+
It is common to have route files stored in a directory, with the
|
15
|
+
file name matching the branch name. In that case, you can set
|
16
|
+
autoloading for all route files in a given directory:
|
17
|
+
|
18
|
+
plugin :autoload_hash_branches
|
19
|
+
autoload_hash_branch_dir('/path/to/dir')
|
20
|
+
autoload_hash_branch_dir('namespace', '/path/to/dir')
|
21
|
+
|
22
|
+
Note that autoloading hash branches does not work if the application
|
23
|
+
is frozen. This plugin should only be used in development mode for
|
24
|
+
faster startup, or when running tests on a subset of the application
|
25
|
+
in order to avoid loading parts of the application unrelated to what
|
26
|
+
is being tested.
|
27
|
+
|
28
|
+
* The mailer plugin now supports a :terminal plugin option to make
|
29
|
+
the r.mail method force a terminal match, similar to how r.get
|
30
|
+
and other HTTP verb methods work in standard Roda. This behavior
|
31
|
+
will become the default in Roda 4.
|
32
|
+
|
33
|
+
= Other Improvements
|
34
|
+
|
35
|
+
* The mailer plugin now correctly sets the content_type of the body
|
36
|
+
for emails with attachments when using mail 2.8.0+.
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
class Roda
|
5
|
+
module RodaPlugins
|
6
|
+
# The autoload_hash_branches plugin builds on the hash_branches plugin and allows for
|
7
|
+
# delaying loading of a file containing a hash branch for an application until there
|
8
|
+
# is a request that uses the hash branch. This can be useful in development
|
9
|
+
# to improvement startup time by not loading all branches up front. It can also be
|
10
|
+
# useful in testing subsets of an application by only loading the hash branches being
|
11
|
+
# tested.
|
12
|
+
#
|
13
|
+
# You can specify a single hash branch for autoloading:
|
14
|
+
#
|
15
|
+
# plugin :autoload_hash_branches
|
16
|
+
# autoload_hash_branch('branch_name', '/path/to/file')
|
17
|
+
# autoload_hash_branch('namespace', 'branch_name', '/path/to/file')
|
18
|
+
#
|
19
|
+
# You can also set the plugin to autoload load all hash branch files in a given directory.
|
20
|
+
# This will look at each .rb file in the directory, and add an autoload for it, using the
|
21
|
+
# filename without the .rb as the branch name:
|
22
|
+
#
|
23
|
+
# autoload_hash_branch_dir('/path/to/dir')
|
24
|
+
# autoload_hash_branch_dir('namespace', '/path/to/dir')
|
25
|
+
#
|
26
|
+
# In both cases, when the autoloaded file is required, it should redefine the same
|
27
|
+
# hash branch. If it does not, requests to the hash branch will result in a 404 error.
|
28
|
+
#
|
29
|
+
# This plugin will not work correctly when freezing applications, because it requires
|
30
|
+
# modifying the class at runtime as hash branches are autoloaded.
|
31
|
+
module AutoloadHashBranches
|
32
|
+
def self.load_dependencies(app)
|
33
|
+
app.plugin :hash_branches
|
34
|
+
end
|
35
|
+
|
36
|
+
module ClassMethods
|
37
|
+
# Autoload the given file when there is request for the hash branch.
|
38
|
+
# The given file should configure the hash branch specified.
|
39
|
+
def autoload_hash_branch(namespace='', segment, file)
|
40
|
+
segment = "/#{segment}"
|
41
|
+
routes = opts[:hash_branches][namespace] ||= {}
|
42
|
+
meth = routes[segment] = define_roda_method(routes[segment] || "hash_branch_#{namespace}_#{segment}", 1) do |r|
|
43
|
+
loc = method(routes[segment]).source_location
|
44
|
+
require file
|
45
|
+
# Avoid infinite loop in case method is not overridden
|
46
|
+
if method(meth).source_location != loc
|
47
|
+
send(meth, r)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
# For each .rb file in the given directory, add an autoloaded hash branch
|
54
|
+
# based on the file name.
|
55
|
+
def autoload_hash_branch_dir(namespace='', dir)
|
56
|
+
Dir.new(dir).entries.each do |file|
|
57
|
+
if file =~ /\.rb\z/i
|
58
|
+
autoload_hash_branch(namespace, file.sub(/\.rb\z/i, ''), File.join(dir, file))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
register_plugin(:autoload_hash_branches, AutoloadHashBranches)
|
66
|
+
end
|
67
|
+
end
|
data/lib/roda/plugins/mailer.rb
CHANGED
@@ -115,6 +115,11 @@ class Roda
|
|
115
115
|
#
|
116
116
|
# plugin :mailer, content_type: 'text/html'
|
117
117
|
#
|
118
|
+
# For backwards compatibility reasons, the +r.mail+ method does not do
|
119
|
+
# a terminal match by default if provided arguments (unlike +r.get+ and
|
120
|
+
# +r.post+). You can pass the :terminal option to make +r.mail+ enforce
|
121
|
+
# a terminal match if provided arguments.
|
122
|
+
#
|
118
123
|
# The mailer plugin does support being used inside a Roda application
|
119
124
|
# that is handling web requests, where the routing block for mails and
|
120
125
|
# web requests is shared. However, it's recommended that you create a
|
@@ -163,7 +168,8 @@ class Roda
|
|
163
168
|
# any arguments passed to the +mail+ or +sendmail+ Roda class methods.
|
164
169
|
def mail(*args)
|
165
170
|
if @env["REQUEST_METHOD"] == "MAIL"
|
166
|
-
|
171
|
+
# RODA4: Make terminal match the default
|
172
|
+
send(roda_class.opts[:mailer][:terminal] ? :_verb : :if_match, args) do |*vs|
|
167
173
|
yield(*(vs + @env['roda.mail_args']))
|
168
174
|
end
|
169
175
|
end
|
@@ -190,9 +196,9 @@ class Roda
|
|
190
196
|
|
191
197
|
if content_type = header_content_type || roda_class.opts[:mailer][:content_type]
|
192
198
|
if mail.multipart?
|
193
|
-
if
|
199
|
+
if /multipart\/mixed/ =~ mail.content_type &&
|
194
200
|
mail.parts.length >= 2 &&
|
195
|
-
(part = mail.parts.find{|p| !p.attachment && p.
|
201
|
+
(part = mail.parts.find{|p| !p.attachment && (p.encoded; /text\/plain/ =~ p.content_type)})
|
196
202
|
part.content_type = content_type
|
197
203
|
end
|
198
204
|
else
|
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.63.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: 2022-
|
11
|
+
date: 2022-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -235,6 +235,7 @@ extra_rdoc_files:
|
|
235
235
|
- doc/release_notes/3.60.0.txt
|
236
236
|
- doc/release_notes/3.61.0.txt
|
237
237
|
- doc/release_notes/3.62.0.txt
|
238
|
+
- doc/release_notes/3.63.0.txt
|
238
239
|
- doc/release_notes/3.7.0.txt
|
239
240
|
- doc/release_notes/3.8.0.txt
|
240
241
|
- doc/release_notes/3.9.0.txt
|
@@ -304,6 +305,7 @@ files:
|
|
304
305
|
- doc/release_notes/3.60.0.txt
|
305
306
|
- doc/release_notes/3.61.0.txt
|
306
307
|
- doc/release_notes/3.62.0.txt
|
308
|
+
- doc/release_notes/3.63.0.txt
|
307
309
|
- doc/release_notes/3.7.0.txt
|
308
310
|
- doc/release_notes/3.8.0.txt
|
309
311
|
- doc/release_notes/3.9.0.txt
|
@@ -320,6 +322,7 @@ files:
|
|
320
322
|
- lib/roda/plugins/all_verbs.rb
|
321
323
|
- lib/roda/plugins/assets.rb
|
322
324
|
- lib/roda/plugins/assets_preloading.rb
|
325
|
+
- lib/roda/plugins/autoload_hash_branches.rb
|
323
326
|
- lib/roda/plugins/backtracking_array.rb
|
324
327
|
- lib/roda/plugins/branch_locals.rb
|
325
328
|
- lib/roda/plugins/caching.rb
|
@@ -457,7 +460,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
457
460
|
- !ruby/object:Gem::Version
|
458
461
|
version: '0'
|
459
462
|
requirements: []
|
460
|
-
rubygems_version: 3.3.
|
463
|
+
rubygems_version: 3.3.26
|
461
464
|
signing_key:
|
462
465
|
specification_version: 4
|
463
466
|
summary: Routing tree web toolkit
|