roda 3.106.0 → 3.107.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90404574f8af3e952feb444cabe5bb01430e2d7c3658daee9f22f0c22e25d5f6
4
- data.tar.gz: 347ba47cf4c3b9e280848ba717a1a4a9f57f8ac0712d2aaa8e5942020c22cb29
3
+ metadata.gz: 84bb84bd98ebe0d00d48315d9036ae1c22d93c92715922a6dba297f225c9fec7
4
+ data.tar.gz: 7cf2abbe3656ec22aef206a4e895c2520a8f80dc0ed11ec058a8a5f4cf3194b5
5
5
  SHA512:
6
- metadata.gz: 00e03ccebd8d48c4c1576ae0da2929d85a30430114b9a292bd8b9029fba31b4a7fa10767d7fb59a643c4280fb659e9afa90dacde27c7a5bdbc98fc5ee1df40a6
7
- data.tar.gz: 7867f8da5bad9db4102f09fc692158feee7605c8021b5d01bb07ebfe57d3a82ca0b18d7fc1341d6e5cdf9ff534736a6c9c3ce2420b2078abe96209ad423bce92
6
+ metadata.gz: 874ed7d5065e77c593bccd1939d3742acf3e65a0b6ea6eb95e02cd6ce9ca55c9819cfafe6ecfc61ce548075832b91c68800e7f5ae35774efb60949f0a86cb1ae
7
+ data.tar.gz: 40a37368dfc79527849fec46d615c26680cad15dd590b8b6a3dba0fa2809c2b90bacefa70f65b78566f88c62485f97afd715494a214fcc87050125ac7743d519
@@ -159,6 +159,35 @@ class Roda
159
159
  # plugin :assets,
160
160
  # css_opts: {style: :compressed}
161
161
  #
162
+ # In Roda 4, automatic compression of assets will not be attempted. You will
163
+ # need to specify the compressor to use using a Proc or Method. Here are values
164
+ # that you can use.
165
+ #
166
+ # ==== yui
167
+ #
168
+ # require 'yuicompressor'
169
+ # plugin :assets,
170
+ # css_compressor: lambda{|v| ::YUICompressor.compress_css(v, munge: true) },
171
+ # js_compressor: lambda{|v| ::YUICompressor.compress_js(v, munge: true) }
172
+ #
173
+ # ==== closure-compiler
174
+ #
175
+ # require 'closure-compiler'
176
+ # plugin :assets, js_compressor: ::Closure::Compiler.new.method(:compile)
177
+ #
178
+ # ==== uglifier
179
+ #
180
+ # require 'uglifier'
181
+ # plugin :assets, js_compressor: Uglifier.method(:compile)
182
+ #
183
+ # ==== minjs
184
+ #
185
+ # require 'minjs'
186
+ # plugin :assets,
187
+ # js_compressor: proc { |content|
188
+ # Minjs::Compressor::Compressor.new(debug: false).compress(content).to_js
189
+ # }
190
+ #
162
191
  # === Source Maps (CSS)
163
192
  #
164
193
  # The assets plugin does not have direct support for source maps, so it is
@@ -274,7 +303,7 @@ class Roda
274
303
  # :compiled_path:: Path inside public folder in which compiled files are stored (default: :prefix)
275
304
  # :concat_only :: Whether to just concatenate instead of concatenating
276
305
  # and compressing files (default: false)
277
- # :css_compressor :: Compressor to use for compressing CSS, either :yui, :none, or nil (the default, which will try
306
+ # :css_compressor :: Compressor to use for compressing CSS, either a Proc, Method, :yui, :none, or nil (the default, which will try
278
307
  # :yui if available, but not fail if it is not available)
279
308
  # :css_dir :: Directory name containing your css source, inside :path (default: 'css')
280
309
  # :css_headers :: A hash of additional headers for your rendered css files
@@ -288,7 +317,7 @@ class Roda
288
317
  # related group are contained in a subdirectory with the same name (default: true)
289
318
  # :gzip :: Store gzipped compiled assets files, and serve those to clients who accept gzip encoding.
290
319
  # :headers :: A hash of additional headers for both js and css rendered files
291
- # :js_compressor :: Compressor to use for compressing javascript, either :yui, :closure, :uglifier, :minjs,
320
+ # :js_compressor :: Compressor to use for compressing javascript, either a Proc, Method, :yui, :closure, :uglifier, :minjs,
292
321
  # :none, or nil (the default, which will try :yui, :closure, :uglifier, then :minjs, but
293
322
  # not fail if any of them is not available)
294
323
  # :js_dir :: Directory name containing your javascript source, inside :path (default: 'js')
@@ -454,6 +483,17 @@ class Roda
454
483
  opts[:js_suffix] = (opts[:add_suffix] ? '.js' : '').freeze
455
484
  opts[:css_suffix] = (opts[:add_suffix] ? '.css' : '').freeze
456
485
 
486
+ unless opts[:concat_only]
487
+ [:css_compressor, :js_compressor].each do |s|
488
+ case v = opts[s]
489
+ when nil, :none, Proc, Method
490
+ nil
491
+ else
492
+ RodaPlugins.warn "Support for the assets plugin #{s}: #{v.inspect} option will be removed in Roda 4. See the assets plugin documentation for how to use an appropriate proc or method."
493
+ end
494
+ end
495
+ end
496
+
457
497
  opts.freeze
458
498
  end
459
499
 
@@ -535,6 +575,7 @@ class Roda
535
575
  app.read_asset_file(file, type)
536
576
  end.join("\n")
537
577
 
578
+ # RODA4: Remove :concat_only option
538
579
  unless o[:concat_only]
539
580
  content = compress_asset(content, type)
540
581
  end
@@ -564,6 +605,8 @@ class Roda
564
605
  return content
565
606
  when nil
566
607
  # default, try different compressors
608
+ when Proc, Method
609
+ return compressor.call(content)
567
610
  else
568
611
  # Allow calling private compress methods
569
612
  return send("compress_#{type}_#{compressor}", content)
@@ -579,6 +622,7 @@ class Roda
579
622
  begin
580
623
  # Allow calling private compress methods
581
624
  if c = send("compress_#{type}_#{comp}", content)
625
+ RodaPlugins.warn "Support for automatic compression of assets by trying common asset compressor libraries will be removed in Roda 4. The #{comp} #{type.to_s.upcase} compressor is currently used. See the assets plugin documentation for how to use an appropriate value for the assets plugin :#{type}_compressor option."
582
626
  return c
583
627
  end
584
628
  rescue LoadError, CompressorNotFound
@@ -1,5 +1,7 @@
1
1
  # frozen-string-literal: true
2
2
 
3
+ # RODA4: Remove plugin
4
+
3
5
  require 'rack/csrf'
4
6
 
5
7
  class Roda
@@ -7,6 +9,7 @@ class Roda
7
9
  # This plugin is no longer recommended for use, it exists only for
8
10
  # backwards compatibility. Consider using the route_csrf plugin
9
11
  # instead, as that provides stronger CSRF protection.
12
+ # This plugin will no longer ship with Roda starting in Roda 4.
10
13
  #
11
14
  # The csrf plugin adds CSRF protection using rack_csrf, along with
12
15
  # some csrf helper methods to use in your views. To use it, load
@@ -3,6 +3,8 @@
3
3
  #
4
4
  class Roda
5
5
  module RodaPlugins
6
+ warn("The delay_build plugin no longer has an effect. It will be removed in Roda 4.")
7
+
6
8
  module DelayBuild
7
9
  module ClassMethods
8
10
  # No-op for backwards compatibility
@@ -125,6 +125,7 @@ class Roda
125
125
  app.opts[:middleware_configure] = block if block
126
126
  app.opts[:middleware_handle_result] = opts[:handle_result]
127
127
  app.opts[:middleware_forward_response_headers] = opts[:forward_response_headers]
128
+ # RODA4: Make next_if_not_found default to true
128
129
  app.opts[:middleware_next_if_not_found] = opts[:next_if_not_found]
129
130
  end
130
131
 
@@ -1,5 +1,7 @@
1
1
  # frozen-string-literal: true
2
2
 
3
+ # RODA4: Remove plugin
4
+
3
5
  #
4
6
  class Roda
5
7
  module RodaPlugins
@@ -22,6 +24,10 @@ class Roda
22
24
  # end
23
25
  # end
24
26
  # end
27
+ #
28
+ # This plugin will be no longer ship with Roda starting in Roda 4. Users
29
+ # are encouraged to switch to defining local variables at the top of the
30
+ # route block instead of using this plugin.
25
31
  module RouteBlockArgs
26
32
  def self.configure(app, &block)
27
33
  app.instance_exec do
@@ -67,7 +67,7 @@ class Roda
67
67
  # given, it will be merged into the default cookie options.
68
68
  # :env_key :: The key in `env` where the session should be located. Defaults to <tt>"rack.session"</tt>, the
69
69
  # default key for sessions in Rack.
70
- # :gzip_over :: For session data over this many bytes, compress it with the deflate algorithm (default: nil,
70
+ # :gzip_over (deprecated) :: For session data over this many bytes, compress it with the deflate algorithm (default: nil,
71
71
  # so never compress). Note that compression should not be enabled if you are storing data in
72
72
  # the session derived from user input and also storing sensitive data in the session.
73
73
  # :key :: The cookie name to use (default: <tt>'roda.session'</tt>)
@@ -94,7 +94,7 @@ class Roda
94
94
  # (default: 3600).
95
95
  # :upgrade_from_rack_session_cookie_key :: The cookie name to use for transparently upgrading from
96
96
  # Rack::Session:Cookie (defaults to <tt>'rack.session'</tt>).
97
- # :upgrade_from_rack_session_cookie_secret :: The secret for the HMAC-SHA1 signature when allowing
97
+ # :upgrade_from_rack_session_cookie_secret (deprecated) :: The secret for the HMAC-SHA1 signature when allowing
98
98
  # transparent upgrades from Rack::Session::Cookie. Using this
99
99
  # option is only recommended during a short transition period,
100
100
  # and is not enabled by default as it lowers security.
@@ -189,12 +189,17 @@ class Roda
189
189
  opts[:session_version_num] = opts[:per_cookie_cipher_secret] ? 1 : 0
190
190
 
191
191
  if opts[:upgrade_from_rack_session_cookie_secret]
192
+ RodaPlugins.warn("Support for upgrading rack session cookie sessions will be removed in Roda 4.")
192
193
  opts[:upgrade_from_rack_session_cookie_key] ||= 'rack.session'
193
194
  rsco = opts[:upgrade_from_rack_session_cookie_options] = Hash[opts[:upgrade_from_rack_session_cookie_options] || OPTS]
194
195
  rsco[:path] ||= co[:path]
195
196
  rsco[:domain] ||= co[:domain]
196
197
  end
197
198
 
199
+ if opts[:gzip_over]
200
+ RodaPlugins.warn("Support for compressing session data will be removed in Roda 4.")
201
+ end
202
+
198
203
  opts[:cipher_secret], opts[:hmac_secret] = split_secret(:secret, opts[:secret])
199
204
  opts[:old_cipher_secret], opts[:old_hmac_secret] = (split_secret(:old_secret, opts[:old_secret]) if opts[:old_secret])
200
205
 
@@ -1,5 +1,7 @@
1
1
  # frozen-string-literal: true
2
2
 
3
+ # RODA4: Remove plugin
4
+
3
5
  require 'rack/static'
4
6
 
5
7
  #
@@ -26,6 +28,15 @@ class Roda
26
28
  # plugin :static, ['/js', '/css'] # path: /path/to/app/public
27
29
  # plugin :static, ['/images'], root: 'pub' # path: /path/to/app/pub
28
30
  # plugin :static, ['/media'], root: '/path/to/public' # path: /path/to/public
31
+ #
32
+ # This plugin will no longer ship with Roda starting in Roda 4. As the plugin only
33
+ # configures a middleware, you should switch to doing so directly. Translating
34
+ # the above example to direct middleware usage:
35
+ #
36
+ # require 'rack/static'
37
+ # use Rack::Static, urls: ['/js', '/css'], root: '/path/to/app/public'
38
+ # use Rack::Static, urls: ['/images'], root: '/path/to/app/pub'
39
+ # use Rack::Static, urls: ['/media'], root: '/path/to/public'
29
40
  module Static
30
41
  # Load the Rack::Static middleware. Use the paths given as the :urls option,
31
42
  # and set the :root option to be relative to the application's :root option.
@@ -0,0 +1,39 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'rack/utils'
4
+
5
+ #
6
+ class Roda
7
+ module RodaPlugins
8
+ # The url_escape plugin add url_escape and url_unescape methods
9
+ # to the route block scope.
10
+ #
11
+ # plugin :url_escape
12
+ #
13
+ # route do |r|
14
+ # link = "/path/q=#{url_escape(r.params["some_param"])}"
15
+ # response_body(link)
16
+ # end
17
+ module UrlEscape
18
+ module InstanceMethods
19
+ if RUBY_VERSION >= '2'
20
+ define_method(:url_escape, Rack::Utils.instance_method(:escape))
21
+ define_method(:url_unescape, Rack::Utils.instance_method(:unescape))
22
+ # :nocov:
23
+ else
24
+ def url_escape(v)
25
+ Rack::Utils.escape(v)
26
+ end
27
+
28
+ def url_unescape(v)
29
+ Rack::Utils.unescape(v)
30
+ end
31
+ end
32
+ # :nocov:
33
+ end
34
+ end
35
+
36
+ register_plugin(:url_escape, UrlEscape)
37
+ end
38
+ end
39
+
data/lib/roda/request.rb CHANGED
@@ -569,8 +569,9 @@ class Roda
569
569
  if meth
570
570
  return unless captures = scope.send(meth, *captures)
571
571
  # :nocov:
572
+ # RODA4: Remove elsif block
572
573
  elsif defined?(yield)
573
- # RODA4: Remove
574
+ RodaPlugins.warn("Passing a block to RodaRequest#consume will be ignored in Roda 4. Update the code to pass a scope method symbol as the second argument.")
574
575
  return unless captures = yield(*captures)
575
576
  # :nocov:
576
577
  end
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 = 106
7
+ RodaMinorVersion = 107
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
data/lib/roda.rb CHANGED
@@ -71,29 +71,34 @@ class Roda
71
71
  #
72
72
  # If the :check_arity app option is not set to false, Roda will check that
73
73
  # the arity of the block matches the expected arity, and compensate for
74
- # cases where it does not. If it is set to :warn, Roda will warn in the
75
- # cases where the arity does not match what is expected.
74
+ # cases where it does not. The :check_arity default app option setting is
75
+ # :warn, in which case Roda will warn in the cases where the arity does not
76
+ # match what is expected.
76
77
  #
77
78
  # If the expected arity is :any, Roda must perform a dynamic arity check
78
79
  # when the method is called, which can hurt performance even in the case
79
80
  # where the arity matches. The :check_dynamic_arity app option can be
80
81
  # set to false to turn off the dynamic arity checks. The
81
82
  # :check_dynamic_arity app option can be to :warn to warn if Roda needs
82
- # to adjust arity dynamically.
83
+ # to adjust arity dynamically. The default value of the :check_dynamic_arity
84
+ # app option is to use the same value as the :check_arity app option.
83
85
  #
84
86
  # Roda only checks arity for regular blocks, not lambda blocks, as the
85
87
  # fixes Roda uses for regular blocks would not work for lambda blocks.
86
88
  #
87
89
  # Roda does not support blocks with required keyword arguments if the
88
90
  # expected arity is 0 or 1.
91
+ #
92
+ # Support for the :check_arity and :check_dynamic_arity options will be
93
+ # removed in Roda 4.
89
94
  def define_roda_method(meth, expected_arity, &block)
90
95
  if meth.is_a?(String)
91
96
  meth = roda_method_name(meth)
92
97
  end
93
98
  call_meth = meth
94
99
 
95
- # RODA4: Switch to false # :warn in last Roda 3 version
96
- if (check_arity = opts.fetch(:check_arity, true)) && !block.lambda?
100
+ # RODA4: Remove support for :check_arity, default to false behavior
101
+ if (check_arity = opts.fetch(:check_arity, :warn)) && !block.lambda?
97
102
  required_args, optional_args, rest, keyword = _define_roda_method_arg_numbers(block)
98
103
 
99
104
  if keyword == :required && (expected_arity == 0 || expected_arity == 1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.106.0
4
+ version: 3.107.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -310,6 +310,7 @@ files:
310
310
  - lib/roda/plugins/typecast_params.rb
311
311
  - lib/roda/plugins/typecast_params_sized_integers.rb
312
312
  - lib/roda/plugins/unescape_path.rb
313
+ - lib/roda/plugins/url_escape.rb
313
314
  - lib/roda/plugins/view_options.rb
314
315
  - lib/roda/plugins/view_subdir_leading_slash.rb
315
316
  - lib/roda/request.rb
@@ -339,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
339
340
  - !ruby/object:Gem::Version
340
341
  version: '0'
341
342
  requirements: []
342
- rubygems_version: 4.0.10
343
+ rubygems_version: 4.0.16
343
344
  specification_version: 4
344
345
  summary: Routing tree web toolkit
345
346
  test_files: []