roda 3.58.0 → 3.59.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01acdb87d6bf21ec4137dd2b6c7e3210c5923c43f188a510135c30a66945160a
4
- data.tar.gz: e84ddddfbfe23a4be3951c2611f38916cb6dfb60b15c1a6bfd18155869ad4985
3
+ metadata.gz: 963e2d9ac538dbe97835ef65e2e2ba4184838664696bb084ce423a85ef23c205
4
+ data.tar.gz: d47a7f9c86357e99b0c9f470b6c33a32962df55189303020982af55d70907c7b
5
5
  SHA512:
6
- metadata.gz: 1681a1b8b8eb950be113d1a533c545ed0a71c24dc6d027a41d2cddb1ae99e4a2c2d23fc0e4c84d1f2960fd141021684d37d75e8509b247d732203100eae6ab2f
7
- data.tar.gz: a21456321d0ab6f3c32d4ba97dabd31635751caee7889a2b556dd17cc74fb019d974cc06500081a859402cbf8002a26144d4885dbd8c47589852395d1e398ed2
6
+ metadata.gz: c84cb0ae8c66b537c0a7d32d83d9c5a639439b15fbc650d3569efab5e134e0883ba06183c7f17bfb379f4018060c7d276a5016431ae3e21d05c2db3801a85762
7
+ data.tar.gz: 0c9495ec5fe24b774512f6495f97f5bb4cf8189b964f21a04c5e880d4a536ade2e045c7131f0a54a7c1cd203fe142d53c6d7cde4cf223a8e8be4cb5c5475fede
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ = 3.59.0 (2022-08-12)
2
+
3
+ * Add additional_render_engines plugin, for considering multiple render engines for templates (jeremyevans)
4
+
5
+ * Fix typo in private method name in delete_empty_headers plugin (mculpt) (#279)
6
+
1
7
  = 3.58.0 (2022-07-13)
2
8
 
3
9
  * Add filter_common_logger plugin for skipping the logging of certain requests when using the common_logger plugin (jeremyevans)
@@ -0,0 +1,17 @@
1
+ = New Features
2
+
3
+ * An additional_render_engines plugin has been added, for considering
4
+ multiple render engines for templates. If the template path does not
5
+ exist for the default render engine, then each additional render
6
+ engine will be checked, returning the first path that exists:
7
+
8
+ plugin :additional_render_engines, ['haml', 'str']
9
+
10
+ This is similar to the additional_view_directories plugin added in
11
+ 3.53.0. Both plugins can be used if you want to consider multiple
12
+ view directories and multiple render engines.
13
+
14
+ = Other Improvements
15
+
16
+ * A typo in a private method name in the delete_empty_headers plugin
17
+ has been fixed.
@@ -0,0 +1,61 @@
1
+ # frozen-string-literal: true
2
+
3
+ #
4
+ class Roda
5
+ module RodaPlugins
6
+ # The additional_render_engines plugin allows for specifying additional render
7
+ # engines to consider for templates. When rendering a template, it will
8
+ # first try the default template engine specified in the render plugin. If the
9
+ # template file to be rendered does not exist, it will try each additional render
10
+ # engine specified in this plugin, in order, using the path to the first
11
+ # template file that exists in the file system. If no such path is found, it
12
+ # uses the default path specified by the render plugin.
13
+ #
14
+ # Example:
15
+ #
16
+ # plugin :render # default engine is 'erb'
17
+ # plugin :additional_render_engines, ['haml', 'str']
18
+ #
19
+ # route do |r|
20
+ # # Will check the following in order, using path for first
21
+ # # template file that exists:
22
+ # # * views/t.erb
23
+ # # * views/t.haml
24
+ # # * views/t.str
25
+ # render :t
26
+ # end
27
+ module AdditionalRenderEngines
28
+ def self.load_dependencies(app, render_engines)
29
+ app.plugin :render
30
+ end
31
+
32
+ # Set the additional render engines to consider.
33
+ def self.configure(app, render_engines)
34
+ app.opts[:additional_render_engines] = render_engines.dup.freeze
35
+ end
36
+
37
+ module InstanceMethods
38
+ private
39
+
40
+ # If the template path does not exist, try looking for the template
41
+ # using each of the render engines, in order, returning
42
+ # the first path that exists. If no template path exists for the
43
+ # default any or any additional engines, return the original path.
44
+ def template_path(opts)
45
+ orig_path = super
46
+
47
+ unless File.file?(orig_path)
48
+ self.opts[:additional_render_engines].each do |engine|
49
+ path = super(opts.merge(:engine=>engine))
50
+ return path if File.file?(path)
51
+ end
52
+ end
53
+
54
+ orig_path
55
+ end
56
+ end
57
+ end
58
+
59
+ register_plugin(:additional_render_engines, AdditionalRenderEngines)
60
+ end
61
+ end
@@ -147,7 +147,7 @@ class Roda
147
147
  # If you have the yuicompressor gem installed and working, it will be used
148
148
  # automatically to compress your javascript and css assets. For javascript
149
149
  # assets, if yuicompressor is not available, the plugin will check for
150
- # closure_compiler, uglifier, and minjs and use the first one that works.
150
+ # closure-compiler, uglifier, and minjs and use the first one that works.
151
151
  # If no compressors are available, the assets will just be concatenated
152
152
  # together and not compressed during compilation. You can use the
153
153
  # :css_compressor and :js_compressor options to specify the compressor to use.
@@ -13,18 +13,18 @@ class Roda
13
13
  module ResponseMethods
14
14
  # Delete any empty headers when calling finish
15
15
  def finish
16
- delelete_empty_headers(super)
16
+ delete_empty_headers(super)
17
17
  end
18
18
 
19
19
  # Delete any empty headers when calling finish_with_body
20
20
  def finish_with_body(_)
21
- delelete_empty_headers(super)
21
+ delete_empty_headers(super)
22
22
  end
23
23
 
24
24
  private
25
25
 
26
26
  # Delete any empty headers from response
27
- def delelete_empty_headers(res)
27
+ def delete_empty_headers(res)
28
28
  res[1].delete_if{|_, v| v.is_a?(String) && v.empty?}
29
29
  res
30
30
  end
@@ -465,7 +465,11 @@ class Roda
465
465
  def #{field}(address, &block)
466
466
  on(:#{field}=>address, &block)
467
467
  end
468
+ END
469
+
470
+ next if [:rcpt, :text, :body, :subject].include?(field)
468
471
 
472
+ class_eval(<<-END, __FILE__, __LINE__+1)
469
473
  private
470
474
 
471
475
  def match_#{field}(address)
@@ -474,11 +478,6 @@ class Roda
474
478
  END
475
479
  end
476
480
 
477
- undef_method :match_rcpt
478
- undef_method :match_text
479
- undef_method :match_body
480
- undef_method :match_subject
481
-
482
481
  # Same as +header+, but also mark the message as being handled.
483
482
  def handle_header(key, value=nil)
484
483
  header(key, value) do |*args|
data/lib/roda/version.rb CHANGED
@@ -4,7 +4,7 @@ class Roda
4
4
  RodaMajorVersion = 3
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 58
7
+ RodaMinorVersion = 59
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
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.58.0
4
+ version: 3.59.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-07-13 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -230,6 +230,7 @@ extra_rdoc_files:
230
230
  - doc/release_notes/3.56.0.txt
231
231
  - doc/release_notes/3.57.0.txt
232
232
  - doc/release_notes/3.58.0.txt
233
+ - doc/release_notes/3.59.0.txt
233
234
  - doc/release_notes/3.6.0.txt
234
235
  - doc/release_notes/3.7.0.txt
235
236
  - doc/release_notes/3.8.0.txt
@@ -295,6 +296,7 @@ files:
295
296
  - doc/release_notes/3.56.0.txt
296
297
  - doc/release_notes/3.57.0.txt
297
298
  - doc/release_notes/3.58.0.txt
299
+ - doc/release_notes/3.59.0.txt
298
300
  - doc/release_notes/3.6.0.txt
299
301
  - doc/release_notes/3.7.0.txt
300
302
  - doc/release_notes/3.8.0.txt
@@ -306,6 +308,7 @@ files:
306
308
  - lib/roda/plugins/_before_hook.rb
307
309
  - lib/roda/plugins/_optimized_matching.rb
308
310
  - lib/roda/plugins/_symbol_regexp_matchers.rb
311
+ - lib/roda/plugins/additional_render_engines.rb
309
312
  - lib/roda/plugins/additional_view_directories.rb
310
313
  - lib/roda/plugins/all_verbs.rb
311
314
  - lib/roda/plugins/assets.rb