jets 1.4.11 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +6 -5
- data/jets.gemspec +3 -2
- data/lib/jets.rb +8 -2
- data/lib/jets/builders/tidy.rb +2 -1
- data/lib/jets/commands/db.rb +3 -3
- data/lib/jets/commands/db/tasks.rb +5 -4
- data/lib/jets/generator.rb +3 -2
- data/lib/jets/router.rb +29 -4
- data/lib/jets/router/scope.rb +30 -0
- data/lib/jets/version.rb +1 -1
- data/vendor/rails/Brewfile +13 -0
- data/vendor/rails/CODE_OF_CONDUCT.md +12 -0
- data/vendor/rails/CONTRIBUTING.md +49 -0
- data/vendor/rails/Gemfile +174 -0
- data/vendor/rails/Gemfile.lock +564 -0
- data/vendor/rails/MIT-LICENSE +20 -0
- data/vendor/rails/RAILS_VERSION +1 -0
- data/vendor/rails/README.md +97 -0
- data/vendor/rails/RELEASING_RAILS.md +225 -0
- data/vendor/rails/Rakefile +72 -0
- data/vendor/rails/actionpack/CHANGELOG.md +407 -0
- data/vendor/rails/actionpack/MIT-LICENSE +21 -0
- data/vendor/rails/actionpack/README.rdoc +57 -0
- data/vendor/rails/actionpack/Rakefile +40 -0
- data/vendor/rails/actionpack/actionpack.gemspec +38 -0
- data/vendor/rails/actionpack/bin/test +5 -0
- data/vendor/rails/actionpack/lib/abstract_controller.rb +27 -0
- data/vendor/rails/actionpack/lib/abstract_controller/asset_paths.rb +12 -0
- data/vendor/rails/actionpack/lib/abstract_controller/base.rb +265 -0
- data/vendor/rails/actionpack/lib/abstract_controller/caching.rb +66 -0
- data/vendor/rails/actionpack/lib/abstract_controller/caching/fragments.rb +166 -0
- data/vendor/rails/actionpack/lib/abstract_controller/callbacks.rb +212 -0
- data/vendor/rails/actionpack/lib/abstract_controller/collector.rb +43 -0
- data/vendor/rails/actionpack/lib/abstract_controller/error.rb +6 -0
- data/vendor/rails/actionpack/lib/abstract_controller/helpers.rb +194 -0
- data/vendor/rails/actionpack/lib/abstract_controller/logger.rb +14 -0
- data/vendor/rails/actionpack/lib/abstract_controller/railties/routes_helpers.rb +20 -0
- data/vendor/rails/actionpack/lib/abstract_controller/rendering.rb +127 -0
- data/vendor/rails/actionpack/lib/abstract_controller/translation.rb +31 -0
- data/vendor/rails/actionpack/lib/abstract_controller/url_for.rb +35 -0
- data/vendor/rails/actionpack/lib/action_controller.rb +66 -0
- data/vendor/rails/actionpack/lib/action_controller/api.rb +149 -0
- data/vendor/rails/actionpack/lib/action_controller/api/api_rendering.rb +16 -0
- data/vendor/rails/actionpack/lib/action_controller/base.rb +276 -0
- data/vendor/rails/actionpack/lib/action_controller/caching.rb +46 -0
- data/vendor/rails/actionpack/lib/action_controller/form_builder.rb +50 -0
- data/vendor/rails/actionpack/lib/action_controller/log_subscriber.rb +78 -0
- data/vendor/rails/actionpack/lib/action_controller/metal.rb +256 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/basic_implicit_render.rb +13 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/conditional_get.rb +274 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/content_security_policy.rb +52 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/cookies.rb +16 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/data_streaming.rb +152 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/etag_with_flash.rb +18 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/etag_with_template_digest.rb +57 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/exceptions.rb +53 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/flash.rb +61 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/force_ssl.rb +99 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/head.rb +60 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/helpers.rb +123 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/http_authentication.rb +519 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/implicit_render.rb +73 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/instrumentation.rb +107 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/live.rb +312 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/mime_responds.rb +313 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/parameter_encoding.rb +51 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/params_wrapper.rb +293 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/redirecting.rb +133 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/renderers.rb +181 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/rendering.rb +122 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/request_forgery_protection.rb +445 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/rescue.rb +28 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/streaming.rb +223 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/strong_parameters.rb +1086 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/testing.rb +16 -0
- data/vendor/rails/actionpack/lib/action_controller/metal/url_for.rb +58 -0
- data/vendor/rails/actionpack/lib/action_controller/railtie.rb +89 -0
- data/vendor/rails/actionpack/lib/action_controller/railties/helpers.rb +24 -0
- data/vendor/rails/actionpack/lib/action_controller/renderer.rb +117 -0
- data/vendor/rails/actionpack/lib/action_controller/template_assertions.rb +11 -0
- data/vendor/rails/actionpack/lib/action_controller/test_case.rb +629 -0
- data/vendor/rails/actionpack/lib/action_dispatch.rb +112 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/cache.rb +220 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/content_security_policy.rb +272 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/filter_parameters.rb +84 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/filter_redirect.rb +37 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/headers.rb +132 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/mime_negotiation.rb +170 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/mime_type.rb +342 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/mime_types.rb +50 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/parameter_filter.rb +86 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/parameters.rb +126 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/rack_cache.rb +63 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/request.rb +430 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/response.rb +520 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/upload.rb +84 -0
- data/vendor/rails/actionpack/lib/action_dispatch/http/url.rb +350 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey.rb +7 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/formatter.rb +189 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/gtg/builder.rb +164 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/gtg/simulator.rb +41 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb +158 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/builder.rb +78 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/dot.rb +36 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/simulator.rb +49 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb +120 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/nodes/node.rb +140 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/parser.rb +199 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/parser.y +50 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/parser_extras.rb +31 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/path/pattern.rb +198 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/route.rb +203 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/router.rb +156 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/router/utils.rb +102 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/routes.rb +82 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/scanner.rb +64 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/visitors.rb +268 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/visualizer/fsm.css +30 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/visualizer/fsm.js +134 -0
- data/vendor/rails/actionpack/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb +36 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/cookies.rb +685 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +205 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/debug_locks.rb +124 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +147 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/executor.rb +21 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/flash.rb +300 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +57 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/reloader.rb +12 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb +183 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/request_id.rb +43 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +92 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/cache_store.rb +54 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb +117 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb +28 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +62 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/ssl.rb +150 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/stack.rb +116 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/static.rb +130 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +22 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +27 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +52 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +16 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +21 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +13 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb +161 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +32 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +6 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb +16 -0
- data/vendor/rails/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb +200 -0
- data/vendor/rails/actionpack/lib/action_dispatch/railtie.rb +55 -0
- data/vendor/rails/actionpack/lib/action_dispatch/request/session.rb +234 -0
- data/vendor/rails/actionpack/lib/action_dispatch/request/utils.rb +78 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing.rb +260 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/endpoint.rb +17 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/inspector.rb +225 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/mapper.rb +2267 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +352 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/redirection.rb +201 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/route_set.rb +890 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/routes_proxy.rb +69 -0
- data/vendor/rails/actionpack/lib/action_dispatch/routing/url_for.rb +236 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_test_case.rb +147 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_testing/browser.rb +49 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_testing/driver.rb +59 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_testing/server.rb +31 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +96 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +31 -0
- data/vendor/rails/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +26 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/assertion_response.rb +47 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/assertions.rb +24 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/assertions/response.rb +107 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/assertions/routing.rb +222 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/integration.rb +652 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/request_encoder.rb +55 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/test_process.rb +50 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/test_request.rb +71 -0
- data/vendor/rails/actionpack/lib/action_dispatch/testing/test_response.rb +53 -0
- data/vendor/rails/actionpack/lib/action_pack.rb +26 -0
- data/vendor/rails/actionpack/lib/action_pack/gem_version.rb +17 -0
- data/vendor/rails/actionpack/lib/action_pack/version.rb +10 -0
- data/vendor/rails/actionpack/test/abstract/callbacks_test.rb +270 -0
- data/vendor/rails/actionpack/test/abstract/collector_test.rb +65 -0
- data/vendor/rails/actionpack/test/abstract/translation_test.rb +79 -0
- data/vendor/rails/actionpack/test/abstract_unit.rb +457 -0
- data/vendor/rails/actionpack/test/assertions/response_assertions_test.rb +141 -0
- data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +493 -0
- data/vendor/rails/actionpack/test/controller/api/conditional_get_test.rb +59 -0
- data/vendor/rails/actionpack/test/controller/api/data_streaming_test.rb +28 -0
- data/vendor/rails/actionpack/test/controller/api/force_ssl_test.rb +22 -0
- data/vendor/rails/actionpack/test/controller/api/implicit_render_test.rb +17 -0
- data/vendor/rails/actionpack/test/controller/api/params_wrapper_test.rb +28 -0
- data/vendor/rails/actionpack/test/controller/api/redirect_to_test.rb +21 -0
- data/vendor/rails/actionpack/test/controller/api/renderers_test.rb +50 -0
- data/vendor/rails/actionpack/test/controller/api/url_for_test.rb +22 -0
- data/vendor/rails/actionpack/test/controller/api/with_cookies_test.rb +23 -0
- data/vendor/rails/actionpack/test/controller/api/with_helpers_test.rb +44 -0
- data/vendor/rails/actionpack/test/controller/base_test.rb +323 -0
- data/vendor/rails/actionpack/test/controller/caching_test.rb +511 -0
- data/vendor/rails/actionpack/test/controller/content_type_test.rb +169 -0
- data/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
- data/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
- data/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
- data/vendor/rails/actionpack/test/controller/default_url_options_with_before_action_test.rb +28 -0
- data/vendor/rails/actionpack/test/controller/filters_test.rb +1050 -0
- data/vendor/rails/actionpack/test/controller/flash_hash_test.rb +216 -0
- data/vendor/rails/actionpack/test/controller/flash_test.rb +373 -0
- data/vendor/rails/actionpack/test/controller/force_ssl_test.rb +333 -0
- data/vendor/rails/actionpack/test/controller/form_builder_test.rb +19 -0
- data/vendor/rails/actionpack/test/controller/helper_test.rb +295 -0
- data/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +179 -0
- data/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +282 -0
- data/vendor/rails/actionpack/test/controller/http_token_authentication_test.rb +216 -0
- data/vendor/rails/actionpack/test/controller/integration_test.rb +1136 -0
- data/vendor/rails/actionpack/test/controller/live_stream_test.rb +518 -0
- data/vendor/rails/actionpack/test/controller/localized_templates_test.rb +48 -0
- data/vendor/rails/actionpack/test/controller/log_subscriber_test.rb +371 -0
- data/vendor/rails/actionpack/test/controller/metal/renderers_test.rb +50 -0
- data/vendor/rails/actionpack/test/controller/metal_test.rb +32 -0
- data/vendor/rails/actionpack/test/controller/mime/accept_format_test.rb +94 -0
- data/vendor/rails/actionpack/test/controller/mime/respond_to_test.rb +843 -0
- data/vendor/rails/actionpack/test/controller/new_base/bare_metal_test.rb +184 -0
- data/vendor/rails/actionpack/test/controller/new_base/base_test.rb +131 -0
- data/vendor/rails/actionpack/test/controller/new_base/content_negotiation_test.rb +28 -0
- data/vendor/rails/actionpack/test/controller/new_base/content_type_test.rb +116 -0
- data/vendor/rails/actionpack/test/controller/new_base/middleware_test.rb +112 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_action_test.rb +314 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_body_test.rb +172 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_context_test.rb +54 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_file_test.rb +72 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_html_test.rb +192 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_implicit_action_test.rb +59 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_layout_test.rb +128 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_partial_test.rb +62 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_plain_test.rb +170 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_streaming_test.rb +116 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_template_test.rb +240 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_test.rb +142 -0
- data/vendor/rails/actionpack/test/controller/new_base/render_xml_test.rb +12 -0
- data/vendor/rails/actionpack/test/controller/output_escaping_test.rb +17 -0
- data/vendor/rails/actionpack/test/controller/parameter_encoding_test.rb +52 -0
- data/vendor/rails/actionpack/test/controller/parameters/accessors_test.rb +324 -0
- data/vendor/rails/actionpack/test/controller/parameters/always_permitted_parameters_test.rb +30 -0
- data/vendor/rails/actionpack/test/controller/parameters/dup_test.rb +67 -0
- data/vendor/rails/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb +70 -0
- data/vendor/rails/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb +39 -0
- data/vendor/rails/actionpack/test/controller/parameters/mutators_test.rb +122 -0
- data/vendor/rails/actionpack/test/controller/parameters/nested_parameters_permit_test.rb +184 -0
- data/vendor/rails/actionpack/test/controller/parameters/parameters_permit_test.rb +516 -0
- data/vendor/rails/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb +33 -0
- data/vendor/rails/actionpack/test/controller/parameters/serialization_test.rb +55 -0
- data/vendor/rails/actionpack/test/controller/params_wrapper_test.rb +422 -0
- data/vendor/rails/actionpack/test/controller/permitted_params_test.rb +27 -0
- data/vendor/rails/actionpack/test/controller/redirect_test.rb +395 -0
- data/vendor/rails/actionpack/test/controller/render_js_test.rb +36 -0
- data/vendor/rails/actionpack/test/controller/render_json_test.rb +137 -0
- data/vendor/rails/actionpack/test/controller/render_test.rb +843 -0
- data/vendor/rails/actionpack/test/controller/render_xml_test.rb +102 -0
- data/vendor/rails/actionpack/test/controller/renderer_test.rb +136 -0
- data/vendor/rails/actionpack/test/controller/renderers_test.rb +91 -0
- data/vendor/rails/actionpack/test/controller/request/test_request_test.rb +42 -0
- data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +1013 -0
- data/vendor/rails/actionpack/test/controller/required_params_test.rb +100 -0
- data/vendor/rails/actionpack/test/controller/rescue_test.rb +364 -0
- data/vendor/rails/actionpack/test/controller/resources_test.rb +1369 -0
- data/vendor/rails/actionpack/test/controller/routing_test.rb +2108 -0
- data/vendor/rails/actionpack/test/controller/runner_test.rb +24 -0
- data/vendor/rails/actionpack/test/controller/send_file_test.rb +259 -0
- data/vendor/rails/actionpack/test/controller/show_exceptions_test.rb +114 -0
- data/vendor/rails/actionpack/test/controller/streaming_test.rb +28 -0
- data/vendor/rails/actionpack/test/controller/test_case_test.rb +1157 -0
- data/vendor/rails/actionpack/test/controller/url_for_integration_test.rb +192 -0
- data/vendor/rails/actionpack/test/controller/url_for_test.rb +519 -0
- data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +92 -0
- data/vendor/rails/actionpack/test/controller/webservice_test.rb +135 -0
- data/vendor/rails/actionpack/test/dispatch/callbacks_test.rb +47 -0
- data/vendor/rails/actionpack/test/dispatch/content_security_policy_test.rb +525 -0
- data/vendor/rails/actionpack/test/dispatch/cookies_test.rb +1345 -0
- data/vendor/rails/actionpack/test/dispatch/debug_exceptions_test.rb +502 -0
- data/vendor/rails/actionpack/test/dispatch/debug_locks_test.rb +38 -0
- data/vendor/rails/actionpack/test/dispatch/exception_wrapper_test.rb +120 -0
- data/vendor/rails/actionpack/test/dispatch/executor_test.rb +136 -0
- data/vendor/rails/actionpack/test/dispatch/header_test.rb +169 -0
- data/vendor/rails/actionpack/test/dispatch/live_response_test.rb +98 -0
- data/vendor/rails/actionpack/test/dispatch/mapper_test.rb +210 -0
- data/vendor/rails/actionpack/test/dispatch/middleware_stack_test.rb +115 -0
- data/vendor/rails/actionpack/test/dispatch/mime_type_test.rb +187 -0
- data/vendor/rails/actionpack/test/dispatch/mount_test.rb +95 -0
- data/vendor/rails/actionpack/test/dispatch/prefix_generation_test.rb +463 -0
- data/vendor/rails/actionpack/test/dispatch/rack_cache_test.rb +23 -0
- data/vendor/rails/actionpack/test/dispatch/reloader_test.rb +167 -0
- data/vendor/rails/actionpack/test/dispatch/request/json_params_parsing_test.rb +207 -0
- data/vendor/rails/actionpack/test/dispatch/request/multipart_params_parsing_test.rb +202 -0
- data/vendor/rails/actionpack/test/dispatch/request/query_string_parsing_test.rb +176 -0
- data/vendor/rails/actionpack/test/dispatch/request/session_test.rb +165 -0
- data/vendor/rails/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb +181 -0
- data/vendor/rails/actionpack/test/dispatch/request_id_test.rb +75 -0
- data/vendor/rails/actionpack/test/dispatch/request_test.rb +1307 -0
- data/vendor/rails/actionpack/test/dispatch/response_test.rb +542 -0
- data/vendor/rails/actionpack/test/dispatch/routing/concerns_test.rb +124 -0
- data/vendor/rails/actionpack/test/dispatch/routing/custom_url_helpers_test.rb +333 -0
- data/vendor/rails/actionpack/test/dispatch/routing/inspector_test.rb +425 -0
- data/vendor/rails/actionpack/test/dispatch/routing/ipv6_redirect_test.rb +46 -0
- data/vendor/rails/actionpack/test/dispatch/routing/route_set_test.rb +166 -0
- data/vendor/rails/actionpack/test/dispatch/routing_assertions_test.rb +209 -0
- data/vendor/rails/actionpack/test/dispatch/routing_test.rb +5112 -0
- data/vendor/rails/actionpack/test/dispatch/runner_test.rb +19 -0
- data/vendor/rails/actionpack/test/dispatch/session/abstract_store_test.rb +58 -0
- data/vendor/rails/actionpack/test/dispatch/session/cache_store_test.rb +183 -0
- data/vendor/rails/actionpack/test/dispatch/session/cookie_store_test.rb +417 -0
- data/vendor/rails/actionpack/test/dispatch/session/mem_cache_store_test.rb +205 -0
- data/vendor/rails/actionpack/test/dispatch/session/test_session_test.rb +65 -0
- data/vendor/rails/actionpack/test/dispatch/show_exceptions_test.rb +138 -0
- data/vendor/rails/actionpack/test/dispatch/ssl_test.rb +228 -0
- data/vendor/rails/actionpack/test/dispatch/static_test.rb +318 -0
- data/vendor/rails/actionpack/test/dispatch/system_testing/driver_test.rb +54 -0
- data/vendor/rails/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb +81 -0
- data/vendor/rails/actionpack/test/dispatch/system_testing/server_test.rb +32 -0
- data/vendor/rails/actionpack/test/dispatch/system_testing/system_test_case_test.rb +84 -0
- data/vendor/rails/actionpack/test/dispatch/test_request_test.rb +131 -0
- data/vendor/rails/actionpack/test/dispatch/test_response_test.rb +37 -0
- data/vendor/rails/actionpack/test/dispatch/uploaded_file_test.rb +113 -0
- data/vendor/rails/actionpack/test/dispatch/url_generation_test.rb +141 -0
- data/vendor/rails/actionpack/test/fixtures/_top_level_partial_only.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/alternate_helpers/foo_helper.rb +5 -0
- data/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/collection_cache/index.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/company.rb +11 -0
- data/vendor/rails/actionpack/test/fixtures/customers/_commented_customer.html.erb +5 -0
- data/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb +4 -0
- data/vendor/rails/actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/_formatted_partial.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +5 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/functional_caching/xml_fragment_cached_with_html_partial.xml.builder +5 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +5 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +7 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +7 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/just_me_helper.rb +5 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/me_too_helper.rb +5 -0
- data/vendor/rails/actionpack/test/fixtures/helpers1_pack/pack1_helper.rb +7 -0
- data/vendor/rails/actionpack/test/fixtures/helpers2_pack/pack2_helper.rb +7 -0
- data/vendor/rails/actionpack/test/fixtures/helpers_typo/admin/users_helper.rb +6 -0
- data/vendor/rails/actionpack/test/fixtures/implicit_render_test/empty_action_with_mobile_variant.html+mobile.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/implicit_render_test/empty_action_with_template.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/_customers.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/builder.builder +3 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/standard.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/with_html_partial.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/xhr.html.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/yield.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/load_me.rb +4 -0
- data/vendor/rails/actionpack/test/fixtures/localized/hello_world.de.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/localized/hello_world.en.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/localized/hello_world.it.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/binary_file +0 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file +10 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param +5 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/bracketed_utf8_param +5 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/empty +10 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/hello.txt +1 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +10 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/mixed_files +0 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/none +9 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/ruby_on_rails.jpg +0 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +5 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/single_utf8_param +5 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/text_file +10 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/utf8_filename +10 -0
- data/vendor/rails/actionpack/test/fixtures/namespaced/implicit_render_test/hello_world.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/old_content_type/render_default_content_types_for_respond_to.xml.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/old_content_type/render_default_for_builder.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/old_content_type/render_default_for_erb.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/400.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/404.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/500.da.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/500.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/bar.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/bar/index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo/bar.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo/baz.css +3 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo/index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo/other-index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo//343/201/223/343/202/223/343/201/253/343/201/241/343/201/257.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html.gz +0 -0
- data/vendor/rails/actionpack/test/fixtures/public/gzip/application-a71b3024f80aea3181c09774ca17e712.js +4 -0
- data/vendor/rails/actionpack/test/fixtures/public/gzip/application-a71b3024f80aea3181c09774ca17e712.js.gz +0 -0
- data/vendor/rails/actionpack/test/fixtures/public/gzip/foo.zoo +4 -0
- data/vendor/rails/actionpack/test/fixtures/public/gzip/foo.zoo.gz +0 -0
- data/vendor/rails/actionpack/test/fixtures/public/index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/other-index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_all.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/variant_any_implicit_render.html+phablet.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/variant_any_implicit_render.html+tablet.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/variant_inline_syntax_without_block.html+phone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/variant_plus_none_for_format.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/variant_with_implicit_template_rendering.html+mobile.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/ruby_template.ruby +2 -0
- data/vendor/rails/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +12 -0
- data/vendor/rails/actionpack/test/fixtures/shared.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/star_star_mime/index.js.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello/hello.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world_with_partial.html.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder +11 -0
- data/vendor/rails/actionpack/test/fixtures/test/implicit_content_type.atom.builder +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/with_implicit_template.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/bar.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/bar/index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/bar.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/baz.css +3 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo/other-index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo//343/201/223/343/202/223/343/201/253/343/201/241/343/201/257.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/foo//343/201/225/343/202/210/343/201/206/343/201/252/343/202/211.html.gz +0 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/application-a71b3024f80aea3181c09774ca17e712.js +4 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/application-a71b3024f80aea3181c09774ca17e712.js.gz +0 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/foo.zoo +4 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/gzip/foo.zoo.gz +0 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/index.html +1 -0
- data/vendor/rails/actionpack/test/fixtures//345/205/254/345/205/261/other-index.html +1 -0
- data/vendor/rails/actionpack/test/journey/gtg/builder_test.rb +81 -0
- data/vendor/rails/actionpack/test/journey/gtg/transition_table_test.rb +125 -0
- data/vendor/rails/actionpack/test/journey/nfa/simulator_test.rb +100 -0
- data/vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb +74 -0
- data/vendor/rails/actionpack/test/journey/nodes/symbol_test.rb +19 -0
- data/vendor/rails/actionpack/test/journey/path/pattern_test.rb +286 -0
- data/vendor/rails/actionpack/test/journey/route/definition/parser_test.rb +112 -0
- data/vendor/rails/actionpack/test/journey/route/definition/scanner_test.rb +71 -0
- data/vendor/rails/actionpack/test/journey/route_test.rb +113 -0
- data/vendor/rails/actionpack/test/journey/router/utils_test.rb +48 -0
- data/vendor/rails/actionpack/test/journey/router_test.rb +544 -0
- data/vendor/rails/actionpack/test/journey/routes_test.rb +62 -0
- data/vendor/rails/actionpack/test/lib/controller/fake_controllers.rb +37 -0
- data/vendor/rails/actionpack/test/lib/controller/fake_models.rb +79 -0
- data/vendor/rails/actionpack/test/routing/helper_test.rb +33 -0
- data/vendor/rails/actionview/CHANGELOG.md +122 -0
- data/vendor/rails/actionview/MIT-LICENSE +21 -0
- data/vendor/rails/actionview/README.rdoc +38 -0
- data/vendor/rails/actionview/RUNNING_UJS_TESTS.rdoc +8 -0
- data/vendor/rails/actionview/RUNNING_UNIT_TESTS.rdoc +26 -0
- data/vendor/rails/actionview/Rakefile +136 -0
- data/vendor/rails/actionview/actionview.gemspec +38 -0
- data/vendor/rails/actionview/app/assets/javascripts/MIT-LICENSE +20 -0
- data/vendor/rails/actionview/app/assets/javascripts/README.md +55 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs.coffee +39 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/BANNER.js +5 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee +26 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee +82 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/method.coffee +34 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee +90 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/start.coffee +71 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee +97 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/csp.coffee +4 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/csrf.coffee +25 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/dom.coffee +35 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee +68 -0
- data/vendor/rails/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee +36 -0
- data/vendor/rails/actionview/bin/test +5 -0
- data/vendor/rails/actionview/blade.yml +11 -0
- data/vendor/rails/actionview/coffeelint.json +135 -0
- data/vendor/rails/actionview/lib/action_view.rb +97 -0
- data/vendor/rails/actionview/lib/action_view/base.rb +215 -0
- data/vendor/rails/actionview/lib/action_view/buffers.rb +52 -0
- data/vendor/rails/actionview/lib/action_view/context.rb +36 -0
- data/vendor/rails/actionview/lib/action_view/dependency_tracker.rb +175 -0
- data/vendor/rails/actionview/lib/action_view/digestor.rb +136 -0
- data/vendor/rails/actionview/lib/action_view/flows.rb +76 -0
- data/vendor/rails/actionview/lib/action_view/gem_version.rb +17 -0
- data/vendor/rails/actionview/lib/action_view/helpers.rb +68 -0
- data/vendor/rails/actionview/lib/action_view/helpers/active_model_helper.rb +55 -0
- data/vendor/rails/actionview/lib/action_view/helpers/asset_tag_helper.rb +511 -0
- data/vendor/rails/actionview/lib/action_view/helpers/asset_url_helper.rb +469 -0
- data/vendor/rails/actionview/lib/action_view/helpers/atom_feed_helper.rb +205 -0
- data/vendor/rails/actionview/lib/action_view/helpers/cache_helper.rb +263 -0
- data/vendor/rails/actionview/lib/action_view/helpers/capture_helper.rb +212 -0
- data/vendor/rails/actionview/lib/action_view/helpers/controller_helper.rb +36 -0
- data/vendor/rails/actionview/lib/action_view/helpers/csp_helper.rb +24 -0
- data/vendor/rails/actionview/lib/action_view/helpers/csrf_helper.rb +35 -0
- data/vendor/rails/actionview/lib/action_view/helpers/date_helper.rb +1156 -0
- data/vendor/rails/actionview/lib/action_view/helpers/debug_helper.rb +36 -0
- data/vendor/rails/actionview/lib/action_view/helpers/form_helper.rb +2337 -0
- data/vendor/rails/actionview/lib/action_view/helpers/form_options_helper.rb +887 -0
- data/vendor/rails/actionview/lib/action_view/helpers/form_tag_helper.rb +917 -0
- data/vendor/rails/actionview/lib/action_view/helpers/javascript_helper.rb +94 -0
- data/vendor/rails/actionview/lib/action_view/helpers/number_helper.rb +451 -0
- data/vendor/rails/actionview/lib/action_view/helpers/output_safety_helper.rb +70 -0
- data/vendor/rails/actionview/lib/action_view/helpers/record_tag_helper.rb +23 -0
- data/vendor/rails/actionview/lib/action_view/helpers/rendering_helper.rb +99 -0
- data/vendor/rails/actionview/lib/action_view/helpers/sanitize_helper.rb +177 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tag_helper.rb +313 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags.rb +44 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/base.rb +192 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/check_box.rb +66 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/checkable.rb +18 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +36 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_helpers.rb +119 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb +31 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/collection_select.rb +30 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/color_field.rb +27 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/date_field.rb +15 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/date_select.rb +74 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/datetime_field.rb +32 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/datetime_local_field.rb +21 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/datetime_select.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/email_field.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/file_field.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb +31 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/hidden_field.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/label.rb +81 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/month_field.rb +15 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/number_field.rb +20 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/password_field.rb +14 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/placeholderable.rb +24 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/radio_button.rb +33 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/range_field.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/search_field.rb +27 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/select.rb +43 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/tel_field.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/text_area.rb +24 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/text_field.rb +34 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/time_field.rb +15 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/time_select.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/time_zone_select.rb +22 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/translator.rb +44 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/url_field.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/helpers/tags/week_field.rb +15 -0
- data/vendor/rails/actionview/lib/action_view/helpers/text_helper.rb +486 -0
- data/vendor/rails/actionview/lib/action_view/helpers/translation_helper.rb +141 -0
- data/vendor/rails/actionview/lib/action_view/helpers/url_helper.rb +676 -0
- data/vendor/rails/actionview/lib/action_view/layouts.rb +433 -0
- data/vendor/rails/actionview/lib/action_view/locale/en.yml +56 -0
- data/vendor/rails/actionview/lib/action_view/log_subscriber.rb +96 -0
- data/vendor/rails/actionview/lib/action_view/lookup_context.rb +274 -0
- data/vendor/rails/actionview/lib/action_view/model_naming.rb +14 -0
- data/vendor/rails/actionview/lib/action_view/path_set.rb +100 -0
- data/vendor/rails/actionview/lib/action_view/railtie.rb +82 -0
- data/vendor/rails/actionview/lib/action_view/record_identifier.rb +112 -0
- data/vendor/rails/actionview/lib/action_view/renderer/abstract_renderer.rb +55 -0
- data/vendor/rails/actionview/lib/action_view/renderer/partial_renderer.rb +552 -0
- data/vendor/rails/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb +57 -0
- data/vendor/rails/actionview/lib/action_view/renderer/renderer.rb +56 -0
- data/vendor/rails/actionview/lib/action_view/renderer/streaming_template_renderer.rb +105 -0
- data/vendor/rails/actionview/lib/action_view/renderer/template_renderer.rb +102 -0
- data/vendor/rails/actionview/lib/action_view/rendering.rb +151 -0
- data/vendor/rails/actionview/lib/action_view/routing_url_for.rb +145 -0
- data/vendor/rails/actionview/lib/action_view/tasks/cache_digests.rake +25 -0
- data/vendor/rails/actionview/lib/action_view/template.rb +361 -0
- data/vendor/rails/actionview/lib/action_view/template/error.rb +141 -0
- data/vendor/rails/actionview/lib/action_view/template/handlers.rb +66 -0
- data/vendor/rails/actionview/lib/action_view/template/handlers/builder.rb +25 -0
- data/vendor/rails/actionview/lib/action_view/template/handlers/erb.rb +74 -0
- data/vendor/rails/actionview/lib/action_view/template/handlers/erb/erubi.rb +83 -0
- data/vendor/rails/actionview/lib/action_view/template/handlers/html.rb +11 -0
- data/vendor/rails/actionview/lib/action_view/template/handlers/raw.rb +11 -0
- data/vendor/rails/actionview/lib/action_view/template/html.rb +34 -0
- data/vendor/rails/actionview/lib/action_view/template/resolver.rb +391 -0
- data/vendor/rails/actionview/lib/action_view/template/text.rb +33 -0
- data/vendor/rails/actionview/lib/action_view/template/types.rb +57 -0
- data/vendor/rails/actionview/lib/action_view/test_case.rb +300 -0
- data/vendor/rails/actionview/lib/action_view/testing/resolvers.rb +54 -0
- data/vendor/rails/actionview/lib/action_view/version.rb +10 -0
- data/vendor/rails/actionview/lib/action_view/view_paths.rb +105 -0
- data/vendor/rails/actionview/package.json +36 -0
- data/vendor/rails/actionview/test/abstract_unit.rb +236 -0
- data/vendor/rails/actionview/test/actionpack/abstract/abstract_controller_test.rb +292 -0
- data/vendor/rails/actionview/test/actionpack/abstract/helper_test.rb +128 -0
- data/vendor/rails/actionview/test/actionpack/abstract/layouts_test.rb +568 -0
- data/vendor/rails/actionview/test/actionpack/abstract/render_test.rb +103 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/abstract_controller/testing/me3/formatted.html.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/abstract_controller/testing/me3/index.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/abstract_controller/testing/me4/index.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/action_with_ivars.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/helper_test.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/index.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/layouts/abstract_controller/testing/me4.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/layouts/application.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/abstract/views/naked_render.erb +1 -0
- data/vendor/rails/actionview/test/actionpack/controller/capture_test.rb +83 -0
- data/vendor/rails/actionview/test/actionpack/controller/layout_test.rb +270 -0
- data/vendor/rails/actionview/test/actionpack/controller/render_test.rb +1294 -0
- data/vendor/rails/actionview/test/actionpack/controller/view_paths_test.rb +174 -0
- data/vendor/rails/actionview/test/active_record_unit.rb +92 -0
- data/vendor/rails/actionview/test/activerecord/controller_runtime_test.rb +95 -0
- data/vendor/rails/actionview/test/activerecord/debug_helper_test.rb +19 -0
- data/vendor/rails/actionview/test/activerecord/form_helper_activerecord_test.rb +90 -0
- data/vendor/rails/actionview/test/activerecord/polymorphic_routes_test.rb +780 -0
- data/vendor/rails/actionview/test/activerecord/relation_cache_test.rb +23 -0
- data/vendor/rails/actionview/test/activerecord/render_partial_with_record_identification_test.rb +188 -0
- data/vendor/rails/actionview/test/fixtures/_top_level_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/_top_level_partial_only.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/bad_customers/_bad_customer.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/customers/_customer.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/fun/games/_form.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/fun/games/hello_world.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/good_customers/_good_customer.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/hello.html +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/alt/layouts/alt.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/controller_name_space/nested.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/item.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/layout_test.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/multiple_extensions.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/symlinked/symlinked_layout.erb +5 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/layouts/third_party_template_library.mab +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/views/goodbye.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layout_tests/views/hello.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_column.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_customers.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_partial_and_yield.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_yield_only.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/_yield_with_params.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/block_with_layout.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/builder.builder +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/partial_with_layout.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/standard.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/standard.text.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/streaming.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/talk_from_action.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/with_html_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/xhr.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/yield.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/yield_with_render_inline_inside.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/layouts/yield_with_render_partial_inside.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/quiz/questions/_question.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/shared.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_changing_priority.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_changing_priority.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_counter.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_counter.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_counter_with_as.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_greeting.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_iteration.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_iteration_with_as.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_customer_with_var.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_directory/_partial_with_locales.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_first_json_partial.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_form.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_hash_greeting.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_hash_object.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_hello.builder +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_json_change_priority.json.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_labelling_form.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_layout_for_partial.html.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial.js.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_for_use_in_layout.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_html_erb.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_name_local_variable.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_only.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_only_html.html +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_partial_with_partial.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_person.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_raise_indentation.html.erb +13 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/_second_json_partial.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/action_talk_to_layout.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/calling_partial_with_layout.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/capturing.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/change_priority.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/content_for.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/content_for_concatenated.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/content_for_with_parameter.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/dot.directory/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_html_erb.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_xml_erb.builder +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_xml_erb.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/formatted_xml_erb.xml.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/greeting.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/greeting.xml.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello,world.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello.builder +4 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello/hello.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_container.builder +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_from_rxml.builder +3 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_with_layout_false.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_world_with_partial.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hello_xml_world.builder +11 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/html_template.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/hyphen-ated.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/implicit_content_type.atom.builder +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/list.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/non_erb_block_content_for.builder +4 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/potential_conflicts.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/proper_block_detection.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_from_template.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_with_locals.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_file_with_locals_and_default.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_implicit_html_template_from_xhr_request.da.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_implicit_html_template_from_xhr_request.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_implicit_js_template_without_layout.js.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_partial_inside_directory.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_to_string_test.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/render_two_partials.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/using_layout_around_block.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/with_html_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/with_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/with_partial.text.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/actionpack/test/with_xml_template.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/comments/empty.de.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/comments/empty.html+grid.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/comments/empty.html.builder +1 -0
- data/vendor/rails/actionview/test/fixtures/comments/empty.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/comments/empty.xml.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/companies.yml +24 -0
- data/vendor/rails/actionview/test/fixtures/company.rb +11 -0
- data/vendor/rails/actionview/test/fixtures/custom_pattern/another.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/custom_pattern/html/another.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/custom_pattern/html/path.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/customers/_customer.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/customers/_customer.xml.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/db_definitions/sqlite.sql +49 -0
- data/vendor/rails/actionview/test/fixtures/developer.rb +8 -0
- data/vendor/rails/actionview/test/fixtures/developers.yml +21 -0
- data/vendor/rails/actionview/test/fixtures/developers/_developer.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/developers_projects.yml +13 -0
- data/vendor/rails/actionview/test/fixtures/digestor/api/comments/_comment.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/api/comments/_comments.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/comments/_comment.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/comments/_comments.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/comments/show.js.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/events/_completed.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/digestor/events/_event.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/digestor/events/index.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/level/_recursion.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/level/below/_header.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/digestor/level/below/index.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/level/recursion.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/_form.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/_header.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/_message.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/actions/_move.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/edit.html.erb +5 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/index.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/new.html+iphone.erb +15 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/peek.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/show.html.erb +14 -0
- data/vendor/rails/actionview/test/fixtures/digestor/messages/thread.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/fun/games/_game.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/fun/games/hello_world.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/fun/serious/games/_game.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/games/_game.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/good_customers/_good_customer.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/helpers/abc_helper.rb +5 -0
- data/vendor/rails/actionview/test/fixtures/helpers/helpery_test_helper.rb +7 -0
- data/vendor/rails/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb +6 -0
- data/vendor/rails/actionview/test/fixtures/layout_tests/alt/hello.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/layouts/_column.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/layouts/_customers.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/layouts/_partial_and_yield.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/layouts/_yield_only.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/layouts/_yield_with_params.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/layouts/render_partial_html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/layouts/streaming.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/layouts/streaming_with_capture.erb +6 -0
- data/vendor/rails/actionview/test/fixtures/layouts/streaming_with_locale.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/layouts/yield.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/layouts/yield_with_render_inline_inside.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/layouts/yield_with_render_partial_inside.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/mascot.rb +5 -0
- data/vendor/rails/actionview/test/fixtures/mascots.yml +4 -0
- data/vendor/rails/actionview/test/fixtures/mascots/_mascot.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/override/test/hello_world.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/override2/layouts/test/sub.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/plain_text.raw +1 -0
- data/vendor/rails/actionview/test/fixtures/plain_text_with_characters.raw +1 -0
- data/vendor/rails/actionview/test/fixtures/project.rb +9 -0
- data/vendor/rails/actionview/test/fixtures/projects.yml +7 -0
- data/vendor/rails/actionview/test/fixtures/projects/_project.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/public/elsewhere/cools.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/elsewhere/file.css +1 -0
- data/vendor/rails/actionview/test/fixtures/public/foo/baz.css +3 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/application.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/bank.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/common.javascript +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/controls.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/dragdrop.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/effects.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/prototype.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/robber.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/subdir/subdir.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/javascripts/version.1.0.js +1 -0
- data/vendor/rails/actionview/test/fixtures/public/stylesheets/bank.css +1 -0
- data/vendor/rails/actionview/test/fixtures/public/stylesheets/random.styles +1 -0
- data/vendor/rails/actionview/test/fixtures/public/stylesheets/robber.css +1 -0
- data/vendor/rails/actionview/test/fixtures/public/stylesheets/subdir/subdir.css +1 -0
- data/vendor/rails/actionview/test/fixtures/public/stylesheets/version.1.0.css +1 -0
- data/vendor/rails/actionview/test/fixtures/replies.yml +15 -0
- data/vendor/rails/actionview/test/fixtures/replies/_reply.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/reply.rb +9 -0
- data/vendor/rails/actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/ruby_template.ruby +2 -0
- data/vendor/rails/actionview/test/fixtures/shared.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_200.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_FooBar.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_a-in.html.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/test/_b_layout_for_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_b_layout_for_partial_with_object.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_builder_tag_nested_in_content_tag.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_cached_customer.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_cached_customer_as.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_cached_nested_cached_customer.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_changing_priority.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_changing_priority.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_content_tag_nested_in_content_tag.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_counter.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_customer.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_customer.mobile.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_customer_greeting.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_customer_with_var.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_first_json_partial.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_from_helper.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_json_change_priority.json.erb +0 -0
- data/vendor/rails/actionview/test/fixtures/test/_klass.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_label_with_block.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/test/_layout_for_block_with_args.html.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_layout_for_partial.html.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_layout_with_partial_and_yield.html.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/test/_local_inspector.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_nested_cached_customer.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_object_inspector.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_one.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial.js.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_iteration_1.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_iteration_2.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_name_in_local_assigns.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_name_local_variable.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_only.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_shortcut_with_block_content.html.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_with_layout.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_with_layout_block_content.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_with_layout_block_partial.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_with_only_html_version.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_with_partial.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/_partial_with_variants.html+grid.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_partialhtml.html +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_raise.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_raise_indentation.html.erb +13 -0
- data/vendor/rails/actionview/test/fixtures/test/_second_json_partial.json.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_two.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_utf8_partial.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/_utf8_partial_magic.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/_/360/237/215/243.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/basic.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/change_priority.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/dont_pick_me +1 -0
- data/vendor/rails/actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/greeting.xml.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello.builder +4 -0
- data/vendor/rails/actionview/test/fixtures/test/hello/hello.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world.da.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world.erb~ +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world.html+phone.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world.text+phone.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/hello_world_with_partial.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/html_template.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/layout_render_file.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/layout_render_object.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/list.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/malformed/malformed.en.html.erb~ +1 -0
- data/vendor/rails/actionview/test/fixtures/test/malformed/malformed.erb~ +1 -0
- data/vendor/rails/actionview/test/fixtures/test/malformed/malformed.html.erb~ +1 -0
- data/vendor/rails/actionview/test/fixtures/test/malformed/malformed~ +1 -0
- data/vendor/rails/actionview/test/fixtures/test/nested_layout.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/nested_streaming.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/nil_return.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/one.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_inspect_local_assigns.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_instance_variable.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_unicode_local.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_with_locals.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_with_locals_and_default.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_file_with_ruby_keyword_locals.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_partial_inside_directory.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/render_two_partials.html.erb +2 -0
- data/vendor/rails/actionview/test/fixtures/test/streaming.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/streaming_buster.erb +3 -0
- data/vendor/rails/actionview/test/fixtures/test/streaming_with_locale.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/sub_template_raise.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/template.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/test/update_element_with_capture.erb +9 -0
- data/vendor/rails/actionview/test/fixtures/test/utf8.html.erb +4 -0
- data/vendor/rails/actionview/test/fixtures/test/utf8_magic.html.erb +5 -0
- data/vendor/rails/actionview/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +5 -0
- data/vendor/rails/actionview/test/fixtures/topic.rb +5 -0
- data/vendor/rails/actionview/test/fixtures/topics.yml +22 -0
- data/vendor/rails/actionview/test/fixtures/topics/_topic.html.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/translations/templates/array.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/translations/templates/default.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/translations/templates/found.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/translations/templates/missing.erb +1 -0
- data/vendor/rails/actionview/test/fixtures/with_format.json.erb +1 -0
- data/vendor/rails/actionview/test/lib/controller/fake_models.rb +204 -0
- data/vendor/rails/actionview/test/template/active_model_helper_test.rb +172 -0
- data/vendor/rails/actionview/test/template/asset_tag_helper_test.rb +913 -0
- data/vendor/rails/actionview/test/template/atom_feed_helper_test.rb +375 -0
- data/vendor/rails/actionview/test/template/capture_helper_test.rb +228 -0
- data/vendor/rails/actionview/test/template/compiled_templates_test.rb +94 -0
- data/vendor/rails/actionview/test/template/controller_helper_test.rb +34 -0
- data/vendor/rails/actionview/test/template/date_helper_i18n_test.rb +166 -0
- data/vendor/rails/actionview/test/template/date_helper_test.rb +3642 -0
- data/vendor/rails/actionview/test/template/dependency_tracker_test.rb +195 -0
- data/vendor/rails/actionview/test/template/digestor_test.rb +389 -0
- data/vendor/rails/actionview/test/template/erb/form_for_test.rb +13 -0
- data/vendor/rails/actionview/test/template/erb/helper.rb +26 -0
- data/vendor/rails/actionview/test/template/erb/tag_helper_test.rb +32 -0
- data/vendor/rails/actionview/test/template/erb_util_test.rb +114 -0
- data/vendor/rails/actionview/test/template/form_collections_helper_test.rb +527 -0
- data/vendor/rails/actionview/test/template/form_helper/form_with_test.rb +2293 -0
- data/vendor/rails/actionview/test/template/form_helper_test.rb +3554 -0
- data/vendor/rails/actionview/test/template/form_options_helper_i18n_test.rb +30 -0
- data/vendor/rails/actionview/test/template/form_options_helper_test.rb +1452 -0
- data/vendor/rails/actionview/test/template/form_tag_helper_test.rb +785 -0
- data/vendor/rails/actionview/test/template/html_test.rb +19 -0
- data/vendor/rails/actionview/test/template/javascript_helper_test.rb +68 -0
- data/vendor/rails/actionview/test/template/log_subscriber_test.rb +224 -0
- data/vendor/rails/actionview/test/template/lookup_context_test.rb +289 -0
- data/vendor/rails/actionview/test/template/number_helper_test.rb +204 -0
- data/vendor/rails/actionview/test/template/output_safety_helper_test.rb +119 -0
- data/vendor/rails/actionview/test/template/partial_iteration_test.rb +35 -0
- data/vendor/rails/actionview/test/template/record_identifier_test.rb +93 -0
- data/vendor/rails/actionview/test/template/record_tag_helper_test.rb +33 -0
- data/vendor/rails/actionview/test/template/render_test.rb +725 -0
- data/vendor/rails/actionview/test/template/resolver_cache_test.rb +9 -0
- data/vendor/rails/actionview/test/template/resolver_patterns_test.rb +44 -0
- data/vendor/rails/actionview/test/template/sanitize_helper_test.rb +43 -0
- data/vendor/rails/actionview/test/template/streaming_render_test.rb +132 -0
- data/vendor/rails/actionview/test/template/tag_helper_test.rb +357 -0
- data/vendor/rails/actionview/test/template/template_error_test.rb +37 -0
- data/vendor/rails/actionview/test/template/template_test.rb +207 -0
- data/vendor/rails/actionview/test/template/test_case_test.rb +335 -0
- data/vendor/rails/actionview/test/template/test_test.rb +94 -0
- data/vendor/rails/actionview/test/template/testing/fixture_resolver_test.rb +20 -0
- data/vendor/rails/actionview/test/template/testing/null_resolver_test.rb +14 -0
- data/vendor/rails/actionview/test/template/text_helper_test.rb +535 -0
- data/vendor/rails/actionview/test/template/text_test.rb +25 -0
- data/vendor/rails/actionview/test/template/translation_helper_test.rb +238 -0
- data/vendor/rails/actionview/test/template/url_helper_test.rb +976 -0
- data/vendor/rails/actionview/test/ujs/config.ru +6 -0
- data/vendor/rails/actionview/test/ujs/public/test/call-ajax.js +26 -0
- data/vendor/rails/actionview/test/ujs/public/test/call-remote-callbacks.js +239 -0
- data/vendor/rails/actionview/test/ujs/public/test/call-remote.js +275 -0
- data/vendor/rails/actionview/test/ujs/public/test/csrf-refresh.js +24 -0
- data/vendor/rails/actionview/test/ujs/public/test/csrf-token.js +27 -0
- data/vendor/rails/actionview/test/ujs/public/test/data-confirm.js +316 -0
- data/vendor/rails/actionview/test/ujs/public/test/data-disable-with.js +394 -0
- data/vendor/rails/actionview/test/ujs/public/test/data-disable.js +322 -0
- data/vendor/rails/actionview/test/ujs/public/test/data-method.js +85 -0
- data/vendor/rails/actionview/test/ujs/public/test/data-remote.js +441 -0
- data/vendor/rails/actionview/test/ujs/public/test/override.js +56 -0
- data/vendor/rails/actionview/test/ujs/public/test/settings.js +118 -0
- data/vendor/rails/actionview/test/ujs/public/vendor/jquery-2.2.0.js +9831 -0
- data/vendor/rails/actionview/test/ujs/public/vendor/jquery.metadata.js +122 -0
- data/vendor/rails/actionview/test/ujs/public/vendor/qunit.css +237 -0
- data/vendor/rails/actionview/test/ujs/public/vendor/qunit.js +2288 -0
- data/vendor/rails/actionview/test/ujs/server.rb +86 -0
- data/vendor/rails/actionview/test/ujs/views/layouts/application.html.erb +26 -0
- data/vendor/rails/actionview/test/ujs/views/tests/index.html.erb +11 -0
- data/vendor/rails/ci/qunit-selenium-runner.rb +16 -0
- data/vendor/rails/ci/travis.rb +187 -0
- data/vendor/rails/rails.gemspec +36 -0
- data/vendor/rails/version.rb +17 -0
- metadata +1030 -30
@@ -0,0 +1,212 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/string/output_safety"
|
4
|
+
|
5
|
+
module ActionView
|
6
|
+
# = Action View Capture Helper
|
7
|
+
module Helpers #:nodoc:
|
8
|
+
# CaptureHelper exposes methods to let you extract generated markup which
|
9
|
+
# can be used in other parts of a template or layout file.
|
10
|
+
#
|
11
|
+
# It provides a method to capture blocks into variables through capture and
|
12
|
+
# a way to capture a block of markup for use in a layout through {content_for}[rdoc-ref:ActionView::Helpers::CaptureHelper#content_for].
|
13
|
+
module CaptureHelper
|
14
|
+
# The capture method extracts part of a template as a String object.
|
15
|
+
# You can then use this object anywhere in your templates, layout, or helpers.
|
16
|
+
#
|
17
|
+
# The capture method can be used in ERB templates...
|
18
|
+
#
|
19
|
+
# <% @greeting = capture do %>
|
20
|
+
# Welcome to my shiny new web page! The date and time is
|
21
|
+
# <%= Time.now %>
|
22
|
+
# <% end %>
|
23
|
+
#
|
24
|
+
# ...and Builder (RXML) templates.
|
25
|
+
#
|
26
|
+
# @timestamp = capture do
|
27
|
+
# "The current timestamp is #{Time.now}."
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# You can then use that variable anywhere else. For example:
|
31
|
+
#
|
32
|
+
# <html>
|
33
|
+
# <head><title><%= @greeting %></title></head>
|
34
|
+
# <body>
|
35
|
+
# <b><%= @greeting %></b>
|
36
|
+
# </body>
|
37
|
+
# </html>
|
38
|
+
#
|
39
|
+
def capture(*args)
|
40
|
+
value = nil
|
41
|
+
buffer = with_output_buffer { value = yield(*args) }
|
42
|
+
if (string = buffer.presence || value) && string.is_a?(String)
|
43
|
+
ERB::Util.html_escape string
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Calling <tt>content_for</tt> stores a block of markup in an identifier for later use.
|
48
|
+
# In order to access this stored content in other templates, helper modules
|
49
|
+
# or the layout, you would pass the identifier as an argument to <tt>content_for</tt>.
|
50
|
+
#
|
51
|
+
# Note: <tt>yield</tt> can still be used to retrieve the stored content, but calling
|
52
|
+
# <tt>yield</tt> doesn't work in helper modules, while <tt>content_for</tt> does.
|
53
|
+
#
|
54
|
+
# <% content_for :not_authorized do %>
|
55
|
+
# alert('You are not authorized to do that!')
|
56
|
+
# <% end %>
|
57
|
+
#
|
58
|
+
# You can then use <tt>content_for :not_authorized</tt> anywhere in your templates.
|
59
|
+
#
|
60
|
+
# <%= content_for :not_authorized if current_user.nil? %>
|
61
|
+
#
|
62
|
+
# This is equivalent to:
|
63
|
+
#
|
64
|
+
# <%= yield :not_authorized if current_user.nil? %>
|
65
|
+
#
|
66
|
+
# <tt>content_for</tt>, however, can also be used in helper modules.
|
67
|
+
#
|
68
|
+
# module StorageHelper
|
69
|
+
# def stored_content
|
70
|
+
# content_for(:storage) || "Your storage is empty"
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# This helper works just like normal helpers.
|
75
|
+
#
|
76
|
+
# <%= stored_content %>
|
77
|
+
#
|
78
|
+
# You can also use the <tt>yield</tt> syntax alongside an existing call to
|
79
|
+
# <tt>yield</tt> in a layout. For example:
|
80
|
+
#
|
81
|
+
# <%# This is the layout %>
|
82
|
+
# <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
83
|
+
# <head>
|
84
|
+
# <title>My Website</title>
|
85
|
+
# <%= yield :script %>
|
86
|
+
# </head>
|
87
|
+
# <body>
|
88
|
+
# <%= yield %>
|
89
|
+
# </body>
|
90
|
+
# </html>
|
91
|
+
#
|
92
|
+
# And now, we'll create a view that has a <tt>content_for</tt> call that
|
93
|
+
# creates the <tt>script</tt> identifier.
|
94
|
+
#
|
95
|
+
# <%# This is our view %>
|
96
|
+
# Please login!
|
97
|
+
#
|
98
|
+
# <% content_for :script do %>
|
99
|
+
# <script>alert('You are not authorized to view this page!')</script>
|
100
|
+
# <% end %>
|
101
|
+
#
|
102
|
+
# Then, in another view, you could to do something like this:
|
103
|
+
#
|
104
|
+
# <%= link_to 'Logout', action: 'logout', remote: true %>
|
105
|
+
#
|
106
|
+
# <% content_for :script do %>
|
107
|
+
# <%= javascript_include_tag :defaults %>
|
108
|
+
# <% end %>
|
109
|
+
#
|
110
|
+
# That will place +script+ tags for your default set of JavaScript files on the page;
|
111
|
+
# this technique is useful if you'll only be using these scripts in a few views.
|
112
|
+
#
|
113
|
+
# Note that <tt>content_for</tt> concatenates (default) the blocks it is given for a particular
|
114
|
+
# identifier in order. For example:
|
115
|
+
#
|
116
|
+
# <% content_for :navigation do %>
|
117
|
+
# <li><%= link_to 'Home', action: 'index' %></li>
|
118
|
+
# <% end %>
|
119
|
+
#
|
120
|
+
# And in another place:
|
121
|
+
#
|
122
|
+
# <% content_for :navigation do %>
|
123
|
+
# <li><%= link_to 'Login', action: 'login' %></li>
|
124
|
+
# <% end %>
|
125
|
+
#
|
126
|
+
# Then, in another template or layout, this code would render both links in order:
|
127
|
+
#
|
128
|
+
# <ul><%= content_for :navigation %></ul>
|
129
|
+
#
|
130
|
+
# If the flush parameter is +true+ <tt>content_for</tt> replaces the blocks it is given. For example:
|
131
|
+
#
|
132
|
+
# <% content_for :navigation do %>
|
133
|
+
# <li><%= link_to 'Home', action: 'index' %></li>
|
134
|
+
# <% end %>
|
135
|
+
#
|
136
|
+
# <%# Add some other content, or use a different template: %>
|
137
|
+
#
|
138
|
+
# <% content_for :navigation, flush: true do %>
|
139
|
+
# <li><%= link_to 'Login', action: 'login' %></li>
|
140
|
+
# <% end %>
|
141
|
+
#
|
142
|
+
# Then, in another template or layout, this code would render only the last link:
|
143
|
+
#
|
144
|
+
# <ul><%= content_for :navigation %></ul>
|
145
|
+
#
|
146
|
+
# Lastly, simple content can be passed as a parameter:
|
147
|
+
#
|
148
|
+
# <% content_for :script, javascript_include_tag(:defaults) %>
|
149
|
+
#
|
150
|
+
# WARNING: <tt>content_for</tt> is ignored in caches. So you shouldn't use it for elements that will be fragment cached.
|
151
|
+
def content_for(name, content = nil, options = {}, &block)
|
152
|
+
if content || block_given?
|
153
|
+
if block_given?
|
154
|
+
options = content if content
|
155
|
+
content = capture(&block)
|
156
|
+
end
|
157
|
+
if content
|
158
|
+
options[:flush] ? @view_flow.set(name, content) : @view_flow.append(name, content)
|
159
|
+
end
|
160
|
+
nil
|
161
|
+
else
|
162
|
+
@view_flow.get(name).presence
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# The same as +content_for+ but when used with streaming flushes
|
167
|
+
# straight back to the layout. In other words, if you want to
|
168
|
+
# concatenate several times to the same buffer when rendering a given
|
169
|
+
# template, you should use +content_for+, if not, use +provide+ to tell
|
170
|
+
# the layout to stop looking for more contents.
|
171
|
+
def provide(name, content = nil, &block)
|
172
|
+
content = capture(&block) if block_given?
|
173
|
+
result = @view_flow.append!(name, content) if content
|
174
|
+
result unless content
|
175
|
+
end
|
176
|
+
|
177
|
+
# <tt>content_for?</tt> checks whether any content has been captured yet using <tt>content_for</tt>.
|
178
|
+
# Useful to render parts of your layout differently based on what is in your views.
|
179
|
+
#
|
180
|
+
# <%# This is the layout %>
|
181
|
+
# <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
182
|
+
# <head>
|
183
|
+
# <title>My Website</title>
|
184
|
+
# <%= yield :script %>
|
185
|
+
# </head>
|
186
|
+
# <body class="<%= content_for?(:right_col) ? 'two-column' : 'one-column' %>">
|
187
|
+
# <%= yield %>
|
188
|
+
# <%= yield :right_col %>
|
189
|
+
# </body>
|
190
|
+
# </html>
|
191
|
+
def content_for?(name)
|
192
|
+
@view_flow.get(name).present?
|
193
|
+
end
|
194
|
+
|
195
|
+
# Use an alternate output buffer for the duration of the block.
|
196
|
+
# Defaults to a new empty string.
|
197
|
+
def with_output_buffer(buf = nil) #:nodoc:
|
198
|
+
unless buf
|
199
|
+
buf = ActionView::OutputBuffer.new
|
200
|
+
if output_buffer && output_buffer.respond_to?(:encoding)
|
201
|
+
buf.force_encoding(output_buffer.encoding)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
self.output_buffer, old_buffer = buf, output_buffer
|
205
|
+
yield
|
206
|
+
output_buffer
|
207
|
+
ensure
|
208
|
+
self.output_buffer = old_buffer
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/module/attr_internal"
|
4
|
+
|
5
|
+
module ActionView
|
6
|
+
module Helpers #:nodoc:
|
7
|
+
# This module keeps all methods and behavior in ActionView
|
8
|
+
# that simply delegates to the controller.
|
9
|
+
module ControllerHelper #:nodoc:
|
10
|
+
attr_internal :controller, :request
|
11
|
+
|
12
|
+
CONTROLLER_DELEGATES = [:request_forgery_protection_token, :params,
|
13
|
+
:session, :cookies, :response, :headers, :flash, :action_name,
|
14
|
+
:controller_name, :controller_path]
|
15
|
+
|
16
|
+
delegate(*CONTROLLER_DELEGATES, to: :controller)
|
17
|
+
|
18
|
+
def assign_controller(controller)
|
19
|
+
if @_controller = controller
|
20
|
+
@_request = controller.request if controller.respond_to?(:request)
|
21
|
+
@_config = controller.config.inheritable_copy if controller.respond_to?(:config)
|
22
|
+
@_default_form_builder = controller.default_form_builder if controller.respond_to?(:default_form_builder)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def logger
|
27
|
+
controller.logger if controller.respond_to?(:logger)
|
28
|
+
end
|
29
|
+
|
30
|
+
def respond_to?(method_name, include_private = false)
|
31
|
+
return controller.respond_to?(method_name) if CONTROLLER_DELEGATES.include?(method_name.to_sym)
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
# = Action View CSP Helper
|
5
|
+
module Helpers #:nodoc:
|
6
|
+
module CspHelper
|
7
|
+
# Returns a meta tag "csp-nonce" with the per-session nonce value
|
8
|
+
# for allowing inline <script> tags.
|
9
|
+
#
|
10
|
+
# <head>
|
11
|
+
# <%= csp_meta_tag %>
|
12
|
+
# </head>
|
13
|
+
#
|
14
|
+
# This is used by the Rails UJS helper to create dynamically
|
15
|
+
# loaded inline <script> elements.
|
16
|
+
#
|
17
|
+
def csp_meta_tag
|
18
|
+
if content_security_policy?
|
19
|
+
tag("meta", name: "csp-nonce", content: content_security_policy_nonce)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
# = Action View CSRF Helper
|
5
|
+
module Helpers #:nodoc:
|
6
|
+
module CsrfHelper
|
7
|
+
# Returns meta tags "csrf-param" and "csrf-token" with the name of the cross-site
|
8
|
+
# request forgery protection parameter and token, respectively.
|
9
|
+
#
|
10
|
+
# <head>
|
11
|
+
# <%= csrf_meta_tags %>
|
12
|
+
# </head>
|
13
|
+
#
|
14
|
+
# These are used to generate the dynamic forms that implement non-remote links with
|
15
|
+
# <tt>:method</tt>.
|
16
|
+
#
|
17
|
+
# You don't need to use these tags for regular forms as they generate their own hidden fields.
|
18
|
+
#
|
19
|
+
# For AJAX requests other than GETs, extract the "csrf-token" from the meta-tag and send as the
|
20
|
+
# "X-CSRF-Token" HTTP header. If you are using rails-ujs this happens automatically.
|
21
|
+
#
|
22
|
+
def csrf_meta_tags
|
23
|
+
if protect_against_forgery?
|
24
|
+
[
|
25
|
+
tag("meta", name: "csrf-param", content: request_forgery_protection_token),
|
26
|
+
tag("meta", name: "csrf-token", content: form_authenticity_token)
|
27
|
+
].join("\n").html_safe
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# For backwards compatibility.
|
32
|
+
alias csrf_meta_tag csrf_meta_tags
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,1156 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "action_view/helpers/tag_helper"
|
5
|
+
require "active_support/core_ext/array/extract_options"
|
6
|
+
require "active_support/core_ext/date/conversions"
|
7
|
+
require "active_support/core_ext/hash/slice"
|
8
|
+
require "active_support/core_ext/object/acts_like"
|
9
|
+
require "active_support/core_ext/object/with_options"
|
10
|
+
|
11
|
+
module ActionView
|
12
|
+
module Helpers #:nodoc:
|
13
|
+
# = Action View Date Helpers
|
14
|
+
#
|
15
|
+
# The Date Helper primarily creates select/option tags for different kinds of dates and times or date and time
|
16
|
+
# elements. All of the select-type methods share a number of common options that are as follows:
|
17
|
+
#
|
18
|
+
# * <tt>:prefix</tt> - overwrites the default prefix of "date" used for the select names. So specifying "birthday"
|
19
|
+
# would give \birthday[month] instead of \date[month] if passed to the <tt>select_month</tt> method.
|
20
|
+
# * <tt>:include_blank</tt> - set to true if it should be possible to set an empty date.
|
21
|
+
# * <tt>:discard_type</tt> - set to true if you want to discard the type part of the select name. If set to true,
|
22
|
+
# the <tt>select_month</tt> method would use simply "date" (which can be overwritten using <tt>:prefix</tt>) instead
|
23
|
+
# of \date[month].
|
24
|
+
module DateHelper
|
25
|
+
MINUTES_IN_YEAR = 525600
|
26
|
+
MINUTES_IN_QUARTER_YEAR = 131400
|
27
|
+
MINUTES_IN_THREE_QUARTERS_YEAR = 394200
|
28
|
+
|
29
|
+
# Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.
|
30
|
+
# Pass <tt>include_seconds: true</tt> if you want more detailed approximations when distance < 1 min, 29 secs.
|
31
|
+
# Distances are reported based on the following table:
|
32
|
+
#
|
33
|
+
# 0 <-> 29 secs # => less than a minute
|
34
|
+
# 30 secs <-> 1 min, 29 secs # => 1 minute
|
35
|
+
# 1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes
|
36
|
+
# 44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour
|
37
|
+
# 89 mins, 30 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours
|
38
|
+
# 23 hrs, 59 mins, 30 secs <-> 41 hrs, 59 mins, 29 secs # => 1 day
|
39
|
+
# 41 hrs, 59 mins, 30 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days
|
40
|
+
# 29 days, 23 hrs, 59 mins, 30 secs <-> 44 days, 23 hrs, 59 mins, 29 secs # => about 1 month
|
41
|
+
# 44 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 2 months
|
42
|
+
# 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months
|
43
|
+
# 1 yr <-> 1 yr, 3 months # => about 1 year
|
44
|
+
# 1 yr, 3 months <-> 1 yr, 9 months # => over 1 year
|
45
|
+
# 1 yr, 9 months <-> 2 yr minus 1 sec # => almost 2 years
|
46
|
+
# 2 yrs <-> max time or date # => (same rules as 1 yr)
|
47
|
+
#
|
48
|
+
# With <tt>include_seconds: true</tt> and the difference < 1 minute 29 seconds:
|
49
|
+
# 0-4 secs # => less than 5 seconds
|
50
|
+
# 5-9 secs # => less than 10 seconds
|
51
|
+
# 10-19 secs # => less than 20 seconds
|
52
|
+
# 20-39 secs # => half a minute
|
53
|
+
# 40-59 secs # => less than a minute
|
54
|
+
# 60-89 secs # => 1 minute
|
55
|
+
#
|
56
|
+
# from_time = Time.now
|
57
|
+
# distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour
|
58
|
+
# distance_of_time_in_words(from_time, 50.minutes.from_now) # => about 1 hour
|
59
|
+
# distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute
|
60
|
+
# distance_of_time_in_words(from_time, from_time + 15.seconds, include_seconds: true) # => less than 20 seconds
|
61
|
+
# distance_of_time_in_words(from_time, 3.years.from_now) # => about 3 years
|
62
|
+
# distance_of_time_in_words(from_time, from_time + 60.hours) # => 3 days
|
63
|
+
# distance_of_time_in_words(from_time, from_time + 45.seconds, include_seconds: true) # => less than a minute
|
64
|
+
# distance_of_time_in_words(from_time, from_time - 45.seconds, include_seconds: true) # => less than a minute
|
65
|
+
# distance_of_time_in_words(from_time, 76.seconds.from_now) # => 1 minute
|
66
|
+
# distance_of_time_in_words(from_time, from_time + 1.year + 3.days) # => about 1 year
|
67
|
+
# distance_of_time_in_words(from_time, from_time + 3.years + 6.months) # => over 3 years
|
68
|
+
# distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # => about 4 years
|
69
|
+
#
|
70
|
+
# to_time = Time.now + 6.years + 19.days
|
71
|
+
# distance_of_time_in_words(from_time, to_time, include_seconds: true) # => about 6 years
|
72
|
+
# distance_of_time_in_words(to_time, from_time, include_seconds: true) # => about 6 years
|
73
|
+
# distance_of_time_in_words(Time.now, Time.now) # => less than a minute
|
74
|
+
#
|
75
|
+
# With the <tt>scope</tt> option, you can define a custom scope for Rails
|
76
|
+
# to look up the translation.
|
77
|
+
#
|
78
|
+
# For example you can define the following in your locale (e.g. en.yml).
|
79
|
+
#
|
80
|
+
# datetime:
|
81
|
+
# distance_in_words:
|
82
|
+
# short:
|
83
|
+
# about_x_hours:
|
84
|
+
# one: 'an hour'
|
85
|
+
# other: '%{count} hours'
|
86
|
+
#
|
87
|
+
# See https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml
|
88
|
+
# for more examples.
|
89
|
+
#
|
90
|
+
# Which will then result in the following:
|
91
|
+
#
|
92
|
+
# from_time = Time.now
|
93
|
+
# distance_of_time_in_words(from_time, from_time + 50.minutes, scope: 'datetime.distance_in_words.short') # => "an hour"
|
94
|
+
# distance_of_time_in_words(from_time, from_time + 3.hours, scope: 'datetime.distance_in_words.short') # => "3 hours"
|
95
|
+
def distance_of_time_in_words(from_time, to_time = 0, options = {})
|
96
|
+
options = {
|
97
|
+
scope: :'datetime.distance_in_words'
|
98
|
+
}.merge!(options)
|
99
|
+
|
100
|
+
from_time = normalize_distance_of_time_argument_to_time(from_time)
|
101
|
+
to_time = normalize_distance_of_time_argument_to_time(to_time)
|
102
|
+
from_time, to_time = to_time, from_time if from_time > to_time
|
103
|
+
distance_in_minutes = ((to_time - from_time) / 60.0).round
|
104
|
+
distance_in_seconds = (to_time - from_time).round
|
105
|
+
|
106
|
+
I18n.with_options locale: options[:locale], scope: options[:scope] do |locale|
|
107
|
+
case distance_in_minutes
|
108
|
+
when 0..1
|
109
|
+
return distance_in_minutes == 0 ?
|
110
|
+
locale.t(:less_than_x_minutes, count: 1) :
|
111
|
+
locale.t(:x_minutes, count: distance_in_minutes) unless options[:include_seconds]
|
112
|
+
|
113
|
+
case distance_in_seconds
|
114
|
+
when 0..4 then locale.t :less_than_x_seconds, count: 5
|
115
|
+
when 5..9 then locale.t :less_than_x_seconds, count: 10
|
116
|
+
when 10..19 then locale.t :less_than_x_seconds, count: 20
|
117
|
+
when 20..39 then locale.t :half_a_minute
|
118
|
+
when 40..59 then locale.t :less_than_x_minutes, count: 1
|
119
|
+
else locale.t :x_minutes, count: 1
|
120
|
+
end
|
121
|
+
|
122
|
+
when 2...45 then locale.t :x_minutes, count: distance_in_minutes
|
123
|
+
when 45...90 then locale.t :about_x_hours, count: 1
|
124
|
+
# 90 mins up to 24 hours
|
125
|
+
when 90...1440 then locale.t :about_x_hours, count: (distance_in_minutes.to_f / 60.0).round
|
126
|
+
# 24 hours up to 42 hours
|
127
|
+
when 1440...2520 then locale.t :x_days, count: 1
|
128
|
+
# 42 hours up to 30 days
|
129
|
+
when 2520...43200 then locale.t :x_days, count: (distance_in_minutes.to_f / 1440.0).round
|
130
|
+
# 30 days up to 60 days
|
131
|
+
when 43200...86400 then locale.t :about_x_months, count: (distance_in_minutes.to_f / 43200.0).round
|
132
|
+
# 60 days up to 365 days
|
133
|
+
when 86400...525600 then locale.t :x_months, count: (distance_in_minutes.to_f / 43200.0).round
|
134
|
+
else
|
135
|
+
from_year = from_time.year
|
136
|
+
from_year += 1 if from_time.month >= 3
|
137
|
+
to_year = to_time.year
|
138
|
+
to_year -= 1 if to_time.month < 3
|
139
|
+
leap_years = (from_year > to_year) ? 0 : (from_year..to_year).count { |x| Date.leap?(x) }
|
140
|
+
minute_offset_for_leap_year = leap_years * 1440
|
141
|
+
# Discount the leap year days when calculating year distance.
|
142
|
+
# e.g. if there are 20 leap year days between 2 dates having the same day
|
143
|
+
# and month then the based on 365 days calculation
|
144
|
+
# the distance in years will come out to over 80 years when in written
|
145
|
+
# English it would read better as about 80 years.
|
146
|
+
minutes_with_offset = distance_in_minutes - minute_offset_for_leap_year
|
147
|
+
remainder = (minutes_with_offset % MINUTES_IN_YEAR)
|
148
|
+
distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR)
|
149
|
+
if remainder < MINUTES_IN_QUARTER_YEAR
|
150
|
+
locale.t(:about_x_years, count: distance_in_years)
|
151
|
+
elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR
|
152
|
+
locale.t(:over_x_years, count: distance_in_years)
|
153
|
+
else
|
154
|
+
locale.t(:almost_x_years, count: distance_in_years + 1)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Like <tt>distance_of_time_in_words</tt>, but where <tt>to_time</tt> is fixed to <tt>Time.now</tt>.
|
161
|
+
#
|
162
|
+
# time_ago_in_words(3.minutes.from_now) # => 3 minutes
|
163
|
+
# time_ago_in_words(3.minutes.ago) # => 3 minutes
|
164
|
+
# time_ago_in_words(Time.now - 15.hours) # => about 15 hours
|
165
|
+
# time_ago_in_words(Time.now) # => less than a minute
|
166
|
+
# time_ago_in_words(Time.now, include_seconds: true) # => less than 5 seconds
|
167
|
+
#
|
168
|
+
# from_time = Time.now - 3.days - 14.minutes - 25.seconds
|
169
|
+
# time_ago_in_words(from_time) # => 3 days
|
170
|
+
#
|
171
|
+
# from_time = (3.days + 14.minutes + 25.seconds).ago
|
172
|
+
# time_ago_in_words(from_time) # => 3 days
|
173
|
+
#
|
174
|
+
# Note that you cannot pass a <tt>Numeric</tt> value to <tt>time_ago_in_words</tt>.
|
175
|
+
#
|
176
|
+
def time_ago_in_words(from_time, options = {})
|
177
|
+
distance_of_time_in_words(from_time, Time.now, options)
|
178
|
+
end
|
179
|
+
|
180
|
+
alias_method :distance_of_time_in_words_to_now, :time_ago_in_words
|
181
|
+
|
182
|
+
# Returns a set of select tags (one for year, month, and day) pre-selected for accessing a specified date-based
|
183
|
+
# attribute (identified by +method+) on an object assigned to the template (identified by +object+).
|
184
|
+
#
|
185
|
+
# ==== Options
|
186
|
+
# * <tt>:use_month_numbers</tt> - Set to true if you want to use month numbers rather than month names (e.g.
|
187
|
+
# "2" instead of "February").
|
188
|
+
# * <tt>:use_two_digit_numbers</tt> - Set to true if you want to display two digit month and day numbers (e.g.
|
189
|
+
# "02" instead of "February" and "08" instead of "8").
|
190
|
+
# * <tt>:use_short_month</tt> - Set to true if you want to use abbreviated month names instead of full
|
191
|
+
# month names (e.g. "Feb" instead of "February").
|
192
|
+
# * <tt>:add_month_numbers</tt> - Set to true if you want to use both month numbers and month names (e.g.
|
193
|
+
# "2 - February" instead of "February").
|
194
|
+
# * <tt>:use_month_names</tt> - Set to an array with 12 month names if you want to customize month names.
|
195
|
+
# Note: You can also use Rails' i18n functionality for this.
|
196
|
+
# * <tt>:month_format_string</tt> - Set to a format string. The string gets passed keys +:number+ (integer)
|
197
|
+
# and +:name+ (string). A format string would be something like "%{name} (%<number>02d)" for example.
|
198
|
+
# See <tt>Kernel.sprintf</tt> for documentation on format sequences.
|
199
|
+
# * <tt>:date_separator</tt> - Specifies a string to separate the date fields. Default is "" (i.e. nothing).
|
200
|
+
# * <tt>:time_separator</tt> - Specifies a string to separate the time fields. Default is "" (i.e. nothing).
|
201
|
+
# * <tt>:datetime_separator</tt>- Specifies a string to separate the date and time fields. Default is "" (i.e. nothing).
|
202
|
+
# * <tt>:start_year</tt> - Set the start year for the year select. Default is <tt>Date.today.year - 5</tt> if
|
203
|
+
# you are creating new record. While editing existing record, <tt>:start_year</tt> defaults to
|
204
|
+
# the current selected year minus 5.
|
205
|
+
# * <tt>:end_year</tt> - Set the end year for the year select. Default is <tt>Date.today.year + 5</tt> if
|
206
|
+
# you are creating new record. While editing existing record, <tt>:end_year</tt> defaults to
|
207
|
+
# the current selected year plus 5.
|
208
|
+
# * <tt>:discard_day</tt> - Set to true if you don't want to show a day select. This includes the day
|
209
|
+
# as a hidden field instead of showing a select field. Also note that this implicitly sets the day to be the
|
210
|
+
# first of the given month in order to not create invalid dates like 31 February.
|
211
|
+
# * <tt>:discard_month</tt> - Set to true if you don't want to show a month select. This includes the month
|
212
|
+
# as a hidden field instead of showing a select field. Also note that this implicitly sets :discard_day to true.
|
213
|
+
# * <tt>:discard_year</tt> - Set to true if you don't want to show a year select. This includes the year
|
214
|
+
# as a hidden field instead of showing a select field.
|
215
|
+
# * <tt>:order</tt> - Set to an array containing <tt>:day</tt>, <tt>:month</tt> and <tt>:year</tt> to
|
216
|
+
# customize the order in which the select fields are shown. If you leave out any of the symbols, the respective
|
217
|
+
# select will not be shown (like when you set <tt>discard_xxx: true</tt>. Defaults to the order defined in
|
218
|
+
# the respective locale (e.g. [:year, :month, :day] in the en locale that ships with Rails).
|
219
|
+
# * <tt>:include_blank</tt> - Include a blank option in every select field so it's possible to set empty
|
220
|
+
# dates.
|
221
|
+
# * <tt>:default</tt> - Set a default date if the affected date isn't set or is +nil+.
|
222
|
+
# * <tt>:selected</tt> - Set a date that overrides the actual value.
|
223
|
+
# * <tt>:disabled</tt> - Set to true if you want show the select fields as disabled.
|
224
|
+
# * <tt>:prompt</tt> - Set to true (for a generic prompt), a prompt string or a hash of prompt strings
|
225
|
+
# for <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, <tt>:hour</tt>, <tt>:minute</tt> and <tt>:second</tt>.
|
226
|
+
# Setting this option prepends a select option with a generic prompt (Day, Month, Year, Hour, Minute, Seconds)
|
227
|
+
# or the given prompt string.
|
228
|
+
# * <tt>:with_css_classes</tt> - Set to true or a hash of strings. Use true if you want to assign generic styles for
|
229
|
+
# select tags. This automatically set classes 'year', 'month', 'day', 'hour', 'minute' and 'second'. A hash of
|
230
|
+
# strings for <tt>:year</tt>, <tt>:month</tt>, <tt>:day</tt>, <tt>:hour</tt>, <tt>:minute</tt>, <tt>:second</tt>
|
231
|
+
# will extend the select type with the given value. Use +html_options+ to modify every select tag in the set.
|
232
|
+
# * <tt>:use_hidden</tt> - Set to true if you only want to generate hidden input tags.
|
233
|
+
#
|
234
|
+
# If anything is passed in the +html_options+ hash it will be applied to every select tag in the set.
|
235
|
+
#
|
236
|
+
# NOTE: Discarded selects will default to 1. So if no month select is available, January will be assumed.
|
237
|
+
#
|
238
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute.
|
239
|
+
# date_select("article", "written_on")
|
240
|
+
#
|
241
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute,
|
242
|
+
# # with the year in the year drop down box starting at 1995.
|
243
|
+
# date_select("article", "written_on", start_year: 1995)
|
244
|
+
#
|
245
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute,
|
246
|
+
# # with the year in the year drop down box starting at 1995, numbers used for months instead of words,
|
247
|
+
# # and without a day select box.
|
248
|
+
# date_select("article", "written_on", start_year: 1995, use_month_numbers: true,
|
249
|
+
# discard_day: true, include_blank: true)
|
250
|
+
#
|
251
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute,
|
252
|
+
# # with two digit numbers used for months and days.
|
253
|
+
# date_select("article", "written_on", use_two_digit_numbers: true)
|
254
|
+
#
|
255
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute
|
256
|
+
# # with the fields ordered as day, month, year rather than month, day, year.
|
257
|
+
# date_select("article", "written_on", order: [:day, :month, :year])
|
258
|
+
#
|
259
|
+
# # Generates a date select that when POSTed is stored in the user variable, in the birthday attribute
|
260
|
+
# # lacking a year field.
|
261
|
+
# date_select("user", "birthday", order: [:month, :day])
|
262
|
+
#
|
263
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute
|
264
|
+
# # which is initially set to the date 3 days from the current date
|
265
|
+
# date_select("article", "written_on", default: 3.days.from_now)
|
266
|
+
#
|
267
|
+
# # Generates a date select that when POSTed is stored in the article variable, in the written_on attribute
|
268
|
+
# # which is set in the form with today's date, regardless of the value in the Active Record object.
|
269
|
+
# date_select("article", "written_on", selected: Date.today)
|
270
|
+
#
|
271
|
+
# # Generates a date select that when POSTed is stored in the credit_card variable, in the bill_due attribute
|
272
|
+
# # that will have a default day of 20.
|
273
|
+
# date_select("credit_card", "bill_due", default: { day: 20 })
|
274
|
+
#
|
275
|
+
# # Generates a date select with custom prompts.
|
276
|
+
# date_select("article", "written_on", prompt: { day: 'Select day', month: 'Select month', year: 'Select year' })
|
277
|
+
#
|
278
|
+
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
279
|
+
#
|
280
|
+
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
|
281
|
+
# all month choices are valid.
|
282
|
+
def date_select(object_name, method, options = {}, html_options = {})
|
283
|
+
Tags::DateSelect.new(object_name, method, self, options, html_options).render
|
284
|
+
end
|
285
|
+
|
286
|
+
# Returns a set of select tags (one for hour, minute and optionally second) pre-selected for accessing a
|
287
|
+
# specified time-based attribute (identified by +method+) on an object assigned to the template (identified by
|
288
|
+
# +object+). You can include the seconds with <tt>:include_seconds</tt>. You can get hours in the AM/PM format
|
289
|
+
# with <tt>:ampm</tt> option.
|
290
|
+
#
|
291
|
+
# This method will also generate 3 input hidden tags, for the actual year, month and day unless the option
|
292
|
+
# <tt>:ignore_date</tt> is set to +true+. If you set the <tt>:ignore_date</tt> to +true+, you must have a
|
293
|
+
# +date_select+ on the same method within the form otherwise an exception will be raised.
|
294
|
+
#
|
295
|
+
# If anything is passed in the html_options hash it will be applied to every select tag in the set.
|
296
|
+
#
|
297
|
+
# # Creates a time select tag that, when POSTed, will be stored in the article variable in the sunrise attribute.
|
298
|
+
# time_select("article", "sunrise")
|
299
|
+
#
|
300
|
+
# # Creates a time select tag with a seconds field that, when POSTed, will be stored in the article variables in
|
301
|
+
# # the sunrise attribute.
|
302
|
+
# time_select("article", "start_time", include_seconds: true)
|
303
|
+
#
|
304
|
+
# # You can set the <tt>:minute_step</tt> to 15 which will give you: 00, 15, 30, and 45.
|
305
|
+
# time_select 'game', 'game_time', {minute_step: 15}
|
306
|
+
#
|
307
|
+
# # Creates a time select tag with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
308
|
+
# time_select("article", "written_on", prompt: {hour: 'Choose hour', minute: 'Choose minute', second: 'Choose seconds'})
|
309
|
+
# time_select("article", "written_on", prompt: {hour: true}) # generic prompt for hours
|
310
|
+
# time_select("article", "written_on", prompt: true) # generic prompts for all
|
311
|
+
#
|
312
|
+
# # You can set :ampm option to true which will show the hours as: 12 PM, 01 AM .. 11 PM.
|
313
|
+
# time_select 'game', 'game_time', {ampm: true}
|
314
|
+
#
|
315
|
+
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
316
|
+
#
|
317
|
+
# Note: If the day is not included as an option but the month is, the day will be set to the 1st to ensure that
|
318
|
+
# all month choices are valid.
|
319
|
+
def time_select(object_name, method, options = {}, html_options = {})
|
320
|
+
Tags::TimeSelect.new(object_name, method, self, options, html_options).render
|
321
|
+
end
|
322
|
+
|
323
|
+
# Returns a set of select tags (one for year, month, day, hour, and minute) pre-selected for accessing a
|
324
|
+
# specified datetime-based attribute (identified by +method+) on an object assigned to the template (identified
|
325
|
+
# by +object+).
|
326
|
+
#
|
327
|
+
# If anything is passed in the html_options hash it will be applied to every select tag in the set.
|
328
|
+
#
|
329
|
+
# # Generates a datetime select that, when POSTed, will be stored in the article variable in the written_on
|
330
|
+
# # attribute.
|
331
|
+
# datetime_select("article", "written_on")
|
332
|
+
#
|
333
|
+
# # Generates a datetime select with a year select that starts at 1995 that, when POSTed, will be stored in the
|
334
|
+
# # article variable in the written_on attribute.
|
335
|
+
# datetime_select("article", "written_on", start_year: 1995)
|
336
|
+
#
|
337
|
+
# # Generates a datetime select with a default value of 3 days from the current time that, when POSTed, will
|
338
|
+
# # be stored in the trip variable in the departing attribute.
|
339
|
+
# datetime_select("trip", "departing", default: 3.days.from_now)
|
340
|
+
#
|
341
|
+
# # Generate a datetime select with hours in the AM/PM format
|
342
|
+
# datetime_select("article", "written_on", ampm: true)
|
343
|
+
#
|
344
|
+
# # Generates a datetime select that discards the type that, when POSTed, will be stored in the article variable
|
345
|
+
# # as the written_on attribute.
|
346
|
+
# datetime_select("article", "written_on", discard_type: true)
|
347
|
+
#
|
348
|
+
# # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
349
|
+
# datetime_select("article", "written_on", prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
350
|
+
# datetime_select("article", "written_on", prompt: {hour: true}) # generic prompt for hours
|
351
|
+
# datetime_select("article", "written_on", prompt: true) # generic prompts for all
|
352
|
+
#
|
353
|
+
# The selects are prepared for multi-parameter assignment to an Active Record object.
|
354
|
+
def datetime_select(object_name, method, options = {}, html_options = {})
|
355
|
+
Tags::DatetimeSelect.new(object_name, method, self, options, html_options).render
|
356
|
+
end
|
357
|
+
|
358
|
+
# Returns a set of HTML select-tags (one for year, month, day, hour, minute, and second) pre-selected with the
|
359
|
+
# +datetime+. It's also possible to explicitly set the order of the tags using the <tt>:order</tt> option with
|
360
|
+
# an array of symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt> in the desired order. If you do not
|
361
|
+
# supply a Symbol, it will be appended onto the <tt>:order</tt> passed in. You can also add
|
362
|
+
# <tt>:date_separator</tt>, <tt>:datetime_separator</tt> and <tt>:time_separator</tt> keys to the +options+ to
|
363
|
+
# control visual display of the elements.
|
364
|
+
#
|
365
|
+
# If anything is passed in the html_options hash it will be applied to every select tag in the set.
|
366
|
+
#
|
367
|
+
# my_date_time = Time.now + 4.days
|
368
|
+
#
|
369
|
+
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today).
|
370
|
+
# select_datetime(my_date_time)
|
371
|
+
#
|
372
|
+
# # Generates a datetime select that defaults to today (no specified datetime)
|
373
|
+
# select_datetime()
|
374
|
+
#
|
375
|
+
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
|
376
|
+
# # with the fields ordered year, month, day rather than month, day, year.
|
377
|
+
# select_datetime(my_date_time, order: [:year, :month, :day])
|
378
|
+
#
|
379
|
+
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
|
380
|
+
# # with a '/' between each date field.
|
381
|
+
# select_datetime(my_date_time, date_separator: '/')
|
382
|
+
#
|
383
|
+
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
|
384
|
+
# # with a date fields separated by '/', time fields separated by '' and the date and time fields
|
385
|
+
# # separated by a comma (',').
|
386
|
+
# select_datetime(my_date_time, date_separator: '/', time_separator: '', datetime_separator: ',')
|
387
|
+
#
|
388
|
+
# # Generates a datetime select that discards the type of the field and defaults to the datetime in
|
389
|
+
# # my_date_time (four days after today)
|
390
|
+
# select_datetime(my_date_time, discard_type: true)
|
391
|
+
#
|
392
|
+
# # Generate a datetime field with hours in the AM/PM format
|
393
|
+
# select_datetime(my_date_time, ampm: true)
|
394
|
+
#
|
395
|
+
# # Generates a datetime select that defaults to the datetime in my_date_time (four days after today)
|
396
|
+
# # prefixed with 'payday' rather than 'date'
|
397
|
+
# select_datetime(my_date_time, prefix: 'payday')
|
398
|
+
#
|
399
|
+
# # Generates a datetime select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
400
|
+
# select_datetime(my_date_time, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
401
|
+
# select_datetime(my_date_time, prompt: {hour: true}) # generic prompt for hours
|
402
|
+
# select_datetime(my_date_time, prompt: true) # generic prompts for all
|
403
|
+
def select_datetime(datetime = Time.current, options = {}, html_options = {})
|
404
|
+
DateTimeSelector.new(datetime, options, html_options).select_datetime
|
405
|
+
end
|
406
|
+
|
407
|
+
# Returns a set of HTML select-tags (one for year, month, and day) pre-selected with the +date+.
|
408
|
+
# It's possible to explicitly set the order of the tags using the <tt>:order</tt> option with an array of
|
409
|
+
# symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt> in the desired order.
|
410
|
+
# If the array passed to the <tt>:order</tt> option does not contain all the three symbols, all tags will be hidden.
|
411
|
+
#
|
412
|
+
# If anything is passed in the html_options hash it will be applied to every select tag in the set.
|
413
|
+
#
|
414
|
+
# my_date = Time.now + 6.days
|
415
|
+
#
|
416
|
+
# # Generates a date select that defaults to the date in my_date (six days after today).
|
417
|
+
# select_date(my_date)
|
418
|
+
#
|
419
|
+
# # Generates a date select that defaults to today (no specified date).
|
420
|
+
# select_date()
|
421
|
+
#
|
422
|
+
# # Generates a date select that defaults to the date in my_date (six days after today)
|
423
|
+
# # with the fields ordered year, month, day rather than month, day, year.
|
424
|
+
# select_date(my_date, order: [:year, :month, :day])
|
425
|
+
#
|
426
|
+
# # Generates a date select that discards the type of the field and defaults to the date in
|
427
|
+
# # my_date (six days after today).
|
428
|
+
# select_date(my_date, discard_type: true)
|
429
|
+
#
|
430
|
+
# # Generates a date select that defaults to the date in my_date,
|
431
|
+
# # which has fields separated by '/'.
|
432
|
+
# select_date(my_date, date_separator: '/')
|
433
|
+
#
|
434
|
+
# # Generates a date select that defaults to the datetime in my_date (six days after today)
|
435
|
+
# # prefixed with 'payday' rather than 'date'.
|
436
|
+
# select_date(my_date, prefix: 'payday')
|
437
|
+
#
|
438
|
+
# # Generates a date select with a custom prompt. Use <tt>prompt: true</tt> for generic prompts.
|
439
|
+
# select_date(my_date, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
440
|
+
# select_date(my_date, prompt: {hour: true}) # generic prompt for hours
|
441
|
+
# select_date(my_date, prompt: true) # generic prompts for all
|
442
|
+
def select_date(date = Date.current, options = {}, html_options = {})
|
443
|
+
DateTimeSelector.new(date, options, html_options).select_date
|
444
|
+
end
|
445
|
+
|
446
|
+
# Returns a set of HTML select-tags (one for hour and minute).
|
447
|
+
# You can set <tt>:time_separator</tt> key to format the output, and
|
448
|
+
# the <tt>:include_seconds</tt> option to include an input for seconds.
|
449
|
+
#
|
450
|
+
# If anything is passed in the html_options hash it will be applied to every select tag in the set.
|
451
|
+
#
|
452
|
+
# my_time = Time.now + 5.days + 7.hours + 3.minutes + 14.seconds
|
453
|
+
#
|
454
|
+
# # Generates a time select that defaults to the time in my_time.
|
455
|
+
# select_time(my_time)
|
456
|
+
#
|
457
|
+
# # Generates a time select that defaults to the current time (no specified time).
|
458
|
+
# select_time()
|
459
|
+
#
|
460
|
+
# # Generates a time select that defaults to the time in my_time,
|
461
|
+
# # which has fields separated by ':'.
|
462
|
+
# select_time(my_time, time_separator: ':')
|
463
|
+
#
|
464
|
+
# # Generates a time select that defaults to the time in my_time,
|
465
|
+
# # that also includes an input for seconds.
|
466
|
+
# select_time(my_time, include_seconds: true)
|
467
|
+
#
|
468
|
+
# # Generates a time select that defaults to the time in my_time, that has fields
|
469
|
+
# # separated by ':' and includes an input for seconds.
|
470
|
+
# select_time(my_time, time_separator: ':', include_seconds: true)
|
471
|
+
#
|
472
|
+
# # Generate a time select field with hours in the AM/PM format
|
473
|
+
# select_time(my_time, ampm: true)
|
474
|
+
#
|
475
|
+
# # Generates a time select field with hours that range from 2 to 14
|
476
|
+
# select_time(my_time, start_hour: 2, end_hour: 14)
|
477
|
+
#
|
478
|
+
# # Generates a time select with a custom prompt. Use <tt>:prompt</tt> to true for generic prompts.
|
479
|
+
# select_time(my_time, prompt: {day: 'Choose day', month: 'Choose month', year: 'Choose year'})
|
480
|
+
# select_time(my_time, prompt: {hour: true}) # generic prompt for hours
|
481
|
+
# select_time(my_time, prompt: true) # generic prompts for all
|
482
|
+
def select_time(datetime = Time.current, options = {}, html_options = {})
|
483
|
+
DateTimeSelector.new(datetime, options, html_options).select_time
|
484
|
+
end
|
485
|
+
|
486
|
+
# Returns a select tag with options for each of the seconds 0 through 59 with the current second selected.
|
487
|
+
# The <tt>datetime</tt> can be either a +Time+ or +DateTime+ object or an integer.
|
488
|
+
# Override the field name using the <tt>:field_name</tt> option, 'second' by default.
|
489
|
+
#
|
490
|
+
# my_time = Time.now + 16.seconds
|
491
|
+
#
|
492
|
+
# # Generates a select field for seconds that defaults to the seconds for the time in my_time.
|
493
|
+
# select_second(my_time)
|
494
|
+
#
|
495
|
+
# # Generates a select field for seconds that defaults to the number given.
|
496
|
+
# select_second(33)
|
497
|
+
#
|
498
|
+
# # Generates a select field for seconds that defaults to the seconds for the time in my_time
|
499
|
+
# # that is named 'interval' rather than 'second'.
|
500
|
+
# select_second(my_time, field_name: 'interval')
|
501
|
+
#
|
502
|
+
# # Generates a select field for seconds with a custom prompt. Use <tt>prompt: true</tt> for a
|
503
|
+
# # generic prompt.
|
504
|
+
# select_second(14, prompt: 'Choose seconds')
|
505
|
+
def select_second(datetime, options = {}, html_options = {})
|
506
|
+
DateTimeSelector.new(datetime, options, html_options).select_second
|
507
|
+
end
|
508
|
+
|
509
|
+
# Returns a select tag with options for each of the minutes 0 through 59 with the current minute selected.
|
510
|
+
# Also can return a select tag with options by <tt>minute_step</tt> from 0 through 59 with the 00 minute
|
511
|
+
# selected. The <tt>datetime</tt> can be either a +Time+ or +DateTime+ object or an integer.
|
512
|
+
# Override the field name using the <tt>:field_name</tt> option, 'minute' by default.
|
513
|
+
#
|
514
|
+
# my_time = Time.now + 10.minutes
|
515
|
+
#
|
516
|
+
# # Generates a select field for minutes that defaults to the minutes for the time in my_time.
|
517
|
+
# select_minute(my_time)
|
518
|
+
#
|
519
|
+
# # Generates a select field for minutes that defaults to the number given.
|
520
|
+
# select_minute(14)
|
521
|
+
#
|
522
|
+
# # Generates a select field for minutes that defaults to the minutes for the time in my_time
|
523
|
+
# # that is named 'moment' rather than 'minute'.
|
524
|
+
# select_minute(my_time, field_name: 'moment')
|
525
|
+
#
|
526
|
+
# # Generates a select field for minutes with a custom prompt. Use <tt>prompt: true</tt> for a
|
527
|
+
# # generic prompt.
|
528
|
+
# select_minute(14, prompt: 'Choose minutes')
|
529
|
+
def select_minute(datetime, options = {}, html_options = {})
|
530
|
+
DateTimeSelector.new(datetime, options, html_options).select_minute
|
531
|
+
end
|
532
|
+
|
533
|
+
# Returns a select tag with options for each of the hours 0 through 23 with the current hour selected.
|
534
|
+
# The <tt>datetime</tt> can be either a +Time+ or +DateTime+ object or an integer.
|
535
|
+
# Override the field name using the <tt>:field_name</tt> option, 'hour' by default.
|
536
|
+
#
|
537
|
+
# my_time = Time.now + 6.hours
|
538
|
+
#
|
539
|
+
# # Generates a select field for hours that defaults to the hour for the time in my_time.
|
540
|
+
# select_hour(my_time)
|
541
|
+
#
|
542
|
+
# # Generates a select field for hours that defaults to the number given.
|
543
|
+
# select_hour(13)
|
544
|
+
#
|
545
|
+
# # Generates a select field for hours that defaults to the hour for the time in my_time
|
546
|
+
# # that is named 'stride' rather than 'hour'.
|
547
|
+
# select_hour(my_time, field_name: 'stride')
|
548
|
+
#
|
549
|
+
# # Generates a select field for hours with a custom prompt. Use <tt>prompt: true</tt> for a
|
550
|
+
# # generic prompt.
|
551
|
+
# select_hour(13, prompt: 'Choose hour')
|
552
|
+
#
|
553
|
+
# # Generate a select field for hours in the AM/PM format
|
554
|
+
# select_hour(my_time, ampm: true)
|
555
|
+
#
|
556
|
+
# # Generates a select field that includes options for hours from 2 to 14.
|
557
|
+
# select_hour(my_time, start_hour: 2, end_hour: 14)
|
558
|
+
def select_hour(datetime, options = {}, html_options = {})
|
559
|
+
DateTimeSelector.new(datetime, options, html_options).select_hour
|
560
|
+
end
|
561
|
+
|
562
|
+
# Returns a select tag with options for each of the days 1 through 31 with the current day selected.
|
563
|
+
# The <tt>date</tt> can also be substituted for a day number.
|
564
|
+
# If you want to display days with a leading zero set the <tt>:use_two_digit_numbers</tt> key in +options+ to true.
|
565
|
+
# Override the field name using the <tt>:field_name</tt> option, 'day' by default.
|
566
|
+
#
|
567
|
+
# my_date = Time.now + 2.days
|
568
|
+
#
|
569
|
+
# # Generates a select field for days that defaults to the day for the date in my_date.
|
570
|
+
# select_day(my_date)
|
571
|
+
#
|
572
|
+
# # Generates a select field for days that defaults to the number given.
|
573
|
+
# select_day(5)
|
574
|
+
#
|
575
|
+
# # Generates a select field for days that defaults to the number given, but displays it with two digits.
|
576
|
+
# select_day(5, use_two_digit_numbers: true)
|
577
|
+
#
|
578
|
+
# # Generates a select field for days that defaults to the day for the date in my_date
|
579
|
+
# # that is named 'due' rather than 'day'.
|
580
|
+
# select_day(my_date, field_name: 'due')
|
581
|
+
#
|
582
|
+
# # Generates a select field for days with a custom prompt. Use <tt>prompt: true</tt> for a
|
583
|
+
# # generic prompt.
|
584
|
+
# select_day(5, prompt: 'Choose day')
|
585
|
+
def select_day(date, options = {}, html_options = {})
|
586
|
+
DateTimeSelector.new(date, options, html_options).select_day
|
587
|
+
end
|
588
|
+
|
589
|
+
# Returns a select tag with options for each of the months January through December with the current month
|
590
|
+
# selected. The month names are presented as keys (what's shown to the user) and the month numbers (1-12) are
|
591
|
+
# used as values (what's submitted to the server). It's also possible to use month numbers for the presentation
|
592
|
+
# instead of names -- set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you
|
593
|
+
# want both numbers and names, set the <tt>:add_month_numbers</tt> key in +options+ to true. If you would prefer
|
594
|
+
# to show month names as abbreviations, set the <tt>:use_short_month</tt> key in +options+ to true. If you want
|
595
|
+
# to use your own month names, set the <tt>:use_month_names</tt> key in +options+ to an array of 12 month names.
|
596
|
+
# If you want to display months with a leading zero set the <tt>:use_two_digit_numbers</tt> key in +options+ to true.
|
597
|
+
# Override the field name using the <tt>:field_name</tt> option, 'month' by default.
|
598
|
+
#
|
599
|
+
# # Generates a select field for months that defaults to the current month that
|
600
|
+
# # will use keys like "January", "March".
|
601
|
+
# select_month(Date.today)
|
602
|
+
#
|
603
|
+
# # Generates a select field for months that defaults to the current month that
|
604
|
+
# # is named "start" rather than "month".
|
605
|
+
# select_month(Date.today, field_name: 'start')
|
606
|
+
#
|
607
|
+
# # Generates a select field for months that defaults to the current month that
|
608
|
+
# # will use keys like "1", "3".
|
609
|
+
# select_month(Date.today, use_month_numbers: true)
|
610
|
+
#
|
611
|
+
# # Generates a select field for months that defaults to the current month that
|
612
|
+
# # will use keys like "1 - January", "3 - March".
|
613
|
+
# select_month(Date.today, add_month_numbers: true)
|
614
|
+
#
|
615
|
+
# # Generates a select field for months that defaults to the current month that
|
616
|
+
# # will use keys like "Jan", "Mar".
|
617
|
+
# select_month(Date.today, use_short_month: true)
|
618
|
+
#
|
619
|
+
# # Generates a select field for months that defaults to the current month that
|
620
|
+
# # will use keys like "Januar", "Marts."
|
621
|
+
# select_month(Date.today, use_month_names: %w(Januar Februar Marts ...))
|
622
|
+
#
|
623
|
+
# # Generates a select field for months that defaults to the current month that
|
624
|
+
# # will use keys with two digit numbers like "01", "03".
|
625
|
+
# select_month(Date.today, use_two_digit_numbers: true)
|
626
|
+
#
|
627
|
+
# # Generates a select field for months with a custom prompt. Use <tt>prompt: true</tt> for a
|
628
|
+
# # generic prompt.
|
629
|
+
# select_month(14, prompt: 'Choose month')
|
630
|
+
def select_month(date, options = {}, html_options = {})
|
631
|
+
DateTimeSelector.new(date, options, html_options).select_month
|
632
|
+
end
|
633
|
+
|
634
|
+
# Returns a select tag with options for each of the five years on each side of the current, which is selected.
|
635
|
+
# The five year radius can be changed using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the
|
636
|
+
# +options+. Both ascending and descending year lists are supported by making <tt>:start_year</tt> less than or
|
637
|
+
# greater than <tt>:end_year</tt>. The <tt>date</tt> can also be substituted for a year given as a number.
|
638
|
+
# Override the field name using the <tt>:field_name</tt> option, 'year' by default.
|
639
|
+
#
|
640
|
+
# # Generates a select field for years that defaults to the current year that
|
641
|
+
# # has ascending year values.
|
642
|
+
# select_year(Date.today, start_year: 1992, end_year: 2007)
|
643
|
+
#
|
644
|
+
# # Generates a select field for years that defaults to the current year that
|
645
|
+
# # is named 'birth' rather than 'year'.
|
646
|
+
# select_year(Date.today, field_name: 'birth')
|
647
|
+
#
|
648
|
+
# # Generates a select field for years that defaults to the current year that
|
649
|
+
# # has descending year values.
|
650
|
+
# select_year(Date.today, start_year: 2005, end_year: 1900)
|
651
|
+
#
|
652
|
+
# # Generates a select field for years that defaults to the year 2006 that
|
653
|
+
# # has ascending year values.
|
654
|
+
# select_year(2006, start_year: 2000, end_year: 2010)
|
655
|
+
#
|
656
|
+
# # Generates a select field for years with a custom prompt. Use <tt>prompt: true</tt> for a
|
657
|
+
# # generic prompt.
|
658
|
+
# select_year(14, prompt: 'Choose year')
|
659
|
+
def select_year(date, options = {}, html_options = {})
|
660
|
+
DateTimeSelector.new(date, options, html_options).select_year
|
661
|
+
end
|
662
|
+
|
663
|
+
# Returns an HTML time tag for the given date or time.
|
664
|
+
#
|
665
|
+
# time_tag Date.today # =>
|
666
|
+
# <time datetime="2010-11-04">November 04, 2010</time>
|
667
|
+
# time_tag Time.now # =>
|
668
|
+
# <time datetime="2010-11-04T17:55:45+01:00">November 04, 2010 17:55</time>
|
669
|
+
# time_tag Date.yesterday, 'Yesterday' # =>
|
670
|
+
# <time datetime="2010-11-03">Yesterday</time>
|
671
|
+
# time_tag Date.today, pubdate: true # =>
|
672
|
+
# <time datetime="2010-11-04" pubdate="pubdate">November 04, 2010</time>
|
673
|
+
# time_tag Date.today, datetime: Date.today.strftime('%G-W%V') # =>
|
674
|
+
# <time datetime="2010-W44">November 04, 2010</time>
|
675
|
+
#
|
676
|
+
# <%= time_tag Time.now do %>
|
677
|
+
# <span>Right now</span>
|
678
|
+
# <% end %>
|
679
|
+
# # => <time datetime="2010-11-04T17:55:45+01:00"><span>Right now</span></time>
|
680
|
+
def time_tag(date_or_time, *args, &block)
|
681
|
+
options = args.extract_options!
|
682
|
+
format = options.delete(:format) || :long
|
683
|
+
content = args.first || I18n.l(date_or_time, format: format)
|
684
|
+
datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601
|
685
|
+
|
686
|
+
content_tag("time".freeze, content, options.reverse_merge(datetime: datetime), &block)
|
687
|
+
end
|
688
|
+
|
689
|
+
private
|
690
|
+
|
691
|
+
def normalize_distance_of_time_argument_to_time(value)
|
692
|
+
if value.is_a?(Numeric)
|
693
|
+
Time.at(value)
|
694
|
+
elsif value.respond_to?(:to_time)
|
695
|
+
value.to_time
|
696
|
+
else
|
697
|
+
raise ArgumentError, "#{value.inspect} can't be converted to a Time value"
|
698
|
+
end
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
702
|
+
class DateTimeSelector #:nodoc:
|
703
|
+
include ActionView::Helpers::TagHelper
|
704
|
+
|
705
|
+
DEFAULT_PREFIX = "date".freeze
|
706
|
+
POSITION = {
|
707
|
+
year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6
|
708
|
+
}.freeze
|
709
|
+
|
710
|
+
AMPM_TRANSLATION = Hash[
|
711
|
+
[[0, "12 AM"], [1, "01 AM"], [2, "02 AM"], [3, "03 AM"],
|
712
|
+
[4, "04 AM"], [5, "05 AM"], [6, "06 AM"], [7, "07 AM"],
|
713
|
+
[8, "08 AM"], [9, "09 AM"], [10, "10 AM"], [11, "11 AM"],
|
714
|
+
[12, "12 PM"], [13, "01 PM"], [14, "02 PM"], [15, "03 PM"],
|
715
|
+
[16, "04 PM"], [17, "05 PM"], [18, "06 PM"], [19, "07 PM"],
|
716
|
+
[20, "08 PM"], [21, "09 PM"], [22, "10 PM"], [23, "11 PM"]]
|
717
|
+
].freeze
|
718
|
+
|
719
|
+
def initialize(datetime, options = {}, html_options = {})
|
720
|
+
@options = options.dup
|
721
|
+
@html_options = html_options.dup
|
722
|
+
@datetime = datetime
|
723
|
+
@options[:datetime_separator] ||= " — "
|
724
|
+
@options[:time_separator] ||= " : "
|
725
|
+
end
|
726
|
+
|
727
|
+
def select_datetime
|
728
|
+
order = date_order.dup
|
729
|
+
order -= [:hour, :minute, :second]
|
730
|
+
@options[:discard_year] ||= true unless order.include?(:year)
|
731
|
+
@options[:discard_month] ||= true unless order.include?(:month)
|
732
|
+
@options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
|
733
|
+
@options[:discard_minute] ||= true if @options[:discard_hour]
|
734
|
+
@options[:discard_second] ||= true unless @options[:include_seconds] && !@options[:discard_minute]
|
735
|
+
|
736
|
+
set_day_if_discarded
|
737
|
+
|
738
|
+
if @options[:tag] && @options[:ignore_date]
|
739
|
+
select_time
|
740
|
+
else
|
741
|
+
[:day, :month, :year].each { |o| order.unshift(o) unless order.include?(o) }
|
742
|
+
order += [:hour, :minute, :second] unless @options[:discard_hour]
|
743
|
+
|
744
|
+
build_selects_from_types(order)
|
745
|
+
end
|
746
|
+
end
|
747
|
+
|
748
|
+
def select_date
|
749
|
+
order = date_order.dup
|
750
|
+
|
751
|
+
@options[:discard_hour] = true
|
752
|
+
@options[:discard_minute] = true
|
753
|
+
@options[:discard_second] = true
|
754
|
+
|
755
|
+
@options[:discard_year] ||= true unless order.include?(:year)
|
756
|
+
@options[:discard_month] ||= true unless order.include?(:month)
|
757
|
+
@options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
|
758
|
+
|
759
|
+
set_day_if_discarded
|
760
|
+
|
761
|
+
[:day, :month, :year].each { |o| order.unshift(o) unless order.include?(o) }
|
762
|
+
|
763
|
+
build_selects_from_types(order)
|
764
|
+
end
|
765
|
+
|
766
|
+
def select_time
|
767
|
+
order = []
|
768
|
+
|
769
|
+
@options[:discard_month] = true
|
770
|
+
@options[:discard_year] = true
|
771
|
+
@options[:discard_day] = true
|
772
|
+
@options[:discard_second] ||= true unless @options[:include_seconds]
|
773
|
+
|
774
|
+
order += [:year, :month, :day] unless @options[:ignore_date]
|
775
|
+
|
776
|
+
order += [:hour, :minute]
|
777
|
+
order << :second if @options[:include_seconds]
|
778
|
+
|
779
|
+
build_selects_from_types(order)
|
780
|
+
end
|
781
|
+
|
782
|
+
def select_second
|
783
|
+
if @options[:use_hidden] || @options[:discard_second]
|
784
|
+
build_hidden(:second, sec) if @options[:include_seconds]
|
785
|
+
else
|
786
|
+
build_options_and_select(:second, sec)
|
787
|
+
end
|
788
|
+
end
|
789
|
+
|
790
|
+
def select_minute
|
791
|
+
if @options[:use_hidden] || @options[:discard_minute]
|
792
|
+
build_hidden(:minute, min)
|
793
|
+
else
|
794
|
+
build_options_and_select(:minute, min, step: @options[:minute_step])
|
795
|
+
end
|
796
|
+
end
|
797
|
+
|
798
|
+
def select_hour
|
799
|
+
if @options[:use_hidden] || @options[:discard_hour]
|
800
|
+
build_hidden(:hour, hour)
|
801
|
+
else
|
802
|
+
options = {}
|
803
|
+
options[:ampm] = @options[:ampm] || false
|
804
|
+
options[:start] = @options[:start_hour] || 0
|
805
|
+
options[:end] = @options[:end_hour] || 23
|
806
|
+
build_options_and_select(:hour, hour, options)
|
807
|
+
end
|
808
|
+
end
|
809
|
+
|
810
|
+
def select_day
|
811
|
+
if @options[:use_hidden] || @options[:discard_day]
|
812
|
+
build_hidden(:day, day || 1)
|
813
|
+
else
|
814
|
+
build_options_and_select(:day, day, start: 1, end: 31, leading_zeros: false, use_two_digit_numbers: @options[:use_two_digit_numbers])
|
815
|
+
end
|
816
|
+
end
|
817
|
+
|
818
|
+
def select_month
|
819
|
+
if @options[:use_hidden] || @options[:discard_month]
|
820
|
+
build_hidden(:month, month || 1)
|
821
|
+
else
|
822
|
+
month_options = []
|
823
|
+
1.upto(12) do |month_number|
|
824
|
+
options = { value: month_number }
|
825
|
+
options[:selected] = "selected" if month == month_number
|
826
|
+
month_options << content_tag("option".freeze, month_name(month_number), options) + "\n"
|
827
|
+
end
|
828
|
+
build_select(:month, month_options.join)
|
829
|
+
end
|
830
|
+
end
|
831
|
+
|
832
|
+
def select_year
|
833
|
+
if !@datetime || @datetime == 0
|
834
|
+
val = "1"
|
835
|
+
middle_year = Date.today.year
|
836
|
+
else
|
837
|
+
val = middle_year = year
|
838
|
+
end
|
839
|
+
|
840
|
+
if @options[:use_hidden] || @options[:discard_year]
|
841
|
+
build_hidden(:year, val)
|
842
|
+
else
|
843
|
+
options = {}
|
844
|
+
options[:start] = @options[:start_year] || middle_year - 5
|
845
|
+
options[:end] = @options[:end_year] || middle_year + 5
|
846
|
+
options[:step] = options[:start] < options[:end] ? 1 : -1
|
847
|
+
options[:leading_zeros] = false
|
848
|
+
options[:max_years_allowed] = @options[:max_years_allowed] || 1000
|
849
|
+
|
850
|
+
if (options[:end] - options[:start]).abs > options[:max_years_allowed]
|
851
|
+
raise ArgumentError, "There are too many years options to be built. Are you sure you haven't mistyped something? You can provide the :max_years_allowed parameter."
|
852
|
+
end
|
853
|
+
|
854
|
+
build_options_and_select(:year, val, options)
|
855
|
+
end
|
856
|
+
end
|
857
|
+
|
858
|
+
private
|
859
|
+
%w( sec min hour day month year ).each do |method|
|
860
|
+
define_method(method) do
|
861
|
+
case @datetime
|
862
|
+
when Hash then @datetime[method.to_sym]
|
863
|
+
when Numeric then @datetime
|
864
|
+
when nil then nil
|
865
|
+
else @datetime.send(method)
|
866
|
+
end
|
867
|
+
end
|
868
|
+
end
|
869
|
+
|
870
|
+
# If the day is hidden, the day should be set to the 1st so all month and year choices are
|
871
|
+
# valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid.
|
872
|
+
def set_day_if_discarded
|
873
|
+
if @datetime && @options[:discard_day]
|
874
|
+
@datetime = @datetime.change(day: 1)
|
875
|
+
end
|
876
|
+
end
|
877
|
+
|
878
|
+
# Returns translated month names, but also ensures that a custom month
|
879
|
+
# name array has a leading +nil+ element.
|
880
|
+
def month_names
|
881
|
+
@month_names ||= begin
|
882
|
+
month_names = @options[:use_month_names] || translated_month_names
|
883
|
+
month_names.unshift(nil) if month_names.size < 13
|
884
|
+
month_names
|
885
|
+
end
|
886
|
+
end
|
887
|
+
|
888
|
+
# Returns translated month names.
|
889
|
+
# => [nil, "January", "February", "March",
|
890
|
+
# "April", "May", "June", "July",
|
891
|
+
# "August", "September", "October",
|
892
|
+
# "November", "December"]
|
893
|
+
#
|
894
|
+
# If <tt>:use_short_month</tt> option is set
|
895
|
+
# => [nil, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
896
|
+
# "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
897
|
+
def translated_month_names
|
898
|
+
key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names'
|
899
|
+
I18n.translate(key, locale: @options[:locale])
|
900
|
+
end
|
901
|
+
|
902
|
+
# Looks up month names by number (1-based):
|
903
|
+
#
|
904
|
+
# month_name(1) # => "January"
|
905
|
+
#
|
906
|
+
# If the <tt>:use_month_numbers</tt> option is passed:
|
907
|
+
#
|
908
|
+
# month_name(1) # => 1
|
909
|
+
#
|
910
|
+
# If the <tt>:use_two_month_numbers</tt> option is passed:
|
911
|
+
#
|
912
|
+
# month_name(1) # => '01'
|
913
|
+
#
|
914
|
+
# If the <tt>:add_month_numbers</tt> option is passed:
|
915
|
+
#
|
916
|
+
# month_name(1) # => "1 - January"
|
917
|
+
#
|
918
|
+
# If the <tt>:month_format_string</tt> option is passed:
|
919
|
+
#
|
920
|
+
# month_name(1) # => "January (01)"
|
921
|
+
#
|
922
|
+
# depending on the format string.
|
923
|
+
def month_name(number)
|
924
|
+
if @options[:use_month_numbers]
|
925
|
+
number
|
926
|
+
elsif @options[:use_two_digit_numbers]
|
927
|
+
"%02d" % number
|
928
|
+
elsif @options[:add_month_numbers]
|
929
|
+
"#{number} - #{month_names[number]}"
|
930
|
+
elsif format_string = @options[:month_format_string]
|
931
|
+
format_string % { number: number, name: month_names[number] }
|
932
|
+
else
|
933
|
+
month_names[number]
|
934
|
+
end
|
935
|
+
end
|
936
|
+
|
937
|
+
def date_order
|
938
|
+
@date_order ||= @options[:order] || translated_date_order
|
939
|
+
end
|
940
|
+
|
941
|
+
def translated_date_order
|
942
|
+
date_order = I18n.translate(:'date.order', locale: @options[:locale], default: [])
|
943
|
+
date_order = date_order.map(&:to_sym)
|
944
|
+
|
945
|
+
forbidden_elements = date_order - [:year, :month, :day]
|
946
|
+
if forbidden_elements.any?
|
947
|
+
raise StandardError,
|
948
|
+
"#{@options[:locale]}.date.order only accepts :year, :month and :day"
|
949
|
+
end
|
950
|
+
|
951
|
+
date_order
|
952
|
+
end
|
953
|
+
|
954
|
+
# Build full select tag from date type and options.
|
955
|
+
def build_options_and_select(type, selected, options = {})
|
956
|
+
build_select(type, build_options(selected, options))
|
957
|
+
end
|
958
|
+
|
959
|
+
# Build select option HTML from date value and options.
|
960
|
+
# build_options(15, start: 1, end: 31)
|
961
|
+
# => "<option value="1">1</option>
|
962
|
+
# <option value="2">2</option>
|
963
|
+
# <option value="3">3</option>..."
|
964
|
+
#
|
965
|
+
# If <tt>use_two_digit_numbers: true</tt> option is passed
|
966
|
+
# build_options(15, start: 1, end: 31, use_two_digit_numbers: true)
|
967
|
+
# => "<option value="1">01</option>
|
968
|
+
# <option value="2">02</option>
|
969
|
+
# <option value="3">03</option>..."
|
970
|
+
#
|
971
|
+
# If <tt>:step</tt> options is passed
|
972
|
+
# build_options(15, start: 1, end: 31, step: 2)
|
973
|
+
# => "<option value="1">1</option>
|
974
|
+
# <option value="3">3</option>
|
975
|
+
# <option value="5">5</option>..."
|
976
|
+
def build_options(selected, options = {})
|
977
|
+
options = {
|
978
|
+
leading_zeros: true, ampm: false, use_two_digit_numbers: false
|
979
|
+
}.merge!(options)
|
980
|
+
|
981
|
+
start = options.delete(:start) || 0
|
982
|
+
stop = options.delete(:end) || 59
|
983
|
+
step = options.delete(:step) || 1
|
984
|
+
leading_zeros = options.delete(:leading_zeros)
|
985
|
+
|
986
|
+
select_options = []
|
987
|
+
start.step(stop, step) do |i|
|
988
|
+
value = leading_zeros ? sprintf("%02d", i) : i
|
989
|
+
tag_options = { value: value }
|
990
|
+
tag_options[:selected] = "selected" if selected == i
|
991
|
+
text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value
|
992
|
+
text = options[:ampm] ? AMPM_TRANSLATION[i] : text
|
993
|
+
select_options << content_tag("option".freeze, text, tag_options)
|
994
|
+
end
|
995
|
+
|
996
|
+
(select_options.join("\n") + "\n").html_safe
|
997
|
+
end
|
998
|
+
|
999
|
+
# Builds select tag from date type and HTML select options.
|
1000
|
+
# build_select(:month, "<option value="1">January</option>...")
|
1001
|
+
# => "<select id="post_written_on_2i" name="post[written_on(2i)]">
|
1002
|
+
# <option value="1">January</option>...
|
1003
|
+
# </select>"
|
1004
|
+
def build_select(type, select_options_as_html)
|
1005
|
+
select_options = {
|
1006
|
+
id: input_id_from_type(type),
|
1007
|
+
name: input_name_from_type(type)
|
1008
|
+
}.merge!(@html_options)
|
1009
|
+
select_options[:disabled] = "disabled" if @options[:disabled]
|
1010
|
+
select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes]
|
1011
|
+
|
1012
|
+
select_html = "\n".dup
|
1013
|
+
select_html << content_tag("option".freeze, "", value: "") + "\n" if @options[:include_blank]
|
1014
|
+
select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt]
|
1015
|
+
select_html << select_options_as_html
|
1016
|
+
|
1017
|
+
(content_tag("select".freeze, select_html.html_safe, select_options) + "\n").html_safe
|
1018
|
+
end
|
1019
|
+
|
1020
|
+
# Builds the css class value for the select element
|
1021
|
+
# css_class_attribute(:year, 'date optional', { year: 'my-year' })
|
1022
|
+
# => "date optional my-year"
|
1023
|
+
def css_class_attribute(type, html_options_class, options) # :nodoc:
|
1024
|
+
css_class = \
|
1025
|
+
case options
|
1026
|
+
when Hash
|
1027
|
+
options[type.to_sym]
|
1028
|
+
else
|
1029
|
+
type
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
[html_options_class, css_class].compact.join(" ")
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
# Builds a prompt option tag with supplied options or from default options.
|
1036
|
+
# prompt_option_tag(:month, prompt: 'Select month')
|
1037
|
+
# => "<option value="">Select month</option>"
|
1038
|
+
def prompt_option_tag(type, options)
|
1039
|
+
prompt = \
|
1040
|
+
case options
|
1041
|
+
when Hash
|
1042
|
+
default_options = { year: false, month: false, day: false, hour: false, minute: false, second: false }
|
1043
|
+
default_options.merge!(options)[type.to_sym]
|
1044
|
+
when String
|
1045
|
+
options
|
1046
|
+
else
|
1047
|
+
I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale])
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
prompt ? content_tag("option".freeze, prompt, value: "") : ""
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
# Builds hidden input tag for date part and value.
|
1054
|
+
# build_hidden(:year, 2008)
|
1055
|
+
# => "<input id="post_written_on_1i" name="post[written_on(1i)]" type="hidden" value="2008" />"
|
1056
|
+
def build_hidden(type, value)
|
1057
|
+
select_options = {
|
1058
|
+
type: "hidden",
|
1059
|
+
id: input_id_from_type(type),
|
1060
|
+
name: input_name_from_type(type),
|
1061
|
+
value: value
|
1062
|
+
}.merge!(@html_options.slice(:disabled))
|
1063
|
+
select_options[:disabled] = "disabled" if @options[:disabled]
|
1064
|
+
|
1065
|
+
tag(:input, select_options) + "\n".html_safe
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
# Returns the name attribute for the input tag.
|
1069
|
+
# => post[written_on(1i)]
|
1070
|
+
def input_name_from_type(type)
|
1071
|
+
prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
|
1072
|
+
prefix += "[#{@options[:index]}]" if @options.has_key?(:index)
|
1073
|
+
|
1074
|
+
field_name = @options[:field_name] || type.to_s
|
1075
|
+
if @options[:include_position]
|
1076
|
+
field_name += "(#{ActionView::Helpers::DateTimeSelector::POSITION[type]}i)"
|
1077
|
+
end
|
1078
|
+
|
1079
|
+
@options[:discard_type] ? prefix : "#{prefix}[#{field_name}]"
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
# Returns the id attribute for the input tag.
|
1083
|
+
# => "post_written_on_1i"
|
1084
|
+
def input_id_from_type(type)
|
1085
|
+
id = input_name_from_type(type).gsub(/([\[\(])|(\]\[)/, "_").gsub(/[\]\)]/, "")
|
1086
|
+
id = @options[:namespace] + "_" + id if @options[:namespace]
|
1087
|
+
|
1088
|
+
id
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
# Given an ordering of datetime components, create the selection HTML
|
1092
|
+
# and join them with their appropriate separators.
|
1093
|
+
def build_selects_from_types(order)
|
1094
|
+
select = "".dup
|
1095
|
+
first_visible = order.find { |type| !@options[:"discard_#{type}"] }
|
1096
|
+
order.reverse_each do |type|
|
1097
|
+
separator = separator(type) unless type == first_visible # don't add before first visible field
|
1098
|
+
select.insert(0, separator.to_s + send("select_#{type}").to_s)
|
1099
|
+
end
|
1100
|
+
select.html_safe
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
# Returns the separator for a given datetime component.
|
1104
|
+
def separator(type)
|
1105
|
+
return "" if @options[:use_hidden]
|
1106
|
+
|
1107
|
+
case type
|
1108
|
+
when :year, :month, :day
|
1109
|
+
@options[:"discard_#{type}"] ? "" : @options[:date_separator]
|
1110
|
+
when :hour
|
1111
|
+
(@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
|
1112
|
+
when :minute, :second
|
1113
|
+
@options[:"discard_#{type}"] ? "" : @options[:time_separator]
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
class FormBuilder
|
1119
|
+
# Wraps ActionView::Helpers::DateHelper#date_select for form builders:
|
1120
|
+
#
|
1121
|
+
# <%= form_for @person do |f| %>
|
1122
|
+
# <%= f.date_select :birth_date %>
|
1123
|
+
# <%= f.submit %>
|
1124
|
+
# <% end %>
|
1125
|
+
#
|
1126
|
+
# Please refer to the documentation of the base helper for details.
|
1127
|
+
def date_select(method, options = {}, html_options = {})
|
1128
|
+
@template.date_select(@object_name, method, objectify_options(options), html_options)
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
# Wraps ActionView::Helpers::DateHelper#time_select for form builders:
|
1132
|
+
#
|
1133
|
+
# <%= form_for @race do |f| %>
|
1134
|
+
# <%= f.time_select :average_lap %>
|
1135
|
+
# <%= f.submit %>
|
1136
|
+
# <% end %>
|
1137
|
+
#
|
1138
|
+
# Please refer to the documentation of the base helper for details.
|
1139
|
+
def time_select(method, options = {}, html_options = {})
|
1140
|
+
@template.time_select(@object_name, method, objectify_options(options), html_options)
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
# Wraps ActionView::Helpers::DateHelper#datetime_select for form builders:
|
1144
|
+
#
|
1145
|
+
# <%= form_for @person do |f| %>
|
1146
|
+
# <%= f.datetime_select :last_request_at %>
|
1147
|
+
# <%= f.submit %>
|
1148
|
+
# <% end %>
|
1149
|
+
#
|
1150
|
+
# Please refer to the documentation of the base helper for details.
|
1151
|
+
def datetime_select(method, options = {}, html_options = {})
|
1152
|
+
@template.datetime_select(@object_name, method, objectify_options(options), html_options)
|
1153
|
+
end
|
1154
|
+
end
|
1155
|
+
end
|
1156
|
+
end
|