roda 3.108.0 → 3.110.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/lib/roda/cache.rb +0 -2
- data/lib/roda/opts.rb +22 -0
- data/lib/roda/plugins/Integer_matcher_max.rb +1 -1
- data/lib/roda/plugins/_add_script_name.rb +14 -0
- data/lib/roda/plugins/_json.rb +22 -0
- data/lib/roda/plugins/_symbol_class_matchers.rb +8 -10
- data/lib/roda/plugins/additional_render_engines.rb +5 -1
- data/lib/roda/plugins/additional_view_directories.rb +7 -3
- data/lib/roda/plugins/assets.rb +179 -151
- data/lib/roda/plugins/assets_preloading.rb +26 -10
- data/lib/roda/plugins/autoload_hash_branches.rb +9 -3
- data/lib/roda/plugins/autoload_named_routes.rb +9 -3
- data/lib/roda/plugins/backtracking_array.rb +2 -2
- data/lib/roda/plugins/branch_locals.rb +4 -4
- data/lib/roda/plugins/break.rb +2 -2
- data/lib/roda/plugins/caching.rb +27 -17
- data/lib/roda/plugins/capture_erb.rb +19 -12
- data/lib/roda/plugins/chunked.rb +42 -34
- data/lib/roda/plugins/class_level_routing.rb +10 -5
- data/lib/roda/plugins/class_matchers.rb +14 -7
- data/lib/roda/plugins/common_logger.rb +27 -5
- data/lib/roda/plugins/conditional_sessions.rb +4 -4
- data/lib/roda/plugins/content_for.rb +12 -7
- data/lib/roda/plugins/content_security_policy.rb +17 -14
- data/lib/roda/plugins/cookie_flags.rb +17 -7
- data/lib/roda/plugins/cookies.rb +12 -6
- data/lib/roda/plugins/csrf.rb +2 -1
- data/lib/roda/plugins/custom_block_results.rb +11 -10
- data/lib/roda/plugins/custom_matchers.rb +4 -2
- data/lib/roda/plugins/default_headers.rb +4 -7
- data/lib/roda/plugins/default_status.rb +1 -0
- data/lib/roda/plugins/delay_build.rb +1 -1
- data/lib/roda/plugins/delegate.rb +7 -6
- data/lib/roda/plugins/direct_call.rb +5 -1
- data/lib/roda/plugins/disallow_file_uploads.rb +2 -3
- data/lib/roda/plugins/drop_body.rb +3 -6
- data/lib/roda/plugins/each_part.rb +23 -29
- data/lib/roda/plugins/early_hints.rb +4 -4
- data/lib/roda/plugins/empty_root.rb +5 -5
- data/lib/roda/plugins/environments.rb +11 -15
- data/lib/roda/plugins/erb_h.rb +4 -4
- data/lib/roda/plugins/error_email.rb +23 -20
- data/lib/roda/plugins/error_handler.rb +28 -34
- data/lib/roda/plugins/error_mail.rb +31 -16
- data/lib/roda/plugins/exception_page.rb +41 -35
- data/lib/roda/plugins/filter_common_logger.rb +6 -4
- data/lib/roda/plugins/flash.rb +16 -13
- data/lib/roda/plugins/freeze_request_response.rb +24 -0
- data/lib/roda/plugins/hash_branch_view_subdir.rb +6 -4
- data/lib/roda/plugins/hash_branches.rb +7 -5
- data/lib/roda/plugins/hash_paths.rb +7 -5
- data/lib/roda/plugins/hash_public.rb +11 -7
- data/lib/roda/plugins/hash_public_cache.rb +9 -7
- data/lib/roda/plugins/hash_routes.rb +6 -4
- data/lib/roda/plugins/heartbeat.rb +6 -2
- data/lib/roda/plugins/hmac_paths.rb +9 -3
- data/lib/roda/plugins/hooks.rb +13 -10
- data/lib/roda/plugins/host_authorization.rb +7 -2
- data/lib/roda/plugins/host_routing.rb +7 -2
- data/lib/roda/plugins/invalid_request_body.rb +20 -4
- data/lib/roda/plugins/ip_from_header.rb +5 -1
- data/lib/roda/plugins/json.rb +10 -8
- data/lib/roda/plugins/json_parser.rb +26 -12
- data/lib/roda/plugins/mail_processor.rb +9 -6
- data/lib/roda/plugins/mailer.rb +5 -3
- data/lib/roda/plugins/match_affix.rb +6 -1
- data/lib/roda/plugins/match_hook_args.rb +7 -5
- data/lib/roda/plugins/middleware.rb +13 -7
- data/lib/roda/plugins/module_include.rb +1 -1
- data/lib/roda/plugins/multi_public.rb +6 -2
- data/lib/roda/plugins/multi_route.rb +1 -1
- data/lib/roda/plugins/multi_run.rb +13 -17
- data/lib/roda/plugins/named_routes.rb +8 -6
- data/lib/roda/plugins/named_templates.rb +5 -3
- data/lib/roda/plugins/path.rb +16 -14
- data/lib/roda/plugins/path_rewriter.rb +8 -5
- data/lib/roda/plugins/permissions_policy.rb +21 -19
- data/lib/roda/plugins/public.rb +22 -10
- data/lib/roda/plugins/recheck_precompiled_assets.rb +30 -8
- data/lib/roda/plugins/redirect_http_to_https.rb +6 -3
- data/lib/roda/plugins/render.rb +37 -49
- data/lib/roda/plugins/render_coverage.rb +6 -3
- data/lib/roda/plugins/render_locals.rb +13 -7
- data/lib/roda/plugins/request_aref.rb +1 -1
- data/lib/roda/plugins/response_content_type.rb +7 -3
- data/lib/roda/plugins/route_csrf.rb +7 -2
- data/lib/roda/plugins/run_append_slash.rb +5 -1
- data/lib/roda/plugins/sec_fetch_site_csrf.rb +6 -2
- data/lib/roda/plugins/sessions.rb +164 -139
- data/lib/roda/plugins/shape_friendly.rb +3 -1
- data/lib/roda/plugins/sinatra_helpers.rb +7 -3
- data/lib/roda/plugins/status_handler.rb +5 -3
- data/lib/roda/plugins/strip_path_prefix.rb +4 -2
- data/lib/roda/plugins/symbol_matchers.rb +11 -6
- data/lib/roda/plugins/symbol_views.rb +1 -1
- data/lib/roda/plugins/timestamp_public.rb +8 -4
- data/lib/roda/plugins/type_routing.rb +9 -5
- data/lib/roda/plugins/typecast_params.rb +2 -2
- data/lib/roda/plugins/typecast_params_sized_integers.rb +1 -1
- data/lib/roda/plugins/unescape_path.rb +22 -4
- data/lib/roda/plugins/url_escape.rb +2 -14
- data/lib/roda/plugins.rb +34 -0
- data/lib/roda/request.rb +8 -7
- data/lib/roda/response.rb +9 -7
- data/lib/roda/version.rb +1 -1
- data/lib/roda.rb +37 -23
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d8c250a96cd296885c7195c790048bd57e1c679cc73b412a7b360a50dd45082d
|
|
4
|
+
data.tar.gz: a07ad795f01660d62a1853da0151f845f0c12c2d5593437d936cba913226c745
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c5fa7733dd8b99d5652520911af3fb8987751bb353761b6f8635a7fcc2a5e5ce8af40532778cb065ffd31b116a2f86c0cf3a281d1a7b90169480a3ab64ad199
|
|
7
|
+
data.tar.gz: b5f2686179b495755d3b6caa9e2da384e5709421b7e99cb9c1172e4726f6ced14def40ed498cdaa044c957b206c7be72ba6d42f3705807dea32716bed702964f
|
data/lib/roda/cache.rb
CHANGED
data/lib/roda/opts.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
|
|
3
|
+
class Roda
|
|
4
|
+
class RodaOpts < Hash
|
|
5
|
+
# The Roda class to set instance variables on when calling #[]=
|
|
6
|
+
attr_writer :roda_class
|
|
7
|
+
|
|
8
|
+
# If duplicating the hash, detach the Roda class.
|
|
9
|
+
def initialize_copy(_)
|
|
10
|
+
super
|
|
11
|
+
@roda_class = nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Set an <tt>@opt_*</tt> instance variable in the Roda class if it is tied
|
|
15
|
+
# to a Roda class and the key is a symbol.
|
|
16
|
+
def []=(k, v)
|
|
17
|
+
super
|
|
18
|
+
@roda_class.instance_variable_set(:"@opt_#{k}", v) if @roda_class && Symbol === k
|
|
19
|
+
v
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
class Roda
|
|
5
|
+
module RodaPlugins
|
|
6
|
+
module AddScriptName_
|
|
7
|
+
module ClassMethods
|
|
8
|
+
RodaPlugins.opt_attr_reader(self, :add_script_name, name: :add_script_name?)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
register_plugin(:_add_script_name, AddScriptName_)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
class Roda
|
|
7
|
+
module RodaPlugins
|
|
8
|
+
module JSON_
|
|
9
|
+
module ClassMethods
|
|
10
|
+
def json_parser
|
|
11
|
+
@opt_json_parser || ::JSON.method(:parse)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def json_serializer
|
|
15
|
+
@opt_json_serializer || :to_json.to_proc
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
register_plugin(:_json, JSON_)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -8,7 +8,7 @@ class Roda
|
|
|
8
8
|
private
|
|
9
9
|
|
|
10
10
|
# Backend of symbol_matcher and class_matcher.
|
|
11
|
-
def _symbol_class_matcher(expected_class, obj, matcher, block,
|
|
11
|
+
def _symbol_class_matcher(expected_class, obj, matcher, block, segment: nil, &request_class_block)
|
|
12
12
|
unless obj.is_a?(expected_class)
|
|
13
13
|
raise RodaError, "Invalid type passed to class_matcher or symbol_matcher: #{matcher.inspect}"
|
|
14
14
|
end
|
|
@@ -26,23 +26,21 @@ class Roda
|
|
|
26
26
|
regexp = matcher
|
|
27
27
|
consume_regexp = self::RodaRequest.send(:consume_pattern, regexp)
|
|
28
28
|
when Symbol
|
|
29
|
-
unless
|
|
29
|
+
unless respond_to?(:symbol_matchers)
|
|
30
30
|
raise RodaError, "cannot provide Symbol matcher to class_matcher unless using symbol_matchers plugin: #{matcher.inspect}"
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
regexp, consume_regexp, convert_meth, consume_meth =
|
|
34
|
-
|
|
33
|
+
regexp, consume_regexp, convert_meth, consume_meth = symbol_matchers[matcher]
|
|
35
34
|
unless regexp
|
|
36
35
|
raise RodaError, "unregistered symbol matcher given to #{type}_matcher: #{matcher.inspect}"
|
|
37
36
|
end
|
|
38
|
-
|
|
39
37
|
block = _merge_matcher_blocks(type, obj, block, convert_meth)
|
|
40
38
|
when Class
|
|
41
|
-
unless
|
|
39
|
+
unless respond_to?(:class_matchers)
|
|
42
40
|
raise RodaError, "cannot provide Class matcher to symbol_matcher unless using class_matchers plugin: #{matcher.inspect}"
|
|
43
41
|
end
|
|
44
42
|
|
|
45
|
-
regexp, consume_regexp, convert_meth, consume_meth =
|
|
43
|
+
regexp, consume_regexp, convert_meth, consume_meth = class_matchers[matcher]
|
|
46
44
|
unless regexp
|
|
47
45
|
raise RodaError, "unregistered class matcher given to #{type}_matcher: #{matcher.inspect}"
|
|
48
46
|
end
|
|
@@ -59,10 +57,10 @@ class Roda
|
|
|
59
57
|
private convert_meth
|
|
60
58
|
end
|
|
61
59
|
|
|
62
|
-
consume_meth ||=
|
|
63
|
-
array =
|
|
60
|
+
consume_meth ||= segment ? :_consume_single_segment : :consume
|
|
61
|
+
array = (obj.is_a?(Symbol) ? symbol_matchers : class_matchers)[obj] = [regexp, consume_regexp, convert_meth, consume_meth].freeze
|
|
64
62
|
|
|
65
|
-
self::RodaRequest.
|
|
63
|
+
self::RodaRequest.class_exec do
|
|
66
64
|
class_exec(meth, array, &request_class_block)
|
|
67
65
|
private meth
|
|
68
66
|
end
|
|
@@ -34,6 +34,10 @@ class Roda
|
|
|
34
34
|
app.opts[:additional_render_engines] = render_engines.dup.freeze
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
module ClassMethods
|
|
38
|
+
RodaPlugins.opt_attr_reader(self, :additional_render_engines)
|
|
39
|
+
end
|
|
40
|
+
|
|
37
41
|
module InstanceMethods
|
|
38
42
|
private
|
|
39
43
|
|
|
@@ -45,7 +49,7 @@ class Roda
|
|
|
45
49
|
orig_path = super
|
|
46
50
|
|
|
47
51
|
unless File.file?(orig_path)
|
|
48
|
-
self.
|
|
52
|
+
self.class.additional_render_engines.each do |engine|
|
|
49
53
|
path = super(opts.merge(:engine=>engine))
|
|
50
54
|
return path if File.file?(path)
|
|
51
55
|
end
|
|
@@ -13,7 +13,7 @@ class Roda
|
|
|
13
13
|
#
|
|
14
14
|
# Example:
|
|
15
15
|
#
|
|
16
|
-
# plugin :render, :
|
|
16
|
+
# plugin :render, views: 'dir'
|
|
17
17
|
# plugin :additional_view_directories, ['dir1', 'dir2', 'dir3']
|
|
18
18
|
#
|
|
19
19
|
# route do |r|
|
|
@@ -36,7 +36,11 @@ class Roda
|
|
|
36
36
|
# is also added as an allowed path.
|
|
37
37
|
def self.configure(app, view_dirs)
|
|
38
38
|
view_dirs = app.opts[:additional_view_directories] = view_dirs.map{|f| app.expand_path(f, nil)}.freeze
|
|
39
|
-
app.plugin :render, :allowed_paths=>(app.
|
|
39
|
+
app.plugin :render, :allowed_paths=>(app.render_opts[:allowed_paths] + view_dirs).uniq.freeze
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
module ClassMethods
|
|
43
|
+
RodaPlugins.opt_attr_reader(self, :additional_view_directories)
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
module InstanceMethods
|
|
@@ -50,7 +54,7 @@ class Roda
|
|
|
50
54
|
orig_path = super
|
|
51
55
|
|
|
52
56
|
unless File.file?(orig_path)
|
|
53
|
-
self.
|
|
57
|
+
self.class.additional_view_directories.each do |view_dir|
|
|
54
58
|
path = super(opts.merge(:views=>view_dir))
|
|
55
59
|
return path if File.file?(path)
|
|
56
60
|
end
|