actionpack 3.2.22.5 → 5.2.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (271) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +279 -603
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +13 -297
  5. data/lib/abstract_controller/asset_paths.rb +4 -2
  6. data/lib/abstract_controller/base.rb +82 -52
  7. data/lib/abstract_controller/caching/fragments.rb +166 -0
  8. data/lib/abstract_controller/caching.rb +66 -0
  9. data/lib/abstract_controller/callbacks.rb +117 -103
  10. data/lib/abstract_controller/collector.rb +18 -7
  11. data/lib/abstract_controller/error.rb +6 -0
  12. data/lib/abstract_controller/helpers.rb +65 -38
  13. data/lib/abstract_controller/logger.rb +3 -2
  14. data/lib/abstract_controller/railties/routes_helpers.rb +5 -3
  15. data/lib/abstract_controller/rendering.rb +77 -129
  16. data/lib/abstract_controller/translation.rb +21 -3
  17. data/lib/abstract_controller/url_for.rb +9 -7
  18. data/lib/abstract_controller.rb +12 -13
  19. data/lib/action_controller/api/api_rendering.rb +16 -0
  20. data/lib/action_controller/api.rb +149 -0
  21. data/lib/action_controller/base.rb +81 -40
  22. data/lib/action_controller/caching.rb +22 -62
  23. data/lib/action_controller/form_builder.rb +50 -0
  24. data/lib/action_controller/log_subscriber.rb +30 -18
  25. data/lib/action_controller/metal/basic_implicit_render.rb +13 -0
  26. data/lib/action_controller/metal/conditional_get.rb +190 -47
  27. data/lib/action_controller/metal/content_security_policy.rb +52 -0
  28. data/lib/action_controller/metal/cookies.rb +3 -3
  29. data/lib/action_controller/metal/data_streaming.rb +40 -65
  30. data/lib/action_controller/metal/etag_with_flash.rb +18 -0
  31. data/lib/action_controller/metal/etag_with_template_digest.rb +57 -0
  32. data/lib/action_controller/metal/exceptions.rb +19 -12
  33. data/lib/action_controller/metal/flash.rb +42 -9
  34. data/lib/action_controller/metal/force_ssl.rb +79 -19
  35. data/lib/action_controller/metal/head.rb +35 -10
  36. data/lib/action_controller/metal/helpers.rb +31 -21
  37. data/lib/action_controller/metal/http_authentication.rb +182 -134
  38. data/lib/action_controller/metal/implicit_render.rb +62 -8
  39. data/lib/action_controller/metal/instrumentation.rb +28 -26
  40. data/lib/action_controller/metal/live.rb +312 -0
  41. data/lib/action_controller/metal/mime_responds.rb +159 -163
  42. data/lib/action_controller/metal/parameter_encoding.rb +51 -0
  43. data/lib/action_controller/metal/params_wrapper.rb +146 -93
  44. data/lib/action_controller/metal/redirecting.rb +80 -56
  45. data/lib/action_controller/metal/renderers.rb +119 -47
  46. data/lib/action_controller/metal/rendering.rb +89 -32
  47. data/lib/action_controller/metal/request_forgery_protection.rb +373 -41
  48. data/lib/action_controller/metal/rescue.rb +9 -16
  49. data/lib/action_controller/metal/streaming.rb +39 -45
  50. data/lib/action_controller/metal/strong_parameters.rb +1086 -0
  51. data/lib/action_controller/metal/testing.rb +8 -29
  52. data/lib/action_controller/metal/url_for.rb +43 -32
  53. data/lib/action_controller/metal.rb +112 -106
  54. data/lib/action_controller/railtie.rb +56 -18
  55. data/lib/action_controller/railties/helpers.rb +24 -0
  56. data/lib/action_controller/renderer.rb +117 -0
  57. data/lib/action_controller/template_assertions.rb +11 -0
  58. data/lib/action_controller/test_case.rb +402 -347
  59. data/lib/action_controller.rb +31 -30
  60. data/lib/action_dispatch/http/cache.rb +133 -34
  61. data/lib/action_dispatch/http/content_security_policy.rb +272 -0
  62. data/lib/action_dispatch/http/filter_parameters.rb +40 -24
  63. data/lib/action_dispatch/http/filter_redirect.rb +37 -0
  64. data/lib/action_dispatch/http/headers.rb +117 -16
  65. data/lib/action_dispatch/http/mime_negotiation.rb +98 -33
  66. data/lib/action_dispatch/http/mime_type.rb +198 -146
  67. data/lib/action_dispatch/http/mime_types.rb +22 -7
  68. data/lib/action_dispatch/http/parameter_filter.rb +61 -49
  69. data/lib/action_dispatch/http/parameters.rb +94 -51
  70. data/lib/action_dispatch/http/rack_cache.rb +4 -3
  71. data/lib/action_dispatch/http/request.rb +262 -117
  72. data/lib/action_dispatch/http/response.rb +400 -86
  73. data/lib/action_dispatch/http/upload.rb +66 -29
  74. data/lib/action_dispatch/http/url.rb +232 -60
  75. data/lib/action_dispatch/journey/formatter.rb +189 -0
  76. data/lib/action_dispatch/journey/gtg/builder.rb +164 -0
  77. data/lib/action_dispatch/journey/gtg/simulator.rb +41 -0
  78. data/lib/action_dispatch/journey/gtg/transition_table.rb +158 -0
  79. data/lib/action_dispatch/journey/nfa/builder.rb +78 -0
  80. data/lib/action_dispatch/journey/nfa/dot.rb +36 -0
  81. data/lib/action_dispatch/journey/nfa/simulator.rb +49 -0
  82. data/lib/action_dispatch/journey/nfa/transition_table.rb +120 -0
  83. data/lib/action_dispatch/journey/nodes/node.rb +140 -0
  84. data/lib/action_dispatch/journey/parser.rb +199 -0
  85. data/lib/action_dispatch/journey/parser.y +50 -0
  86. data/lib/action_dispatch/journey/parser_extras.rb +31 -0
  87. data/lib/action_dispatch/journey/path/pattern.rb +199 -0
  88. data/lib/action_dispatch/journey/route.rb +203 -0
  89. data/lib/action_dispatch/journey/router/utils.rb +102 -0
  90. data/lib/action_dispatch/journey/router.rb +156 -0
  91. data/lib/action_dispatch/journey/routes.rb +82 -0
  92. data/lib/action_dispatch/journey/scanner.rb +64 -0
  93. data/lib/action_dispatch/journey/visitors.rb +268 -0
  94. data/lib/action_dispatch/journey/visualizer/fsm.css +30 -0
  95. data/lib/action_dispatch/journey/visualizer/fsm.js +134 -0
  96. data/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
  97. data/lib/action_dispatch/journey.rb +7 -0
  98. data/lib/action_dispatch/middleware/callbacks.rb +17 -13
  99. data/lib/action_dispatch/middleware/cookies.rb +494 -162
  100. data/lib/action_dispatch/middleware/debug_exceptions.rb +176 -53
  101. data/lib/action_dispatch/middleware/debug_locks.rb +124 -0
  102. data/lib/action_dispatch/middleware/exception_wrapper.rb +103 -38
  103. data/lib/action_dispatch/middleware/executor.rb +21 -0
  104. data/lib/action_dispatch/middleware/flash.rb +128 -91
  105. data/lib/action_dispatch/middleware/public_exceptions.rb +43 -16
  106. data/lib/action_dispatch/middleware/reloader.rb +6 -83
  107. data/lib/action_dispatch/middleware/remote_ip.rb +151 -49
  108. data/lib/action_dispatch/middleware/request_id.rb +19 -15
  109. data/lib/action_dispatch/middleware/session/abstract_store.rb +38 -34
  110. data/lib/action_dispatch/middleware/session/cache_store.rb +14 -9
  111. data/lib/action_dispatch/middleware/session/cookie_store.rb +94 -44
  112. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +15 -4
  113. data/lib/action_dispatch/middleware/show_exceptions.rb +36 -61
  114. data/lib/action_dispatch/middleware/ssl.rb +150 -0
  115. data/lib/action_dispatch/middleware/stack.rb +33 -41
  116. data/lib/action_dispatch/middleware/static.rb +92 -48
  117. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +22 -0
  118. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
  119. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +27 -0
  120. data/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
  121. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +52 -0
  122. data/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
  123. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +16 -0
  124. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
  125. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +21 -0
  126. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +13 -0
  127. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +134 -5
  128. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
  129. data/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
  130. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +32 -0
  131. data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
  132. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
  133. data/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
  134. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +6 -0
  135. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
  136. data/lib/action_dispatch/middleware/templates/routes/_route.html.erb +16 -0
  137. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +200 -0
  138. data/lib/action_dispatch/railtie.rb +29 -8
  139. data/lib/action_dispatch/request/session.rb +234 -0
  140. data/lib/action_dispatch/request/utils.rb +78 -0
  141. data/lib/action_dispatch/routing/endpoint.rb +17 -0
  142. data/lib/action_dispatch/routing/inspector.rb +225 -0
  143. data/lib/action_dispatch/routing/mapper.rb +1329 -582
  144. data/lib/action_dispatch/routing/polymorphic_routes.rb +237 -94
  145. data/lib/action_dispatch/routing/redirection.rb +120 -50
  146. data/lib/action_dispatch/routing/route_set.rb +545 -322
  147. data/lib/action_dispatch/routing/routes_proxy.rb +37 -7
  148. data/lib/action_dispatch/routing/url_for.rb +103 -34
  149. data/lib/action_dispatch/routing.rb +66 -99
  150. data/lib/action_dispatch/system_test_case.rb +147 -0
  151. data/lib/action_dispatch/system_testing/browser.rb +49 -0
  152. data/lib/action_dispatch/system_testing/driver.rb +59 -0
  153. data/lib/action_dispatch/system_testing/server.rb +31 -0
  154. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +96 -0
  155. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +31 -0
  156. data/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +26 -0
  157. data/lib/action_dispatch/testing/assertion_response.rb +47 -0
  158. data/lib/action_dispatch/testing/assertions/response.rb +53 -42
  159. data/lib/action_dispatch/testing/assertions/routing.rb +79 -74
  160. data/lib/action_dispatch/testing/assertions.rb +15 -9
  161. data/lib/action_dispatch/testing/integration.rb +361 -207
  162. data/lib/action_dispatch/testing/request_encoder.rb +55 -0
  163. data/lib/action_dispatch/testing/test_process.rb +28 -19
  164. data/lib/action_dispatch/testing/test_request.rb +30 -33
  165. data/lib/action_dispatch/testing/test_response.rb +35 -11
  166. data/lib/action_dispatch.rb +42 -32
  167. data/lib/action_pack/gem_version.rb +17 -0
  168. data/lib/action_pack/version.rb +7 -7
  169. data/lib/action_pack.rb +4 -2
  170. metadata +116 -175
  171. data/lib/abstract_controller/layouts.rb +0 -423
  172. data/lib/abstract_controller/view_paths.rb +0 -96
  173. data/lib/action_controller/caching/actions.rb +0 -185
  174. data/lib/action_controller/caching/fragments.rb +0 -127
  175. data/lib/action_controller/caching/pages.rb +0 -187
  176. data/lib/action_controller/caching/sweeping.rb +0 -97
  177. data/lib/action_controller/deprecated/integration_test.rb +0 -2
  178. data/lib/action_controller/deprecated/performance_test.rb +0 -1
  179. data/lib/action_controller/deprecated.rb +0 -3
  180. data/lib/action_controller/metal/compatibility.rb +0 -65
  181. data/lib/action_controller/metal/hide_actions.rb +0 -41
  182. data/lib/action_controller/metal/rack_delegation.rb +0 -26
  183. data/lib/action_controller/metal/responder.rb +0 -286
  184. data/lib/action_controller/metal/session_management.rb +0 -14
  185. data/lib/action_controller/middleware.rb +0 -39
  186. data/lib/action_controller/railties/paths.rb +0 -25
  187. data/lib/action_controller/record_identifier.rb +0 -85
  188. data/lib/action_controller/vendor/html-scanner/html/document.rb +0 -68
  189. data/lib/action_controller/vendor/html-scanner/html/node.rb +0 -532
  190. data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +0 -177
  191. data/lib/action_controller/vendor/html-scanner/html/selector.rb +0 -830
  192. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +0 -107
  193. data/lib/action_controller/vendor/html-scanner/html/version.rb +0 -11
  194. data/lib/action_controller/vendor/html-scanner.rb +0 -20
  195. data/lib/action_dispatch/middleware/best_standards_support.rb +0 -30
  196. data/lib/action_dispatch/middleware/body_proxy.rb +0 -30
  197. data/lib/action_dispatch/middleware/head.rb +0 -18
  198. data/lib/action_dispatch/middleware/params_parser.rb +0 -75
  199. data/lib/action_dispatch/middleware/rescue.rb +0 -26
  200. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +0 -31
  201. data/lib/action_dispatch/middleware/templates/rescues/_trace.erb +0 -26
  202. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb +0 -10
  203. data/lib/action_dispatch/middleware/templates/rescues/missing_template.erb +0 -2
  204. data/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +0 -15
  205. data/lib/action_dispatch/middleware/templates/rescues/template_error.erb +0 -17
  206. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.erb +0 -2
  207. data/lib/action_dispatch/testing/assertions/dom.rb +0 -37
  208. data/lib/action_dispatch/testing/assertions/selector.rb +0 -435
  209. data/lib/action_dispatch/testing/assertions/tag.rb +0 -138
  210. data/lib/action_dispatch/testing/performance_test.rb +0 -10
  211. data/lib/action_view/asset_paths.rb +0 -142
  212. data/lib/action_view/base.rb +0 -220
  213. data/lib/action_view/buffers.rb +0 -43
  214. data/lib/action_view/context.rb +0 -36
  215. data/lib/action_view/flows.rb +0 -79
  216. data/lib/action_view/helpers/active_model_helper.rb +0 -50
  217. data/lib/action_view/helpers/asset_paths.rb +0 -7
  218. data/lib/action_view/helpers/asset_tag_helper.rb +0 -457
  219. data/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb +0 -146
  220. data/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb +0 -93
  221. data/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +0 -193
  222. data/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +0 -148
  223. data/lib/action_view/helpers/atom_feed_helper.rb +0 -200
  224. data/lib/action_view/helpers/cache_helper.rb +0 -64
  225. data/lib/action_view/helpers/capture_helper.rb +0 -203
  226. data/lib/action_view/helpers/controller_helper.rb +0 -25
  227. data/lib/action_view/helpers/csrf_helper.rb +0 -32
  228. data/lib/action_view/helpers/date_helper.rb +0 -1062
  229. data/lib/action_view/helpers/debug_helper.rb +0 -40
  230. data/lib/action_view/helpers/form_helper.rb +0 -1486
  231. data/lib/action_view/helpers/form_options_helper.rb +0 -658
  232. data/lib/action_view/helpers/form_tag_helper.rb +0 -685
  233. data/lib/action_view/helpers/javascript_helper.rb +0 -110
  234. data/lib/action_view/helpers/number_helper.rb +0 -622
  235. data/lib/action_view/helpers/output_safety_helper.rb +0 -38
  236. data/lib/action_view/helpers/record_tag_helper.rb +0 -111
  237. data/lib/action_view/helpers/rendering_helper.rb +0 -92
  238. data/lib/action_view/helpers/sanitize_helper.rb +0 -259
  239. data/lib/action_view/helpers/tag_helper.rb +0 -167
  240. data/lib/action_view/helpers/text_helper.rb +0 -426
  241. data/lib/action_view/helpers/translation_helper.rb +0 -91
  242. data/lib/action_view/helpers/url_helper.rb +0 -693
  243. data/lib/action_view/helpers.rb +0 -60
  244. data/lib/action_view/locale/en.yml +0 -160
  245. data/lib/action_view/log_subscriber.rb +0 -28
  246. data/lib/action_view/lookup_context.rb +0 -258
  247. data/lib/action_view/path_set.rb +0 -101
  248. data/lib/action_view/railtie.rb +0 -55
  249. data/lib/action_view/renderer/abstract_renderer.rb +0 -41
  250. data/lib/action_view/renderer/partial_renderer.rb +0 -415
  251. data/lib/action_view/renderer/renderer.rb +0 -61
  252. data/lib/action_view/renderer/streaming_template_renderer.rb +0 -106
  253. data/lib/action_view/renderer/template_renderer.rb +0 -95
  254. data/lib/action_view/template/error.rb +0 -128
  255. data/lib/action_view/template/handlers/builder.rb +0 -26
  256. data/lib/action_view/template/handlers/erb.rb +0 -125
  257. data/lib/action_view/template/handlers.rb +0 -50
  258. data/lib/action_view/template/resolver.rb +0 -298
  259. data/lib/action_view/template/text.rb +0 -30
  260. data/lib/action_view/template.rb +0 -337
  261. data/lib/action_view/test_case.rb +0 -246
  262. data/lib/action_view/testing/resolvers.rb +0 -49
  263. data/lib/action_view.rb +0 -84
  264. data/lib/sprockets/assets.rake +0 -99
  265. data/lib/sprockets/bootstrap.rb +0 -37
  266. data/lib/sprockets/compressors.rb +0 -83
  267. data/lib/sprockets/helpers/isolated_helper.rb +0 -13
  268. data/lib/sprockets/helpers/rails_helper.rb +0 -182
  269. data/lib/sprockets/helpers.rb +0 -6
  270. data/lib/sprockets/railtie.rb +0 -62
  271. data/lib/sprockets/static_compiler.rb +0 -56
@@ -1,60 +0,0 @@
1
- require 'active_support/benchmarkable'
2
-
3
- module ActionView #:nodoc:
4
- module Helpers #:nodoc:
5
- extend ActiveSupport::Autoload
6
-
7
- autoload :ActiveModelHelper
8
- autoload :AssetTagHelper
9
- autoload :AtomFeedHelper
10
- autoload :CacheHelper
11
- autoload :CaptureHelper
12
- autoload :ControllerHelper
13
- autoload :CsrfHelper
14
- autoload :DateHelper
15
- autoload :DebugHelper
16
- autoload :FormHelper
17
- autoload :FormOptionsHelper
18
- autoload :FormTagHelper
19
- autoload :JavaScriptHelper, "action_view/helpers/javascript_helper"
20
- autoload :NumberHelper
21
- autoload :OutputSafetyHelper
22
- autoload :RecordTagHelper
23
- autoload :RenderingHelper
24
- autoload :SanitizeHelper
25
- autoload :TagHelper
26
- autoload :TextHelper
27
- autoload :TranslationHelper
28
- autoload :UrlHelper
29
-
30
- extend ActiveSupport::Concern
31
-
32
- included do
33
- extend SanitizeHelper::ClassMethods
34
- end
35
-
36
- include ActiveSupport::Benchmarkable
37
- include ActiveModelHelper
38
- include AssetTagHelper
39
- include AtomFeedHelper
40
- include CacheHelper
41
- include CaptureHelper
42
- include ControllerHelper
43
- include CsrfHelper
44
- include DateHelper
45
- include DebugHelper
46
- include FormHelper
47
- include FormOptionsHelper
48
- include FormTagHelper
49
- include JavaScriptHelper
50
- include NumberHelper
51
- include OutputSafetyHelper
52
- include RecordTagHelper
53
- include RenderingHelper
54
- include SanitizeHelper
55
- include TagHelper
56
- include TextHelper
57
- include TranslationHelper
58
- include UrlHelper
59
- end
60
- end
@@ -1,160 +0,0 @@
1
- "en":
2
- number:
3
- # Used in number_with_delimiter()
4
- # These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
5
- format:
6
- # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
7
- separator: "."
8
- # Delimits thousands (e.g. 1,000,000 is a million) (always in groups of three)
9
- delimiter: ","
10
- # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
11
- precision: 3
12
- # If set to true, precision will mean the number of significant digits instead
13
- # of the number of decimal digits (1234 with precision 2 becomes 1200, 1.23543 becomes 1.2)
14
- significant: false
15
- # If set, the zeros after the decimal separator will always be stripped (eg.: 1.200 will be 1.2)
16
- strip_insignificant_zeros: false
17
-
18
- # Used in number_to_currency()
19
- currency:
20
- format:
21
- # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
22
- format: "%u%n"
23
- unit: "$"
24
- # These five are to override number.format and are optional
25
- separator: "."
26
- delimiter: ","
27
- precision: 2
28
- significant: false
29
- strip_insignificant_zeros: false
30
-
31
- # Used in number_to_percentage()
32
- percentage:
33
- format:
34
- # These five are to override number.format and are optional
35
- # separator:
36
- delimiter: ""
37
- # precision:
38
- # significant: false
39
- # strip_insignificant_zeros: false
40
-
41
- # Used in number_to_precision()
42
- precision:
43
- format:
44
- # These five are to override number.format and are optional
45
- # separator:
46
- delimiter: ""
47
- # precision:
48
- # significant: false
49
- # strip_insignificant_zeros: false
50
-
51
- # Used in number_to_human_size() and number_to_human()
52
- human:
53
- format:
54
- # These five are to override number.format and are optional
55
- # separator:
56
- delimiter: ""
57
- precision: 3
58
- significant: true
59
- strip_insignificant_zeros: true
60
- # Used in number_to_human_size()
61
- storage_units:
62
- # Storage units output formatting.
63
- # %u is the storage unit, %n is the number (default: 2 MB)
64
- format: "%n %u"
65
- units:
66
- byte:
67
- one: "Byte"
68
- other: "Bytes"
69
- kb: "KB"
70
- mb: "MB"
71
- gb: "GB"
72
- tb: "TB"
73
- # Used in number_to_human()
74
- decimal_units:
75
- format: "%n %u"
76
- # Decimal units output formatting
77
- # By default we will only quantify some of the exponents
78
- # but the commented ones might be defined or overridden
79
- # by the user.
80
- units:
81
- # femto: Quadrillionth
82
- # pico: Trillionth
83
- # nano: Billionth
84
- # micro: Millionth
85
- # mili: Thousandth
86
- # centi: Hundredth
87
- # deci: Tenth
88
- unit: ""
89
- # ten:
90
- # one: Ten
91
- # other: Tens
92
- # hundred: Hundred
93
- thousand: Thousand
94
- million: Million
95
- billion: Billion
96
- trillion: Trillion
97
- quadrillion: Quadrillion
98
-
99
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
100
- datetime:
101
- distance_in_words:
102
- half_a_minute: "half a minute"
103
- less_than_x_seconds:
104
- one: "less than 1 second"
105
- other: "less than %{count} seconds"
106
- x_seconds:
107
- one: "1 second"
108
- other: "%{count} seconds"
109
- less_than_x_minutes:
110
- one: "less than a minute"
111
- other: "less than %{count} minutes"
112
- x_minutes:
113
- one: "1 minute"
114
- other: "%{count} minutes"
115
- about_x_hours:
116
- one: "about 1 hour"
117
- other: "about %{count} hours"
118
- x_days:
119
- one: "1 day"
120
- other: "%{count} days"
121
- about_x_months:
122
- one: "about 1 month"
123
- other: "about %{count} months"
124
- x_months:
125
- one: "1 month"
126
- other: "%{count} months"
127
- about_x_years:
128
- one: "about 1 year"
129
- other: "about %{count} years"
130
- over_x_years:
131
- one: "over 1 year"
132
- other: "over %{count} years"
133
- almost_x_years:
134
- one: "almost 1 year"
135
- other: "almost %{count} years"
136
- prompts:
137
- year: "Year"
138
- month: "Month"
139
- day: "Day"
140
- hour: "Hour"
141
- minute: "Minute"
142
- second: "Seconds"
143
-
144
- helpers:
145
- select:
146
- # Default value for :prompt => true in FormOptionsHelper
147
- prompt: "Please select"
148
-
149
- # Default translation keys for submit FormHelper
150
- submit:
151
- create: 'Create %{model}'
152
- update: 'Update %{model}'
153
- submit: 'Save %{model}'
154
-
155
- # Default translation keys for button FormHelper
156
- button:
157
- create: 'Create %{model}'
158
- update: 'Update %{model}'
159
- submit: 'Save %{model}'
160
-
@@ -1,28 +0,0 @@
1
- module ActionView
2
- # = Action View Log Subscriber
3
- #
4
- # Provides functionality so that Rails can output logs from Action View.
5
- class LogSubscriber < ActiveSupport::LogSubscriber
6
- def render_template(event)
7
- message = " Rendered #{from_rails_root(event.payload[:identifier])}"
8
- message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
9
- message << (" (%.1fms)" % event.duration)
10
- info(message)
11
- end
12
- alias :render_partial :render_template
13
- alias :render_collection :render_template
14
-
15
- # TODO: Ideally, ActionView should have its own logger so it does not depend on AC.logger
16
- def logger
17
- ActionController::Base.logger if defined?(ActionController::Base)
18
- end
19
-
20
- protected
21
-
22
- def from_rails_root(string)
23
- string.sub("#{Rails.root}/", "").sub(/^app\/views\//, "")
24
- end
25
- end
26
- end
27
-
28
- ActionView::LogSubscriber.attach_to :action_view
@@ -1,258 +0,0 @@
1
- require 'active_support/core_ext/array/wrap'
2
- require 'active_support/core_ext/object/blank'
3
- require 'active_support/core_ext/module/remove_method'
4
-
5
- module ActionView
6
- # = Action View Lookup Context
7
- #
8
- # LookupContext is the object responsible to hold all information required to lookup
9
- # templates, i.e. view paths and details. The LookupContext is also responsible to
10
- # generate a key, given to view paths, used in the resolver cache lookup. Since
11
- # this key is generated just once during the request, it speeds up all cache accesses.
12
- class LookupContext #:nodoc:
13
- attr_accessor :prefixes, :rendered_format
14
-
15
- mattr_accessor :fallbacks
16
- @@fallbacks = FallbackFileSystemResolver.instances
17
-
18
- mattr_accessor :registered_details
19
- self.registered_details = []
20
-
21
- def self.register_detail(name, options = {}, &block)
22
- self.registered_details << name
23
- initialize = registered_details.map { |n| "@details[:#{n}] = details[:#{n}] || default_#{n}" }
24
-
25
- Accessors.send :define_method, :"default_#{name}", &block
26
- Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
27
- def #{name}
28
- @details[:#{name}]
29
- end
30
-
31
- def #{name}=(value)
32
- value = value.present? ? Array.wrap(value) : default_#{name}
33
- _set_detail(:#{name}, value) if value != @details[:#{name}]
34
- end
35
-
36
- remove_possible_method :initialize_details
37
- def initialize_details(details)
38
- #{initialize.join("\n")}
39
- end
40
- METHOD
41
- end
42
-
43
- # Holds accessors for the registered details.
44
- module Accessors #:nodoc:
45
- end
46
-
47
- register_detail(:locale) do
48
- locales = [I18n.locale]
49
- locales.concat(I18n.fallbacks[I18n.locale]) if I18n.respond_to? :fallbacks
50
- locales << I18n.default_locale
51
- locales.uniq!
52
- locales
53
- end
54
- register_detail(:formats) { Mime::SET.symbols }
55
- register_detail(:handlers){ Template::Handlers.extensions }
56
-
57
- class DetailsKey #:nodoc:
58
- alias :eql? :equal?
59
- alias :object_hash :hash
60
-
61
- attr_reader :hash
62
- @details_keys = Hash.new
63
-
64
- def self.get(details)
65
- if details[:formats]
66
- details = details.dup
67
- syms = Set.new Mime::SET.symbols
68
- details[:formats] = details[:formats].select { |v|
69
- syms.include? v
70
- }
71
- end
72
- @details_keys[details] ||= new
73
- end
74
-
75
- def self.clear
76
- @details_keys.clear
77
- end
78
-
79
- def initialize
80
- @hash = object_hash
81
- end
82
- end
83
-
84
- # Add caching behavior on top of Details.
85
- module DetailsCache
86
- attr_accessor :cache
87
-
88
- # Calculate the details key. Remove the handlers from calculation to improve performance
89
- # since the user cannot modify it explicitly.
90
- def details_key #:nodoc:
91
- @details_key ||= DetailsKey.get(@details) if @cache
92
- end
93
-
94
- # Temporary skip passing the details_key forward.
95
- def disable_cache
96
- old_value, @cache = @cache, false
97
- yield
98
- ensure
99
- @cache = old_value
100
- end
101
-
102
- protected
103
-
104
- def _set_detail(key, value)
105
- @details = @details.dup if @details_key
106
- @details_key = nil
107
- @details[key] = value
108
- end
109
- end
110
-
111
- # Helpers related to template lookup using the lookup context information.
112
- module ViewPaths
113
- attr_reader :view_paths
114
-
115
- # Whenever setting view paths, makes a copy so we can manipulate then in
116
- # instance objects as we wish.
117
- def view_paths=(paths)
118
- @view_paths = ActionView::PathSet.new(Array.wrap(paths))
119
- end
120
-
121
- def find(name, prefixes = [], partial = false, keys = [], options = {})
122
- @view_paths.find(*args_for_lookup(name, prefixes, partial, keys, options))
123
- end
124
- alias :find_template :find
125
-
126
- def find_all(name, prefixes = [], partial = false, keys = [], options = {})
127
- @view_paths.find_all(*args_for_lookup(name, prefixes, partial, keys, options))
128
- end
129
-
130
- def find_file(name, prefixes = [], partial = false, keys = [], options = {})
131
- @view_paths.find_file(*args_for_lookup(name, prefixes, partial, keys, options))
132
- end
133
-
134
- def exists?(name, prefixes = [], partial = false, keys = [], options = {})
135
- @view_paths.exists?(*args_for_lookup(name, prefixes, partial, keys, options))
136
- end
137
- alias :template_exists? :exists?
138
-
139
- # Add fallbacks to the view paths. Useful in cases you are rendering a :file.
140
- def with_fallbacks
141
- added_resolvers = 0
142
- self.class.fallbacks.each do |resolver|
143
- next if view_paths.include?(resolver)
144
- view_paths.push(resolver)
145
- added_resolvers += 1
146
- end
147
- yield
148
- ensure
149
- added_resolvers.times { view_paths.pop }
150
- end
151
-
152
- protected
153
-
154
- def args_for_lookup(name, prefixes, partial, keys, details_options) #:nodoc:
155
- name, prefixes = normalize_name(name, prefixes)
156
- details, details_key = detail_args_for(details_options)
157
- [name, prefixes, partial || false, details, details_key, keys]
158
- end
159
-
160
- # Compute details hash and key according to user options (e.g. passed from #render).
161
- def detail_args_for(options)
162
- return @details, details_key if options.empty? # most common path.
163
- user_details = @details.merge(options)
164
- [user_details, DetailsKey.get(user_details)]
165
- end
166
-
167
- # Support legacy foo.erb names even though we now ignore .erb
168
- # as well as incorrectly putting part of the path in the template
169
- # name instead of the prefix.
170
- def normalize_name(name, prefixes) #:nodoc:
171
- name = name.to_s.sub(handlers_regexp) do |match|
172
- ActiveSupport::Deprecation.warn "Passing a template handler in the template name is deprecated. " \
173
- "You can simply remove the handler name or pass render :handlers => [:#{match[1..-1]}] instead.", caller
174
- ""
175
- end
176
-
177
- prefixes = nil if prefixes.blank?
178
- parts = name.split('/')
179
- name = parts.pop
180
-
181
- return name, prefixes || [""] if parts.empty?
182
-
183
- parts = parts.join('/')
184
- prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts]
185
-
186
- return name, prefixes
187
- end
188
-
189
- def handlers_regexp #:nodoc:
190
- @@handlers_regexp ||= /\.(?:#{default_handlers.join('|')})$/
191
- end
192
- end
193
-
194
- include Accessors
195
- include DetailsCache
196
- include ViewPaths
197
-
198
- def initialize(view_paths, details = {}, prefixes = [])
199
- @details, @details_key = {}, nil
200
- @skip_default_locale = false
201
- @cache = true
202
- @prefixes = prefixes
203
- @rendered_format = nil
204
-
205
- self.view_paths = view_paths
206
- initialize_details(details)
207
- end
208
-
209
- # Override formats= to expand ["*/*"] values and automatically
210
- # add :html as fallback to :js.
211
- def formats=(values)
212
- if values
213
- values.concat(default_formats) if values.delete "*/*"
214
- values << :html if values == [:js]
215
- end
216
- super(values)
217
- end
218
-
219
- # Do not use the default locale on template lookup.
220
- def skip_default_locale!
221
- @skip_default_locale = true
222
- self.locale = nil
223
- end
224
-
225
- # Override locale to return a symbol instead of array.
226
- def locale
227
- @details[:locale].first
228
- end
229
-
230
- # Overload locale= to also set the I18n.locale. If the current I18n.config object responds
231
- # to original_config, it means that it's has a copy of the original I18n configuration and it's
232
- # acting as proxy, which we need to skip.
233
- def locale=(value)
234
- if value
235
- config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
236
- config.locale = value
237
- end
238
-
239
- super(@skip_default_locale ? I18n.locale : default_locale)
240
- end
241
-
242
- # A method which only uses the first format in the formats array for layout lookup.
243
- def with_layout_format
244
- if formats.size == 1
245
- yield
246
- else
247
- old_formats = formats
248
- _set_detail(:formats, formats[0,1])
249
-
250
- begin
251
- yield
252
- ensure
253
- _set_detail(:formats, old_formats)
254
- end
255
- end
256
- end
257
- end
258
- end
@@ -1,101 +0,0 @@
1
- module ActionView #:nodoc:
2
- # = Action View PathSet
3
- class PathSet #:nodoc:
4
- include Enumerable
5
-
6
- attr_reader :paths
7
-
8
- def initialize(paths = [])
9
- @paths = typecast paths
10
- end
11
-
12
- def initialize_copy(other)
13
- @paths = other.paths.dup
14
- self
15
- end
16
-
17
- def [](i)
18
- paths[i]
19
- end
20
-
21
- def to_ary
22
- paths.dup
23
- end
24
-
25
- def include?(item)
26
- paths.include? item
27
- end
28
-
29
- def pop
30
- paths.pop
31
- end
32
-
33
- def size
34
- paths.size
35
- end
36
-
37
- def each(&block)
38
- paths.each(&block)
39
- end
40
-
41
- def compact
42
- PathSet.new paths.compact
43
- end
44
-
45
- def +(array)
46
- PathSet.new(paths + array)
47
- end
48
-
49
- %w(<< concat push insert unshift).each do |method|
50
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
51
- def #{method}(*args)
52
- paths.#{method}(*typecast(args))
53
- end
54
- METHOD
55
- end
56
-
57
- def find(*args)
58
- find_all(*args).first || raise(MissingTemplate.new(self, *args))
59
- end
60
-
61
- def find_file(path, prefixes = [], *args)
62
- _find_all(path, prefixes, args, true).first || raise(MissingTemplate.new(self, path, prefixes, *args))
63
- end
64
-
65
- def find_all(path, prefixes = [], *args)
66
- _find_all path, prefixes, args, false
67
- end
68
-
69
- def exists?(path, prefixes, *args)
70
- find_all(path, prefixes, *args).any?
71
- end
72
-
73
- private
74
-
75
- def _find_all(path, prefixes, args, outside_app)
76
- prefixes = [prefixes] if String === prefixes
77
- prefixes.each do |prefix|
78
- paths.each do |resolver|
79
- if outside_app
80
- templates = resolver.find_all_anywhere(path, prefix, *args)
81
- else
82
- templates = resolver.find_all(path, prefix, *args)
83
- end
84
- return templates unless templates.empty?
85
- end
86
- end
87
- []
88
- end
89
-
90
- def typecast(paths)
91
- paths.map do |path|
92
- case path
93
- when Pathname, String
94
- OptimizedFileSystemResolver.new path.to_s
95
- else
96
- path
97
- end
98
- end
99
- end
100
- end
101
- end
@@ -1,55 +0,0 @@
1
- require "action_view"
2
- require "rails"
3
-
4
- module ActionView
5
- # = Action View Railtie
6
- class Railtie < Rails::Railtie
7
- config.action_view = ActiveSupport::OrderedOptions.new
8
- config.action_view.stylesheet_expansions = {}
9
- config.action_view.javascript_expansions = { :defaults => %w(jquery jquery_ujs) }
10
- config.action_view.embed_authenticity_token_in_remote_forms = true
11
-
12
- initializer "action_view.embed_authenticity_token_in_remote_forms" do |app|
13
- ActiveSupport.on_load(:action_view) do
14
- ActionView::Helpers::FormTagHelper.embed_authenticity_token_in_remote_forms =
15
- app.config.action_view.delete(:embed_authenticity_token_in_remote_forms)
16
- end
17
- end
18
-
19
- initializer "action_view.cache_asset_ids" do |app|
20
- unless app.config.cache_classes
21
- ActiveSupport.on_load(:action_view) do
22
- ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids = false
23
- end
24
- end
25
- end
26
-
27
- initializer "action_view.javascript_expansions" do |app|
28
- ActiveSupport.on_load(:action_view) do
29
- ActionView::Helpers::AssetTagHelper.register_javascript_expansion(
30
- app.config.action_view.delete(:javascript_expansions)
31
- )
32
-
33
- ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion(
34
- app.config.action_view.delete(:stylesheet_expansions)
35
- )
36
- end
37
- end
38
-
39
- initializer "action_view.set_configs" do |app|
40
- ActiveSupport.on_load(:action_view) do
41
- app.config.action_view.each do |k,v|
42
- send "#{k}=", v
43
- end
44
- end
45
- end
46
-
47
- initializer "action_view.caching" do |app|
48
- ActiveSupport.on_load(:action_view) do
49
- if app.config.action_view.cache_template_loading.nil?
50
- ActionView::Resolver.caching = app.config.cache_classes
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,41 +0,0 @@
1
- module ActionView
2
- class AbstractRenderer #:nodoc:
3
- delegate :find_template, :find_file, :template_exists?, :with_fallbacks, :update_details,
4
- :with_layout_format, :formats, :to => :@lookup_context
5
-
6
- def initialize(lookup_context)
7
- @lookup_context = lookup_context
8
- end
9
-
10
- def render
11
- raise NotImplementedError
12
- end
13
-
14
- protected
15
-
16
- def extract_details(options)
17
- details = {}
18
- @lookup_context.registered_details.each do |key|
19
- next unless value = options[key]
20
- details[key] = Array.wrap(value)
21
- end
22
- details
23
- end
24
-
25
- def extract_format(value, details)
26
- if value.is_a?(String) && value.sub!(formats_regexp, "")
27
- ActiveSupport::Deprecation.warn "Passing the format in the template name is deprecated. " \
28
- "Please pass render with :formats => [:#{$1}] instead.", caller
29
- details[:formats] ||= [$1.to_sym]
30
- end
31
- end
32
-
33
- def formats_regexp
34
- @@formats_regexp ||= /\.(#{Mime::SET.symbols.join('|')})$/
35
- end
36
-
37
- def instrument(name, options={})
38
- ActiveSupport::Notifications.instrument("render_#{name}.action_view", options){ yield }
39
- end
40
- end
41
- end