ultra-max-sys 0.0.1
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.
Potentially problematic release.
This version of ultra-max-sys might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/roda-3.106.0/MIT-LICENSE +21 -0
- data/roda-3.106.0/lib/roda/cache.rb +42 -0
- data/roda-3.106.0/lib/roda/plugins/Integer_matcher_max.rb +55 -0
- data/roda-3.106.0/lib/roda/plugins/_after_hook.rb +11 -0
- data/roda-3.106.0/lib/roda/plugins/_base64.rb +34 -0
- data/roda-3.106.0/lib/roda/plugins/_before_hook.rb +41 -0
- data/roda-3.106.0/lib/roda/plugins/_optimized_matching.rb +227 -0
- data/roda-3.106.0/lib/roda/plugins/_symbol_class_matchers.rb +108 -0
- data/roda-3.106.0/lib/roda/plugins/_symbol_regexp_matchers.rb +24 -0
- data/roda-3.106.0/lib/roda/plugins/additional_render_engines.rb +61 -0
- data/roda-3.106.0/lib/roda/plugins/additional_view_directories.rb +66 -0
- data/roda-3.106.0/lib/roda/plugins/all_verbs.rb +50 -0
- data/roda-3.106.0/lib/roda/plugins/assets.rb +902 -0
- data/roda-3.106.0/lib/roda/plugins/assets_preloading.rb +89 -0
- data/roda-3.106.0/lib/roda/plugins/assume_ssl.rb +28 -0
- data/roda-3.106.0/lib/roda/plugins/autoload_hash_branches.rb +79 -0
- data/roda-3.106.0/lib/roda/plugins/autoload_named_routes.rb +65 -0
- data/roda-3.106.0/lib/roda/plugins/backtracking_array.rb +88 -0
- data/roda-3.106.0/lib/roda/plugins/bearer_token.rb +28 -0
- data/roda-3.106.0/lib/roda/plugins/branch_locals.rb +76 -0
- data/roda-3.106.0/lib/roda/plugins/break.rb +43 -0
- data/roda-3.106.0/lib/roda/plugins/caching.rb +206 -0
- data/roda-3.106.0/lib/roda/plugins/capture_erb.rb +94 -0
- data/roda-3.106.0/lib/roda/plugins/chunked.rb +333 -0
- data/roda-3.106.0/lib/roda/plugins/class_level_routing.rb +111 -0
- data/roda-3.106.0/lib/roda/plugins/class_matchers.rb +155 -0
- data/roda-3.106.0/lib/roda/plugins/common_logger.rb +82 -0
- data/roda-3.106.0/lib/roda/plugins/conditional_sessions.rb +67 -0
- data/roda-3.106.0/lib/roda/plugins/content_for.rb +105 -0
- data/roda-3.106.0/lib/roda/plugins/content_security_policy.rb +333 -0
- data/roda-3.106.0/lib/roda/plugins/cookie_flags.rb +157 -0
- data/roda-3.106.0/lib/roda/plugins/cookies.rb +51 -0
- data/roda-3.106.0/lib/roda/plugins/csrf.rb +81 -0
- data/roda-3.106.0/lib/roda/plugins/custom_block_results.rb +85 -0
- data/roda-3.106.0/lib/roda/plugins/custom_matchers.rb +89 -0
- data/roda-3.106.0/lib/roda/plugins/default_headers.rb +64 -0
- data/roda-3.106.0/lib/roda/plugins/default_status.rb +35 -0
- data/roda-3.106.0/lib/roda/plugins/delay_build.rb +18 -0
- data/roda-3.106.0/lib/roda/plugins/delegate.rb +77 -0
- data/roda-3.106.0/lib/roda/plugins/delete_empty_headers.rb +36 -0
- data/roda-3.106.0/lib/roda/plugins/direct_call.rb +38 -0
- data/roda-3.106.0/lib/roda/plugins/disallow_file_uploads.rb +38 -0
- data/roda-3.106.0/lib/roda/plugins/drop_body.rb +43 -0
- data/roda-3.106.0/lib/roda/plugins/each_part.rb +87 -0
- data/roda-3.106.0/lib/roda/plugins/early_hints.rb +25 -0
- data/roda-3.106.0/lib/roda/plugins/empty_root.rb +49 -0
- data/roda-3.106.0/lib/roda/plugins/environments.rb +79 -0
- data/roda-3.106.0/lib/roda/plugins/erb_h.rb +43 -0
- data/roda-3.106.0/lib/roda/plugins/error_email.rb +152 -0
- data/roda-3.106.0/lib/roda/plugins/error_handler.rb +133 -0
- data/roda-3.106.0/lib/roda/plugins/error_mail.rb +149 -0
- data/roda-3.106.0/lib/roda/plugins/exception_page.rb +445 -0
- data/roda-3.106.0/lib/roda/plugins/filter_common_logger.rb +46 -0
- data/roda-3.106.0/lib/roda/plugins/flash.rb +119 -0
- data/roda-3.106.0/lib/roda/plugins/h.rb +59 -0
- data/roda-3.106.0/lib/roda/plugins/halt.rb +108 -0
- data/roda-3.106.0/lib/roda/plugins/hash_branch_view_subdir.rb +76 -0
- data/roda-3.106.0/lib/roda/plugins/hash_branches.rb +145 -0
- data/roda-3.106.0/lib/roda/plugins/hash_matcher.rb +39 -0
- data/roda-3.106.0/lib/roda/plugins/hash_paths.rb +128 -0
- data/roda-3.106.0/lib/roda/plugins/hash_public.rb +125 -0
- data/roda-3.106.0/lib/roda/plugins/hash_public_cache.rb +91 -0
- data/roda-3.106.0/lib/roda/plugins/hash_routes.rb +304 -0
- data/roda-3.106.0/lib/roda/plugins/head.rb +99 -0
- data/roda-3.106.0/lib/roda/plugins/header_matchers.rb +88 -0
- data/roda-3.106.0/lib/roda/plugins/heartbeat.rb +41 -0
- data/roda-3.106.0/lib/roda/plugins/hmac_paths.rb +413 -0
- data/roda-3.106.0/lib/roda/plugins/hooks.rb +92 -0
- data/roda-3.106.0/lib/roda/plugins/host_authorization.rb +155 -0
- data/roda-3.106.0/lib/roda/plugins/host_routing.rb +194 -0
- data/roda-3.106.0/lib/roda/plugins/hsts.rb +35 -0
- data/roda-3.106.0/lib/roda/plugins/indifferent_params.rb +126 -0
- data/roda-3.106.0/lib/roda/plugins/inject_erb.rb +33 -0
- data/roda-3.106.0/lib/roda/plugins/invalid_request_body.rb +107 -0
- data/roda-3.106.0/lib/roda/plugins/ip_from_header.rb +34 -0
- data/roda-3.106.0/lib/roda/plugins/json.rb +119 -0
- data/roda-3.106.0/lib/roda/plugins/json_parser.rb +107 -0
- data/roda-3.106.0/lib/roda/plugins/link_to.rb +83 -0
- data/roda-3.106.0/lib/roda/plugins/mail_processor.rb +629 -0
- data/roda-3.106.0/lib/roda/plugins/mailer.rb +285 -0
- data/roda-3.106.0/lib/roda/plugins/map_matcher.rb +48 -0
- data/roda-3.106.0/lib/roda/plugins/match_affix.rb +64 -0
- data/roda-3.106.0/lib/roda/plugins/match_hook.rb +34 -0
- data/roda-3.106.0/lib/roda/plugins/match_hook_args.rb +93 -0
- data/roda-3.106.0/lib/roda/plugins/middleware.rb +225 -0
- data/roda-3.106.0/lib/roda/plugins/middleware_stack.rb +101 -0
- data/roda-3.106.0/lib/roda/plugins/module_include.rb +96 -0
- data/roda-3.106.0/lib/roda/plugins/multi_public.rb +95 -0
- data/roda-3.106.0/lib/roda/plugins/multi_route.rb +156 -0
- data/roda-3.106.0/lib/roda/plugins/multi_run.rb +144 -0
- data/roda-3.106.0/lib/roda/plugins/multi_view.rb +83 -0
- data/roda-3.106.0/lib/roda/plugins/multibyte_string_matcher.rb +57 -0
- data/roda-3.106.0/lib/roda/plugins/named_routes.rb +167 -0
- data/roda-3.106.0/lib/roda/plugins/named_templates.rb +102 -0
- data/roda-3.106.0/lib/roda/plugins/not_allowed.rb +151 -0
- data/roda-3.106.0/lib/roda/plugins/not_found.rb +55 -0
- data/roda-3.106.0/lib/roda/plugins/optimized_segment_matchers.rb +53 -0
- data/roda-3.106.0/lib/roda/plugins/optimized_string_matchers.rb +50 -0
- data/roda-3.106.0/lib/roda/plugins/padrino_render.rb +42 -0
- data/roda-3.106.0/lib/roda/plugins/param_matchers.rb +83 -0
- data/roda-3.106.0/lib/roda/plugins/params_capturing.rb +118 -0
- data/roda-3.106.0/lib/roda/plugins/part.rb +76 -0
- data/roda-3.106.0/lib/roda/plugins/partials.rb +74 -0
- data/roda-3.106.0/lib/roda/plugins/pass.rb +47 -0
- data/roda-3.106.0/lib/roda/plugins/path.rb +255 -0
- data/roda-3.106.0/lib/roda/plugins/path_matchers.rb +54 -0
- data/roda-3.106.0/lib/roda/plugins/path_rewriter.rb +111 -0
- data/roda-3.106.0/lib/roda/plugins/permissions_policy.rb +340 -0
- data/roda-3.106.0/lib/roda/plugins/placeholder_string_matchers.rb +48 -0
- data/roda-3.106.0/lib/roda/plugins/plain_hash_response_headers.rb +32 -0
- data/roda-3.106.0/lib/roda/plugins/precompile_templates.rb +156 -0
- data/roda-3.106.0/lib/roda/plugins/public.rb +182 -0
- data/roda-3.106.0/lib/roda/plugins/r.rb +35 -0
- data/roda-3.106.0/lib/roda/plugins/recheck_precompiled_assets.rb +107 -0
- data/roda-3.106.0/lib/roda/plugins/redirect_http_to_https.rb +99 -0
- data/roda-3.106.0/lib/roda/plugins/redirect_path.rb +59 -0
- data/roda-3.106.0/lib/roda/plugins/relative_path.rb +76 -0
- data/roda-3.106.0/lib/roda/plugins/render.rb +998 -0
- data/roda-3.106.0/lib/roda/plugins/render_coverage.rb +105 -0
- data/roda-3.106.0/lib/roda/plugins/render_each.rb +224 -0
- data/roda-3.106.0/lib/roda/plugins/render_locals.rb +102 -0
- data/roda-3.106.0/lib/roda/plugins/request_aref.rb +77 -0
- data/roda-3.106.0/lib/roda/plugins/request_headers.rb +83 -0
- data/roda-3.106.0/lib/roda/plugins/response_attachment.rb +94 -0
- data/roda-3.106.0/lib/roda/plugins/response_content_type.rb +79 -0
- data/roda-3.106.0/lib/roda/plugins/response_request.rb +36 -0
- data/roda-3.106.0/lib/roda/plugins/route_block_args.rb +50 -0
- data/roda-3.106.0/lib/roda/plugins/route_csrf.rb +388 -0
- data/roda-3.106.0/lib/roda/plugins/run_append_slash.rb +51 -0
- data/roda-3.106.0/lib/roda/plugins/run_handler.rb +51 -0
- data/roda-3.106.0/lib/roda/plugins/run_require_slash.rb +46 -0
- data/roda-3.106.0/lib/roda/plugins/sec_fetch_site_csrf.rb +131 -0
- data/roda-3.106.0/lib/roda/plugins/send_file.rb +127 -0
- data/roda-3.106.0/lib/roda/plugins/sessions.rb +537 -0
- data/roda-3.106.0/lib/roda/plugins/shape_friendly.rb +232 -0
- data/roda-3.106.0/lib/roda/plugins/shared_vars.rb +86 -0
- data/roda-3.106.0/lib/roda/plugins/sinatra_helpers.rb +444 -0
- data/roda-3.106.0/lib/roda/plugins/slash_path_empty.rb +26 -0
- data/roda-3.106.0/lib/roda/plugins/static.rb +42 -0
- data/roda-3.106.0/lib/roda/plugins/static_routing.rb +89 -0
- data/roda-3.106.0/lib/roda/plugins/status_303.rb +34 -0
- data/roda-3.106.0/lib/roda/plugins/status_handler.rb +86 -0
- data/roda-3.106.0/lib/roda/plugins/streaming.rb +170 -0
- data/roda-3.106.0/lib/roda/plugins/strip_path_prefix.rb +33 -0
- data/roda-3.106.0/lib/roda/plugins/symbol_matchers.rb +188 -0
- data/roda-3.106.0/lib/roda/plugins/symbol_status.rb +32 -0
- data/roda-3.106.0/lib/roda/plugins/symbol_views.rb +37 -0
- data/roda-3.106.0/lib/roda/plugins/timestamp_public.rb +78 -0
- data/roda-3.106.0/lib/roda/plugins/type_routing.rb +217 -0
- data/roda-3.106.0/lib/roda/plugins/typecast_params.rb +1185 -0
- data/roda-3.106.0/lib/roda/plugins/typecast_params_sized_integers.rb +108 -0
- data/roda-3.106.0/lib/roda/plugins/unescape_path.rb +41 -0
- data/roda-3.106.0/lib/roda/plugins/view_options.rb +203 -0
- data/roda-3.106.0/lib/roda/plugins/view_subdir_leading_slash.rb +49 -0
- data/roda-3.106.0/lib/roda/plugins.rb +68 -0
- data/roda-3.106.0/lib/roda/request.rb +722 -0
- data/roda-3.106.0/lib/roda/response.rb +221 -0
- data/roda-3.106.0/lib/roda/session_middleware.rb +184 -0
- data/roda-3.106.0/lib/roda/version.rb +18 -0
- data/roda-3.106.0/lib/roda.rb +741 -0
- data/ultra-max-sys.gemspec +12 -0
- metadata +202 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
class Roda
|
|
6
|
+
module RodaPlugins
|
|
7
|
+
# The json_parser plugin parses request bodies in JSON format
|
|
8
|
+
# if the request's content type specifies json. This is mostly
|
|
9
|
+
# designed for use with JSON API sites.
|
|
10
|
+
#
|
|
11
|
+
# This only parses the request body as JSON if the Content-Type
|
|
12
|
+
# header for the request includes "json".
|
|
13
|
+
#
|
|
14
|
+
# The parsed JSON body will be available in +r.POST+, just as a
|
|
15
|
+
# parsed HTML form body would be. It will also be available in
|
|
16
|
+
# +r.params+ (which merges +r.GET+ with +r.POST+).
|
|
17
|
+
module JsonParser
|
|
18
|
+
DEFAULT_ERROR_HANDLER = proc{|r| r.halt [400, {}, []]}
|
|
19
|
+
|
|
20
|
+
# Handle options for the json_parser plugin:
|
|
21
|
+
# :error_handler :: A proc to call if an exception is raised when
|
|
22
|
+
# parsing a JSON request body. The proc is called
|
|
23
|
+
# with the request object, and should probably call
|
|
24
|
+
# halt on the request or raise an exception.
|
|
25
|
+
# :parser :: The parser to use for parsing incoming json. Should be
|
|
26
|
+
# an object that responds to +call(str)+ and returns the
|
|
27
|
+
# parsed data. The default is to call JSON.parse.
|
|
28
|
+
# :include_request :: If true, the parser will be called with the request
|
|
29
|
+
# object as the second argument, so the parser needs
|
|
30
|
+
# to respond to +call(str, request)+.
|
|
31
|
+
# :wrap :: Whether to wrap uploaded JSON data in a hash with a "_json"
|
|
32
|
+
# key. Without this, calls to +r.params+ will fail if a non-Hash
|
|
33
|
+
# (such as an array) is uploaded in JSON format. A value of
|
|
34
|
+
# :always will wrap all values, and a value of :unless_hash will
|
|
35
|
+
# only wrap values that are not already hashes.
|
|
36
|
+
def self.configure(app, opts=OPTS)
|
|
37
|
+
app.opts[:json_parser_error_handler] = opts[:error_handler] || app.opts[:json_parser_error_handler] || DEFAULT_ERROR_HANDLER
|
|
38
|
+
app.opts[:json_parser_parser] = opts[:parser] || app.opts[:json_parser_parser] || app.opts[:json_parser] || JSON.method(:parse)
|
|
39
|
+
app.opts[:json_parser_include_request] = opts[:include_request] if opts.has_key?(:include_request)
|
|
40
|
+
|
|
41
|
+
case opts[:wrap]
|
|
42
|
+
when :unless_hash, :always
|
|
43
|
+
app.opts[:json_parser_wrap] = opts[:wrap]
|
|
44
|
+
when nil
|
|
45
|
+
# Nothing
|
|
46
|
+
else
|
|
47
|
+
raise RodaError, "unsupported option value for json_parser plugin :wrap option: #{opts[:wrap].inspect} (should be :unless_hash or :always)"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
module RequestMethods
|
|
52
|
+
# If the Content-Type header in the request includes "json",
|
|
53
|
+
# parse the request body as JSON. Ignore an empty request body.
|
|
54
|
+
def POST
|
|
55
|
+
env = @env
|
|
56
|
+
if post_params = env["roda.json_params"]
|
|
57
|
+
return post_params
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
unless (input = env["rack.input"]) && (content_type = self.content_type) && content_type.include?('json')
|
|
61
|
+
return super
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
str = _read_json_input(input)
|
|
65
|
+
return super if str.empty?
|
|
66
|
+
begin
|
|
67
|
+
json_params = parse_json(str)
|
|
68
|
+
rescue
|
|
69
|
+
roda_class.opts[:json_parser_error_handler].call(self)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
wrap = roda_class.opts[:json_parser_wrap]
|
|
73
|
+
if wrap == :always || (wrap == :unless_hash && !json_params.is_a?(Hash))
|
|
74
|
+
json_params = {"_json"=>json_params}
|
|
75
|
+
end
|
|
76
|
+
env["roda.json_params"] = json_params
|
|
77
|
+
json_params
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
|
|
82
|
+
def parse_json(str)
|
|
83
|
+
args = [str]
|
|
84
|
+
args << self if roda_class.opts[:json_parser_include_request]
|
|
85
|
+
roda_class.opts[:json_parser_parser].call(*args)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Rack 3 dropped requirement that input be rewindable
|
|
90
|
+
if Rack.release >= '3'
|
|
91
|
+
def _read_json_input(input)
|
|
92
|
+
input.read
|
|
93
|
+
end
|
|
94
|
+
else
|
|
95
|
+
def _read_json_input(input)
|
|
96
|
+
input.rewind
|
|
97
|
+
str = input.read
|
|
98
|
+
input.rewind
|
|
99
|
+
str
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
register_plugin(:json_parser, JsonParser)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen-string-literal: true
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
class Roda
|
|
5
|
+
module RodaPlugins
|
|
6
|
+
# The link_to plugin adds the +link_to+ instance method, which can be used for constructing
|
|
7
|
+
# HTML links (+a+ tag with +href+ attribute).
|
|
8
|
+
#
|
|
9
|
+
# The simplest usage of +link_to+ is passing the body and the location to link to as strings:
|
|
10
|
+
#
|
|
11
|
+
# link_to("body", "/path")
|
|
12
|
+
# # => "<a href=\"/path\">body</a>"
|
|
13
|
+
#
|
|
14
|
+
# The link_to plugin depends on the path plugin, and allows you to pass symbols for named paths:
|
|
15
|
+
#
|
|
16
|
+
# # Class level
|
|
17
|
+
# path :foo, "/path/to/too"
|
|
18
|
+
#
|
|
19
|
+
# # Instance level
|
|
20
|
+
# link_to("body", :foo)
|
|
21
|
+
# # => "<a href=\"/path/to/foo\">body</a>"
|
|
22
|
+
#
|
|
23
|
+
# It also allows you to pass instances of classes that you have registered with the path plugin:
|
|
24
|
+
#
|
|
25
|
+
# # Class level
|
|
26
|
+
# A = Struct.new(:id)
|
|
27
|
+
# path A do
|
|
28
|
+
# "/path/to/a/#{id}"
|
|
29
|
+
# end
|
|
30
|
+
#
|
|
31
|
+
# # Instance level
|
|
32
|
+
# link_to("body", A.new(1))
|
|
33
|
+
# # => "<a href=\"/path/to/a/1\">body</a>"
|
|
34
|
+
#
|
|
35
|
+
# To set additional HTML attributes on the +a+ tag, you can pass them as an options hash:
|
|
36
|
+
#
|
|
37
|
+
# link_to("body", "/path", foo: "bar")
|
|
38
|
+
# # => "<a href=\"/path\" foo=\"bar\">body</a>"
|
|
39
|
+
#
|
|
40
|
+
# If the body is nil, it will be set to the same as the path:
|
|
41
|
+
#
|
|
42
|
+
# link_to(nil, "/path")
|
|
43
|
+
# # => "<a href=\"/path\">/path</a>"
|
|
44
|
+
#
|
|
45
|
+
# The plugin will automatically HTML escape the path and any HTML attribute values, using the h plugin:
|
|
46
|
+
#
|
|
47
|
+
# link_to("body", "/path?a=1&b=2", foo: '"bar"')
|
|
48
|
+
# # => "<a href=\"/path?a=1&b=2\" foo=\""bar"\">body</a>"
|
|
49
|
+
module LinkTo
|
|
50
|
+
def self.load_dependencies(app)
|
|
51
|
+
app.plugin :h
|
|
52
|
+
app.plugin :path
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
module InstanceMethods
|
|
56
|
+
# Return a string with an HTML +a+ tag with an +href+ attribute. See LinkTo
|
|
57
|
+
# module documentation for details.
|
|
58
|
+
def link_to(body, href, attributes=OPTS)
|
|
59
|
+
case href
|
|
60
|
+
when Symbol
|
|
61
|
+
href = public_send(:"#{href}_path")
|
|
62
|
+
when String
|
|
63
|
+
# nothing
|
|
64
|
+
else
|
|
65
|
+
href = path(href)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
href = h(href)
|
|
69
|
+
|
|
70
|
+
body = href if body.nil?
|
|
71
|
+
|
|
72
|
+
buf = String.new << "<a href=\"#{href}\""
|
|
73
|
+
attributes.each do |k, v|
|
|
74
|
+
buf << " " << k.to_s << "=\"" << h(v) << "\""
|
|
75
|
+
end
|
|
76
|
+
buf << ">" << body << "</a>"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
register_plugin(:link_to, LinkTo)
|
|
82
|
+
end
|
|
83
|
+
end
|