ruby-on-quails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3458) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +13 -0
  3. data/.gitattributes +2 -0
  4. data/.github/issue_template.md +15 -0
  5. data/.github/pull_request_template.md +21 -0
  6. data/.github/stale.yml +28 -0
  7. data/.gitignore +24 -0
  8. data/.rubocop.yml +137 -0
  9. data/.travis.yml +123 -0
  10. data/.yardopts +4 -0
  11. data/CODE_OF_CONDUCT.md +12 -0
  12. data/CONTRIBUTING.md +49 -0
  13. data/Gemfile +168 -0
  14. data/Gemfile.lock +547 -0
  15. data/MIT-LICENSE +20 -0
  16. data/RAILS_VERSION +1 -0
  17. data/README.md +97 -0
  18. data/RELEASING_RAILS.md +225 -0
  19. data/Rakefile +72 -0
  20. data/actioncable/.gitignore +2 -0
  21. data/actioncable/CHANGELOG.md +26 -0
  22. data/actioncable/MIT-LICENSE +20 -0
  23. data/actioncable/README.md +567 -0
  24. data/actioncable/Rakefile +76 -0
  25. data/actioncable/actioncable.gemspec +32 -0
  26. data/actioncable/app/assets/javascripts/action_cable.coffee.erb +38 -0
  27. data/actioncable/app/assets/javascripts/action_cable/connection.coffee +116 -0
  28. data/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee +95 -0
  29. data/actioncable/app/assets/javascripts/action_cable/consumer.coffee +46 -0
  30. data/actioncable/app/assets/javascripts/action_cable/subscription.coffee +72 -0
  31. data/actioncable/app/assets/javascripts/action_cable/subscriptions.coffee +66 -0
  32. data/actioncable/bin/test +5 -0
  33. data/actioncable/blade.yml +34 -0
  34. data/actioncable/lib/action_cable.rb +54 -0
  35. data/actioncable/lib/action_cable/channel.rb +16 -0
  36. data/actioncable/lib/action_cable/channel/base.rb +305 -0
  37. data/actioncable/lib/action_cable/channel/broadcasting.rb +31 -0
  38. data/actioncable/lib/action_cable/channel/callbacks.rb +37 -0
  39. data/actioncable/lib/action_cable/channel/naming.rb +25 -0
  40. data/actioncable/lib/action_cable/channel/periodic_timers.rb +78 -0
  41. data/actioncable/lib/action_cable/channel/streams.rb +176 -0
  42. data/actioncable/lib/action_cable/connection.rb +21 -0
  43. data/actioncable/lib/action_cable/connection/authorization.rb +15 -0
  44. data/actioncable/lib/action_cable/connection/base.rb +260 -0
  45. data/actioncable/lib/action_cable/connection/client_socket.rb +157 -0
  46. data/actioncable/lib/action_cable/connection/identification.rb +47 -0
  47. data/actioncable/lib/action_cable/connection/internal_channel.rb +45 -0
  48. data/actioncable/lib/action_cable/connection/message_buffer.rb +57 -0
  49. data/actioncable/lib/action_cable/connection/stream.rb +115 -0
  50. data/actioncable/lib/action_cable/connection/stream_event_loop.rb +136 -0
  51. data/actioncable/lib/action_cable/connection/subscriptions.rb +83 -0
  52. data/actioncable/lib/action_cable/connection/tagged_logger_proxy.rb +42 -0
  53. data/actioncable/lib/action_cable/connection/web_socket.rb +43 -0
  54. data/actioncable/lib/action_cable/engine.rb +79 -0
  55. data/actioncable/lib/action_cable/gem_version.rb +17 -0
  56. data/actioncable/lib/action_cable/helpers/action_cable_helper.rb +42 -0
  57. data/actioncable/lib/action_cable/remote_connections.rb +69 -0
  58. data/actioncable/lib/action_cable/server.rb +17 -0
  59. data/actioncable/lib/action_cable/server/base.rb +89 -0
  60. data/actioncable/lib/action_cable/server/broadcasting.rb +54 -0
  61. data/actioncable/lib/action_cable/server/configuration.rb +43 -0
  62. data/actioncable/lib/action_cable/server/connections.rb +36 -0
  63. data/actioncable/lib/action_cable/server/worker.rb +77 -0
  64. data/actioncable/lib/action_cable/server/worker/active_record_connection_management.rb +21 -0
  65. data/actioncable/lib/action_cable/subscription_adapter.rb +11 -0
  66. data/actioncable/lib/action_cable/subscription_adapter/async.rb +29 -0
  67. data/actioncable/lib/action_cable/subscription_adapter/base.rb +30 -0
  68. data/actioncable/lib/action_cable/subscription_adapter/channel_prefix.rb +28 -0
  69. data/actioncable/lib/action_cable/subscription_adapter/evented_redis.rb +89 -0
  70. data/actioncable/lib/action_cable/subscription_adapter/inline.rb +37 -0
  71. data/actioncable/lib/action_cable/subscription_adapter/postgresql.rb +114 -0
  72. data/actioncable/lib/action_cable/subscription_adapter/redis.rb +178 -0
  73. data/actioncable/lib/action_cable/subscription_adapter/subscriber_map.rb +59 -0
  74. data/actioncable/lib/action_cable/version.rb +10 -0
  75. data/actioncable/lib/rails/generators/channel/USAGE +14 -0
  76. data/actioncable/lib/rails/generators/channel/channel_generator.rb +49 -0
  77. data/actioncable/lib/rails/generators/channel/templates/application_cable/channel.rb +4 -0
  78. data/actioncable/lib/rails/generators/channel/templates/application_cable/connection.rb +4 -0
  79. data/actioncable/lib/rails/generators/channel/templates/assets/cable.js +13 -0
  80. data/actioncable/lib/rails/generators/channel/templates/assets/channel.coffee +14 -0
  81. data/actioncable/lib/rails/generators/channel/templates/assets/channel.js +18 -0
  82. data/actioncable/lib/rails/generators/channel/templates/channel.rb +16 -0
  83. data/actioncable/package.json +24 -0
  84. data/actioncable/test/channel/base_test.rb +272 -0
  85. data/actioncable/test/channel/broadcasting_test.rb +31 -0
  86. data/actioncable/test/channel/naming_test.rb +12 -0
  87. data/actioncable/test/channel/periodic_timers_test.rb +74 -0
  88. data/actioncable/test/channel/rejection_test.rb +43 -0
  89. data/actioncable/test/channel/stream_test.rb +208 -0
  90. data/actioncable/test/client_test.rb +313 -0
  91. data/actioncable/test/connection/authorization_test.rb +33 -0
  92. data/actioncable/test/connection/base_test.rb +141 -0
  93. data/actioncable/test/connection/client_socket_test.rb +84 -0
  94. data/actioncable/test/connection/cross_site_forgery_test.rb +92 -0
  95. data/actioncable/test/connection/identifier_test.rb +77 -0
  96. data/actioncable/test/connection/multiple_identifiers_test.rb +39 -0
  97. data/actioncable/test/connection/stream_test.rb +66 -0
  98. data/actioncable/test/connection/string_identifier_test.rb +41 -0
  99. data/actioncable/test/connection/subscriptions_test.rb +116 -0
  100. data/actioncable/test/javascript/src/test.coffee +3 -0
  101. data/actioncable/test/javascript/src/test_helpers/consumer_test_helper.coffee +47 -0
  102. data/actioncable/test/javascript/src/test_helpers/index.coffee +11 -0
  103. data/actioncable/test/javascript/src/unit/action_cable_test.coffee +41 -0
  104. data/actioncable/test/javascript/src/unit/consumer_test.coffee +14 -0
  105. data/actioncable/test/javascript/src/unit/subscription_test.coffee +40 -0
  106. data/actioncable/test/javascript/src/unit/subscriptions_test.coffee +25 -0
  107. data/actioncable/test/javascript/vendor/mock-socket.js +4533 -0
  108. data/actioncable/test/server/base_test.rb +35 -0
  109. data/actioncable/test/server/broadcasting_test.rb +62 -0
  110. data/actioncable/test/stubs/global_id.rb +10 -0
  111. data/actioncable/test/stubs/room.rb +18 -0
  112. data/actioncable/test/stubs/test_adapter.rb +12 -0
  113. data/actioncable/test/stubs/test_connection.rb +35 -0
  114. data/actioncable/test/stubs/test_server.rb +32 -0
  115. data/actioncable/test/stubs/user.rb +17 -0
  116. data/actioncable/test/subscription_adapter/async_test.rb +19 -0
  117. data/actioncable/test/subscription_adapter/base_test.rb +65 -0
  118. data/actioncable/test/subscription_adapter/channel_prefix.rb +38 -0
  119. data/actioncable/test/subscription_adapter/common.rb +131 -0
  120. data/actioncable/test/subscription_adapter/evented_redis_test.rb +61 -0
  121. data/actioncable/test/subscription_adapter/inline_test.rb +19 -0
  122. data/actioncable/test/subscription_adapter/postgresql_test.rb +42 -0
  123. data/actioncable/test/subscription_adapter/redis_test.rb +28 -0
  124. data/actioncable/test/subscription_adapter/subscriber_map_test.rb +19 -0
  125. data/actioncable/test/test_helper.rb +37 -0
  126. data/actioncable/test/worker_test.rb +46 -0
  127. data/actionmailer/CHANGELOG.md +12 -0
  128. data/actionmailer/MIT-LICENSE +21 -0
  129. data/actionmailer/README.rdoc +175 -0
  130. data/actionmailer/Rakefile +25 -0
  131. data/actionmailer/actionmailer.gemspec +35 -0
  132. data/actionmailer/bin/test +5 -0
  133. data/actionmailer/lib/action_mailer.rb +62 -0
  134. data/actionmailer/lib/action_mailer/base.rb +981 -0
  135. data/actionmailer/lib/action_mailer/collector.rb +32 -0
  136. data/actionmailer/lib/action_mailer/delivery_job.rb +36 -0
  137. data/actionmailer/lib/action_mailer/delivery_methods.rb +82 -0
  138. data/actionmailer/lib/action_mailer/gem_version.rb +17 -0
  139. data/actionmailer/lib/action_mailer/inline_preview_interceptor.rb +59 -0
  140. data/actionmailer/lib/action_mailer/log_subscriber.rb +41 -0
  141. data/actionmailer/lib/action_mailer/mail_helper.rb +72 -0
  142. data/actionmailer/lib/action_mailer/message_delivery.rb +144 -0
  143. data/actionmailer/lib/action_mailer/parameterized.rb +154 -0
  144. data/actionmailer/lib/action_mailer/preview.rb +126 -0
  145. data/actionmailer/lib/action_mailer/railtie.rb +82 -0
  146. data/actionmailer/lib/action_mailer/rescuable.rb +29 -0
  147. data/actionmailer/lib/action_mailer/test_case.rb +123 -0
  148. data/actionmailer/lib/action_mailer/test_helper.rb +115 -0
  149. data/actionmailer/lib/action_mailer/version.rb +11 -0
  150. data/actionmailer/lib/rails/generators/mailer/USAGE +17 -0
  151. data/actionmailer/lib/rails/generators/mailer/mailer_generator.rb +38 -0
  152. data/actionmailer/lib/rails/generators/mailer/templates/application_mailer.rb +6 -0
  153. data/actionmailer/lib/rails/generators/mailer/templates/mailer.rb +17 -0
  154. data/actionmailer/test/abstract_unit.rb +47 -0
  155. data/actionmailer/test/assert_select_email_test.rb +49 -0
  156. data/actionmailer/test/asset_host_test.rb +39 -0
  157. data/actionmailer/test/base_test.rb +987 -0
  158. data/actionmailer/test/caching_test.rb +271 -0
  159. data/actionmailer/test/delivery_methods_test.rb +248 -0
  160. data/actionmailer/test/fixtures/anonymous/welcome.erb +1 -0
  161. data/actionmailer/test/fixtures/another.path/base_mailer/welcome.erb +1 -0
  162. data/actionmailer/test/fixtures/asset_host_mailer/email_with_asset.html.erb +1 -0
  163. data/actionmailer/test/fixtures/asset_mailer/welcome.html.erb +1 -0
  164. data/actionmailer/test/fixtures/attachments/foo.jpg +0 -0
  165. data/actionmailer/test/fixtures/attachments/test.jpg +0 -0
  166. data/actionmailer/test/fixtures/auto_layout_mailer/hello.html.erb +1 -0
  167. data/actionmailer/test/fixtures/auto_layout_mailer/multipart.html.erb +1 -0
  168. data/actionmailer/test/fixtures/auto_layout_mailer/multipart.text.erb +1 -0
  169. data/actionmailer/test/fixtures/base_mailer/attachment_with_content.erb +1 -0
  170. data/actionmailer/test/fixtures/base_mailer/attachment_with_hash.html.erb +0 -0
  171. data/actionmailer/test/fixtures/base_mailer/attachment_with_hash_default_encoding.html.erb +0 -0
  172. data/actionmailer/test/fixtures/base_mailer/different_layout.html.erb +1 -0
  173. data/actionmailer/test/fixtures/base_mailer/different_layout.text.erb +1 -0
  174. data/actionmailer/test/fixtures/base_mailer/email_with_translations.html.erb +1 -0
  175. data/actionmailer/test/fixtures/base_mailer/explicit_multipart_templates.html.erb +1 -0
  176. data/actionmailer/test/fixtures/base_mailer/explicit_multipart_templates.text.erb +1 -0
  177. data/actionmailer/test/fixtures/base_mailer/explicit_multipart_with_one_template.erb +1 -0
  178. data/actionmailer/test/fixtures/base_mailer/html_only.html.erb +1 -0
  179. data/actionmailer/test/fixtures/base_mailer/implicit_multipart.html.erb +1 -0
  180. data/actionmailer/test/fixtures/base_mailer/implicit_multipart.text.erb +1 -0
  181. data/actionmailer/test/fixtures/base_mailer/implicit_with_locale.de-AT.text.erb +1 -0
  182. data/actionmailer/test/fixtures/base_mailer/implicit_with_locale.de.html.erb +1 -0
  183. data/actionmailer/test/fixtures/base_mailer/implicit_with_locale.en.html.erb +1 -0
  184. data/actionmailer/test/fixtures/base_mailer/implicit_with_locale.html.erb +1 -0
  185. data/actionmailer/test/fixtures/base_mailer/implicit_with_locale.pl.text.erb +1 -0
  186. data/actionmailer/test/fixtures/base_mailer/implicit_with_locale.text.erb +1 -0
  187. data/actionmailer/test/fixtures/base_mailer/inline_attachment.html.erb +5 -0
  188. data/actionmailer/test/fixtures/base_mailer/inline_attachment.text.erb +4 -0
  189. data/actionmailer/test/fixtures/base_mailer/plain_text_only.text.erb +1 -0
  190. data/actionmailer/test/fixtures/base_mailer/welcome.erb +1 -0
  191. data/actionmailer/test/fixtures/base_mailer/welcome_with_headers.html.erb +0 -0
  192. data/actionmailer/test/fixtures/base_mailer/without_mail_call.erb +1 -0
  193. data/actionmailer/test/fixtures/base_test/after_action_mailer/welcome.html.erb +0 -0
  194. data/actionmailer/test/fixtures/base_test/before_action_mailer/welcome.html.erb +0 -0
  195. data/actionmailer/test/fixtures/base_test/default_inline_attachment_mailer/welcome.html.erb +0 -0
  196. data/actionmailer/test/fixtures/base_test/late_inline_attachment_mailer/on_render.erb +7 -0
  197. data/actionmailer/test/fixtures/caching_mailer/_partial.html.erb +3 -0
  198. data/actionmailer/test/fixtures/caching_mailer/fragment_cache.html.erb +3 -0
  199. data/actionmailer/test/fixtures/caching_mailer/fragment_cache_in_partials.html.erb +1 -0
  200. data/actionmailer/test/fixtures/caching_mailer/fragment_caching_options.html.erb +3 -0
  201. data/actionmailer/test/fixtures/caching_mailer/multipart_cache.html.erb +3 -0
  202. data/actionmailer/test/fixtures/caching_mailer/multipart_cache.text.erb +3 -0
  203. data/actionmailer/test/fixtures/caching_mailer/skip_fragment_cache_digesting.html.erb +3 -0
  204. data/actionmailer/test/fixtures/explicit_layout_mailer/logout.html.erb +1 -0
  205. data/actionmailer/test/fixtures/explicit_layout_mailer/signup.html.erb +1 -0
  206. data/actionmailer/test/fixtures/i18n_test_mailer/mail_with_i18n_subject.erb +4 -0
  207. data/actionmailer/test/fixtures/layouts/auto_layout_mailer.html.erb +1 -0
  208. data/actionmailer/test/fixtures/layouts/auto_layout_mailer.text.erb +1 -0
  209. data/actionmailer/test/fixtures/layouts/different_layout.html.erb +1 -0
  210. data/actionmailer/test/fixtures/layouts/different_layout.text.erb +1 -0
  211. data/actionmailer/test/fixtures/layouts/spam.html.erb +1 -0
  212. data/actionmailer/test/fixtures/mail_delivery_test/delivery_mailer/welcome.html.erb +0 -0
  213. data/actionmailer/test/fixtures/nested_layout_mailer/signup.html.erb +1 -0
  214. data/actionmailer/test/fixtures/proc_mailer/welcome.html.erb +0 -0
  215. data/actionmailer/test/fixtures/raw_email +14 -0
  216. data/actionmailer/test/fixtures/templates/signed_up.erb +3 -0
  217. data/actionmailer/test/fixtures/test_helper_mailer/welcome +1 -0
  218. data/actionmailer/test/fixtures/url_test_mailer/exercise_url_for.erb +1 -0
  219. data/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb +5 -0
  220. data/actionmailer/test/i18n_with_controller_test.rb +77 -0
  221. data/actionmailer/test/log_subscriber_test.rb +49 -0
  222. data/actionmailer/test/mail_helper_test.rb +125 -0
  223. data/actionmailer/test/mail_layout_test.rb +97 -0
  224. data/actionmailer/test/mailers/asset_mailer.rb +9 -0
  225. data/actionmailer/test/mailers/base_mailer.rb +138 -0
  226. data/actionmailer/test/mailers/caching_mailer.rb +25 -0
  227. data/actionmailer/test/mailers/delayed_mailer.rb +28 -0
  228. data/actionmailer/test/mailers/params_mailer.rb +13 -0
  229. data/actionmailer/test/mailers/proc_mailer.rb +18 -0
  230. data/actionmailer/test/message_delivery_test.rb +167 -0
  231. data/actionmailer/test/parameterized_test.rb +56 -0
  232. data/actionmailer/test/test_case_test.rb +68 -0
  233. data/actionmailer/test/test_helper_test.rb +223 -0
  234. data/actionmailer/test/url_test.rb +144 -0
  235. data/actionpack/CHANGELOG.md +75 -0
  236. data/actionpack/MIT-LICENSE +21 -0
  237. data/actionpack/README.rdoc +57 -0
  238. data/actionpack/Rakefile +40 -0
  239. data/actionpack/actionpack.gemspec +38 -0
  240. data/actionpack/bin/test +5 -0
  241. data/actionpack/lib/abstract_controller.rb +26 -0
  242. data/actionpack/lib/abstract_controller/asset_paths.rb +12 -0
  243. data/actionpack/lib/abstract_controller/base.rb +267 -0
  244. data/actionpack/lib/abstract_controller/caching.rb +66 -0
  245. data/actionpack/lib/abstract_controller/caching/fragments.rb +166 -0
  246. data/actionpack/lib/abstract_controller/callbacks.rb +212 -0
  247. data/actionpack/lib/abstract_controller/collector.rb +43 -0
  248. data/actionpack/lib/abstract_controller/error.rb +6 -0
  249. data/actionpack/lib/abstract_controller/helpers.rb +194 -0
  250. data/actionpack/lib/abstract_controller/logger.rb +14 -0
  251. data/actionpack/lib/abstract_controller/railties/routes_helpers.rb +20 -0
  252. data/actionpack/lib/abstract_controller/rendering.rb +136 -0
  253. data/actionpack/lib/abstract_controller/translation.rb +31 -0
  254. data/actionpack/lib/abstract_controller/url_for.rb +35 -0
  255. data/actionpack/lib/action_controller.rb +65 -0
  256. data/actionpack/lib/action_controller/api.rb +149 -0
  257. data/actionpack/lib/action_controller/api/api_rendering.rb +16 -0
  258. data/actionpack/lib/action_controller/base.rb +275 -0
  259. data/actionpack/lib/action_controller/caching.rb +46 -0
  260. data/actionpack/lib/action_controller/form_builder.rb +50 -0
  261. data/actionpack/lib/action_controller/log_subscriber.rb +78 -0
  262. data/actionpack/lib/action_controller/metal.rb +258 -0
  263. data/actionpack/lib/action_controller/metal/basic_implicit_render.rb +13 -0
  264. data/actionpack/lib/action_controller/metal/conditional_get.rb +274 -0
  265. data/actionpack/lib/action_controller/metal/cookies.rb +16 -0
  266. data/actionpack/lib/action_controller/metal/data_streaming.rb +152 -0
  267. data/actionpack/lib/action_controller/metal/etag_with_flash.rb +18 -0
  268. data/actionpack/lib/action_controller/metal/etag_with_template_digest.rb +57 -0
  269. data/actionpack/lib/action_controller/metal/exceptions.rb +56 -0
  270. data/actionpack/lib/action_controller/metal/flash.rb +61 -0
  271. data/actionpack/lib/action_controller/metal/force_ssl.rb +99 -0
  272. data/actionpack/lib/action_controller/metal/head.rb +60 -0
  273. data/actionpack/lib/action_controller/metal/helpers.rb +123 -0
  274. data/actionpack/lib/action_controller/metal/http_authentication.rb +522 -0
  275. data/actionpack/lib/action_controller/metal/implicit_render.rb +73 -0
  276. data/actionpack/lib/action_controller/metal/instrumentation.rb +111 -0
  277. data/actionpack/lib/action_controller/metal/live.rb +312 -0
  278. data/actionpack/lib/action_controller/metal/mime_responds.rb +313 -0
  279. data/actionpack/lib/action_controller/metal/parameter_encoding.rb +51 -0
  280. data/actionpack/lib/action_controller/metal/params_wrapper.rb +285 -0
  281. data/actionpack/lib/action_controller/metal/redirecting.rb +124 -0
  282. data/actionpack/lib/action_controller/metal/renderers.rb +181 -0
  283. data/actionpack/lib/action_controller/metal/rendering.rb +124 -0
  284. data/actionpack/lib/action_controller/metal/request_forgery_protection.rb +433 -0
  285. data/actionpack/lib/action_controller/metal/rescue.rb +28 -0
  286. data/actionpack/lib/action_controller/metal/streaming.rb +223 -0
  287. data/actionpack/lib/action_controller/metal/strong_parameters.rb +1085 -0
  288. data/actionpack/lib/action_controller/metal/testing.rb +22 -0
  289. data/actionpack/lib/action_controller/metal/url_for.rb +58 -0
  290. data/actionpack/lib/action_controller/railtie.rb +89 -0
  291. data/actionpack/lib/action_controller/railties/helpers.rb +24 -0
  292. data/actionpack/lib/action_controller/renderer.rb +117 -0
  293. data/actionpack/lib/action_controller/template_assertions.rb +11 -0
  294. data/actionpack/lib/action_controller/test_case.rb +626 -0
  295. data/actionpack/lib/action_dispatch.rb +111 -0
  296. data/actionpack/lib/action_dispatch/http/cache.rb +216 -0
  297. data/actionpack/lib/action_dispatch/http/filter_parameters.rb +84 -0
  298. data/actionpack/lib/action_dispatch/http/filter_redirect.rb +37 -0
  299. data/actionpack/lib/action_dispatch/http/headers.rb +132 -0
  300. data/actionpack/lib/action_dispatch/http/mime_negotiation.rb +173 -0
  301. data/actionpack/lib/action_dispatch/http/mime_type.rb +342 -0
  302. data/actionpack/lib/action_dispatch/http/mime_types.rb +37 -0
  303. data/actionpack/lib/action_dispatch/http/parameter_filter.rb +86 -0
  304. data/actionpack/lib/action_dispatch/http/parameters.rb +131 -0
  305. data/actionpack/lib/action_dispatch/http/rack_cache.rb +63 -0
  306. data/actionpack/lib/action_dispatch/http/request.rb +412 -0
  307. data/actionpack/lib/action_dispatch/http/response.rb +519 -0
  308. data/actionpack/lib/action_dispatch/http/upload.rb +84 -0
  309. data/actionpack/lib/action_dispatch/http/url.rb +350 -0
  310. data/actionpack/lib/action_dispatch/journey.rb +7 -0
  311. data/actionpack/lib/action_dispatch/journey/formatter.rb +189 -0
  312. data/actionpack/lib/action_dispatch/journey/gtg/builder.rb +164 -0
  313. data/actionpack/lib/action_dispatch/journey/gtg/simulator.rb +41 -0
  314. data/actionpack/lib/action_dispatch/journey/gtg/transition_table.rb +158 -0
  315. data/actionpack/lib/action_dispatch/journey/nfa/builder.rb +78 -0
  316. data/actionpack/lib/action_dispatch/journey/nfa/dot.rb +36 -0
  317. data/actionpack/lib/action_dispatch/journey/nfa/simulator.rb +49 -0
  318. data/actionpack/lib/action_dispatch/journey/nfa/transition_table.rb +120 -0
  319. data/actionpack/lib/action_dispatch/journey/nodes/node.rb +140 -0
  320. data/actionpack/lib/action_dispatch/journey/parser.rb +199 -0
  321. data/actionpack/lib/action_dispatch/journey/parser.y +50 -0
  322. data/actionpack/lib/action_dispatch/journey/parser_extras.rb +31 -0
  323. data/actionpack/lib/action_dispatch/journey/path/pattern.rb +198 -0
  324. data/actionpack/lib/action_dispatch/journey/route.rb +203 -0
  325. data/actionpack/lib/action_dispatch/journey/router.rb +156 -0
  326. data/actionpack/lib/action_dispatch/journey/router/utils.rb +102 -0
  327. data/actionpack/lib/action_dispatch/journey/routes.rb +81 -0
  328. data/actionpack/lib/action_dispatch/journey/scanner.rb +64 -0
  329. data/actionpack/lib/action_dispatch/journey/visitors.rb +268 -0
  330. data/actionpack/lib/action_dispatch/journey/visualizer/fsm.css +30 -0
  331. data/actionpack/lib/action_dispatch/journey/visualizer/fsm.js +134 -0
  332. data/actionpack/lib/action_dispatch/journey/visualizer/index.html.erb +52 -0
  333. data/actionpack/lib/action_dispatch/middleware/callbacks.rb +36 -0
  334. data/actionpack/lib/action_dispatch/middleware/cookies.rb +686 -0
  335. data/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +205 -0
  336. data/actionpack/lib/action_dispatch/middleware/debug_locks.rb +124 -0
  337. data/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb +146 -0
  338. data/actionpack/lib/action_dispatch/middleware/executor.rb +21 -0
  339. data/actionpack/lib/action_dispatch/middleware/flash.rb +300 -0
  340. data/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +57 -0
  341. data/actionpack/lib/action_dispatch/middleware/reloader.rb +12 -0
  342. data/actionpack/lib/action_dispatch/middleware/remote_ip.rb +183 -0
  343. data/actionpack/lib/action_dispatch/middleware/request_id.rb +43 -0
  344. data/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +92 -0
  345. data/actionpack/lib/action_dispatch/middleware/session/cache_store.rb +54 -0
  346. data/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb +131 -0
  347. data/actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb +28 -0
  348. data/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +62 -0
  349. data/actionpack/lib/action_dispatch/middleware/ssl.rb +144 -0
  350. data/actionpack/lib/action_dispatch/middleware/stack.rb +116 -0
  351. data/actionpack/lib/action_dispatch/middleware/static.rb +130 -0
  352. data/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +22 -0
  353. data/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +23 -0
  354. data/actionpack/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +27 -0
  355. data/actionpack/lib/action_dispatch/middleware/templates/rescues/_source.text.erb +8 -0
  356. data/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +52 -0
  357. data/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb +9 -0
  358. data/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +16 -0
  359. data/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +9 -0
  360. data/actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb +160 -0
  361. data/actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +11 -0
  362. data/actionpack/lib/action_dispatch/middleware/templates/rescues/missing_template.text.erb +3 -0
  363. data/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +32 -0
  364. data/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +11 -0
  365. data/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +20 -0
  366. data/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb +7 -0
  367. data/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +6 -0
  368. data/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.text.erb +3 -0
  369. data/actionpack/lib/action_dispatch/middleware/templates/routes/_route.html.erb +16 -0
  370. data/actionpack/lib/action_dispatch/middleware/templates/routes/_table.html.erb +200 -0
  371. data/actionpack/lib/action_dispatch/railtie.rb +50 -0
  372. data/actionpack/lib/action_dispatch/request/session.rb +233 -0
  373. data/actionpack/lib/action_dispatch/request/utils.rb +76 -0
  374. data/actionpack/lib/action_dispatch/routing.rb +260 -0
  375. data/actionpack/lib/action_dispatch/routing/endpoint.rb +12 -0
  376. data/actionpack/lib/action_dispatch/routing/inspector.rb +225 -0
  377. data/actionpack/lib/action_dispatch/routing/mapper.rb +2256 -0
  378. data/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +352 -0
  379. data/actionpack/lib/action_dispatch/routing/redirection.rb +201 -0
  380. data/actionpack/lib/action_dispatch/routing/route_set.rb +870 -0
  381. data/actionpack/lib/action_dispatch/routing/routes_proxy.rb +69 -0
  382. data/actionpack/lib/action_dispatch/routing/url_for.rb +218 -0
  383. data/actionpack/lib/action_dispatch/system_test_case.rb +133 -0
  384. data/actionpack/lib/action_dispatch/system_testing/driver.rb +55 -0
  385. data/actionpack/lib/action_dispatch/system_testing/server.rb +45 -0
  386. data/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +100 -0
  387. data/actionpack/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +27 -0
  388. data/actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +26 -0
  389. data/actionpack/lib/action_dispatch/testing/assertion_response.rb +47 -0
  390. data/actionpack/lib/action_dispatch/testing/assertions.rb +24 -0
  391. data/actionpack/lib/action_dispatch/testing/assertions/response.rb +107 -0
  392. data/actionpack/lib/action_dispatch/testing/assertions/routing.rb +222 -0
  393. data/actionpack/lib/action_dispatch/testing/integration.rb +652 -0
  394. data/actionpack/lib/action_dispatch/testing/request_encoder.rb +55 -0
  395. data/actionpack/lib/action_dispatch/testing/test_process.rb +50 -0
  396. data/actionpack/lib/action_dispatch/testing/test_request.rb +71 -0
  397. data/actionpack/lib/action_dispatch/testing/test_response.rb +53 -0
  398. data/actionpack/lib/action_pack.rb +26 -0
  399. data/actionpack/lib/action_pack/gem_version.rb +17 -0
  400. data/actionpack/lib/action_pack/version.rb +10 -0
  401. data/actionpack/test/abstract/callbacks_test.rb +270 -0
  402. data/actionpack/test/abstract/collector_test.rb +65 -0
  403. data/actionpack/test/abstract/translation_test.rb +79 -0
  404. data/actionpack/test/abstract_unit.rb +451 -0
  405. data/actionpack/test/assertions/response_assertions_test.rb +141 -0
  406. data/actionpack/test/controller/action_pack_assertions_test.rb +493 -0
  407. data/actionpack/test/controller/api/conditional_get_test.rb +59 -0
  408. data/actionpack/test/controller/api/data_streaming_test.rb +28 -0
  409. data/actionpack/test/controller/api/force_ssl_test.rb +22 -0
  410. data/actionpack/test/controller/api/implicit_render_test.rb +17 -0
  411. data/actionpack/test/controller/api/params_wrapper_test.rb +28 -0
  412. data/actionpack/test/controller/api/redirect_to_test.rb +21 -0
  413. data/actionpack/test/controller/api/renderers_test.rb +50 -0
  414. data/actionpack/test/controller/api/url_for_test.rb +22 -0
  415. data/actionpack/test/controller/api/with_cookies_test.rb +23 -0
  416. data/actionpack/test/controller/api/with_helpers_test.rb +44 -0
  417. data/actionpack/test/controller/base_test.rb +323 -0
  418. data/actionpack/test/controller/caching_test.rb +503 -0
  419. data/actionpack/test/controller/content_type_test.rb +169 -0
  420. data/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
  421. data/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
  422. data/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
  423. data/actionpack/test/controller/default_url_options_with_before_action_test.rb +28 -0
  424. data/actionpack/test/controller/filters_test.rb +1050 -0
  425. data/actionpack/test/controller/flash_hash_test.rb +216 -0
  426. data/actionpack/test/controller/flash_test.rb +371 -0
  427. data/actionpack/test/controller/force_ssl_test.rb +333 -0
  428. data/actionpack/test/controller/form_builder_test.rb +19 -0
  429. data/actionpack/test/controller/helper_test.rb +295 -0
  430. data/actionpack/test/controller/http_basic_authentication_test.rb +179 -0
  431. data/actionpack/test/controller/http_digest_authentication_test.rb +282 -0
  432. data/actionpack/test/controller/http_token_authentication_test.rb +216 -0
  433. data/actionpack/test/controller/integration_test.rb +1122 -0
  434. data/actionpack/test/controller/live_stream_test.rb +518 -0
  435. data/actionpack/test/controller/localized_templates_test.rb +48 -0
  436. data/actionpack/test/controller/log_subscriber_test.rb +371 -0
  437. data/actionpack/test/controller/metal/renderers_test.rb +50 -0
  438. data/actionpack/test/controller/metal_test.rb +32 -0
  439. data/actionpack/test/controller/mime/accept_format_test.rb +94 -0
  440. data/actionpack/test/controller/mime/respond_to_test.rb +843 -0
  441. data/actionpack/test/controller/new_base/bare_metal_test.rb +184 -0
  442. data/actionpack/test/controller/new_base/base_test.rb +134 -0
  443. data/actionpack/test/controller/new_base/content_negotiation_test.rb +28 -0
  444. data/actionpack/test/controller/new_base/content_type_test.rb +116 -0
  445. data/actionpack/test/controller/new_base/middleware_test.rb +112 -0
  446. data/actionpack/test/controller/new_base/render_action_test.rb +314 -0
  447. data/actionpack/test/controller/new_base/render_body_test.rb +172 -0
  448. data/actionpack/test/controller/new_base/render_context_test.rb +54 -0
  449. data/actionpack/test/controller/new_base/render_file_test.rb +72 -0
  450. data/actionpack/test/controller/new_base/render_html_test.rb +192 -0
  451. data/actionpack/test/controller/new_base/render_implicit_action_test.rb +59 -0
  452. data/actionpack/test/controller/new_base/render_layout_test.rb +128 -0
  453. data/actionpack/test/controller/new_base/render_partial_test.rb +62 -0
  454. data/actionpack/test/controller/new_base/render_plain_test.rb +170 -0
  455. data/actionpack/test/controller/new_base/render_streaming_test.rb +116 -0
  456. data/actionpack/test/controller/new_base/render_template_test.rb +240 -0
  457. data/actionpack/test/controller/new_base/render_test.rb +142 -0
  458. data/actionpack/test/controller/new_base/render_xml_test.rb +12 -0
  459. data/actionpack/test/controller/output_escaping_test.rb +17 -0
  460. data/actionpack/test/controller/parameter_encoding_test.rb +52 -0
  461. data/actionpack/test/controller/parameters/accessors_test.rb +279 -0
  462. data/actionpack/test/controller/parameters/always_permitted_parameters_test.rb +30 -0
  463. data/actionpack/test/controller/parameters/dup_test.rb +67 -0
  464. data/actionpack/test/controller/parameters/log_on_unpermitted_params_test.rb +70 -0
  465. data/actionpack/test/controller/parameters/multi_parameter_attributes_test.rb +39 -0
  466. data/actionpack/test/controller/parameters/mutators_test.rb +122 -0
  467. data/actionpack/test/controller/parameters/nested_parameters_permit_test.rb +184 -0
  468. data/actionpack/test/controller/parameters/parameters_permit_test.rb +513 -0
  469. data/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb +33 -0
  470. data/actionpack/test/controller/parameters/serialization_test.rb +55 -0
  471. data/actionpack/test/controller/params_wrapper_test.rb +408 -0
  472. data/actionpack/test/controller/permitted_params_test.rb +27 -0
  473. data/actionpack/test/controller/redirect_test.rb +358 -0
  474. data/actionpack/test/controller/render_js_test.rb +36 -0
  475. data/actionpack/test/controller/render_json_test.rb +137 -0
  476. data/actionpack/test/controller/render_test.rb +810 -0
  477. data/actionpack/test/controller/render_xml_test.rb +102 -0
  478. data/actionpack/test/controller/renderer_test.rb +136 -0
  479. data/actionpack/test/controller/renderers_test.rb +91 -0
  480. data/actionpack/test/controller/request/test_request_test.rb +42 -0
  481. data/actionpack/test/controller/request_forgery_protection_test.rb +998 -0
  482. data/actionpack/test/controller/required_params_test.rb +100 -0
  483. data/actionpack/test/controller/rescue_test.rb +364 -0
  484. data/actionpack/test/controller/resources_test.rb +1369 -0
  485. data/actionpack/test/controller/routing_test.rb +2108 -0
  486. data/actionpack/test/controller/runner_test.rb +24 -0
  487. data/actionpack/test/controller/send_file_test.rb +259 -0
  488. data/actionpack/test/controller/show_exceptions_test.rb +114 -0
  489. data/actionpack/test/controller/streaming_test.rb +28 -0
  490. data/actionpack/test/controller/test_case_test.rb +1120 -0
  491. data/actionpack/test/controller/url_for_integration_test.rb +193 -0
  492. data/actionpack/test/controller/url_for_test.rb +519 -0
  493. data/actionpack/test/controller/url_rewriter_test.rb +92 -0
  494. data/actionpack/test/controller/webservice_test.rb +135 -0
  495. data/actionpack/test/dispatch/callbacks_test.rb +47 -0
  496. data/actionpack/test/dispatch/cookies_test.rb +1288 -0
  497. data/actionpack/test/dispatch/debug_exceptions_test.rb +502 -0
  498. data/actionpack/test/dispatch/debug_locks_test.rb +38 -0
  499. data/actionpack/test/dispatch/exception_wrapper_test.rb +120 -0
  500. data/actionpack/test/dispatch/executor_test.rb +136 -0
  501. data/actionpack/test/dispatch/header_test.rb +169 -0
  502. data/actionpack/test/dispatch/live_response_test.rb +98 -0
  503. data/actionpack/test/dispatch/mapper_test.rb +210 -0
  504. data/actionpack/test/dispatch/middleware_stack_test.rb +115 -0
  505. data/actionpack/test/dispatch/mime_type_test.rb +187 -0
  506. data/actionpack/test/dispatch/mount_test.rb +95 -0
  507. data/actionpack/test/dispatch/prefix_generation_test.rb +463 -0
  508. data/actionpack/test/dispatch/rack_cache_test.rb +23 -0
  509. data/actionpack/test/dispatch/reloader_test.rb +167 -0
  510. data/actionpack/test/dispatch/request/json_params_parsing_test.rb +207 -0
  511. data/actionpack/test/dispatch/request/multipart_params_parsing_test.rb +202 -0
  512. data/actionpack/test/dispatch/request/query_string_parsing_test.rb +176 -0
  513. data/actionpack/test/dispatch/request/session_test.rb +164 -0
  514. data/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb +181 -0
  515. data/actionpack/test/dispatch/request_id_test.rb +70 -0
  516. data/actionpack/test/dispatch/request_test.rb +1306 -0
  517. data/actionpack/test/dispatch/response_test.rb +536 -0
  518. data/actionpack/test/dispatch/routing/concerns_test.rb +124 -0
  519. data/actionpack/test/dispatch/routing/custom_url_helpers_test.rb +333 -0
  520. data/actionpack/test/dispatch/routing/inspector_test.rb +425 -0
  521. data/actionpack/test/dispatch/routing/ipv6_redirect_test.rb +46 -0
  522. data/actionpack/test/dispatch/routing/route_set_test.rb +166 -0
  523. data/actionpack/test/dispatch/routing_assertions_test.rb +132 -0
  524. data/actionpack/test/dispatch/routing_test.rb +5055 -0
  525. data/actionpack/test/dispatch/runner_test.rb +19 -0
  526. data/actionpack/test/dispatch/session/abstract_store_test.rb +58 -0
  527. data/actionpack/test/dispatch/session/cache_store_test.rb +183 -0
  528. data/actionpack/test/dispatch/session/cookie_store_test.rb +370 -0
  529. data/actionpack/test/dispatch/session/mem_cache_store_test.rb +205 -0
  530. data/actionpack/test/dispatch/session/test_session_test.rb +65 -0
  531. data/actionpack/test/dispatch/show_exceptions_test.rb +138 -0
  532. data/actionpack/test/dispatch/ssl_test.rb +220 -0
  533. data/actionpack/test/dispatch/static_test.rb +309 -0
  534. data/actionpack/test/dispatch/system_testing/driver_test.rb +37 -0
  535. data/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb +74 -0
  536. data/actionpack/test/dispatch/system_testing/server_test.rb +19 -0
  537. data/actionpack/test/dispatch/system_testing/system_test_case_test.rb +67 -0
  538. data/actionpack/test/dispatch/test_request_test.rb +131 -0
  539. data/actionpack/test/dispatch/test_response_test.rb +37 -0
  540. data/actionpack/test/dispatch/uploaded_file_test.rb +113 -0
  541. data/actionpack/test/dispatch/url_generation_test.rb +141 -0
  542. data/actionpack/test/fixtures/_top_level_partial_only.erb +1 -0
  543. data/actionpack/test/fixtures/alternate_helpers/foo_helper.rb +5 -0
  544. data/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
  545. data/actionpack/test/fixtures/collection_cache/index.html.erb +1 -0
  546. data/actionpack/test/fixtures/company.rb +11 -0
  547. data/actionpack/test/fixtures/customers/_commented_customer.html.erb +5 -0
  548. data/actionpack/test/fixtures/customers/_customer.html.erb +4 -0
  549. data/actionpack/test/fixtures/filter_test/implicit_actions/edit.html.erb +1 -0
  550. data/actionpack/test/fixtures/filter_test/implicit_actions/show.html.erb +1 -0
  551. data/actionpack/test/fixtures/functional_caching/_partial.erb +3 -0
  552. data/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +3 -0
  553. data/actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +5 -0
  554. data/actionpack/test/fixtures/functional_caching/formatted_fragment_cached_with_variant.html+phone.erb +3 -0
  555. data/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb +3 -0
  556. data/actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb +3 -0
  557. data/actionpack/test/fixtures/functional_caching/fragment_cached_without_digest.html.erb +3 -0
  558. data/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
  559. data/actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb +2 -0
  560. data/actionpack/test/fixtures/helpers/abc_helper.rb +5 -0
  561. data/actionpack/test/fixtures/helpers/fun/games_helper.rb +7 -0
  562. data/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +7 -0
  563. data/actionpack/test/fixtures/helpers/just_me_helper.rb +5 -0
  564. data/actionpack/test/fixtures/helpers/me_too_helper.rb +5 -0
  565. data/actionpack/test/fixtures/helpers1_pack/pack1_helper.rb +7 -0
  566. data/actionpack/test/fixtures/helpers2_pack/pack2_helper.rb +7 -0
  567. data/actionpack/test/fixtures/helpers_typo/admin/users_helper.rb +6 -0
  568. data/actionpack/test/fixtures/implicit_render_test/empty_action_with_mobile_variant.html+mobile.erb +1 -0
  569. data/actionpack/test/fixtures/implicit_render_test/empty_action_with_template.html.erb +1 -0
  570. data/actionpack/test/fixtures/layouts/_customers.erb +1 -0
  571. data/actionpack/test/fixtures/layouts/block_with_layout.erb +3 -0
  572. data/actionpack/test/fixtures/layouts/builder.builder +3 -0
  573. data/actionpack/test/fixtures/layouts/partial_with_layout.erb +3 -0
  574. data/actionpack/test/fixtures/layouts/standard.html.erb +1 -0
  575. data/actionpack/test/fixtures/layouts/talk_from_action.erb +2 -0
  576. data/actionpack/test/fixtures/layouts/with_html_partial.html.erb +1 -0
  577. data/actionpack/test/fixtures/layouts/xhr.html.erb +2 -0
  578. data/actionpack/test/fixtures/layouts/yield.erb +2 -0
  579. data/actionpack/test/fixtures/load_me.rb +4 -0
  580. data/actionpack/test/fixtures/localized/hello_world.de.html +1 -0
  581. data/actionpack/test/fixtures/localized/hello_world.en.html +1 -0
  582. data/actionpack/test/fixtures/localized/hello_world.it.erb +1 -0
  583. data/actionpack/test/fixtures/multipart/binary_file +0 -0
  584. data/actionpack/test/fixtures/multipart/boundary_problem_file +10 -0
  585. data/actionpack/test/fixtures/multipart/bracketed_param +5 -0
  586. data/actionpack/test/fixtures/multipart/bracketed_utf8_param +5 -0
  587. data/actionpack/test/fixtures/multipart/empty +10 -0
  588. data/actionpack/test/fixtures/multipart/hello.txt +1 -0
  589. data/actionpack/test/fixtures/multipart/large_text_file +10 -0
  590. data/actionpack/test/fixtures/multipart/mixed_files +0 -0
  591. data/actionpack/test/fixtures/multipart/none +9 -0
  592. data/actionpack/test/fixtures/multipart/ruby_on_rails.jpg +0 -0
  593. data/actionpack/test/fixtures/multipart/single_parameter +5 -0
  594. data/actionpack/test/fixtures/multipart/single_utf8_param +5 -0
  595. data/actionpack/test/fixtures/multipart/text_file +10 -0
  596. data/actionpack/test/fixtures/multipart/utf8_filename +10 -0
  597. data/actionpack/test/fixtures/namespaced/implicit_render_test/hello_world.erb +1 -0
  598. data/actionpack/test/fixtures/old_content_type/render_default_content_types_for_respond_to.xml.erb +1 -0
  599. data/actionpack/test/fixtures/old_content_type/render_default_for_builder.builder +1 -0
  600. data/actionpack/test/fixtures/old_content_type/render_default_for_erb.erb +1 -0
  601. data/actionpack/test/fixtures/post_test/layouts/post.html.erb +1 -0
  602. data/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
  603. data/actionpack/test/fixtures/post_test/post/index.html.erb +1 -0
  604. data/actionpack/test/fixtures/post_test/post/index.iphone.erb +1 -0
  605. data/actionpack/test/fixtures/post_test/super_post/index.html.erb +1 -0
  606. data/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
  607. data/actionpack/test/fixtures/public/400.html +1 -0
  608. data/actionpack/test/fixtures/public/404.html +1 -0
  609. data/actionpack/test/fixtures/public/500.da.html +1 -0
  610. data/actionpack/test/fixtures/public/500.html +1 -0
  611. data/actionpack/test/fixtures/public/bar.html +1 -0
  612. data/actionpack/test/fixtures/public/bar/index.html +1 -0
  613. data/actionpack/test/fixtures/public/foo/bar.html +1 -0
  614. data/actionpack/test/fixtures/public/foo/baz.css +3 -0
  615. data/actionpack/test/fixtures/public/foo/index.html +1 -0
  616. data/actionpack/test/fixtures/public/foo/other-index.html +1 -0
  617. data/actionpack/test/fixtures/public/foo//343/201/223/343/202/223/343/201/253/343/201/241/343/201/257.html +1 -0
  618. data/actionpack/test/fixtures/public/gzip/application-a71b3024f80aea3181c09774ca17e712.js +4 -0
  619. data/actionpack/test/fixtures/public/gzip/application-a71b3024f80aea3181c09774ca17e712.js.gz +0 -0
  620. data/actionpack/test/fixtures/public/gzip/foo.zoo +4 -0
  621. data/actionpack/test/fixtures/public/gzip/foo.zoo.gz +0 -0
  622. data/actionpack/test/fixtures/public/index.html +1 -0
  623. data/actionpack/test/fixtures/public/other-index.html +1 -0
  624. data/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
  625. data/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
  626. data/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
  627. data/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
  628. data/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
  629. data/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
  630. data/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
  631. data/actionpack/test/fixtures/respond_to/using_defaults.html.erb +1 -0
  632. data/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
  633. data/actionpack/test/fixtures/respond_to/using_defaults_with_all.html.erb +1 -0
  634. data/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
  635. data/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
  636. data/actionpack/test/fixtures/respond_to/variant_any_implicit_render.html+phablet.erb +1 -0
  637. data/actionpack/test/fixtures/respond_to/variant_any_implicit_render.html+tablet.erb +1 -0
  638. data/actionpack/test/fixtures/respond_to/variant_inline_syntax_without_block.html+phone.erb +1 -0
  639. data/actionpack/test/fixtures/respond_to/variant_plus_none_for_format.html.erb +1 -0
  640. data/actionpack/test/fixtures/respond_to/variant_with_implicit_template_rendering.html+mobile.erb +1 -0
  641. data/actionpack/test/fixtures/ruby_template.ruby +2 -0
  642. data/actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb +12 -0
  643. data/actionpack/test/fixtures/shared.html.erb +1 -0
  644. data/actionpack/test/fixtures/star_star_mime/index.js.erb +1 -0
  645. data/actionpack/test/fixtures/test/_partial.erb +1 -0
  646. data/actionpack/test/fixtures/test/_partial.html.erb +1 -0
  647. data/actionpack/test/fixtures/test/_partial.js.erb +1 -0
  648. data/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
  649. data/actionpack/test/fixtures/test/formatted_xml_erb.builder +1 -0
  650. data/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
  651. data/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
  652. data/actionpack/test/fixtures/test/hello/hello.erb +1 -0
  653. data/actionpack/test/fixtures/test/hello_world.erb +1 -0
  654. data/actionpack/test/fixtures/test/hello_world_with_partial.html.erb +2 -0
  655. data/actionpack/test/fixtures/test/hello_xml_world.builder +11 -0
  656. data/actionpack/test/fixtures/test/implicit_content_type.atom.builder +2 -0
  657. data/actionpack/test/fixtures/test/render_file_with_ivar.erb +1 -0
  658. data/actionpack/test/fixtures/test/render_file_with_locals.erb +1 -0
  659. data/actionpack/test/fixtures/test/with_implicit_template.erb +1 -0
  660. data/actionpack/test/fixtures//345/205/254/345/205/261/bar.html +1 -0
  661. data/actionpack/test/fixtures//345/205/254/345/205/261/bar/index.html +1 -0
  662. data/actionpack/test/fixtures//345/205/254/345/205/261/foo/bar.html +1 -0
  663. data/actionpack/test/fixtures//345/205/254/345/205/261/foo/baz.css +3 -0
  664. data/actionpack/test/fixtures//345/205/254/345/205/261/foo/index.html +1 -0
  665. data/actionpack/test/fixtures//345/205/254/345/205/261/foo/other-index.html +1 -0
  666. data/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
  667. data/actionpack/test/fixtures//345/205/254/345/205/261/gzip/application-a71b3024f80aea3181c09774ca17e712.js +4 -0
  668. data/actionpack/test/fixtures//345/205/254/345/205/261/gzip/application-a71b3024f80aea3181c09774ca17e712.js.gz +0 -0
  669. data/actionpack/test/fixtures//345/205/254/345/205/261/gzip/foo.zoo +4 -0
  670. data/actionpack/test/fixtures//345/205/254/345/205/261/gzip/foo.zoo.gz +0 -0
  671. data/actionpack/test/fixtures//345/205/254/345/205/261/index.html +1 -0
  672. data/actionpack/test/fixtures//345/205/254/345/205/261/other-index.html +1 -0
  673. data/actionpack/test/journey/gtg/builder_test.rb +81 -0
  674. data/actionpack/test/journey/gtg/transition_table_test.rb +125 -0
  675. data/actionpack/test/journey/nfa/simulator_test.rb +100 -0
  676. data/actionpack/test/journey/nfa/transition_table_test.rb +74 -0
  677. data/actionpack/test/journey/nodes/symbol_test.rb +19 -0
  678. data/actionpack/test/journey/path/pattern_test.rb +286 -0
  679. data/actionpack/test/journey/route/definition/parser_test.rb +112 -0
  680. data/actionpack/test/journey/route/definition/scanner_test.rb +71 -0
  681. data/actionpack/test/journey/route_test.rb +113 -0
  682. data/actionpack/test/journey/router/utils_test.rb +48 -0
  683. data/actionpack/test/journey/router_test.rb +535 -0
  684. data/actionpack/test/journey/routes_test.rb +62 -0
  685. data/actionpack/test/lib/controller/fake_controllers.rb +37 -0
  686. data/actionpack/test/lib/controller/fake_models.rb +79 -0
  687. data/actionpack/test/routing/helper_test.rb +33 -0
  688. data/actionview/.gitignore +2 -0
  689. data/actionview/CHANGELOG.md +35 -0
  690. data/actionview/MIT-LICENSE +21 -0
  691. data/actionview/README.rdoc +38 -0
  692. data/actionview/RUNNING_UJS_TESTS.rdoc +7 -0
  693. data/actionview/RUNNING_UNIT_TESTS.rdoc +27 -0
  694. data/actionview/Rakefile +136 -0
  695. data/actionview/actionview.gemspec +38 -0
  696. data/actionview/app/assets/javascripts/MIT-LICENSE +20 -0
  697. data/actionview/app/assets/javascripts/README.md +60 -0
  698. data/actionview/app/assets/javascripts/rails-ujs.coffee +39 -0
  699. data/actionview/app/assets/javascripts/rails-ujs/BANNER.js +5 -0
  700. data/actionview/app/assets/javascripts/rails-ujs/features/confirm.coffee +26 -0
  701. data/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee +82 -0
  702. data/actionview/app/assets/javascripts/rails-ujs/features/method.coffee +34 -0
  703. data/actionview/app/assets/javascripts/rails-ujs/features/remote.coffee +90 -0
  704. data/actionview/app/assets/javascripts/rails-ujs/start.coffee +70 -0
  705. data/actionview/app/assets/javascripts/rails-ujs/utils/ajax.coffee +96 -0
  706. data/actionview/app/assets/javascripts/rails-ujs/utils/csrf.coffee +25 -0
  707. data/actionview/app/assets/javascripts/rails-ujs/utils/dom.coffee +28 -0
  708. data/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee +40 -0
  709. data/actionview/app/assets/javascripts/rails-ujs/utils/form.coffee +36 -0
  710. data/actionview/bin/test +5 -0
  711. data/actionview/blade.yml +11 -0
  712. data/actionview/coffeelint.json +135 -0
  713. data/actionview/lib/action_view.rb +98 -0
  714. data/actionview/lib/action_view/base.rb +215 -0
  715. data/actionview/lib/action_view/buffers.rb +52 -0
  716. data/actionview/lib/action_view/context.rb +38 -0
  717. data/actionview/lib/action_view/dependency_tracker.rb +175 -0
  718. data/actionview/lib/action_view/digestor.rb +128 -0
  719. data/actionview/lib/action_view/flows.rb +76 -0
  720. data/actionview/lib/action_view/gem_version.rb +17 -0
  721. data/actionview/lib/action_view/helpers.rb +66 -0
  722. data/actionview/lib/action_view/helpers/active_model_helper.rb +51 -0
  723. data/actionview/lib/action_view/helpers/asset_tag_helper.rb +400 -0
  724. data/actionview/lib/action_view/helpers/asset_url_helper.rb +469 -0
  725. data/actionview/lib/action_view/helpers/atom_feed_helper.rb +205 -0
  726. data/actionview/lib/action_view/helpers/cache_helper.rb +263 -0
  727. data/actionview/lib/action_view/helpers/capture_helper.rb +212 -0
  728. data/actionview/lib/action_view/helpers/controller_helper.rb +36 -0
  729. data/actionview/lib/action_view/helpers/csrf_helper.rb +35 -0
  730. data/actionview/lib/action_view/helpers/date_helper.rb +1156 -0
  731. data/actionview/lib/action_view/helpers/debug_helper.rb +36 -0
  732. data/actionview/lib/action_view/helpers/form_helper.rb +2355 -0
  733. data/actionview/lib/action_view/helpers/form_options_helper.rb +883 -0
  734. data/actionview/lib/action_view/helpers/form_tag_helper.rb +916 -0
  735. data/actionview/lib/action_view/helpers/javascript_helper.rb +83 -0
  736. data/actionview/lib/action_view/helpers/number_helper.rb +451 -0
  737. data/actionview/lib/action_view/helpers/output_safety_helper.rb +70 -0
  738. data/actionview/lib/action_view/helpers/record_tag_helper.rb +23 -0
  739. data/actionview/lib/action_view/helpers/rendering_helper.rb +100 -0
  740. data/actionview/lib/action_view/helpers/sanitize_helper.rb +177 -0
  741. data/actionview/lib/action_view/helpers/tag_helper.rb +313 -0
  742. data/actionview/lib/action_view/helpers/tags.rb +44 -0
  743. data/actionview/lib/action_view/helpers/tags/base.rb +192 -0
  744. data/actionview/lib/action_view/helpers/tags/check_box.rb +66 -0
  745. data/actionview/lib/action_view/helpers/tags/checkable.rb +18 -0
  746. data/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +36 -0
  747. data/actionview/lib/action_view/helpers/tags/collection_helpers.rb +119 -0
  748. data/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb +31 -0
  749. data/actionview/lib/action_view/helpers/tags/collection_select.rb +30 -0
  750. data/actionview/lib/action_view/helpers/tags/color_field.rb +27 -0
  751. data/actionview/lib/action_view/helpers/tags/date_field.rb +15 -0
  752. data/actionview/lib/action_view/helpers/tags/date_select.rb +74 -0
  753. data/actionview/lib/action_view/helpers/tags/datetime_field.rb +32 -0
  754. data/actionview/lib/action_view/helpers/tags/datetime_local_field.rb +21 -0
  755. data/actionview/lib/action_view/helpers/tags/datetime_select.rb +10 -0
  756. data/actionview/lib/action_view/helpers/tags/email_field.rb +10 -0
  757. data/actionview/lib/action_view/helpers/tags/file_field.rb +10 -0
  758. data/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb +31 -0
  759. data/actionview/lib/action_view/helpers/tags/hidden_field.rb +10 -0
  760. data/actionview/lib/action_view/helpers/tags/label.rb +85 -0
  761. data/actionview/lib/action_view/helpers/tags/month_field.rb +15 -0
  762. data/actionview/lib/action_view/helpers/tags/number_field.rb +20 -0
  763. data/actionview/lib/action_view/helpers/tags/password_field.rb +14 -0
  764. data/actionview/lib/action_view/helpers/tags/placeholderable.rb +24 -0
  765. data/actionview/lib/action_view/helpers/tags/radio_button.rb +33 -0
  766. data/actionview/lib/action_view/helpers/tags/range_field.rb +10 -0
  767. data/actionview/lib/action_view/helpers/tags/search_field.rb +27 -0
  768. data/actionview/lib/action_view/helpers/tags/select.rb +43 -0
  769. data/actionview/lib/action_view/helpers/tags/tel_field.rb +10 -0
  770. data/actionview/lib/action_view/helpers/tags/text_area.rb +24 -0
  771. data/actionview/lib/action_view/helpers/tags/text_field.rb +34 -0
  772. data/actionview/lib/action_view/helpers/tags/time_field.rb +15 -0
  773. data/actionview/lib/action_view/helpers/tags/time_select.rb +10 -0
  774. data/actionview/lib/action_view/helpers/tags/time_zone_select.rb +22 -0
  775. data/actionview/lib/action_view/helpers/tags/translator.rb +44 -0
  776. data/actionview/lib/action_view/helpers/tags/url_field.rb +10 -0
  777. data/actionview/lib/action_view/helpers/tags/week_field.rb +15 -0
  778. data/actionview/lib/action_view/helpers/text_helper.rb +486 -0
  779. data/actionview/lib/action_view/helpers/translation_helper.rb +141 -0
  780. data/actionview/lib/action_view/helpers/url_helper.rb +654 -0
  781. data/actionview/lib/action_view/layouts.rb +433 -0
  782. data/actionview/lib/action_view/locale/en.yml +56 -0
  783. data/actionview/lib/action_view/log_subscriber.rb +96 -0
  784. data/actionview/lib/action_view/lookup_context.rb +274 -0
  785. data/actionview/lib/action_view/model_naming.rb +14 -0
  786. data/actionview/lib/action_view/path_set.rb +100 -0
  787. data/actionview/lib/action_view/railtie.rb +75 -0
  788. data/actionview/lib/action_view/record_identifier.rb +112 -0
  789. data/actionview/lib/action_view/renderer/abstract_renderer.rb +55 -0
  790. data/actionview/lib/action_view/renderer/partial_renderer.rb +552 -0
  791. data/actionview/lib/action_view/renderer/partial_renderer/collection_caching.rb +57 -0
  792. data/actionview/lib/action_view/renderer/renderer.rb +56 -0
  793. data/actionview/lib/action_view/renderer/streaming_template_renderer.rb +103 -0
  794. data/actionview/lib/action_view/renderer/template_renderer.rb +102 -0
  795. data/actionview/lib/action_view/rendering.rb +155 -0
  796. data/actionview/lib/action_view/routing_url_for.rb +145 -0
  797. data/actionview/lib/action_view/tasks/cache_digests.rake +25 -0
  798. data/actionview/lib/action_view/template.rb +361 -0
  799. data/actionview/lib/action_view/template/error.rb +144 -0
  800. data/actionview/lib/action_view/template/handlers.rb +66 -0
  801. data/actionview/lib/action_view/template/handlers/builder.rb +25 -0
  802. data/actionview/lib/action_view/template/handlers/erb.rb +77 -0
  803. data/actionview/lib/action_view/template/handlers/erb/deprecated_erubis.rb +11 -0
  804. data/actionview/lib/action_view/template/handlers/erb/erubi.rb +83 -0
  805. data/actionview/lib/action_view/template/handlers/erb/erubis.rb +83 -0
  806. data/actionview/lib/action_view/template/handlers/html.rb +11 -0
  807. data/actionview/lib/action_view/template/handlers/raw.rb +11 -0
  808. data/actionview/lib/action_view/template/html.rb +34 -0
  809. data/actionview/lib/action_view/template/resolver.rb +391 -0
  810. data/actionview/lib/action_view/template/text.rb +33 -0
  811. data/actionview/lib/action_view/template/types.rb +57 -0
  812. data/actionview/lib/action_view/test_case.rb +300 -0
  813. data/actionview/lib/action_view/testing/resolvers.rb +54 -0
  814. data/actionview/lib/action_view/version.rb +10 -0
  815. data/actionview/lib/action_view/view_paths.rb +105 -0
  816. data/actionview/package.json +36 -0
  817. data/actionview/test/abstract_unit.rb +287 -0
  818. data/actionview/test/actionpack/abstract/abstract_controller_test.rb +292 -0
  819. data/actionview/test/actionpack/abstract/helper_test.rb +128 -0
  820. data/actionview/test/actionpack/abstract/layouts_test.rb +568 -0
  821. data/actionview/test/actionpack/abstract/render_test.rb +103 -0
  822. data/actionview/test/actionpack/abstract/views/abstract_controller/testing/me3/formatted.html.erb +1 -0
  823. data/actionview/test/actionpack/abstract/views/abstract_controller/testing/me3/index.erb +1 -0
  824. data/actionview/test/actionpack/abstract/views/abstract_controller/testing/me4/index.erb +1 -0
  825. data/actionview/test/actionpack/abstract/views/action_with_ivars.erb +1 -0
  826. data/actionview/test/actionpack/abstract/views/helper_test.erb +1 -0
  827. data/actionview/test/actionpack/abstract/views/index.erb +1 -0
  828. data/actionview/test/actionpack/abstract/views/layouts/abstract_controller/testing/me4.erb +1 -0
  829. data/actionview/test/actionpack/abstract/views/layouts/application.erb +1 -0
  830. data/actionview/test/actionpack/abstract/views/naked_render.erb +1 -0
  831. data/actionview/test/actionpack/controller/capture_test.rb +83 -0
  832. data/actionview/test/actionpack/controller/layout_test.rb +270 -0
  833. data/actionview/test/actionpack/controller/render_test.rb +1294 -0
  834. data/actionview/test/actionpack/controller/view_paths_test.rb +174 -0
  835. data/actionview/test/active_record_unit.rb +92 -0
  836. data/actionview/test/activerecord/controller_runtime_test.rb +95 -0
  837. data/actionview/test/activerecord/debug_helper_test.rb +19 -0
  838. data/actionview/test/activerecord/form_helper_activerecord_test.rb +90 -0
  839. data/actionview/test/activerecord/polymorphic_routes_test.rb +780 -0
  840. data/actionview/test/activerecord/relation_cache_test.rb +23 -0
  841. data/actionview/test/activerecord/render_partial_with_record_identification_test.rb +198 -0
  842. data/actionview/test/fixtures/_top_level_partial.html.erb +1 -0
  843. data/actionview/test/fixtures/_top_level_partial_only.erb +1 -0
  844. data/actionview/test/fixtures/actionpack/bad_customers/_bad_customer.html.erb +1 -0
  845. data/actionview/test/fixtures/actionpack/customers/_customer.html.erb +1 -0
  846. data/actionview/test/fixtures/actionpack/fun/games/_form.erb +1 -0
  847. data/actionview/test/fixtures/actionpack/fun/games/hello_world.erb +1 -0
  848. data/actionview/test/fixtures/actionpack/good_customers/_good_customer.html.erb +1 -0
  849. data/actionview/test/fixtures/actionpack/hello.html +1 -0
  850. data/actionview/test/fixtures/actionpack/layout_tests/alt/layouts/alt.erb +1 -0
  851. data/actionview/test/fixtures/actionpack/layout_tests/layouts/controller_name_space/nested.erb +1 -0
  852. data/actionview/test/fixtures/actionpack/layout_tests/layouts/item.erb +1 -0
  853. data/actionview/test/fixtures/actionpack/layout_tests/layouts/layout_test.erb +1 -0
  854. data/actionview/test/fixtures/actionpack/layout_tests/layouts/multiple_extensions.html.erb +1 -0
  855. data/actionview/test/fixtures/actionpack/layout_tests/layouts/symlinked/symlinked_layout.erb +5 -0
  856. data/actionview/test/fixtures/actionpack/layout_tests/layouts/third_party_template_library.mab +1 -0
  857. data/actionview/test/fixtures/actionpack/layout_tests/views/goodbye.erb +1 -0
  858. data/actionview/test/fixtures/actionpack/layout_tests/views/hello.erb +1 -0
  859. data/actionview/test/fixtures/actionpack/layouts/_column.html.erb +2 -0
  860. data/actionview/test/fixtures/actionpack/layouts/_customers.erb +1 -0
  861. data/actionview/test/fixtures/actionpack/layouts/_partial_and_yield.erb +2 -0
  862. data/actionview/test/fixtures/actionpack/layouts/_yield_only.erb +1 -0
  863. data/actionview/test/fixtures/actionpack/layouts/_yield_with_params.erb +1 -0
  864. data/actionview/test/fixtures/actionpack/layouts/block_with_layout.erb +3 -0
  865. data/actionview/test/fixtures/actionpack/layouts/builder.builder +3 -0
  866. data/actionview/test/fixtures/actionpack/layouts/partial_with_layout.erb +3 -0
  867. data/actionview/test/fixtures/actionpack/layouts/standard.html.erb +1 -0
  868. data/actionview/test/fixtures/actionpack/layouts/standard.text.erb +1 -0
  869. data/actionview/test/fixtures/actionpack/layouts/streaming.erb +4 -0
  870. data/actionview/test/fixtures/actionpack/layouts/talk_from_action.erb +2 -0
  871. data/actionview/test/fixtures/actionpack/layouts/with_html_partial.html.erb +1 -0
  872. data/actionview/test/fixtures/actionpack/layouts/xhr.html.erb +2 -0
  873. data/actionview/test/fixtures/actionpack/layouts/yield.erb +2 -0
  874. data/actionview/test/fixtures/actionpack/layouts/yield_with_render_inline_inside.erb +2 -0
  875. data/actionview/test/fixtures/actionpack/layouts/yield_with_render_partial_inside.erb +2 -0
  876. data/actionview/test/fixtures/actionpack/quiz/questions/_question.html.erb +1 -0
  877. data/actionview/test/fixtures/actionpack/shared.html.erb +1 -0
  878. data/actionview/test/fixtures/actionpack/test/_changing_priority.html.erb +1 -0
  879. data/actionview/test/fixtures/actionpack/test/_changing_priority.json.erb +1 -0
  880. data/actionview/test/fixtures/actionpack/test/_counter.html.erb +1 -0
  881. data/actionview/test/fixtures/actionpack/test/_customer.erb +1 -0
  882. data/actionview/test/fixtures/actionpack/test/_customer_counter.erb +1 -0
  883. data/actionview/test/fixtures/actionpack/test/_customer_counter_with_as.erb +1 -0
  884. data/actionview/test/fixtures/actionpack/test/_customer_greeting.erb +1 -0
  885. data/actionview/test/fixtures/actionpack/test/_customer_iteration.erb +1 -0
  886. data/actionview/test/fixtures/actionpack/test/_customer_iteration_with_as.erb +1 -0
  887. data/actionview/test/fixtures/actionpack/test/_customer_with_var.erb +1 -0
  888. data/actionview/test/fixtures/actionpack/test/_directory/_partial_with_locales.html.erb +1 -0
  889. data/actionview/test/fixtures/actionpack/test/_first_json_partial.json.erb +1 -0
  890. data/actionview/test/fixtures/actionpack/test/_form.erb +1 -0
  891. data/actionview/test/fixtures/actionpack/test/_hash_greeting.erb +1 -0
  892. data/actionview/test/fixtures/actionpack/test/_hash_object.erb +2 -0
  893. data/actionview/test/fixtures/actionpack/test/_hello.builder +1 -0
  894. data/actionview/test/fixtures/actionpack/test/_json_change_priority.json.erb +0 -0
  895. data/actionview/test/fixtures/actionpack/test/_labelling_form.erb +1 -0
  896. data/actionview/test/fixtures/actionpack/test/_layout_for_partial.html.erb +3 -0
  897. data/actionview/test/fixtures/actionpack/test/_partial.erb +1 -0
  898. data/actionview/test/fixtures/actionpack/test/_partial.html.erb +1 -0
  899. data/actionview/test/fixtures/actionpack/test/_partial.js.erb +1 -0
  900. data/actionview/test/fixtures/actionpack/test/_partial_for_use_in_layout.html.erb +1 -0
  901. data/actionview/test/fixtures/actionpack/test/_partial_html_erb.html.erb +1 -0
  902. data/actionview/test/fixtures/actionpack/test/_partial_name_local_variable.erb +1 -0
  903. data/actionview/test/fixtures/actionpack/test/_partial_only.erb +1 -0
  904. data/actionview/test/fixtures/actionpack/test/_partial_only_html.html +1 -0
  905. data/actionview/test/fixtures/actionpack/test/_partial_with_partial.erb +2 -0
  906. data/actionview/test/fixtures/actionpack/test/_person.erb +2 -0
  907. data/actionview/test/fixtures/actionpack/test/_raise_indentation.html.erb +13 -0
  908. data/actionview/test/fixtures/actionpack/test/_second_json_partial.json.erb +1 -0
  909. data/actionview/test/fixtures/actionpack/test/action_talk_to_layout.erb +2 -0
  910. data/actionview/test/fixtures/actionpack/test/calling_partial_with_layout.html.erb +1 -0
  911. data/actionview/test/fixtures/actionpack/test/capturing.erb +4 -0
  912. data/actionview/test/fixtures/actionpack/test/change_priority.html.erb +2 -0
  913. data/actionview/test/fixtures/actionpack/test/content_for.erb +1 -0
  914. data/actionview/test/fixtures/actionpack/test/content_for_concatenated.erb +3 -0
  915. data/actionview/test/fixtures/actionpack/test/content_for_with_parameter.erb +2 -0
  916. data/actionview/test/fixtures/actionpack/test/dot.directory/render_file_with_ivar.erb +1 -0
  917. data/actionview/test/fixtures/actionpack/test/formatted_html_erb.html.erb +1 -0
  918. data/actionview/test/fixtures/actionpack/test/formatted_xml_erb.builder +1 -0
  919. data/actionview/test/fixtures/actionpack/test/formatted_xml_erb.html.erb +1 -0
  920. data/actionview/test/fixtures/actionpack/test/formatted_xml_erb.xml.erb +1 -0
  921. data/actionview/test/fixtures/actionpack/test/greeting.html.erb +1 -0
  922. data/actionview/test/fixtures/actionpack/test/greeting.xml.erb +1 -0
  923. data/actionview/test/fixtures/actionpack/test/hello,world.erb +1 -0
  924. data/actionview/test/fixtures/actionpack/test/hello.builder +4 -0
  925. data/actionview/test/fixtures/actionpack/test/hello/hello.erb +1 -0
  926. data/actionview/test/fixtures/actionpack/test/hello_world.erb +1 -0
  927. data/actionview/test/fixtures/actionpack/test/hello_world_container.builder +3 -0
  928. data/actionview/test/fixtures/actionpack/test/hello_world_from_rxml.builder +3 -0
  929. data/actionview/test/fixtures/actionpack/test/hello_world_with_layout_false.erb +1 -0
  930. data/actionview/test/fixtures/actionpack/test/hello_world_with_partial.html.erb +2 -0
  931. data/actionview/test/fixtures/actionpack/test/hello_xml_world.builder +11 -0
  932. data/actionview/test/fixtures/actionpack/test/html_template.html.erb +1 -0
  933. data/actionview/test/fixtures/actionpack/test/hyphen-ated.erb +1 -0
  934. data/actionview/test/fixtures/actionpack/test/implicit_content_type.atom.builder +2 -0
  935. data/actionview/test/fixtures/actionpack/test/list.erb +1 -0
  936. data/actionview/test/fixtures/actionpack/test/non_erb_block_content_for.builder +4 -0
  937. data/actionview/test/fixtures/actionpack/test/potential_conflicts.erb +4 -0
  938. data/actionview/test/fixtures/actionpack/test/proper_block_detection.erb +1 -0
  939. data/actionview/test/fixtures/actionpack/test/render_file_from_template.html.erb +1 -0
  940. data/actionview/test/fixtures/actionpack/test/render_file_with_ivar.erb +1 -0
  941. data/actionview/test/fixtures/actionpack/test/render_file_with_locals.erb +1 -0
  942. data/actionview/test/fixtures/actionpack/test/render_file_with_locals_and_default.erb +1 -0
  943. data/actionview/test/fixtures/actionpack/test/render_implicit_html_template_from_xhr_request.da.html.erb +1 -0
  944. data/actionview/test/fixtures/actionpack/test/render_implicit_html_template_from_xhr_request.html.erb +1 -0
  945. data/actionview/test/fixtures/actionpack/test/render_implicit_js_template_without_layout.js.erb +1 -0
  946. data/actionview/test/fixtures/actionpack/test/render_partial_inside_directory.html.erb +1 -0
  947. data/actionview/test/fixtures/actionpack/test/render_to_string_test.erb +1 -0
  948. data/actionview/test/fixtures/actionpack/test/render_two_partials.html.erb +2 -0
  949. data/actionview/test/fixtures/actionpack/test/using_layout_around_block.html.erb +1 -0
  950. data/actionview/test/fixtures/actionpack/test/with_html_partial.html.erb +1 -0
  951. data/actionview/test/fixtures/actionpack/test/with_partial.html.erb +1 -0
  952. data/actionview/test/fixtures/actionpack/test/with_partial.text.erb +1 -0
  953. data/actionview/test/fixtures/actionpack/test/with_xml_template.html.erb +1 -0
  954. data/actionview/test/fixtures/comments/empty.de.html.erb +1 -0
  955. data/actionview/test/fixtures/comments/empty.html+grid.erb +1 -0
  956. data/actionview/test/fixtures/comments/empty.html.builder +1 -0
  957. data/actionview/test/fixtures/comments/empty.html.erb +1 -0
  958. data/actionview/test/fixtures/comments/empty.xml.erb +1 -0
  959. data/actionview/test/fixtures/companies.yml +24 -0
  960. data/actionview/test/fixtures/company.rb +11 -0
  961. data/actionview/test/fixtures/custom_pattern/another.html.erb +1 -0
  962. data/actionview/test/fixtures/custom_pattern/html/another.erb +1 -0
  963. data/actionview/test/fixtures/custom_pattern/html/path.erb +1 -0
  964. data/actionview/test/fixtures/customers/_customer.html.erb +1 -0
  965. data/actionview/test/fixtures/customers/_customer.xml.erb +1 -0
  966. data/actionview/test/fixtures/db_definitions/sqlite.sql +49 -0
  967. data/actionview/test/fixtures/developer.rb +8 -0
  968. data/actionview/test/fixtures/developers.yml +21 -0
  969. data/actionview/test/fixtures/developers/_developer.erb +1 -0
  970. data/actionview/test/fixtures/developers_projects.yml +13 -0
  971. data/actionview/test/fixtures/digestor/api/comments/_comment.json.erb +1 -0
  972. data/actionview/test/fixtures/digestor/api/comments/_comments.json.erb +1 -0
  973. data/actionview/test/fixtures/digestor/comments/_comment.html.erb +1 -0
  974. data/actionview/test/fixtures/digestor/comments/_comments.html.erb +1 -0
  975. data/actionview/test/fixtures/digestor/events/_completed.html.erb +0 -0
  976. data/actionview/test/fixtures/digestor/events/_event.html.erb +0 -0
  977. data/actionview/test/fixtures/digestor/events/index.html.erb +1 -0
  978. data/actionview/test/fixtures/digestor/level/_recursion.html.erb +1 -0
  979. data/actionview/test/fixtures/digestor/level/below/_header.html.erb +0 -0
  980. data/actionview/test/fixtures/digestor/level/below/index.html.erb +1 -0
  981. data/actionview/test/fixtures/digestor/level/recursion.html.erb +1 -0
  982. data/actionview/test/fixtures/digestor/messages/_form.html.erb +0 -0
  983. data/actionview/test/fixtures/digestor/messages/_header.html.erb +0 -0
  984. data/actionview/test/fixtures/digestor/messages/_message.html.erb +1 -0
  985. data/actionview/test/fixtures/digestor/messages/actions/_move.html.erb +0 -0
  986. data/actionview/test/fixtures/digestor/messages/edit.html.erb +5 -0
  987. data/actionview/test/fixtures/digestor/messages/index.html.erb +2 -0
  988. data/actionview/test/fixtures/digestor/messages/new.html+iphone.erb +15 -0
  989. data/actionview/test/fixtures/digestor/messages/peek.html.erb +2 -0
  990. data/actionview/test/fixtures/digestor/messages/show.html.erb +14 -0
  991. data/actionview/test/fixtures/digestor/messages/thread.json.erb +1 -0
  992. data/actionview/test/fixtures/fun/games/_game.erb +1 -0
  993. data/actionview/test/fixtures/fun/games/hello_world.erb +1 -0
  994. data/actionview/test/fixtures/fun/serious/games/_game.erb +1 -0
  995. data/actionview/test/fixtures/games/_game.erb +1 -0
  996. data/actionview/test/fixtures/good_customers/_good_customer.html.erb +1 -0
  997. data/actionview/test/fixtures/helpers/abc_helper.rb +5 -0
  998. data/actionview/test/fixtures/helpers/helpery_test_helper.rb +7 -0
  999. data/actionview/test/fixtures/helpers_missing/invalid_require_helper.rb +6 -0
  1000. data/actionview/test/fixtures/layout_tests/alt/hello.erb +1 -0
  1001. data/actionview/test/fixtures/layouts/_column.html.erb +2 -0
  1002. data/actionview/test/fixtures/layouts/_customers.erb +1 -0
  1003. data/actionview/test/fixtures/layouts/_partial_and_yield.erb +2 -0
  1004. data/actionview/test/fixtures/layouts/_yield_only.erb +1 -0
  1005. data/actionview/test/fixtures/layouts/_yield_with_params.erb +1 -0
  1006. data/actionview/test/fixtures/layouts/render_partial_html.erb +2 -0
  1007. data/actionview/test/fixtures/layouts/streaming.erb +4 -0
  1008. data/actionview/test/fixtures/layouts/streaming_with_capture.erb +6 -0
  1009. data/actionview/test/fixtures/layouts/yield.erb +2 -0
  1010. data/actionview/test/fixtures/layouts/yield_with_render_inline_inside.erb +2 -0
  1011. data/actionview/test/fixtures/layouts/yield_with_render_partial_inside.erb +2 -0
  1012. data/actionview/test/fixtures/mascot.rb +5 -0
  1013. data/actionview/test/fixtures/mascots.yml +4 -0
  1014. data/actionview/test/fixtures/mascots/_mascot.html.erb +1 -0
  1015. data/actionview/test/fixtures/override/test/hello_world.erb +1 -0
  1016. data/actionview/test/fixtures/override2/layouts/test/sub.erb +1 -0
  1017. data/actionview/test/fixtures/plain_text.raw +1 -0
  1018. data/actionview/test/fixtures/plain_text_with_characters.raw +1 -0
  1019. data/actionview/test/fixtures/project.rb +9 -0
  1020. data/actionview/test/fixtures/projects.yml +7 -0
  1021. data/actionview/test/fixtures/projects/_project.erb +1 -0
  1022. data/actionview/test/fixtures/public/.gitignore +1 -0
  1023. data/actionview/test/fixtures/public/elsewhere/cools.js +1 -0
  1024. data/actionview/test/fixtures/public/elsewhere/file.css +1 -0
  1025. data/actionview/test/fixtures/public/foo/baz.css +3 -0
  1026. data/actionview/test/fixtures/public/javascripts/application.js +1 -0
  1027. data/actionview/test/fixtures/public/javascripts/bank.js +1 -0
  1028. data/actionview/test/fixtures/public/javascripts/common.javascript +1 -0
  1029. data/actionview/test/fixtures/public/javascripts/controls.js +1 -0
  1030. data/actionview/test/fixtures/public/javascripts/dragdrop.js +1 -0
  1031. data/actionview/test/fixtures/public/javascripts/effects.js +1 -0
  1032. data/actionview/test/fixtures/public/javascripts/prototype.js +1 -0
  1033. data/actionview/test/fixtures/public/javascripts/robber.js +1 -0
  1034. data/actionview/test/fixtures/public/javascripts/subdir/subdir.js +1 -0
  1035. data/actionview/test/fixtures/public/javascripts/version.1.0.js +1 -0
  1036. data/actionview/test/fixtures/public/stylesheets/bank.css +1 -0
  1037. data/actionview/test/fixtures/public/stylesheets/random.styles +1 -0
  1038. data/actionview/test/fixtures/public/stylesheets/robber.css +1 -0
  1039. data/actionview/test/fixtures/public/stylesheets/subdir/subdir.css +1 -0
  1040. data/actionview/test/fixtures/public/stylesheets/version.1.0.css +1 -0
  1041. data/actionview/test/fixtures/replies.yml +15 -0
  1042. data/actionview/test/fixtures/replies/_reply.erb +1 -0
  1043. data/actionview/test/fixtures/reply.rb +9 -0
  1044. data/actionview/test/fixtures/respond_to/using_defaults_with_all.html.erb +1 -0
  1045. data/actionview/test/fixtures/ruby_template.ruby +2 -0
  1046. data/actionview/test/fixtures/shared.html.erb +1 -0
  1047. data/actionview/test/fixtures/test/_200.html.erb +1 -0
  1048. data/actionview/test/fixtures/test/_FooBar.html.erb +1 -0
  1049. data/actionview/test/fixtures/test/_a-in.html.erb +0 -0
  1050. data/actionview/test/fixtures/test/_b_layout_for_partial.html.erb +1 -0
  1051. data/actionview/test/fixtures/test/_b_layout_for_partial_with_object.html.erb +1 -0
  1052. data/actionview/test/fixtures/test/_b_layout_for_partial_with_object_counter.html.erb +1 -0
  1053. data/actionview/test/fixtures/test/_builder_tag_nested_in_content_tag.erb +3 -0
  1054. data/actionview/test/fixtures/test/_cached_customer.erb +3 -0
  1055. data/actionview/test/fixtures/test/_cached_customer_as.erb +3 -0
  1056. data/actionview/test/fixtures/test/_cached_nested_cached_customer.erb +3 -0
  1057. data/actionview/test/fixtures/test/_changing_priority.html.erb +1 -0
  1058. data/actionview/test/fixtures/test/_changing_priority.json.erb +1 -0
  1059. data/actionview/test/fixtures/test/_content_tag_nested_in_content_tag.erb +3 -0
  1060. data/actionview/test/fixtures/test/_counter.html.erb +1 -0
  1061. data/actionview/test/fixtures/test/_customer.erb +1 -0
  1062. data/actionview/test/fixtures/test/_customer.mobile.erb +1 -0
  1063. data/actionview/test/fixtures/test/_customer_greeting.erb +1 -0
  1064. data/actionview/test/fixtures/test/_customer_with_var.erb +1 -0
  1065. data/actionview/test/fixtures/test/_directory/_partial_with_locales.html.erb +1 -0
  1066. data/actionview/test/fixtures/test/_first_json_partial.json.erb +1 -0
  1067. data/actionview/test/fixtures/test/_from_helper.erb +1 -0
  1068. data/actionview/test/fixtures/test/_json_change_priority.json.erb +0 -0
  1069. data/actionview/test/fixtures/test/_klass.erb +1 -0
  1070. data/actionview/test/fixtures/test/_label_with_block.erb +4 -0
  1071. data/actionview/test/fixtures/test/_layout_for_block_with_args.html.erb +3 -0
  1072. data/actionview/test/fixtures/test/_layout_for_partial.html.erb +3 -0
  1073. data/actionview/test/fixtures/test/_layout_with_partial_and_yield.html.erb +4 -0
  1074. data/actionview/test/fixtures/test/_local_inspector.html.erb +1 -0
  1075. data/actionview/test/fixtures/test/_nested_cached_customer.erb +1 -0
  1076. data/actionview/test/fixtures/test/_object_inspector.erb +1 -0
  1077. data/actionview/test/fixtures/test/_one.html.erb +1 -0
  1078. data/actionview/test/fixtures/test/_partial.erb +1 -0
  1079. data/actionview/test/fixtures/test/_partial.html.erb +1 -0
  1080. data/actionview/test/fixtures/test/_partial.js.erb +1 -0
  1081. data/actionview/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
  1082. data/actionview/test/fixtures/test/_partial_iteration_1.erb +1 -0
  1083. data/actionview/test/fixtures/test/_partial_iteration_2.erb +1 -0
  1084. data/actionview/test/fixtures/test/_partial_name_in_local_assigns.erb +1 -0
  1085. data/actionview/test/fixtures/test/_partial_name_local_variable.erb +1 -0
  1086. data/actionview/test/fixtures/test/_partial_only.erb +1 -0
  1087. data/actionview/test/fixtures/test/_partial_shortcut_with_block_content.html.erb +3 -0
  1088. data/actionview/test/fixtures/test/_partial_with_layout.erb +2 -0
  1089. data/actionview/test/fixtures/test/_partial_with_layout_block_content.erb +4 -0
  1090. data/actionview/test/fixtures/test/_partial_with_layout_block_partial.erb +4 -0
  1091. data/actionview/test/fixtures/test/_partial_with_only_html_version.html.erb +1 -0
  1092. data/actionview/test/fixtures/test/_partial_with_partial.erb +2 -0
  1093. data/actionview/test/fixtures/test/_partial_with_variants.html+grid.erb +1 -0
  1094. data/actionview/test/fixtures/test/_partialhtml.html +1 -0
  1095. data/actionview/test/fixtures/test/_raise.html.erb +1 -0
  1096. data/actionview/test/fixtures/test/_raise_indentation.html.erb +13 -0
  1097. data/actionview/test/fixtures/test/_second_json_partial.json.erb +1 -0
  1098. data/actionview/test/fixtures/test/_two.html.erb +1 -0
  1099. data/actionview/test/fixtures/test/_utf8_partial.html.erb +1 -0
  1100. data/actionview/test/fixtures/test/_utf8_partial_magic.html.erb +2 -0
  1101. data/actionview/test/fixtures/test/_/360/237/215/243.erb +1 -0
  1102. data/actionview/test/fixtures/test/basic.html.erb +1 -0
  1103. data/actionview/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
  1104. data/actionview/test/fixtures/test/change_priority.html.erb +2 -0
  1105. data/actionview/test/fixtures/test/dont_pick_me +1 -0
  1106. data/actionview/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
  1107. data/actionview/test/fixtures/test/greeting.xml.erb +1 -0
  1108. data/actionview/test/fixtures/test/hello.builder +4 -0
  1109. data/actionview/test/fixtures/test/hello/hello.erb +1 -0
  1110. data/actionview/test/fixtures/test/hello_world.da.html.erb +1 -0
  1111. data/actionview/test/fixtures/test/hello_world.erb +1 -0
  1112. data/actionview/test/fixtures/test/hello_world.erb~ +1 -0
  1113. data/actionview/test/fixtures/test/hello_world.html+phone.erb +1 -0
  1114. data/actionview/test/fixtures/test/hello_world.pt-BR.html.erb +1 -0
  1115. data/actionview/test/fixtures/test/hello_world.text+phone.erb +1 -0
  1116. data/actionview/test/fixtures/test/hello_world_with_partial.html.erb +2 -0
  1117. data/actionview/test/fixtures/test/html_template.html.erb +1 -0
  1118. data/actionview/test/fixtures/test/layout_render_file.erb +2 -0
  1119. data/actionview/test/fixtures/test/layout_render_object.erb +1 -0
  1120. data/actionview/test/fixtures/test/list.erb +1 -0
  1121. data/actionview/test/fixtures/test/malformed/malformed.en.html.erb~ +1 -0
  1122. data/actionview/test/fixtures/test/malformed/malformed.erb~ +1 -0
  1123. data/actionview/test/fixtures/test/malformed/malformed.html.erb~ +1 -0
  1124. data/actionview/test/fixtures/test/malformed/malformed~ +1 -0
  1125. data/actionview/test/fixtures/test/nested_layout.erb +3 -0
  1126. data/actionview/test/fixtures/test/nested_streaming.erb +3 -0
  1127. data/actionview/test/fixtures/test/nil_return.erb +1 -0
  1128. data/actionview/test/fixtures/test/one.html.erb +1 -0
  1129. data/actionview/test/fixtures/test/render_file_inspect_local_assigns.erb +1 -0
  1130. data/actionview/test/fixtures/test/render_file_instance_variable.erb +1 -0
  1131. data/actionview/test/fixtures/test/render_file_unicode_local.erb +1 -0
  1132. data/actionview/test/fixtures/test/render_file_with_ivar.erb +1 -0
  1133. data/actionview/test/fixtures/test/render_file_with_locals.erb +1 -0
  1134. data/actionview/test/fixtures/test/render_file_with_locals_and_default.erb +1 -0
  1135. data/actionview/test/fixtures/test/render_file_with_ruby_keyword_locals.erb +1 -0
  1136. data/actionview/test/fixtures/test/render_partial_inside_directory.html.erb +1 -0
  1137. data/actionview/test/fixtures/test/render_two_partials.html.erb +2 -0
  1138. data/actionview/test/fixtures/test/streaming.erb +3 -0
  1139. data/actionview/test/fixtures/test/streaming_buster.erb +3 -0
  1140. data/actionview/test/fixtures/test/sub_template_raise.html.erb +1 -0
  1141. data/actionview/test/fixtures/test/template.erb +1 -0
  1142. data/actionview/test/fixtures/test/test_template_with_delegation_reserved_keywords.erb +1 -0
  1143. data/actionview/test/fixtures/test/update_element_with_capture.erb +9 -0
  1144. data/actionview/test/fixtures/test/utf8.html.erb +4 -0
  1145. data/actionview/test/fixtures/test/utf8_magic.html.erb +5 -0
  1146. data/actionview/test/fixtures/test/utf8_magic_with_bare_partial.html.erb +5 -0
  1147. data/actionview/test/fixtures/topic.rb +5 -0
  1148. data/actionview/test/fixtures/topics.yml +22 -0
  1149. data/actionview/test/fixtures/topics/_topic.html.erb +1 -0
  1150. data/actionview/test/fixtures/translations/templates/array.erb +1 -0
  1151. data/actionview/test/fixtures/translations/templates/default.erb +1 -0
  1152. data/actionview/test/fixtures/translations/templates/found.erb +1 -0
  1153. data/actionview/test/fixtures/translations/templates/missing.erb +1 -0
  1154. data/actionview/test/fixtures/with_format.json.erb +1 -0
  1155. data/actionview/test/lib/controller/fake_models.rb +204 -0
  1156. data/actionview/test/template/active_model_helper_test.rb +100 -0
  1157. data/actionview/test/template/asset_tag_helper_test.rb +831 -0
  1158. data/actionview/test/template/atom_feed_helper_test.rb +375 -0
  1159. data/actionview/test/template/capture_helper_test.rb +228 -0
  1160. data/actionview/test/template/compiled_templates_test.rb +94 -0
  1161. data/actionview/test/template/controller_helper_test.rb +34 -0
  1162. data/actionview/test/template/date_helper_i18n_test.rb +166 -0
  1163. data/actionview/test/template/date_helper_test.rb +3642 -0
  1164. data/actionview/test/template/dependency_tracker_test.rb +195 -0
  1165. data/actionview/test/template/digestor_test.rb +388 -0
  1166. data/actionview/test/template/erb/deprecated_erubis_implementation_test.rb +15 -0
  1167. data/actionview/test/template/erb/form_for_test.rb +13 -0
  1168. data/actionview/test/template/erb/helper.rb +26 -0
  1169. data/actionview/test/template/erb/tag_helper_test.rb +32 -0
  1170. data/actionview/test/template/erb_util_test.rb +114 -0
  1171. data/actionview/test/template/form_collections_helper_test.rb +527 -0
  1172. data/actionview/test/template/form_helper/form_with_test.rb +2239 -0
  1173. data/actionview/test/template/form_helper_test.rb +3522 -0
  1174. data/actionview/test/template/form_options_helper_i18n_test.rb +30 -0
  1175. data/actionview/test/template/form_options_helper_test.rb +1417 -0
  1176. data/actionview/test/template/form_tag_helper_test.rb +785 -0
  1177. data/actionview/test/template/html_test.rb +19 -0
  1178. data/actionview/test/template/javascript_helper_test.rb +64 -0
  1179. data/actionview/test/template/log_subscriber_test.rb +224 -0
  1180. data/actionview/test/template/lookup_context_test.rb +289 -0
  1181. data/actionview/test/template/number_helper_test.rb +204 -0
  1182. data/actionview/test/template/output_safety_helper_test.rb +119 -0
  1183. data/actionview/test/template/partial_iteration_test.rb +35 -0
  1184. data/actionview/test/template/record_identifier_test.rb +93 -0
  1185. data/actionview/test/template/record_tag_helper_test.rb +33 -0
  1186. data/actionview/test/template/render_test.rb +725 -0
  1187. data/actionview/test/template/resolver_cache_test.rb +9 -0
  1188. data/actionview/test/template/resolver_patterns_test.rb +44 -0
  1189. data/actionview/test/template/sanitize_helper_test.rb +43 -0
  1190. data/actionview/test/template/streaming_render_test.rb +113 -0
  1191. data/actionview/test/template/tag_helper_test.rb +357 -0
  1192. data/actionview/test/template/template_error_test.rb +37 -0
  1193. data/actionview/test/template/template_test.rb +207 -0
  1194. data/actionview/test/template/test_case_test.rb +335 -0
  1195. data/actionview/test/template/test_test.rb +94 -0
  1196. data/actionview/test/template/testing/fixture_resolver_test.rb +20 -0
  1197. data/actionview/test/template/testing/null_resolver_test.rb +14 -0
  1198. data/actionview/test/template/text_helper_test.rb +535 -0
  1199. data/actionview/test/template/text_test.rb +25 -0
  1200. data/actionview/test/template/translation_helper_test.rb +238 -0
  1201. data/actionview/test/template/url_helper_test.rb +969 -0
  1202. data/actionview/test/ujs/.gitignore +1 -0
  1203. data/actionview/test/ujs/config.ru +6 -0
  1204. data/actionview/test/ujs/public/test/.eslintrc.yml +21 -0
  1205. data/actionview/test/ujs/public/test/call-remote-callbacks.js +273 -0
  1206. data/actionview/test/ujs/public/test/call-remote.js +275 -0
  1207. data/actionview/test/ujs/public/test/csrf-refresh.js +24 -0
  1208. data/actionview/test/ujs/public/test/csrf-token.js +27 -0
  1209. data/actionview/test/ujs/public/test/data-confirm.js +316 -0
  1210. data/actionview/test/ujs/public/test/data-disable-with.js +391 -0
  1211. data/actionview/test/ujs/public/test/data-disable.js +321 -0
  1212. data/actionview/test/ujs/public/test/data-method.js +85 -0
  1213. data/actionview/test/ujs/public/test/data-remote.js +438 -0
  1214. data/actionview/test/ujs/public/test/override.js +56 -0
  1215. data/actionview/test/ujs/public/test/settings.js +116 -0
  1216. data/actionview/test/ujs/public/vendor/jquery-2.2.0.js +9831 -0
  1217. data/actionview/test/ujs/public/vendor/jquery.metadata.js +122 -0
  1218. data/actionview/test/ujs/public/vendor/qunit.css +237 -0
  1219. data/actionview/test/ujs/public/vendor/qunit.js +2288 -0
  1220. data/actionview/test/ujs/server.rb +74 -0
  1221. data/actionview/test/ujs/views/layouts/application.html.erb +25 -0
  1222. data/actionview/test/ujs/views/tests/index.html.erb +11 -0
  1223. data/activejob/CHANGELOG.md +8 -0
  1224. data/activejob/MIT-LICENSE +21 -0
  1225. data/activejob/README.md +126 -0
  1226. data/activejob/Rakefile +79 -0
  1227. data/activejob/activejob.gemspec +30 -0
  1228. data/activejob/bin/test +5 -0
  1229. data/activejob/lib/active_job.rb +39 -0
  1230. data/activejob/lib/active_job/arguments.rb +156 -0
  1231. data/activejob/lib/active_job/base.rb +74 -0
  1232. data/activejob/lib/active_job/callbacks.rb +155 -0
  1233. data/activejob/lib/active_job/configured_job.rb +18 -0
  1234. data/activejob/lib/active_job/core.rb +140 -0
  1235. data/activejob/lib/active_job/enqueuing.rb +59 -0
  1236. data/activejob/lib/active_job/exceptions.rb +124 -0
  1237. data/activejob/lib/active_job/execution.rb +49 -0
  1238. data/activejob/lib/active_job/gem_version.rb +17 -0
  1239. data/activejob/lib/active_job/logging.rb +130 -0
  1240. data/activejob/lib/active_job/queue_adapter.rb +66 -0
  1241. data/activejob/lib/active_job/queue_adapters.rb +139 -0
  1242. data/activejob/lib/active_job/queue_adapters/async_adapter.rb +116 -0
  1243. data/activejob/lib/active_job/queue_adapters/backburner_adapter.rb +36 -0
  1244. data/activejob/lib/active_job/queue_adapters/delayed_job_adapter.rb +43 -0
  1245. data/activejob/lib/active_job/queue_adapters/inline_adapter.rb +23 -0
  1246. data/activejob/lib/active_job/queue_adapters/qu_adapter.rb +46 -0
  1247. data/activejob/lib/active_job/queue_adapters/que_adapter.rb +39 -0
  1248. data/activejob/lib/active_job/queue_adapters/queue_classic_adapter.rb +58 -0
  1249. data/activejob/lib/active_job/queue_adapters/resque_adapter.rb +53 -0
  1250. data/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb +47 -0
  1251. data/activejob/lib/active_job/queue_adapters/sneakers_adapter.rb +48 -0
  1252. data/activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb +49 -0
  1253. data/activejob/lib/active_job/queue_adapters/test_adapter.rb +67 -0
  1254. data/activejob/lib/active_job/queue_name.rb +49 -0
  1255. data/activejob/lib/active_job/queue_priority.rb +43 -0
  1256. data/activejob/lib/active_job/railtie.rb +34 -0
  1257. data/activejob/lib/active_job/test_case.rb +11 -0
  1258. data/activejob/lib/active_job/test_helper.rb +448 -0
  1259. data/activejob/lib/active_job/translation.rb +13 -0
  1260. data/activejob/lib/active_job/version.rb +10 -0
  1261. data/activejob/lib/rails/generators/job/job_generator.rb +40 -0
  1262. data/activejob/lib/rails/generators/job/templates/application_job.rb +9 -0
  1263. data/activejob/lib/rails/generators/job/templates/job.rb +9 -0
  1264. data/activejob/test/adapters/async.rb +4 -0
  1265. data/activejob/test/adapters/backburner.rb +5 -0
  1266. data/activejob/test/adapters/delayed_job.rb +8 -0
  1267. data/activejob/test/adapters/inline.rb +3 -0
  1268. data/activejob/test/adapters/qu.rb +5 -0
  1269. data/activejob/test/adapters/que.rb +6 -0
  1270. data/activejob/test/adapters/queue_classic.rb +4 -0
  1271. data/activejob/test/adapters/resque.rb +4 -0
  1272. data/activejob/test/adapters/sidekiq.rb +4 -0
  1273. data/activejob/test/adapters/sneakers.rb +4 -0
  1274. data/activejob/test/adapters/sucker_punch.rb +4 -0
  1275. data/activejob/test/adapters/test.rb +5 -0
  1276. data/activejob/test/cases/adapter_test.rb +9 -0
  1277. data/activejob/test/cases/argument_serialization_test.rb +113 -0
  1278. data/activejob/test/cases/callbacks_test.rb +25 -0
  1279. data/activejob/test/cases/exceptions_test.rb +109 -0
  1280. data/activejob/test/cases/job_serialization_test.rb +57 -0
  1281. data/activejob/test/cases/logging_test.rb +137 -0
  1282. data/activejob/test/cases/queue_adapter_test.rb +51 -0
  1283. data/activejob/test/cases/queue_naming_test.rb +104 -0
  1284. data/activejob/test/cases/queue_priority_test.rb +49 -0
  1285. data/activejob/test/cases/queuing_test.rb +44 -0
  1286. data/activejob/test/cases/rescue_test.rb +36 -0
  1287. data/activejob/test/cases/test_case_test.rb +25 -0
  1288. data/activejob/test/cases/test_helper_test.rb +929 -0
  1289. data/activejob/test/cases/translation_test.rb +22 -0
  1290. data/activejob/test/helper.rb +18 -0
  1291. data/activejob/test/integration/queuing_test.rb +117 -0
  1292. data/activejob/test/jobs/application_job.rb +4 -0
  1293. data/activejob/test/jobs/callback_job.rb +29 -0
  1294. data/activejob/test/jobs/gid_job.rb +9 -0
  1295. data/activejob/test/jobs/hello_job.rb +9 -0
  1296. data/activejob/test/jobs/inherited_job.rb +7 -0
  1297. data/activejob/test/jobs/kwargs_job.rb +9 -0
  1298. data/activejob/test/jobs/logging_job.rb +11 -0
  1299. data/activejob/test/jobs/nested_job.rb +11 -0
  1300. data/activejob/test/jobs/overridden_logging_job.rb +11 -0
  1301. data/activejob/test/jobs/provider_jid_job.rb +9 -0
  1302. data/activejob/test/jobs/queue_adapter_job.rb +5 -0
  1303. data/activejob/test/jobs/queue_as_job.rb +12 -0
  1304. data/activejob/test/jobs/rescue_job.rb +29 -0
  1305. data/activejob/test/jobs/retry_job.rb +31 -0
  1306. data/activejob/test/jobs/translated_hello_job.rb +12 -0
  1307. data/activejob/test/models/person.rb +22 -0
  1308. data/activejob/test/support/backburner/inline.rb +10 -0
  1309. data/activejob/test/support/delayed_job/delayed/backend/test.rb +112 -0
  1310. data/activejob/test/support/delayed_job/delayed/serialization/test.rb +0 -0
  1311. data/activejob/test/support/integration/adapters/async.rb +12 -0
  1312. data/activejob/test/support/integration/adapters/backburner.rb +39 -0
  1313. data/activejob/test/support/integration/adapters/delayed_job.rb +23 -0
  1314. data/activejob/test/support/integration/adapters/inline.rb +16 -0
  1315. data/activejob/test/support/integration/adapters/qu.rb +40 -0
  1316. data/activejob/test/support/integration/adapters/que.rb +41 -0
  1317. data/activejob/test/support/integration/adapters/queue_classic.rb +39 -0
  1318. data/activejob/test/support/integration/adapters/resque.rb +51 -0
  1319. data/activejob/test/support/integration/adapters/sidekiq.rb +104 -0
  1320. data/activejob/test/support/integration/adapters/sneakers.rb +90 -0
  1321. data/activejob/test/support/integration/adapters/sucker_punch.rb +8 -0
  1322. data/activejob/test/support/integration/dummy_app_template.rb +32 -0
  1323. data/activejob/test/support/integration/helper.rb +33 -0
  1324. data/activejob/test/support/integration/jobs_manager.rb +29 -0
  1325. data/activejob/test/support/integration/test_case_helpers.rb +65 -0
  1326. data/activejob/test/support/job_buffer.rb +21 -0
  1327. data/activejob/test/support/que/inline.rb +16 -0
  1328. data/activejob/test/support/queue_classic/inline.rb +25 -0
  1329. data/activejob/test/support/sneakers/inline.rb +14 -0
  1330. data/activemodel/CHANGELOG.md +41 -0
  1331. data/activemodel/MIT-LICENSE +21 -0
  1332. data/activemodel/README.rdoc +264 -0
  1333. data/activemodel/Rakefile +23 -0
  1334. data/activemodel/activemodel.gemspec +29 -0
  1335. data/activemodel/bin/test +5 -0
  1336. data/activemodel/lib/active_model.rb +74 -0
  1337. data/activemodel/lib/active_model/attribute_assignment.rb +55 -0
  1338. data/activemodel/lib/active_model/attribute_methods.rb +478 -0
  1339. data/activemodel/lib/active_model/callbacks.rb +153 -0
  1340. data/activemodel/lib/active_model/conversion.rb +111 -0
  1341. data/activemodel/lib/active_model/dirty.rb +274 -0
  1342. data/activemodel/lib/active_model/errors.rb +513 -0
  1343. data/activemodel/lib/active_model/forbidden_attributes_protection.rb +31 -0
  1344. data/activemodel/lib/active_model/gem_version.rb +17 -0
  1345. data/activemodel/lib/active_model/lint.rb +118 -0
  1346. data/activemodel/lib/active_model/locale/en.yml +36 -0
  1347. data/activemodel/lib/active_model/model.rb +99 -0
  1348. data/activemodel/lib/active_model/naming.rb +318 -0
  1349. data/activemodel/lib/active_model/railtie.rb +14 -0
  1350. data/activemodel/lib/active_model/secure_password.rb +129 -0
  1351. data/activemodel/lib/active_model/serialization.rb +192 -0
  1352. data/activemodel/lib/active_model/serializers/json.rb +146 -0
  1353. data/activemodel/lib/active_model/translation.rb +70 -0
  1354. data/activemodel/lib/active_model/type.rb +49 -0
  1355. data/activemodel/lib/active_model/type/big_integer.rb +15 -0
  1356. data/activemodel/lib/active_model/type/binary.rb +52 -0
  1357. data/activemodel/lib/active_model/type/boolean.rb +34 -0
  1358. data/activemodel/lib/active_model/type/date.rb +56 -0
  1359. data/activemodel/lib/active_model/type/date_time.rb +50 -0
  1360. data/activemodel/lib/active_model/type/decimal.rb +70 -0
  1361. data/activemodel/lib/active_model/type/float.rb +36 -0
  1362. data/activemodel/lib/active_model/type/helpers.rb +6 -0
  1363. data/activemodel/lib/active_model/type/helpers/accepts_multiparameter_time.rb +41 -0
  1364. data/activemodel/lib/active_model/type/helpers/mutable.rb +20 -0
  1365. data/activemodel/lib/active_model/type/helpers/numeric.rb +37 -0
  1366. data/activemodel/lib/active_model/type/helpers/time_value.rb +79 -0
  1367. data/activemodel/lib/active_model/type/immutable_string.rb +32 -0
  1368. data/activemodel/lib/active_model/type/integer.rb +70 -0
  1369. data/activemodel/lib/active_model/type/registry.rb +70 -0
  1370. data/activemodel/lib/active_model/type/string.rb +26 -0
  1371. data/activemodel/lib/active_model/type/time.rb +48 -0
  1372. data/activemodel/lib/active_model/type/value.rb +122 -0
  1373. data/activemodel/lib/active_model/validations.rb +439 -0
  1374. data/activemodel/lib/active_model/validations/absence.rb +33 -0
  1375. data/activemodel/lib/active_model/validations/acceptance.rb +106 -0
  1376. data/activemodel/lib/active_model/validations/callbacks.rb +116 -0
  1377. data/activemodel/lib/active_model/validations/clusivity.rb +54 -0
  1378. data/activemodel/lib/active_model/validations/confirmation.rb +80 -0
  1379. data/activemodel/lib/active_model/validations/exclusion.rb +49 -0
  1380. data/activemodel/lib/active_model/validations/format.rb +114 -0
  1381. data/activemodel/lib/active_model/validations/helper_methods.rb +15 -0
  1382. data/activemodel/lib/active_model/validations/inclusion.rb +47 -0
  1383. data/activemodel/lib/active_model/validations/length.rb +123 -0
  1384. data/activemodel/lib/active_model/validations/numericality.rb +165 -0
  1385. data/activemodel/lib/active_model/validations/presence.rb +39 -0
  1386. data/activemodel/lib/active_model/validations/validates.rb +174 -0
  1387. data/activemodel/lib/active_model/validations/with.rb +147 -0
  1388. data/activemodel/lib/active_model/validator.rb +183 -0
  1389. data/activemodel/lib/active_model/version.rb +10 -0
  1390. data/activemodel/test/cases/attribute_assignment_test.rb +131 -0
  1391. data/activemodel/test/cases/attribute_methods_test.rb +283 -0
  1392. data/activemodel/test/cases/callbacks_test.rb +134 -0
  1393. data/activemodel/test/cases/conversion_test.rb +52 -0
  1394. data/activemodel/test/cases/dirty_test.rb +222 -0
  1395. data/activemodel/test/cases/errors_test.rb +420 -0
  1396. data/activemodel/test/cases/forbidden_attributes_protection_test.rb +44 -0
  1397. data/activemodel/test/cases/helper.rb +25 -0
  1398. data/activemodel/test/cases/lint_test.rb +22 -0
  1399. data/activemodel/test/cases/model_test.rb +79 -0
  1400. data/activemodel/test/cases/naming_test.rb +282 -0
  1401. data/activemodel/test/cases/railtie_test.rb +34 -0
  1402. data/activemodel/test/cases/secure_password_test.rb +220 -0
  1403. data/activemodel/test/cases/serialization_test.rb +177 -0
  1404. data/activemodel/test/cases/serializers/json_serialization_test.rb +204 -0
  1405. data/activemodel/test/cases/translation_test.rb +113 -0
  1406. data/activemodel/test/cases/type/big_integer_test.rb +26 -0
  1407. data/activemodel/test/cases/type/binary_test.rb +17 -0
  1408. data/activemodel/test/cases/type/boolean_test.rb +41 -0
  1409. data/activemodel/test/cases/type/date_test.rb +21 -0
  1410. data/activemodel/test/cases/type/date_time_test.rb +40 -0
  1411. data/activemodel/test/cases/type/decimal_test.rb +74 -0
  1412. data/activemodel/test/cases/type/float_test.rb +32 -0
  1413. data/activemodel/test/cases/type/immutable_string_test.rb +23 -0
  1414. data/activemodel/test/cases/type/integer_test.rb +118 -0
  1415. data/activemodel/test/cases/type/registry_test.rb +43 -0
  1416. data/activemodel/test/cases/type/string_test.rb +39 -0
  1417. data/activemodel/test/cases/type/time_test.rb +23 -0
  1418. data/activemodel/test/cases/type/value_test.rb +16 -0
  1419. data/activemodel/test/cases/validations/absence_validation_test.rb +69 -0
  1420. data/activemodel/test/cases/validations/acceptance_validation_test.rb +88 -0
  1421. data/activemodel/test/cases/validations/callbacks_test.rb +145 -0
  1422. data/activemodel/test/cases/validations/conditional_validation_test.rb +149 -0
  1423. data/activemodel/test/cases/validations/confirmation_validation_test.rb +121 -0
  1424. data/activemodel/test/cases/validations/exclusion_validation_test.rb +109 -0
  1425. data/activemodel/test/cases/validations/format_validation_test.rb +149 -0
  1426. data/activemodel/test/cases/validations/i18n_generate_message_validation_test.rb +152 -0
  1427. data/activemodel/test/cases/validations/i18n_validation_test.rb +344 -0
  1428. data/activemodel/test/cases/validations/inclusion_validation_test.rb +161 -0
  1429. data/activemodel/test/cases/validations/length_validation_test.rb +413 -0
  1430. data/activemodel/test/cases/validations/numericality_validation_test.rb +305 -0
  1431. data/activemodel/test/cases/validations/presence_validation_test.rb +107 -0
  1432. data/activemodel/test/cases/validations/validates_test.rb +159 -0
  1433. data/activemodel/test/cases/validations/validations_context_test.rb +70 -0
  1434. data/activemodel/test/cases/validations/with_validation_test.rb +185 -0
  1435. data/activemodel/test/cases/validations_test.rb +465 -0
  1436. data/activemodel/test/models/account.rb +7 -0
  1437. data/activemodel/test/models/blog_post.rb +11 -0
  1438. data/activemodel/test/models/contact.rb +42 -0
  1439. data/activemodel/test/models/custom_reader.rb +17 -0
  1440. data/activemodel/test/models/helicopter.rb +9 -0
  1441. data/activemodel/test/models/person.rb +19 -0
  1442. data/activemodel/test/models/person_with_validator.rb +26 -0
  1443. data/activemodel/test/models/reply.rb +34 -0
  1444. data/activemodel/test/models/sheep.rb +5 -0
  1445. data/activemodel/test/models/topic.rb +41 -0
  1446. data/activemodel/test/models/track_back.rb +13 -0
  1447. data/activemodel/test/models/user.rb +12 -0
  1448. data/activemodel/test/models/visitor.rb +12 -0
  1449. data/activemodel/test/validators/email_validator.rb +8 -0
  1450. data/activemodel/test/validators/namespace/email_validator.rb +8 -0
  1451. data/activerecord/CHANGELOG.md +242 -0
  1452. data/activerecord/MIT-LICENSE +20 -0
  1453. data/activerecord/README.rdoc +217 -0
  1454. data/activerecord/RUNNING_UNIT_TESTS.rdoc +51 -0
  1455. data/activerecord/Rakefile +142 -0
  1456. data/activerecord/activerecord.gemspec +35 -0
  1457. data/activerecord/bin/test +20 -0
  1458. data/activerecord/examples/.gitignore +1 -0
  1459. data/activerecord/examples/performance.rb +185 -0
  1460. data/activerecord/examples/simple.rb +15 -0
  1461. data/activerecord/lib/active_record.rb +183 -0
  1462. data/activerecord/lib/active_record/aggregations.rb +284 -0
  1463. data/activerecord/lib/active_record/association_relation.rb +40 -0
  1464. data/activerecord/lib/active_record/associations.rb +1885 -0
  1465. data/activerecord/lib/active_record/associations/alias_tracker.rb +94 -0
  1466. data/activerecord/lib/active_record/associations/association.rb +284 -0
  1467. data/activerecord/lib/active_record/associations/association_scope.rb +181 -0
  1468. data/activerecord/lib/active_record/associations/belongs_to_association.rb +113 -0
  1469. data/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +42 -0
  1470. data/activerecord/lib/active_record/associations/builder/association.rb +145 -0
  1471. data/activerecord/lib/active_record/associations/builder/belongs_to.rb +150 -0
  1472. data/activerecord/lib/active_record/associations/builder/collection_association.rb +82 -0
  1473. data/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb +135 -0
  1474. data/activerecord/lib/active_record/associations/builder/has_many.rb +17 -0
  1475. data/activerecord/lib/active_record/associations/builder/has_one.rb +30 -0
  1476. data/activerecord/lib/active_record/associations/builder/singular_association.rb +42 -0
  1477. data/activerecord/lib/active_record/associations/collection_association.rb +505 -0
  1478. data/activerecord/lib/active_record/associations/collection_proxy.rb +1159 -0
  1479. data/activerecord/lib/active_record/associations/foreign_association.rb +13 -0
  1480. data/activerecord/lib/active_record/associations/has_many_association.rb +135 -0
  1481. data/activerecord/lib/active_record/associations/has_many_through_association.rb +216 -0
  1482. data/activerecord/lib/active_record/associations/has_one_association.rb +111 -0
  1483. data/activerecord/lib/active_record/associations/has_one_through_association.rb +42 -0
  1484. data/activerecord/lib/active_record/associations/join_dependency.rb +287 -0
  1485. data/activerecord/lib/active_record/associations/join_dependency/join_association.rb +61 -0
  1486. data/activerecord/lib/active_record/associations/join_dependency/join_base.rb +23 -0
  1487. data/activerecord/lib/active_record/associations/join_dependency/join_part.rb +64 -0
  1488. data/activerecord/lib/active_record/associations/preloader.rb +204 -0
  1489. data/activerecord/lib/active_record/associations/preloader/association.rb +133 -0
  1490. data/activerecord/lib/active_record/associations/preloader/belongs_to.rb +17 -0
  1491. data/activerecord/lib/active_record/associations/preloader/collection_association.rb +19 -0
  1492. data/activerecord/lib/active_record/associations/preloader/has_many.rb +17 -0
  1493. data/activerecord/lib/active_record/associations/preloader/has_many_through.rb +21 -0
  1494. data/activerecord/lib/active_record/associations/preloader/has_one.rb +17 -0
  1495. data/activerecord/lib/active_record/associations/preloader/has_one_through.rb +11 -0
  1496. data/activerecord/lib/active_record/associations/preloader/singular_association.rb +20 -0
  1497. data/activerecord/lib/active_record/associations/preloader/through_association.rb +111 -0
  1498. data/activerecord/lib/active_record/associations/singular_association.rb +79 -0
  1499. data/activerecord/lib/active_record/associations/through_association.rb +108 -0
  1500. data/activerecord/lib/active_record/attribute.rb +242 -0
  1501. data/activerecord/lib/active_record/attribute/user_provided_default.rb +32 -0
  1502. data/activerecord/lib/active_record/attribute_assignment.rb +93 -0
  1503. data/activerecord/lib/active_record/attribute_decorators.rb +90 -0
  1504. data/activerecord/lib/active_record/attribute_methods.rb +449 -0
  1505. data/activerecord/lib/active_record/attribute_methods/before_type_cast.rb +78 -0
  1506. data/activerecord/lib/active_record/attribute_methods/dirty.rb +251 -0
  1507. data/activerecord/lib/active_record/attribute_methods/primary_key.rb +141 -0
  1508. data/activerecord/lib/active_record/attribute_methods/query.rb +42 -0
  1509. data/activerecord/lib/active_record/attribute_methods/read.rb +84 -0
  1510. data/activerecord/lib/active_record/attribute_methods/serialization.rb +90 -0
  1511. data/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +91 -0
  1512. data/activerecord/lib/active_record/attribute_methods/write.rb +67 -0
  1513. data/activerecord/lib/active_record/attribute_mutation_tracker.rb +111 -0
  1514. data/activerecord/lib/active_record/attribute_set.rb +113 -0
  1515. data/activerecord/lib/active_record/attribute_set/builder.rb +126 -0
  1516. data/activerecord/lib/active_record/attribute_set/yaml_encoder.rb +43 -0
  1517. data/activerecord/lib/active_record/attributes.rb +266 -0
  1518. data/activerecord/lib/active_record/autosave_association.rb +490 -0
  1519. data/activerecord/lib/active_record/base.rb +329 -0
  1520. data/activerecord/lib/active_record/callbacks.rb +349 -0
  1521. data/activerecord/lib/active_record/coders/json.rb +15 -0
  1522. data/activerecord/lib/active_record/coders/yaml_column.rb +50 -0
  1523. data/activerecord/lib/active_record/collection_cache_key.rb +51 -0
  1524. data/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +990 -0
  1525. data/activerecord/lib/active_record/connection_adapters/abstract/database_limits.rb +67 -0
  1526. data/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +491 -0
  1527. data/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +140 -0
  1528. data/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +216 -0
  1529. data/activerecord/lib/active_record/connection_adapters/abstract/savepoints.rb +23 -0
  1530. data/activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb +145 -0
  1531. data/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +654 -0
  1532. data/activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb +95 -0
  1533. data/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +1378 -0
  1534. data/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb +274 -0
  1535. data/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +599 -0
  1536. data/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +885 -0
  1537. data/activerecord/lib/active_record/connection_adapters/column.rb +91 -0
  1538. data/activerecord/lib/active_record/connection_adapters/connection_specification.rb +275 -0
  1539. data/activerecord/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +24 -0
  1540. data/activerecord/lib/active_record/connection_adapters/mysql/column.rb +27 -0
  1541. data/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb +97 -0
  1542. data/activerecord/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +72 -0
  1543. data/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb +44 -0
  1544. data/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb +73 -0
  1545. data/activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb +92 -0
  1546. data/activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb +73 -0
  1547. data/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb +139 -0
  1548. data/activerecord/lib/active_record/connection_adapters/mysql/type_metadata.rb +35 -0
  1549. data/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +125 -0
  1550. data/activerecord/lib/active_record/connection_adapters/postgresql/column.rb +17 -0
  1551. data/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb +163 -0
  1552. data/activerecord/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +44 -0
  1553. data/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb +33 -0
  1554. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb +82 -0
  1555. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb +56 -0
  1556. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +15 -0
  1557. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +17 -0
  1558. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +50 -0
  1559. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +23 -0
  1560. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +15 -0
  1561. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/enum.rb +21 -0
  1562. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +71 -0
  1563. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/inet.rb +15 -0
  1564. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +15 -0
  1565. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +45 -0
  1566. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb +41 -0
  1567. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/oid.rb +15 -0
  1568. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb +65 -0
  1569. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/range.rb +93 -0
  1570. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +18 -0
  1571. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +111 -0
  1572. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +23 -0
  1573. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/vector.rb +28 -0
  1574. data/activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb +30 -0
  1575. data/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb +152 -0
  1576. data/activerecord/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +51 -0
  1577. data/activerecord/lib/active_record/connection_adapters/postgresql/schema_creation.rb +17 -0
  1578. data/activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +195 -0
  1579. data/activerecord/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +38 -0
  1580. data/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +678 -0
  1581. data/activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb +39 -0
  1582. data/activerecord/lib/active_record/connection_adapters/postgresql/utils.rb +81 -0
  1583. data/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +838 -0
  1584. data/activerecord/lib/active_record/connection_adapters/schema_cache.rb +118 -0
  1585. data/activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb +34 -0
  1586. data/activerecord/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +21 -0
  1587. data/activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb +62 -0
  1588. data/activerecord/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +17 -0
  1589. data/activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +30 -0
  1590. data/activerecord/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
  1591. data/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +102 -0
  1592. data/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +531 -0
  1593. data/activerecord/lib/active_record/connection_adapters/statement_pool.rb +61 -0
  1594. data/activerecord/lib/active_record/connection_handling.rb +145 -0
  1595. data/activerecord/lib/active_record/core.rb +560 -0
  1596. data/activerecord/lib/active_record/counter_cache.rb +214 -0
  1597. data/activerecord/lib/active_record/define_callbacks.rb +22 -0
  1598. data/activerecord/lib/active_record/dynamic_matchers.rb +122 -0
  1599. data/activerecord/lib/active_record/enum.rb +241 -0
  1600. data/activerecord/lib/active_record/errors.rb +342 -0
  1601. data/activerecord/lib/active_record/explain.rb +50 -0
  1602. data/activerecord/lib/active_record/explain_registry.rb +32 -0
  1603. data/activerecord/lib/active_record/explain_subscriber.rb +34 -0
  1604. data/activerecord/lib/active_record/fixture_set/file.rb +82 -0
  1605. data/activerecord/lib/active_record/fixtures.rb +1074 -0
  1606. data/activerecord/lib/active_record/gem_version.rb +17 -0
  1607. data/activerecord/lib/active_record/inheritance.rb +254 -0
  1608. data/activerecord/lib/active_record/integration.rb +155 -0
  1609. data/activerecord/lib/active_record/internal_metadata.rb +45 -0
  1610. data/activerecord/lib/active_record/legacy_yaml_adapter.rb +48 -0
  1611. data/activerecord/lib/active_record/locale/en.yml +48 -0
  1612. data/activerecord/lib/active_record/locking/optimistic.rb +212 -0
  1613. data/activerecord/lib/active_record/locking/pessimistic.rb +88 -0
  1614. data/activerecord/lib/active_record/log_subscriber.rb +96 -0
  1615. data/activerecord/lib/active_record/migration.rb +1340 -0
  1616. data/activerecord/lib/active_record/migration/command_recorder.rb +240 -0
  1617. data/activerecord/lib/active_record/migration/compatibility.rb +170 -0
  1618. data/activerecord/lib/active_record/migration/join_table.rb +17 -0
  1619. data/activerecord/lib/active_record/model_schema.rb +515 -0
  1620. data/activerecord/lib/active_record/nested_attributes.rb +589 -0
  1621. data/activerecord/lib/active_record/no_touching.rb +58 -0
  1622. data/activerecord/lib/active_record/null_relation.rb +68 -0
  1623. data/activerecord/lib/active_record/persistence.rb +623 -0
  1624. data/activerecord/lib/active_record/query_cache.rb +49 -0
  1625. data/activerecord/lib/active_record/querying.rb +70 -0
  1626. data/activerecord/lib/active_record/railtie.rb +214 -0
  1627. data/activerecord/lib/active_record/railties/console_sandbox.rb +7 -0
  1628. data/activerecord/lib/active_record/railties/controller_runtime.rb +56 -0
  1629. data/activerecord/lib/active_record/railties/databases.rake +369 -0
  1630. data/activerecord/lib/active_record/railties/jdbcmysql_error.rb +18 -0
  1631. data/activerecord/lib/active_record/readonly_attributes.rb +24 -0
  1632. data/activerecord/lib/active_record/reflection.rb +1102 -0
  1633. data/activerecord/lib/active_record/relation.rb +730 -0
  1634. data/activerecord/lib/active_record/relation/batches.rb +280 -0
  1635. data/activerecord/lib/active_record/relation/batches/batch_enumerator.rb +69 -0
  1636. data/activerecord/lib/active_record/relation/calculations.rb +407 -0
  1637. data/activerecord/lib/active_record/relation/delegation.rb +113 -0
  1638. data/activerecord/lib/active_record/relation/finder_methods.rb +566 -0
  1639. data/activerecord/lib/active_record/relation/from_clause.rb +26 -0
  1640. data/activerecord/lib/active_record/relation/merger.rb +168 -0
  1641. data/activerecord/lib/active_record/relation/predicate_builder.rb +133 -0
  1642. data/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb +48 -0
  1643. data/activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb +46 -0
  1644. data/activerecord/lib/active_record/relation/predicate_builder/base_handler.rb +19 -0
  1645. data/activerecord/lib/active_record/relation/predicate_builder/basic_object_handler.rb +20 -0
  1646. data/activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +54 -0
  1647. data/activerecord/lib/active_record/relation/predicate_builder/range_handler.rb +41 -0
  1648. data/activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb +15 -0
  1649. data/activerecord/lib/active_record/relation/query_attribute.rb +26 -0
  1650. data/activerecord/lib/active_record/relation/query_methods.rb +1194 -0
  1651. data/activerecord/lib/active_record/relation/record_fetch_warning.rb +51 -0
  1652. data/activerecord/lib/active_record/relation/spawn_methods.rb +77 -0
  1653. data/activerecord/lib/active_record/relation/where_clause.rb +172 -0
  1654. data/activerecord/lib/active_record/relation/where_clause_factory.rb +35 -0
  1655. data/activerecord/lib/active_record/result.rb +149 -0
  1656. data/activerecord/lib/active_record/runtime_registry.rb +24 -0
  1657. data/activerecord/lib/active_record/sanitization.rb +216 -0
  1658. data/activerecord/lib/active_record/schema.rb +70 -0
  1659. data/activerecord/lib/active_record/schema_dumper.rb +254 -0
  1660. data/activerecord/lib/active_record/schema_migration.rb +56 -0
  1661. data/activerecord/lib/active_record/scoping.rb +106 -0
  1662. data/activerecord/lib/active_record/scoping/default.rb +152 -0
  1663. data/activerecord/lib/active_record/scoping/named.rb +199 -0
  1664. data/activerecord/lib/active_record/secure_token.rb +40 -0
  1665. data/activerecord/lib/active_record/serialization.rb +22 -0
  1666. data/activerecord/lib/active_record/statement_cache.rb +121 -0
  1667. data/activerecord/lib/active_record/store.rb +211 -0
  1668. data/activerecord/lib/active_record/suppressor.rb +61 -0
  1669. data/activerecord/lib/active_record/table_metadata.rb +75 -0
  1670. data/activerecord/lib/active_record/tasks/database_tasks.rb +327 -0
  1671. data/activerecord/lib/active_record/tasks/mysql_database_tasks.rb +162 -0
  1672. data/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb +143 -0
  1673. data/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb +83 -0
  1674. data/activerecord/lib/active_record/timestamp.rb +146 -0
  1675. data/activerecord/lib/active_record/touch_later.rb +64 -0
  1676. data/activerecord/lib/active_record/transactions.rb +499 -0
  1677. data/activerecord/lib/active_record/translation.rb +24 -0
  1678. data/activerecord/lib/active_record/type.rb +79 -0
  1679. data/activerecord/lib/active_record/type/adapter_specific_registry.rb +136 -0
  1680. data/activerecord/lib/active_record/type/date.rb +9 -0
  1681. data/activerecord/lib/active_record/type/date_time.rb +9 -0
  1682. data/activerecord/lib/active_record/type/decimal_without_scale.rb +15 -0
  1683. data/activerecord/lib/active_record/type/hash_lookup_type_map.rb +25 -0
  1684. data/activerecord/lib/active_record/type/internal/timezone.rb +17 -0
  1685. data/activerecord/lib/active_record/type/json.rb +30 -0
  1686. data/activerecord/lib/active_record/type/serialized.rb +67 -0
  1687. data/activerecord/lib/active_record/type/text.rb +11 -0
  1688. data/activerecord/lib/active_record/type/time.rb +21 -0
  1689. data/activerecord/lib/active_record/type/type_map.rb +62 -0
  1690. data/activerecord/lib/active_record/type/unsigned_integer.rb +17 -0
  1691. data/activerecord/lib/active_record/type_caster.rb +9 -0
  1692. data/activerecord/lib/active_record/type_caster/connection.rb +33 -0
  1693. data/activerecord/lib/active_record/type_caster/map.rb +23 -0
  1694. data/activerecord/lib/active_record/validations.rb +93 -0
  1695. data/activerecord/lib/active_record/validations/absence.rb +25 -0
  1696. data/activerecord/lib/active_record/validations/associated.rb +60 -0
  1697. data/activerecord/lib/active_record/validations/length.rb +26 -0
  1698. data/activerecord/lib/active_record/validations/presence.rb +68 -0
  1699. data/activerecord/lib/active_record/validations/uniqueness.rb +240 -0
  1700. data/activerecord/lib/active_record/version.rb +10 -0
  1701. data/activerecord/lib/rails/generators/active_record.rb +19 -0
  1702. data/activerecord/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
  1703. data/activerecord/lib/rails/generators/active_record/application_record/templates/application_record.rb +5 -0
  1704. data/activerecord/lib/rails/generators/active_record/migration.rb +35 -0
  1705. data/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb +78 -0
  1706. data/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +24 -0
  1707. data/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb +46 -0
  1708. data/activerecord/lib/rails/generators/active_record/model/model_generator.rb +48 -0
  1709. data/activerecord/lib/rails/generators/active_record/model/templates/model.rb +13 -0
  1710. data/activerecord/lib/rails/generators/active_record/model/templates/module.rb +7 -0
  1711. data/activerecord/test/.gitignore +1 -0
  1712. data/activerecord/test/active_record/connection_adapters/fake_adapter.rb +51 -0
  1713. data/activerecord/test/assets/example.log +1 -0
  1714. data/activerecord/test/assets/flowers.jpg +0 -0
  1715. data/activerecord/test/assets/schema_dump_5_1.yml +345 -0
  1716. data/activerecord/test/assets/test.txt +1 -0
  1717. data/activerecord/test/cases/adapter_test.rb +404 -0
  1718. data/activerecord/test/cases/adapters/mysql2/active_schema_test.rb +195 -0
  1719. data/activerecord/test/cases/adapters/mysql2/bind_parameter_test.rb +52 -0
  1720. data/activerecord/test/cases/adapters/mysql2/boolean_test.rb +102 -0
  1721. data/activerecord/test/cases/adapters/mysql2/case_sensitivity_test.rb +65 -0
  1722. data/activerecord/test/cases/adapters/mysql2/charset_collation_test.rb +56 -0
  1723. data/activerecord/test/cases/adapters/mysql2/connection_test.rb +225 -0
  1724. data/activerecord/test/cases/adapters/mysql2/datetime_precision_quoting_test.rb +54 -0
  1725. data/activerecord/test/cases/adapters/mysql2/enum_test.rb +23 -0
  1726. data/activerecord/test/cases/adapters/mysql2/explain_test.rb +23 -0
  1727. data/activerecord/test/cases/adapters/mysql2/json_test.rb +24 -0
  1728. data/activerecord/test/cases/adapters/mysql2/mysql2_adapter_test.rb +77 -0
  1729. data/activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb +65 -0
  1730. data/activerecord/test/cases/adapters/mysql2/schema_test.rb +128 -0
  1731. data/activerecord/test/cases/adapters/mysql2/sp_test.rb +38 -0
  1732. data/activerecord/test/cases/adapters/mysql2/sql_types_test.rb +16 -0
  1733. data/activerecord/test/cases/adapters/mysql2/table_options_test.rb +44 -0
  1734. data/activerecord/test/cases/adapters/mysql2/transaction_test.rb +69 -0
  1735. data/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb +68 -0
  1736. data/activerecord/test/cases/adapters/mysql2/virtual_column_test.rb +61 -0
  1737. data/activerecord/test/cases/adapters/postgresql/active_schema_test.rb +100 -0
  1738. data/activerecord/test/cases/adapters/postgresql/array_test.rb +388 -0
  1739. data/activerecord/test/cases/adapters/postgresql/bit_string_test.rb +84 -0
  1740. data/activerecord/test/cases/adapters/postgresql/bytea_test.rb +137 -0
  1741. data/activerecord/test/cases/adapters/postgresql/case_insensitive_test.rb +28 -0
  1742. data/activerecord/test/cases/adapters/postgresql/change_schema_test.rb +40 -0
  1743. data/activerecord/test/cases/adapters/postgresql/cidr_test.rb +27 -0
  1744. data/activerecord/test/cases/adapters/postgresql/citext_test.rb +80 -0
  1745. data/activerecord/test/cases/adapters/postgresql/collation_test.rb +55 -0
  1746. data/activerecord/test/cases/adapters/postgresql/composite_test.rb +134 -0
  1747. data/activerecord/test/cases/adapters/postgresql/connection_test.rb +272 -0
  1748. data/activerecord/test/cases/adapters/postgresql/datatype_test.rb +93 -0
  1749. data/activerecord/test/cases/adapters/postgresql/domain_test.rb +49 -0
  1750. data/activerecord/test/cases/adapters/postgresql/enum_test.rb +93 -0
  1751. data/activerecord/test/cases/adapters/postgresql/explain_test.rb +22 -0
  1752. data/activerecord/test/cases/adapters/postgresql/extension_migration_test.rb +65 -0
  1753. data/activerecord/test/cases/adapters/postgresql/full_text_test.rb +46 -0
  1754. data/activerecord/test/cases/adapters/postgresql/geometric_test.rb +373 -0
  1755. data/activerecord/test/cases/adapters/postgresql/hstore_test.rb +380 -0
  1756. data/activerecord/test/cases/adapters/postgresql/infinity_test.rb +71 -0
  1757. data/activerecord/test/cases/adapters/postgresql/integer_test.rb +27 -0
  1758. data/activerecord/test/cases/adapters/postgresql/json_test.rb +52 -0
  1759. data/activerecord/test/cases/adapters/postgresql/ltree_test.rb +55 -0
  1760. data/activerecord/test/cases/adapters/postgresql/money_test.rb +98 -0
  1761. data/activerecord/test/cases/adapters/postgresql/network_test.rb +96 -0
  1762. data/activerecord/test/cases/adapters/postgresql/numbers_test.rb +51 -0
  1763. data/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb +390 -0
  1764. data/activerecord/test/cases/adapters/postgresql/prepared_statements_disabled_test.rb +27 -0
  1765. data/activerecord/test/cases/adapters/postgresql/quoting_test.rb +45 -0
  1766. data/activerecord/test/cases/adapters/postgresql/range_test.rb +351 -0
  1767. data/activerecord/test/cases/adapters/postgresql/referential_integrity_test.rb +113 -0
  1768. data/activerecord/test/cases/adapters/postgresql/rename_table_test.rb +36 -0
  1769. data/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb +110 -0
  1770. data/activerecord/test/cases/adapters/postgresql/schema_test.rb +592 -0
  1771. data/activerecord/test/cases/adapters/postgresql/serial_test.rb +88 -0
  1772. data/activerecord/test/cases/adapters/postgresql/statement_pool_test.rb +43 -0
  1773. data/activerecord/test/cases/adapters/postgresql/timestamp_test.rb +92 -0
  1774. data/activerecord/test/cases/adapters/postgresql/transaction_test.rb +104 -0
  1775. data/activerecord/test/cases/adapters/postgresql/type_lookup_test.rb +35 -0
  1776. data/activerecord/test/cases/adapters/postgresql/utils_test.rb +64 -0
  1777. data/activerecord/test/cases/adapters/postgresql/uuid_test.rb +376 -0
  1778. data/activerecord/test/cases/adapters/postgresql/xml_test.rb +56 -0
  1779. data/activerecord/test/cases/adapters/sqlite3/collation_test.rb +55 -0
  1780. data/activerecord/test/cases/adapters/sqlite3/copy_table_test.rb +101 -0
  1781. data/activerecord/test/cases/adapters/sqlite3/explain_test.rb +23 -0
  1782. data/activerecord/test/cases/adapters/sqlite3/quoting_test.rb +58 -0
  1783. data/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +421 -0
  1784. data/activerecord/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb +26 -0
  1785. data/activerecord/test/cases/adapters/sqlite3/statement_pool_test.rb +21 -0
  1786. data/activerecord/test/cases/aggregations_test.rb +170 -0
  1787. data/activerecord/test/cases/ar_schema_test.rb +145 -0
  1788. data/activerecord/test/cases/associations/belongs_to_associations_test.rb +1196 -0
  1789. data/activerecord/test/cases/associations/bidirectional_destroy_dependencies_test.rb +43 -0
  1790. data/activerecord/test/cases/associations/callbacks_test.rb +191 -0
  1791. data/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +184 -0
  1792. data/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb +44 -0
  1793. data/activerecord/test/cases/associations/eager_load_nested_include_test.rb +126 -0
  1794. data/activerecord/test/cases/associations/eager_singularization_test.rb +148 -0
  1795. data/activerecord/test/cases/associations/eager_test.rb +1500 -0
  1796. data/activerecord/test/cases/associations/extension_test.rb +94 -0
  1797. data/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +1033 -0
  1798. data/activerecord/test/cases/associations/has_many_associations_test.rb +2619 -0
  1799. data/activerecord/test/cases/associations/has_many_through_associations_test.rb +1309 -0
  1800. data/activerecord/test/cases/associations/has_one_associations_test.rb +727 -0
  1801. data/activerecord/test/cases/associations/has_one_through_associations_test.rb +392 -0
  1802. data/activerecord/test/cases/associations/inner_join_association_test.rb +141 -0
  1803. data/activerecord/test/cases/associations/inverse_associations_test.rb +727 -0
  1804. data/activerecord/test/cases/associations/join_model_test.rb +778 -0
  1805. data/activerecord/test/cases/associations/left_outer_join_association_test.rb +90 -0
  1806. data/activerecord/test/cases/associations/nested_through_associations_test.rb +581 -0
  1807. data/activerecord/test/cases/associations/required_test.rb +132 -0
  1808. data/activerecord/test/cases/associations_test.rb +370 -0
  1809. data/activerecord/test/cases/attribute_decorators_test.rb +127 -0
  1810. data/activerecord/test/cases/attribute_methods/read_test.rb +61 -0
  1811. data/activerecord/test/cases/attribute_methods_test.rb +1038 -0
  1812. data/activerecord/test/cases/attribute_set_test.rb +255 -0
  1813. data/activerecord/test/cases/attribute_test.rb +255 -0
  1814. data/activerecord/test/cases/attributes_test.rb +269 -0
  1815. data/activerecord/test/cases/autosave_association_test.rb +1738 -0
  1816. data/activerecord/test/cases/base_test.rb +1460 -0
  1817. data/activerecord/test/cases/batches_test.rb +676 -0
  1818. data/activerecord/test/cases/binary_test.rb +46 -0
  1819. data/activerecord/test/cases/bind_parameter_test.rb +108 -0
  1820. data/activerecord/test/cases/cache_key_test.rb +53 -0
  1821. data/activerecord/test/cases/calculations_test.rb +894 -0
  1822. data/activerecord/test/cases/callbacks_test.rb +479 -0
  1823. data/activerecord/test/cases/clone_test.rb +42 -0
  1824. data/activerecord/test/cases/coders/json_test.rb +17 -0
  1825. data/activerecord/test/cases/coders/yaml_column_test.rb +66 -0
  1826. data/activerecord/test/cases/collection_cache_key_test.rb +117 -0
  1827. data/activerecord/test/cases/column_alias_test.rb +19 -0
  1828. data/activerecord/test/cases/column_definition_test.rb +34 -0
  1829. data/activerecord/test/cases/comment_test.rb +146 -0
  1830. data/activerecord/test/cases/connection_adapters/adapter_leasing_test.rb +58 -0
  1831. data/activerecord/test/cases/connection_adapters/connection_handler_test.rb +232 -0
  1832. data/activerecord/test/cases/connection_adapters/connection_specification_test.rb +14 -0
  1833. data/activerecord/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +257 -0
  1834. data/activerecord/test/cases/connection_adapters/mysql_type_lookup_test.rb +78 -0
  1835. data/activerecord/test/cases/connection_adapters/schema_cache_test.rb +101 -0
  1836. data/activerecord/test/cases/connection_adapters/type_lookup_test.rb +120 -0
  1837. data/activerecord/test/cases/connection_management_test.rb +114 -0
  1838. data/activerecord/test/cases/connection_pool_test.rb +569 -0
  1839. data/activerecord/test/cases/connection_specification/resolver_test.rb +137 -0
  1840. data/activerecord/test/cases/core_test.rb +114 -0
  1841. data/activerecord/test/cases/counter_cache_test.rb +367 -0
  1842. data/activerecord/test/cases/custom_locking_test.rb +19 -0
  1843. data/activerecord/test/cases/database_statements_test.rb +37 -0
  1844. data/activerecord/test/cases/date_test.rb +46 -0
  1845. data/activerecord/test/cases/date_time_precision_test.rb +89 -0
  1846. data/activerecord/test/cases/date_time_test.rb +76 -0
  1847. data/activerecord/test/cases/defaults_test.rb +209 -0
  1848. data/activerecord/test/cases/dirty_test.rb +871 -0
  1849. data/activerecord/test/cases/disconnected_test.rb +32 -0
  1850. data/activerecord/test/cases/dup_test.rb +161 -0
  1851. data/activerecord/test/cases/enum_test.rb +493 -0
  1852. data/activerecord/test/cases/errors_test.rb +18 -0
  1853. data/activerecord/test/cases/explain_subscriber_test.rb +66 -0
  1854. data/activerecord/test/cases/explain_test.rb +89 -0
  1855. data/activerecord/test/cases/finder_respond_to_test.rb +61 -0
  1856. data/activerecord/test/cases/finder_test.rb +1282 -0
  1857. data/activerecord/test/cases/fixture_set/file_test.rb +158 -0
  1858. data/activerecord/test/cases/fixtures_test.rb +1096 -0
  1859. data/activerecord/test/cases/forbidden_attributes_protection_test.rb +166 -0
  1860. data/activerecord/test/cases/habtm_destroy_order_test.rb +63 -0
  1861. data/activerecord/test/cases/helper.rb +187 -0
  1862. data/activerecord/test/cases/hot_compatibility_test.rb +144 -0
  1863. data/activerecord/test/cases/i18n_test.rb +46 -0
  1864. data/activerecord/test/cases/inheritance_test.rb +613 -0
  1865. data/activerecord/test/cases/integration_test.rb +234 -0
  1866. data/activerecord/test/cases/invalid_connection_test.rb +26 -0
  1867. data/activerecord/test/cases/invertible_migration_test.rb +380 -0
  1868. data/activerecord/test/cases/json_attribute_test.rb +35 -0
  1869. data/activerecord/test/cases/json_serialization_test.rb +311 -0
  1870. data/activerecord/test/cases/json_shared_test_cases.rb +256 -0
  1871. data/activerecord/test/cases/locking_test.rb +651 -0
  1872. data/activerecord/test/cases/log_subscriber_test.rb +219 -0
  1873. data/activerecord/test/cases/migration/change_schema_test.rb +468 -0
  1874. data/activerecord/test/cases/migration/change_table_test.rb +258 -0
  1875. data/activerecord/test/cases/migration/column_attributes_test.rb +188 -0
  1876. data/activerecord/test/cases/migration/column_positioning_test.rb +58 -0
  1877. data/activerecord/test/cases/migration/columns_test.rb +319 -0
  1878. data/activerecord/test/cases/migration/command_recorder_test.rb +347 -0
  1879. data/activerecord/test/cases/migration/compatibility_test.rb +238 -0
  1880. data/activerecord/test/cases/migration/create_join_table_test.rb +168 -0
  1881. data/activerecord/test/cases/migration/foreign_key_test.rb +339 -0
  1882. data/activerecord/test/cases/migration/helper.rb +41 -0
  1883. data/activerecord/test/cases/migration/index_test.rb +218 -0
  1884. data/activerecord/test/cases/migration/logger_test.rb +38 -0
  1885. data/activerecord/test/cases/migration/pending_migrations_test.rb +42 -0
  1886. data/activerecord/test/cases/migration/references_foreign_key_test.rb +257 -0
  1887. data/activerecord/test/cases/migration/references_index_test.rb +103 -0
  1888. data/activerecord/test/cases/migration/references_statements_test.rb +138 -0
  1889. data/activerecord/test/cases/migration/rename_table_test.rb +118 -0
  1890. data/activerecord/test/cases/migration_test.rb +1122 -0
  1891. data/activerecord/test/cases/migrator_test.rb +473 -0
  1892. data/activerecord/test/cases/mixin_test.rb +64 -0
  1893. data/activerecord/test/cases/modules_test.rb +174 -0
  1894. data/activerecord/test/cases/multiparameter_attributes_test.rb +399 -0
  1895. data/activerecord/test/cases/multiple_db_test.rb +119 -0
  1896. data/activerecord/test/cases/nested_attributes_test.rb +1097 -0
  1897. data/activerecord/test/cases/nested_attributes_with_callbacks_test.rb +146 -0
  1898. data/activerecord/test/cases/null_relation_test.rb +84 -0
  1899. data/activerecord/test/cases/numeric_data_test.rb +73 -0
  1900. data/activerecord/test/cases/persistence_test.rb +1063 -0
  1901. data/activerecord/test/cases/pooled_connections_test.rb +83 -0
  1902. data/activerecord/test/cases/primary_keys_test.rb +466 -0
  1903. data/activerecord/test/cases/query_cache_test.rb +577 -0
  1904. data/activerecord/test/cases/quoting_test.rb +275 -0
  1905. data/activerecord/test/cases/readonly_test.rb +120 -0
  1906. data/activerecord/test/cases/reaper_test.rb +87 -0
  1907. data/activerecord/test/cases/reflection_test.rb +533 -0
  1908. data/activerecord/test/cases/relation/delegation_test.rb +57 -0
  1909. data/activerecord/test/cases/relation/merging_test.rb +157 -0
  1910. data/activerecord/test/cases/relation/mutation_test.rb +145 -0
  1911. data/activerecord/test/cases/relation/or_test.rb +130 -0
  1912. data/activerecord/test/cases/relation/predicate_builder_test.rb +18 -0
  1913. data/activerecord/test/cases/relation/record_fetch_warning_test.rb +42 -0
  1914. data/activerecord/test/cases/relation/where_chain_test.rb +107 -0
  1915. data/activerecord/test/cases/relation/where_clause_test.rb +241 -0
  1916. data/activerecord/test/cases/relation/where_test.rb +366 -0
  1917. data/activerecord/test/cases/relation_test.rb +331 -0
  1918. data/activerecord/test/cases/relations_test.rb +1923 -0
  1919. data/activerecord/test/cases/reload_models_test.rb +26 -0
  1920. data/activerecord/test/cases/reserved_word_test.rb +134 -0
  1921. data/activerecord/test/cases/result_test.rb +90 -0
  1922. data/activerecord/test/cases/sanitize_test.rb +182 -0
  1923. data/activerecord/test/cases/schema_dumper_test.rb +507 -0
  1924. data/activerecord/test/cases/schema_loading_test.rb +54 -0
  1925. data/activerecord/test/cases/scoping/default_scoping_test.rb +547 -0
  1926. data/activerecord/test/cases/scoping/named_scoping_test.rb +577 -0
  1927. data/activerecord/test/cases/scoping/relation_scoping_test.rb +402 -0
  1928. data/activerecord/test/cases/secure_token_test.rb +34 -0
  1929. data/activerecord/test/cases/serialization_test.rb +106 -0
  1930. data/activerecord/test/cases/serialized_attribute_test.rb +382 -0
  1931. data/activerecord/test/cases/statement_cache_test.rb +137 -0
  1932. data/activerecord/test/cases/store_test.rb +197 -0
  1933. data/activerecord/test/cases/suppressor_test.rb +77 -0
  1934. data/activerecord/test/cases/tasks/database_tasks_test.rb +491 -0
  1935. data/activerecord/test/cases/tasks/mysql_rake_test.rb +388 -0
  1936. data/activerecord/test/cases/tasks/postgresql_rake_test.rb +374 -0
  1937. data/activerecord/test/cases/tasks/sqlite_rake_test.rb +267 -0
  1938. data/activerecord/test/cases/test_case.rb +138 -0
  1939. data/activerecord/test/cases/test_fixtures_test.rb +20 -0
  1940. data/activerecord/test/cases/time_precision_test.rb +85 -0
  1941. data/activerecord/test/cases/timestamp_test.rb +478 -0
  1942. data/activerecord/test/cases/touch_later_test.rb +123 -0
  1943. data/activerecord/test/cases/transaction_callbacks_test.rb +595 -0
  1944. data/activerecord/test/cases/transaction_isolation_test.rb +108 -0
  1945. data/activerecord/test/cases/transactions_test.rb +1030 -0
  1946. data/activerecord/test/cases/type/adapter_specific_registry_test.rb +135 -0
  1947. data/activerecord/test/cases/type/date_time_test.rb +16 -0
  1948. data/activerecord/test/cases/type/integer_test.rb +29 -0
  1949. data/activerecord/test/cases/type/string_test.rb +24 -0
  1950. data/activerecord/test/cases/type/type_map_test.rb +178 -0
  1951. data/activerecord/test/cases/type/unsigned_integer_test.rb +19 -0
  1952. data/activerecord/test/cases/type_test.rb +41 -0
  1953. data/activerecord/test/cases/types_test.rb +26 -0
  1954. data/activerecord/test/cases/unconnected_test.rb +35 -0
  1955. data/activerecord/test/cases/validations/absence_validation_test.rb +75 -0
  1956. data/activerecord/test/cases/validations/association_validation_test.rb +99 -0
  1957. data/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb +86 -0
  1958. data/activerecord/test/cases/validations/i18n_validation_test.rb +85 -0
  1959. data/activerecord/test/cases/validations/length_validation_test.rb +80 -0
  1960. data/activerecord/test/cases/validations/presence_validation_test.rb +105 -0
  1961. data/activerecord/test/cases/validations/uniqueness_validation_test.rb +557 -0
  1962. data/activerecord/test/cases/validations_repair_helper.rb +21 -0
  1963. data/activerecord/test/cases/validations_test.rb +196 -0
  1964. data/activerecord/test/cases/view_test.rb +224 -0
  1965. data/activerecord/test/cases/yaml_serialization_test.rb +141 -0
  1966. data/activerecord/test/config.example.yml +100 -0
  1967. data/activerecord/test/config.rb +7 -0
  1968. data/activerecord/test/fixtures/.gitignore +1 -0
  1969. data/activerecord/test/fixtures/accounts.yml +29 -0
  1970. data/activerecord/test/fixtures/admin/accounts.yml +2 -0
  1971. data/activerecord/test/fixtures/admin/randomly_named_a9.yml +7 -0
  1972. data/activerecord/test/fixtures/admin/randomly_named_b0.yml +7 -0
  1973. data/activerecord/test/fixtures/admin/users.yml +10 -0
  1974. data/activerecord/test/fixtures/all/admin +1 -0
  1975. data/activerecord/test/fixtures/all/developers.yml +0 -0
  1976. data/activerecord/test/fixtures/all/namespaced/accounts.yml +2 -0
  1977. data/activerecord/test/fixtures/all/people.yml +0 -0
  1978. data/activerecord/test/fixtures/all/tasks.yml +0 -0
  1979. data/activerecord/test/fixtures/author_addresses.yml +11 -0
  1980. data/activerecord/test/fixtures/author_favorites.yml +4 -0
  1981. data/activerecord/test/fixtures/authors.yml +17 -0
  1982. data/activerecord/test/fixtures/bad_posts.yml +9 -0
  1983. data/activerecord/test/fixtures/binaries.yml +137 -0
  1984. data/activerecord/test/fixtures/books.yml +33 -0
  1985. data/activerecord/test/fixtures/bulbs.yml +5 -0
  1986. data/activerecord/test/fixtures/cars.yml +9 -0
  1987. data/activerecord/test/fixtures/categories.yml +19 -0
  1988. data/activerecord/test/fixtures/categories/special_categories.yml +9 -0
  1989. data/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
  1990. data/activerecord/test/fixtures/categories_ordered.yml +7 -0
  1991. data/activerecord/test/fixtures/categories_posts.yml +31 -0
  1992. data/activerecord/test/fixtures/categorizations.yml +23 -0
  1993. data/activerecord/test/fixtures/clubs.yml +8 -0
  1994. data/activerecord/test/fixtures/collections.yml +3 -0
  1995. data/activerecord/test/fixtures/colleges.yml +3 -0
  1996. data/activerecord/test/fixtures/comments.yml +65 -0
  1997. data/activerecord/test/fixtures/companies.yml +67 -0
  1998. data/activerecord/test/fixtures/computers.yml +10 -0
  1999. data/activerecord/test/fixtures/content.yml +3 -0
  2000. data/activerecord/test/fixtures/content_positions.yml +3 -0
  2001. data/activerecord/test/fixtures/courses.yml +8 -0
  2002. data/activerecord/test/fixtures/customers.yml +26 -0
  2003. data/activerecord/test/fixtures/dashboards.yml +6 -0
  2004. data/activerecord/test/fixtures/dead_parrots.yml +5 -0
  2005. data/activerecord/test/fixtures/developers.yml +22 -0
  2006. data/activerecord/test/fixtures/developers_projects.yml +17 -0
  2007. data/activerecord/test/fixtures/dog_lovers.yml +7 -0
  2008. data/activerecord/test/fixtures/dogs.yml +4 -0
  2009. data/activerecord/test/fixtures/doubloons.yml +3 -0
  2010. data/activerecord/test/fixtures/edges.yml +5 -0
  2011. data/activerecord/test/fixtures/entrants.yml +14 -0
  2012. data/activerecord/test/fixtures/essays.yml +6 -0
  2013. data/activerecord/test/fixtures/faces.yml +11 -0
  2014. data/activerecord/test/fixtures/fk_test_has_fk.yml +3 -0
  2015. data/activerecord/test/fixtures/fk_test_has_pk.yml +2 -0
  2016. data/activerecord/test/fixtures/friendships.yml +4 -0
  2017. data/activerecord/test/fixtures/funny_jokes.yml +10 -0
  2018. data/activerecord/test/fixtures/interests.yml +33 -0
  2019. data/activerecord/test/fixtures/items.yml +3 -0
  2020. data/activerecord/test/fixtures/jobs.yml +7 -0
  2021. data/activerecord/test/fixtures/legacy_things.yml +3 -0
  2022. data/activerecord/test/fixtures/live_parrots.yml +4 -0
  2023. data/activerecord/test/fixtures/mateys.yml +4 -0
  2024. data/activerecord/test/fixtures/member_details.yml +8 -0
  2025. data/activerecord/test/fixtures/member_types.yml +6 -0
  2026. data/activerecord/test/fixtures/members.yml +11 -0
  2027. data/activerecord/test/fixtures/memberships.yml +34 -0
  2028. data/activerecord/test/fixtures/men.yml +5 -0
  2029. data/activerecord/test/fixtures/minimalistics.yml +2 -0
  2030. data/activerecord/test/fixtures/minivans.yml +5 -0
  2031. data/activerecord/test/fixtures/mixed_case_monkeys.yml +6 -0
  2032. data/activerecord/test/fixtures/mixins.yml +29 -0
  2033. data/activerecord/test/fixtures/movies.yml +7 -0
  2034. data/activerecord/test/fixtures/naked/yml/accounts.yml +1 -0
  2035. data/activerecord/test/fixtures/naked/yml/companies.yml +1 -0
  2036. data/activerecord/test/fixtures/naked/yml/courses.yml +1 -0
  2037. data/activerecord/test/fixtures/naked/yml/courses_with_invalid_key.yml +3 -0
  2038. data/activerecord/test/fixtures/naked/yml/parrots.yml +3 -0
  2039. data/activerecord/test/fixtures/naked/yml/trees.yml +3 -0
  2040. data/activerecord/test/fixtures/nodes.yml +29 -0
  2041. data/activerecord/test/fixtures/organizations.yml +5 -0
  2042. data/activerecord/test/fixtures/other_comments.yml +6 -0
  2043. data/activerecord/test/fixtures/other_dogs.yml +2 -0
  2044. data/activerecord/test/fixtures/other_posts.yml +7 -0
  2045. data/activerecord/test/fixtures/other_topics.yml +42 -0
  2046. data/activerecord/test/fixtures/owners.yml +9 -0
  2047. data/activerecord/test/fixtures/parrots.yml +27 -0
  2048. data/activerecord/test/fixtures/parrots_pirates.yml +7 -0
  2049. data/activerecord/test/fixtures/people.yml +24 -0
  2050. data/activerecord/test/fixtures/peoples_treasures.yml +3 -0
  2051. data/activerecord/test/fixtures/pets.yml +19 -0
  2052. data/activerecord/test/fixtures/pirates.yml +15 -0
  2053. data/activerecord/test/fixtures/posts.yml +80 -0
  2054. data/activerecord/test/fixtures/price_estimates.yml +16 -0
  2055. data/activerecord/test/fixtures/products.yml +4 -0
  2056. data/activerecord/test/fixtures/projects.yml +7 -0
  2057. data/activerecord/test/fixtures/randomly_named_a9.yml +7 -0
  2058. data/activerecord/test/fixtures/ratings.yml +14 -0
  2059. data/activerecord/test/fixtures/readers.yml +11 -0
  2060. data/activerecord/test/fixtures/references.yml +17 -0
  2061. data/activerecord/test/fixtures/reserved_words/distinct.yml +5 -0
  2062. data/activerecord/test/fixtures/reserved_words/distinct_select.yml +11 -0
  2063. data/activerecord/test/fixtures/reserved_words/group.yml +14 -0
  2064. data/activerecord/test/fixtures/reserved_words/select.yml +8 -0
  2065. data/activerecord/test/fixtures/reserved_words/values.yml +7 -0
  2066. data/activerecord/test/fixtures/ships.yml +6 -0
  2067. data/activerecord/test/fixtures/speedometers.yml +8 -0
  2068. data/activerecord/test/fixtures/sponsors.yml +12 -0
  2069. data/activerecord/test/fixtures/string_key_objects.yml +7 -0
  2070. data/activerecord/test/fixtures/subscribers.yml +11 -0
  2071. data/activerecord/test/fixtures/subscriptions.yml +12 -0
  2072. data/activerecord/test/fixtures/taggings.yml +78 -0
  2073. data/activerecord/test/fixtures/tags.yml +11 -0
  2074. data/activerecord/test/fixtures/tasks.yml +7 -0
  2075. data/activerecord/test/fixtures/teapots.yml +3 -0
  2076. data/activerecord/test/fixtures/to_be_linked/accounts.yml +2 -0
  2077. data/activerecord/test/fixtures/to_be_linked/users.yml +10 -0
  2078. data/activerecord/test/fixtures/topics.yml +49 -0
  2079. data/activerecord/test/fixtures/toys.yml +14 -0
  2080. data/activerecord/test/fixtures/traffic_lights.yml +10 -0
  2081. data/activerecord/test/fixtures/treasures.yml +10 -0
  2082. data/activerecord/test/fixtures/trees.yml +3 -0
  2083. data/activerecord/test/fixtures/uuid_children.yml +3 -0
  2084. data/activerecord/test/fixtures/uuid_parents.yml +2 -0
  2085. data/activerecord/test/fixtures/variants.yml +4 -0
  2086. data/activerecord/test/fixtures/vegetables.yml +20 -0
  2087. data/activerecord/test/fixtures/vertices.yml +4 -0
  2088. data/activerecord/test/fixtures/warehouse-things.yml +3 -0
  2089. data/activerecord/test/fixtures/zines.yml +5 -0
  2090. data/activerecord/test/migrations/10_urban/9_add_expressions.rb +13 -0
  2091. data/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb +17 -0
  2092. data/activerecord/test/migrations/empty/.gitkeep +0 -0
  2093. data/activerecord/test/migrations/magic/1_currencies_have_symbols.rb +13 -0
  2094. data/activerecord/test/migrations/missing/1000_people_have_middle_names.rb +11 -0
  2095. data/activerecord/test/migrations/missing/1_people_have_last_names.rb +11 -0
  2096. data/activerecord/test/migrations/missing/3_we_need_reminders.rb +14 -0
  2097. data/activerecord/test/migrations/missing/4_innocent_jointable.rb +14 -0
  2098. data/activerecord/test/migrations/rename/1_we_need_things.rb +13 -0
  2099. data/activerecord/test/migrations/rename/2_rename_things.rb +11 -0
  2100. data/activerecord/test/migrations/to_copy/1_people_have_hobbies.rb +11 -0
  2101. data/activerecord/test/migrations/to_copy/2_people_have_descriptions.rb +11 -0
  2102. data/activerecord/test/migrations/to_copy2/1_create_articles.rb +9 -0
  2103. data/activerecord/test/migrations/to_copy2/2_create_comments.rb +9 -0
  2104. data/activerecord/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +11 -0
  2105. data/activerecord/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +11 -0
  2106. data/activerecord/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +11 -0
  2107. data/activerecord/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +9 -0
  2108. data/activerecord/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +9 -0
  2109. data/activerecord/test/migrations/valid/1_valid_people_have_last_names.rb +11 -0
  2110. data/activerecord/test/migrations/valid/2_we_need_reminders.rb +14 -0
  2111. data/activerecord/test/migrations/valid/3_innocent_jointable.rb +14 -0
  2112. data/activerecord/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +11 -0
  2113. data/activerecord/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +14 -0
  2114. data/activerecord/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +14 -0
  2115. data/activerecord/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +11 -0
  2116. data/activerecord/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +14 -0
  2117. data/activerecord/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +14 -0
  2118. data/activerecord/test/migrations/version_check/20131219224947_migration_version_check.rb +10 -0
  2119. data/activerecord/test/models/account.rb +34 -0
  2120. data/activerecord/test/models/admin.rb +7 -0
  2121. data/activerecord/test/models/admin/account.rb +5 -0
  2122. data/activerecord/test/models/admin/randomly_named_c1.rb +9 -0
  2123. data/activerecord/test/models/admin/user.rb +42 -0
  2124. data/activerecord/test/models/aircraft.rb +7 -0
  2125. data/activerecord/test/models/arunit2_model.rb +5 -0
  2126. data/activerecord/test/models/author.rb +211 -0
  2127. data/activerecord/test/models/auto_id.rb +6 -0
  2128. data/activerecord/test/models/autoloadable/extra_firm.rb +4 -0
  2129. data/activerecord/test/models/binary.rb +4 -0
  2130. data/activerecord/test/models/bird.rb +14 -0
  2131. data/activerecord/test/models/book.rb +26 -0
  2132. data/activerecord/test/models/boolean.rb +7 -0
  2133. data/activerecord/test/models/bulb.rb +54 -0
  2134. data/activerecord/test/models/cake_designer.rb +5 -0
  2135. data/activerecord/test/models/car.rb +31 -0
  2136. data/activerecord/test/models/carrier.rb +4 -0
  2137. data/activerecord/test/models/cat.rb +12 -0
  2138. data/activerecord/test/models/categorization.rb +21 -0
  2139. data/activerecord/test/models/category.rb +46 -0
  2140. data/activerecord/test/models/chef.rb +10 -0
  2141. data/activerecord/test/models/citation.rb +5 -0
  2142. data/activerecord/test/models/club.rb +27 -0
  2143. data/activerecord/test/models/college.rb +12 -0
  2144. data/activerecord/test/models/column.rb +5 -0
  2145. data/activerecord/test/models/column_name.rb +5 -0
  2146. data/activerecord/test/models/comment.rb +88 -0
  2147. data/activerecord/test/models/company.rb +190 -0
  2148. data/activerecord/test/models/company_in_module.rb +100 -0
  2149. data/activerecord/test/models/computer.rb +5 -0
  2150. data/activerecord/test/models/contact.rb +43 -0
  2151. data/activerecord/test/models/content.rb +42 -0
  2152. data/activerecord/test/models/contract.rb +22 -0
  2153. data/activerecord/test/models/country.rb +7 -0
  2154. data/activerecord/test/models/course.rb +8 -0
  2155. data/activerecord/test/models/customer.rb +85 -0
  2156. data/activerecord/test/models/customer_carrier.rb +16 -0
  2157. data/activerecord/test/models/dashboard.rb +5 -0
  2158. data/activerecord/test/models/default.rb +4 -0
  2159. data/activerecord/test/models/department.rb +6 -0
  2160. data/activerecord/test/models/developer.rb +270 -0
  2161. data/activerecord/test/models/dog.rb +7 -0
  2162. data/activerecord/test/models/dog_lover.rb +7 -0
  2163. data/activerecord/test/models/doubloon.rb +14 -0
  2164. data/activerecord/test/models/drink_designer.rb +5 -0
  2165. data/activerecord/test/models/edge.rb +7 -0
  2166. data/activerecord/test/models/electron.rb +7 -0
  2167. data/activerecord/test/models/engine.rb +5 -0
  2168. data/activerecord/test/models/entrant.rb +5 -0
  2169. data/activerecord/test/models/essay.rb +8 -0
  2170. data/activerecord/test/models/event.rb +5 -0
  2171. data/activerecord/test/models/eye.rb +39 -0
  2172. data/activerecord/test/models/face.rb +11 -0
  2173. data/activerecord/test/models/family.rb +6 -0
  2174. data/activerecord/test/models/family_tree.rb +6 -0
  2175. data/activerecord/test/models/friendship.rb +8 -0
  2176. data/activerecord/test/models/guid.rb +4 -0
  2177. data/activerecord/test/models/guitar.rb +6 -0
  2178. data/activerecord/test/models/hotel.rb +13 -0
  2179. data/activerecord/test/models/image.rb +5 -0
  2180. data/activerecord/test/models/interest.rb +7 -0
  2181. data/activerecord/test/models/invoice.rb +6 -0
  2182. data/activerecord/test/models/item.rb +9 -0
  2183. data/activerecord/test/models/job.rb +9 -0
  2184. data/activerecord/test/models/joke.rb +9 -0
  2185. data/activerecord/test/models/keyboard.rb +5 -0
  2186. data/activerecord/test/models/legacy_thing.rb +5 -0
  2187. data/activerecord/test/models/lesson.rb +13 -0
  2188. data/activerecord/test/models/line_item.rb +5 -0
  2189. data/activerecord/test/models/liquid.rb +6 -0
  2190. data/activerecord/test/models/man.rb +13 -0
  2191. data/activerecord/test/models/matey.rb +6 -0
  2192. data/activerecord/test/models/member.rb +44 -0
  2193. data/activerecord/test/models/member_detail.rb +10 -0
  2194. data/activerecord/test/models/member_type.rb +5 -0
  2195. data/activerecord/test/models/membership.rb +38 -0
  2196. data/activerecord/test/models/mentor.rb +5 -0
  2197. data/activerecord/test/models/minimalistic.rb +4 -0
  2198. data/activerecord/test/models/minivan.rb +10 -0
  2199. data/activerecord/test/models/mixed_case_monkey.rb +5 -0
  2200. data/activerecord/test/models/mocktail_designer.rb +4 -0
  2201. data/activerecord/test/models/molecule.rb +8 -0
  2202. data/activerecord/test/models/movie.rb +7 -0
  2203. data/activerecord/test/models/node.rb +7 -0
  2204. data/activerecord/test/models/non_primary_key.rb +4 -0
  2205. data/activerecord/test/models/notification.rb +5 -0
  2206. data/activerecord/test/models/numeric_data.rb +10 -0
  2207. data/activerecord/test/models/order.rb +6 -0
  2208. data/activerecord/test/models/organization.rb +16 -0
  2209. data/activerecord/test/models/other_dog.rb +7 -0
  2210. data/activerecord/test/models/owner.rb +39 -0
  2211. data/activerecord/test/models/parrot.rb +30 -0
  2212. data/activerecord/test/models/person.rb +143 -0
  2213. data/activerecord/test/models/personal_legacy_thing.rb +6 -0
  2214. data/activerecord/test/models/pet.rb +20 -0
  2215. data/activerecord/test/models/pet_treasure.rb +8 -0
  2216. data/activerecord/test/models/pirate.rb +94 -0
  2217. data/activerecord/test/models/possession.rb +5 -0
  2218. data/activerecord/test/models/post.rb +322 -0
  2219. data/activerecord/test/models/price_estimate.rb +6 -0
  2220. data/activerecord/test/models/professor.rb +7 -0
  2221. data/activerecord/test/models/project.rb +42 -0
  2222. data/activerecord/test/models/publisher.rb +4 -0
  2223. data/activerecord/test/models/publisher/article.rb +6 -0
  2224. data/activerecord/test/models/publisher/magazine.rb +5 -0
  2225. data/activerecord/test/models/randomly_named_c1.rb +5 -0
  2226. data/activerecord/test/models/rating.rb +6 -0
  2227. data/activerecord/test/models/reader.rb +25 -0
  2228. data/activerecord/test/models/recipe.rb +5 -0
  2229. data/activerecord/test/models/record.rb +4 -0
  2230. data/activerecord/test/models/reference.rb +24 -0
  2231. data/activerecord/test/models/reply.rb +63 -0
  2232. data/activerecord/test/models/ship.rb +41 -0
  2233. data/activerecord/test/models/ship_part.rb +10 -0
  2234. data/activerecord/test/models/shop.rb +19 -0
  2235. data/activerecord/test/models/shop_account.rb +8 -0
  2236. data/activerecord/test/models/speedometer.rb +8 -0
  2237. data/activerecord/test/models/sponsor.rb +9 -0
  2238. data/activerecord/test/models/string_key_object.rb +5 -0
  2239. data/activerecord/test/models/student.rb +6 -0
  2240. data/activerecord/test/models/subscriber.rb +10 -0
  2241. data/activerecord/test/models/subscription.rb +6 -0
  2242. data/activerecord/test/models/tag.rb +15 -0
  2243. data/activerecord/test/models/tagging.rb +15 -0
  2244. data/activerecord/test/models/task.rb +7 -0
  2245. data/activerecord/test/models/topic.rb +120 -0
  2246. data/activerecord/test/models/toy.rb +8 -0
  2247. data/activerecord/test/models/traffic_light.rb +6 -0
  2248. data/activerecord/test/models/treasure.rb +16 -0
  2249. data/activerecord/test/models/treaty.rb +7 -0
  2250. data/activerecord/test/models/tree.rb +5 -0
  2251. data/activerecord/test/models/tuning_peg.rb +6 -0
  2252. data/activerecord/test/models/tyre.rb +13 -0
  2253. data/activerecord/test/models/user.rb +20 -0
  2254. data/activerecord/test/models/uuid_child.rb +5 -0
  2255. data/activerecord/test/models/uuid_item.rb +8 -0
  2256. data/activerecord/test/models/uuid_parent.rb +5 -0
  2257. data/activerecord/test/models/vegetables.rb +25 -0
  2258. data/activerecord/test/models/vehicle.rb +9 -0
  2259. data/activerecord/test/models/vertex.rb +11 -0
  2260. data/activerecord/test/models/warehouse_thing.rb +7 -0
  2261. data/activerecord/test/models/wheel.rb +5 -0
  2262. data/activerecord/test/models/without_table.rb +5 -0
  2263. data/activerecord/test/models/zine.rb +5 -0
  2264. data/activerecord/test/schema/mysql2_specific_schema.rb +75 -0
  2265. data/activerecord/test/schema/oracle_specific_schema.rb +42 -0
  2266. data/activerecord/test/schema/postgresql_specific_schema.rb +112 -0
  2267. data/activerecord/test/schema/schema.rb +1081 -0
  2268. data/activerecord/test/support/config.rb +46 -0
  2269. data/activerecord/test/support/connection.rb +28 -0
  2270. data/activerecord/test/support/connection_helper.rb +16 -0
  2271. data/activerecord/test/support/ddl_helper.rb +10 -0
  2272. data/activerecord/test/support/schema_dumping_helper.rb +22 -0
  2273. data/activerecord/test/support/yaml_compatibility_fixtures/rails_4_1.yml +22 -0
  2274. data/activerecord/test/support/yaml_compatibility_fixtures/rails_4_2_0.yml +182 -0
  2275. data/activestorage/.babelrc +5 -0
  2276. data/activestorage/.eslintrc +19 -0
  2277. data/activestorage/.gitignore +6 -0
  2278. data/activestorage/CHANGELOG.md +3 -0
  2279. data/activestorage/MIT-LICENSE +20 -0
  2280. data/activestorage/README.md +141 -0
  2281. data/activestorage/Rakefile +14 -0
  2282. data/activestorage/activestorage.gemspec +30 -0
  2283. data/activestorage/app/assets/javascripts/activestorage.js +1 -0
  2284. data/activestorage/app/controllers/active_storage/blobs_controller.rb +25 -0
  2285. data/activestorage/app/controllers/active_storage/direct_uploads_controller.rb +23 -0
  2286. data/activestorage/app/controllers/active_storage/disk_controller.rb +53 -0
  2287. data/activestorage/app/controllers/active_storage/variants_controller.rb +29 -0
  2288. data/activestorage/app/javascript/activestorage/blob_record.js +54 -0
  2289. data/activestorage/app/javascript/activestorage/blob_upload.js +34 -0
  2290. data/activestorage/app/javascript/activestorage/direct_upload.js +42 -0
  2291. data/activestorage/app/javascript/activestorage/direct_upload_controller.js +67 -0
  2292. data/activestorage/app/javascript/activestorage/direct_uploads_controller.js +50 -0
  2293. data/activestorage/app/javascript/activestorage/file_checksum.js +53 -0
  2294. data/activestorage/app/javascript/activestorage/helpers.js +42 -0
  2295. data/activestorage/app/javascript/activestorage/index.js +11 -0
  2296. data/activestorage/app/javascript/activestorage/ujs.js +74 -0
  2297. data/activestorage/app/jobs/active_storage/purge_job.rb +11 -0
  2298. data/activestorage/app/models/active_storage/attachment.rb +28 -0
  2299. data/activestorage/app/models/active_storage/blob.rb +199 -0
  2300. data/activestorage/app/models/active_storage/filename.rb +65 -0
  2301. data/activestorage/app/models/active_storage/filename/parameters.rb +36 -0
  2302. data/activestorage/app/models/active_storage/variant.rb +82 -0
  2303. data/activestorage/app/models/active_storage/variation.rb +55 -0
  2304. data/activestorage/bin/test +5 -0
  2305. data/activestorage/config/routes.rb +30 -0
  2306. data/activestorage/db/migrate/20170806125915_create_active_storage_tables.rb +25 -0
  2307. data/activestorage/lib/active_storage.rb +38 -0
  2308. data/activestorage/lib/active_storage/attached.rb +40 -0
  2309. data/activestorage/lib/active_storage/attached/macros.rb +82 -0
  2310. data/activestorage/lib/active_storage/attached/many.rb +55 -0
  2311. data/activestorage/lib/active_storage/attached/one.rb +76 -0
  2312. data/activestorage/lib/active_storage/engine.rb +65 -0
  2313. data/activestorage/lib/active_storage/gem_version.rb +17 -0
  2314. data/activestorage/lib/active_storage/log_subscriber.rb +52 -0
  2315. data/activestorage/lib/active_storage/service.rb +117 -0
  2316. data/activestorage/lib/active_storage/service/azure_storage_service.rb +124 -0
  2317. data/activestorage/lib/active_storage/service/configurator.rb +32 -0
  2318. data/activestorage/lib/active_storage/service/disk_service.rb +128 -0
  2319. data/activestorage/lib/active_storage/service/gcs_service.rb +83 -0
  2320. data/activestorage/lib/active_storage/service/mirror_service.rb +50 -0
  2321. data/activestorage/lib/active_storage/service/s3_service.rb +100 -0
  2322. data/activestorage/lib/active_storage/version.rb +10 -0
  2323. data/activestorage/lib/tasks/activestorage.rake +8 -0
  2324. data/activestorage/package.json +33 -0
  2325. data/activestorage/test/controllers/blobs_controller_test.rb +17 -0
  2326. data/activestorage/test/controllers/direct_uploads_controller_test.rb +124 -0
  2327. data/activestorage/test/controllers/disk_controller_test.rb +59 -0
  2328. data/activestorage/test/controllers/variants_controller_test.rb +23 -0
  2329. data/activestorage/test/database/create_users_migration.rb +9 -0
  2330. data/activestorage/test/database/setup.rb +7 -0
  2331. data/activestorage/test/dummy/Rakefile +5 -0
  2332. data/activestorage/test/dummy/app/assets/config/manifest.js +5 -0
  2333. data/activestorage/test/dummy/app/assets/images/.keep +0 -0
  2334. data/activestorage/test/dummy/app/assets/javascripts/application.js +13 -0
  2335. data/activestorage/test/dummy/app/assets/stylesheets/application.css +15 -0
  2336. data/activestorage/test/dummy/app/controllers/application_controller.rb +5 -0
  2337. data/activestorage/test/dummy/app/controllers/concerns/.keep +0 -0
  2338. data/activestorage/test/dummy/app/helpers/application_helper.rb +4 -0
  2339. data/activestorage/test/dummy/app/jobs/application_job.rb +4 -0
  2340. data/activestorage/test/dummy/app/models/application_record.rb +5 -0
  2341. data/activestorage/test/dummy/app/models/concerns/.keep +0 -0
  2342. data/activestorage/test/dummy/app/views/layouts/application.html.erb +14 -0
  2343. data/activestorage/test/dummy/bin/bundle +5 -0
  2344. data/activestorage/test/dummy/bin/rails +6 -0
  2345. data/activestorage/test/dummy/bin/rake +6 -0
  2346. data/activestorage/test/dummy/bin/yarn +13 -0
  2347. data/activestorage/test/dummy/config.ru +7 -0
  2348. data/activestorage/test/dummy/config/application.rb +26 -0
  2349. data/activestorage/test/dummy/config/boot.rb +7 -0
  2350. data/activestorage/test/dummy/config/database.yml +25 -0
  2351. data/activestorage/test/dummy/config/environment.rb +7 -0
  2352. data/activestorage/test/dummy/config/environments/development.rb +51 -0
  2353. data/activestorage/test/dummy/config/environments/production.rb +84 -0
  2354. data/activestorage/test/dummy/config/environments/test.rb +35 -0
  2355. data/activestorage/test/dummy/config/initializers/application_controller_renderer.rb +7 -0
  2356. data/activestorage/test/dummy/config/initializers/assets.rb +16 -0
  2357. data/activestorage/test/dummy/config/initializers/backtrace_silencers.rb +8 -0
  2358. data/activestorage/test/dummy/config/initializers/cookies_serializer.rb +7 -0
  2359. data/activestorage/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  2360. data/activestorage/test/dummy/config/initializers/inflections.rb +17 -0
  2361. data/activestorage/test/dummy/config/initializers/mime_types.rb +5 -0
  2362. data/activestorage/test/dummy/config/initializers/wrap_parameters.rb +16 -0
  2363. data/activestorage/test/dummy/config/routes.rb +4 -0
  2364. data/activestorage/test/dummy/config/secrets.yml +32 -0
  2365. data/activestorage/test/dummy/config/spring.rb +8 -0
  2366. data/activestorage/test/dummy/config/storage.yml +3 -0
  2367. data/activestorage/test/dummy/lib/assets/.keep +0 -0
  2368. data/activestorage/test/dummy/log/.keep +0 -0
  2369. data/activestorage/test/dummy/package.json +5 -0
  2370. data/activestorage/test/dummy/public/404.html +67 -0
  2371. data/activestorage/test/dummy/public/422.html +67 -0
  2372. data/activestorage/test/dummy/public/500.html +66 -0
  2373. data/activestorage/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  2374. data/activestorage/test/dummy/public/apple-touch-icon.png +0 -0
  2375. data/activestorage/test/dummy/public/favicon.ico +0 -0
  2376. data/activestorage/test/fixtures/files/racecar.jpg +0 -0
  2377. data/activestorage/test/models/attachments_test.rb +150 -0
  2378. data/activestorage/test/models/blob_test.rb +56 -0
  2379. data/activestorage/test/models/filename/parameters_test.rb +32 -0
  2380. data/activestorage/test/models/filename_test.rb +56 -0
  2381. data/activestorage/test/models/variant_test.rb +29 -0
  2382. data/activestorage/test/service/azure_storage_service_test.rb +22 -0
  2383. data/activestorage/test/service/configurations.yml +30 -0
  2384. data/activestorage/test/service/configurations.yml.enc +0 -0
  2385. data/activestorage/test/service/configurator_test.rb +16 -0
  2386. data/activestorage/test/service/disk_service_test.rb +14 -0
  2387. data/activestorage/test/service/gcs_service_test.rb +46 -0
  2388. data/activestorage/test/service/mirror_service_test.rb +64 -0
  2389. data/activestorage/test/service/s3_service_test.rb +59 -0
  2390. data/activestorage/test/service/shared_service_tests.rb +69 -0
  2391. data/activestorage/test/template/image_tag_test.rb +38 -0
  2392. data/activestorage/test/test_helper.rb +69 -0
  2393. data/activestorage/webpack.config.js +27 -0
  2394. data/activestorage/yarn.lock +3164 -0
  2395. data/activesupport/CHANGELOG.md +190 -0
  2396. data/activesupport/MIT-LICENSE +20 -0
  2397. data/activesupport/README.rdoc +39 -0
  2398. data/activesupport/Rakefile +23 -0
  2399. data/activesupport/activesupport.gemspec +34 -0
  2400. data/activesupport/bin/generate_tables +141 -0
  2401. data/activesupport/bin/test +5 -0
  2402. data/activesupport/lib/active_support.rb +106 -0
  2403. data/activesupport/lib/active_support/all.rb +5 -0
  2404. data/activesupport/lib/active_support/array_inquirer.rb +48 -0
  2405. data/activesupport/lib/active_support/backtrace_cleaner.rb +105 -0
  2406. data/activesupport/lib/active_support/benchmarkable.rb +51 -0
  2407. data/activesupport/lib/active_support/builder.rb +8 -0
  2408. data/activesupport/lib/active_support/cache.rb +759 -0
  2409. data/activesupport/lib/active_support/cache/file_store.rb +197 -0
  2410. data/activesupport/lib/active_support/cache/mem_cache_store.rb +205 -0
  2411. data/activesupport/lib/active_support/cache/memory_store.rb +169 -0
  2412. data/activesupport/lib/active_support/cache/null_store.rb +43 -0
  2413. data/activesupport/lib/active_support/cache/strategy/local_cache.rb +170 -0
  2414. data/activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb +45 -0
  2415. data/activesupport/lib/active_support/callbacks.rb +856 -0
  2416. data/activesupport/lib/active_support/concern.rb +144 -0
  2417. data/activesupport/lib/active_support/concurrency/share_lock.rb +227 -0
  2418. data/activesupport/lib/active_support/configurable.rb +150 -0
  2419. data/activesupport/lib/active_support/core_ext.rb +5 -0
  2420. data/activesupport/lib/active_support/core_ext/array.rb +9 -0
  2421. data/activesupport/lib/active_support/core_ext/array/access.rb +92 -0
  2422. data/activesupport/lib/active_support/core_ext/array/conversions.rb +213 -0
  2423. data/activesupport/lib/active_support/core_ext/array/extract_options.rb +31 -0
  2424. data/activesupport/lib/active_support/core_ext/array/grouping.rb +109 -0
  2425. data/activesupport/lib/active_support/core_ext/array/inquiry.rb +19 -0
  2426. data/activesupport/lib/active_support/core_ext/array/prepend_and_append.rb +9 -0
  2427. data/activesupport/lib/active_support/core_ext/array/wrap.rb +48 -0
  2428. data/activesupport/lib/active_support/core_ext/benchmark.rb +16 -0
  2429. data/activesupport/lib/active_support/core_ext/big_decimal.rb +3 -0
  2430. data/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb +14 -0
  2431. data/activesupport/lib/active_support/core_ext/class.rb +4 -0
  2432. data/activesupport/lib/active_support/core_ext/class/attribute.rb +149 -0
  2433. data/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +6 -0
  2434. data/activesupport/lib/active_support/core_ext/class/subclasses.rb +57 -0
  2435. data/activesupport/lib/active_support/core_ext/date.rb +7 -0
  2436. data/activesupport/lib/active_support/core_ext/date/acts_like.rb +10 -0
  2437. data/activesupport/lib/active_support/core_ext/date/blank.rb +14 -0
  2438. data/activesupport/lib/active_support/core_ext/date/calculations.rb +145 -0
  2439. data/activesupport/lib/active_support/core_ext/date/conversions.rb +100 -0
  2440. data/activesupport/lib/active_support/core_ext/date/zones.rb +8 -0
  2441. data/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb +358 -0
  2442. data/activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb +16 -0
  2443. data/activesupport/lib/active_support/core_ext/date_and_time/zones.rb +41 -0
  2444. data/activesupport/lib/active_support/core_ext/date_time.rb +7 -0
  2445. data/activesupport/lib/active_support/core_ext/date_time/acts_like.rb +16 -0
  2446. data/activesupport/lib/active_support/core_ext/date_time/blank.rb +14 -0
  2447. data/activesupport/lib/active_support/core_ext/date_time/calculations.rb +211 -0
  2448. data/activesupport/lib/active_support/core_ext/date_time/compatibility.rb +18 -0
  2449. data/activesupport/lib/active_support/core_ext/date_time/conversions.rb +107 -0
  2450. data/activesupport/lib/active_support/core_ext/digest/uuid.rb +53 -0
  2451. data/activesupport/lib/active_support/core_ext/enumerable.rb +159 -0
  2452. data/activesupport/lib/active_support/core_ext/file.rb +3 -0
  2453. data/activesupport/lib/active_support/core_ext/file/atomic.rb +70 -0
  2454. data/activesupport/lib/active_support/core_ext/hash.rb +11 -0
  2455. data/activesupport/lib/active_support/core_ext/hash/compact.rb +29 -0
  2456. data/activesupport/lib/active_support/core_ext/hash/conversions.rb +263 -0
  2457. data/activesupport/lib/active_support/core_ext/hash/deep_merge.rb +34 -0
  2458. data/activesupport/lib/active_support/core_ext/hash/except.rb +24 -0
  2459. data/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +24 -0
  2460. data/activesupport/lib/active_support/core_ext/hash/keys.rb +172 -0
  2461. data/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +25 -0
  2462. data/activesupport/lib/active_support/core_ext/hash/slice.rb +50 -0
  2463. data/activesupport/lib/active_support/core_ext/hash/transform_values.rb +32 -0
  2464. data/activesupport/lib/active_support/core_ext/integer.rb +5 -0
  2465. data/activesupport/lib/active_support/core_ext/integer/inflections.rb +31 -0
  2466. data/activesupport/lib/active_support/core_ext/integer/multiple.rb +12 -0
  2467. data/activesupport/lib/active_support/core_ext/integer/time.rb +31 -0
  2468. data/activesupport/lib/active_support/core_ext/kernel.rb +6 -0
  2469. data/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +13 -0
  2470. data/activesupport/lib/active_support/core_ext/kernel/concern.rb +14 -0
  2471. data/activesupport/lib/active_support/core_ext/kernel/reporting.rb +45 -0
  2472. data/activesupport/lib/active_support/core_ext/kernel/singleton_class.rb +8 -0
  2473. data/activesupport/lib/active_support/core_ext/load_error.rb +9 -0
  2474. data/activesupport/lib/active_support/core_ext/marshal.rb +24 -0
  2475. data/activesupport/lib/active_support/core_ext/module.rb +13 -0
  2476. data/activesupport/lib/active_support/core_ext/module/aliasing.rb +31 -0
  2477. data/activesupport/lib/active_support/core_ext/module/anonymous.rb +30 -0
  2478. data/activesupport/lib/active_support/core_ext/module/attr_internal.rb +38 -0
  2479. data/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +215 -0
  2480. data/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +150 -0
  2481. data/activesupport/lib/active_support/core_ext/module/concerning.rb +137 -0
  2482. data/activesupport/lib/active_support/core_ext/module/delegation.rb +290 -0
  2483. data/activesupport/lib/active_support/core_ext/module/deprecation.rb +25 -0
  2484. data/activesupport/lib/active_support/core_ext/module/introspection.rb +62 -0
  2485. data/activesupport/lib/active_support/core_ext/module/reachable.rb +10 -0
  2486. data/activesupport/lib/active_support/core_ext/module/remove_method.rb +37 -0
  2487. data/activesupport/lib/active_support/core_ext/name_error.rb +33 -0
  2488. data/activesupport/lib/active_support/core_ext/numeric.rb +6 -0
  2489. data/activesupport/lib/active_support/core_ext/numeric/bytes.rb +66 -0
  2490. data/activesupport/lib/active_support/core_ext/numeric/conversions.rb +140 -0
  2491. data/activesupport/lib/active_support/core_ext/numeric/inquiry.rb +28 -0
  2492. data/activesupport/lib/active_support/core_ext/numeric/time.rb +76 -0
  2493. data/activesupport/lib/active_support/core_ext/object.rb +16 -0
  2494. data/activesupport/lib/active_support/core_ext/object/acts_like.rb +12 -0
  2495. data/activesupport/lib/active_support/core_ext/object/blank.rb +147 -0
  2496. data/activesupport/lib/active_support/core_ext/object/conversions.rb +6 -0
  2497. data/activesupport/lib/active_support/core_ext/object/deep_dup.rb +55 -0
  2498. data/activesupport/lib/active_support/core_ext/object/duplicable.rb +156 -0
  2499. data/activesupport/lib/active_support/core_ext/object/inclusion.rb +29 -0
  2500. data/activesupport/lib/active_support/core_ext/object/instance_variables.rb +30 -0
  2501. data/activesupport/lib/active_support/core_ext/object/json.rb +221 -0
  2502. data/activesupport/lib/active_support/core_ext/object/to_param.rb +3 -0
  2503. data/activesupport/lib/active_support/core_ext/object/to_query.rb +86 -0
  2504. data/activesupport/lib/active_support/core_ext/object/try.rb +148 -0
  2505. data/activesupport/lib/active_support/core_ext/object/with_options.rb +82 -0
  2506. data/activesupport/lib/active_support/core_ext/range.rb +6 -0
  2507. data/activesupport/lib/active_support/core_ext/range/conversions.rb +33 -0
  2508. data/activesupport/lib/active_support/core_ext/range/each.rb +23 -0
  2509. data/activesupport/lib/active_support/core_ext/range/include_range.rb +25 -0
  2510. data/activesupport/lib/active_support/core_ext/range/overlaps.rb +10 -0
  2511. data/activesupport/lib/active_support/core_ext/regexp.rb +11 -0
  2512. data/activesupport/lib/active_support/core_ext/securerandom.rb +25 -0
  2513. data/activesupport/lib/active_support/core_ext/string.rb +15 -0
  2514. data/activesupport/lib/active_support/core_ext/string/access.rb +106 -0
  2515. data/activesupport/lib/active_support/core_ext/string/behavior.rb +8 -0
  2516. data/activesupport/lib/active_support/core_ext/string/conversions.rb +59 -0
  2517. data/activesupport/lib/active_support/core_ext/string/exclude.rb +13 -0
  2518. data/activesupport/lib/active_support/core_ext/string/filters.rb +104 -0
  2519. data/activesupport/lib/active_support/core_ext/string/indent.rb +45 -0
  2520. data/activesupport/lib/active_support/core_ext/string/inflections.rb +254 -0
  2521. data/activesupport/lib/active_support/core_ext/string/inquiry.rb +15 -0
  2522. data/activesupport/lib/active_support/core_ext/string/multibyte.rb +55 -0
  2523. data/activesupport/lib/active_support/core_ext/string/output_safety.rb +261 -0
  2524. data/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +6 -0
  2525. data/activesupport/lib/active_support/core_ext/string/strip.rb +25 -0
  2526. data/activesupport/lib/active_support/core_ext/string/zones.rb +16 -0
  2527. data/activesupport/lib/active_support/core_ext/time.rb +7 -0
  2528. data/activesupport/lib/active_support/core_ext/time/acts_like.rb +10 -0
  2529. data/activesupport/lib/active_support/core_ext/time/calculations.rb +315 -0
  2530. data/activesupport/lib/active_support/core_ext/time/compatibility.rb +16 -0
  2531. data/activesupport/lib/active_support/core_ext/time/conversions.rb +72 -0
  2532. data/activesupport/lib/active_support/core_ext/time/zones.rb +113 -0
  2533. data/activesupport/lib/active_support/core_ext/uri.rb +26 -0
  2534. data/activesupport/lib/active_support/current_attributes.rb +195 -0
  2535. data/activesupport/lib/active_support/dependencies.rb +744 -0
  2536. data/activesupport/lib/active_support/dependencies/autoload.rb +79 -0
  2537. data/activesupport/lib/active_support/dependencies/interlock.rb +57 -0
  2538. data/activesupport/lib/active_support/deprecation.rb +46 -0
  2539. data/activesupport/lib/active_support/deprecation/behaviors.rb +105 -0
  2540. data/activesupport/lib/active_support/deprecation/constant_accessor.rb +52 -0
  2541. data/activesupport/lib/active_support/deprecation/instance_delegator.rb +39 -0
  2542. data/activesupport/lib/active_support/deprecation/method_wrappers.rb +72 -0
  2543. data/activesupport/lib/active_support/deprecation/proxy_wrappers.rb +153 -0
  2544. data/activesupport/lib/active_support/deprecation/reporting.rb +114 -0
  2545. data/activesupport/lib/active_support/descendants_tracker.rb +62 -0
  2546. data/activesupport/lib/active_support/duration.rb +422 -0
  2547. data/activesupport/lib/active_support/duration/iso8601_parser.rb +125 -0
  2548. data/activesupport/lib/active_support/duration/iso8601_serializer.rb +55 -0
  2549. data/activesupport/lib/active_support/evented_file_update_checker.rb +205 -0
  2550. data/activesupport/lib/active_support/execution_wrapper.rb +128 -0
  2551. data/activesupport/lib/active_support/executor.rb +8 -0
  2552. data/activesupport/lib/active_support/file_update_checker.rb +163 -0
  2553. data/activesupport/lib/active_support/gem_version.rb +17 -0
  2554. data/activesupport/lib/active_support/gzip.rb +38 -0
  2555. data/activesupport/lib/active_support/hash_with_indifferent_access.rb +358 -0
  2556. data/activesupport/lib/active_support/i18n.rb +15 -0
  2557. data/activesupport/lib/active_support/i18n_railtie.rb +114 -0
  2558. data/activesupport/lib/active_support/inflections.rb +72 -0
  2559. data/activesupport/lib/active_support/inflector.rb +9 -0
  2560. data/activesupport/lib/active_support/inflector/inflections.rb +246 -0
  2561. data/activesupport/lib/active_support/inflector/methods.rb +408 -0
  2562. data/activesupport/lib/active_support/inflector/transliterate.rb +112 -0
  2563. data/activesupport/lib/active_support/json.rb +4 -0
  2564. data/activesupport/lib/active_support/json/decoding.rb +76 -0
  2565. data/activesupport/lib/active_support/json/encoding.rb +130 -0
  2566. data/activesupport/lib/active_support/key_generator.rb +73 -0
  2567. data/activesupport/lib/active_support/lazy_load_hooks.rb +78 -0
  2568. data/activesupport/lib/active_support/locale/en.yml +135 -0
  2569. data/activesupport/lib/active_support/log_subscriber.rb +112 -0
  2570. data/activesupport/lib/active_support/log_subscriber/test_helper.rb +106 -0
  2571. data/activesupport/lib/active_support/logger.rb +108 -0
  2572. data/activesupport/lib/active_support/logger_silence.rb +29 -0
  2573. data/activesupport/lib/active_support/logger_thread_safe_level.rb +33 -0
  2574. data/activesupport/lib/active_support/message_encryptor.rb +202 -0
  2575. data/activesupport/lib/active_support/message_verifier.rb +178 -0
  2576. data/activesupport/lib/active_support/messages/metadata.rb +71 -0
  2577. data/activesupport/lib/active_support/multibyte.rb +23 -0
  2578. data/activesupport/lib/active_support/multibyte/chars.rb +235 -0
  2579. data/activesupport/lib/active_support/multibyte/unicode.rb +394 -0
  2580. data/activesupport/lib/active_support/notifications.rb +216 -0
  2581. data/activesupport/lib/active_support/notifications/fanout.rb +159 -0
  2582. data/activesupport/lib/active_support/notifications/instrumenter.rb +93 -0
  2583. data/activesupport/lib/active_support/number_helper.rb +371 -0
  2584. data/activesupport/lib/active_support/number_helper/number_converter.rb +184 -0
  2585. data/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb +46 -0
  2586. data/activesupport/lib/active_support/number_helper/number_to_delimited_converter.rb +29 -0
  2587. data/activesupport/lib/active_support/number_helper/number_to_human_converter.rb +68 -0
  2588. data/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb +59 -0
  2589. data/activesupport/lib/active_support/number_helper/number_to_percentage_converter.rb +14 -0
  2590. data/activesupport/lib/active_support/number_helper/number_to_phone_converter.rb +58 -0
  2591. data/activesupport/lib/active_support/number_helper/number_to_rounded_converter.rb +74 -0
  2592. data/activesupport/lib/active_support/number_helper/rounding_helper.rb +66 -0
  2593. data/activesupport/lib/active_support/option_merger.rb +27 -0
  2594. data/activesupport/lib/active_support/ordered_hash.rb +50 -0
  2595. data/activesupport/lib/active_support/ordered_options.rb +85 -0
  2596. data/activesupport/lib/active_support/per_thread_registry.rb +60 -0
  2597. data/activesupport/lib/active_support/proxy_object.rb +15 -0
  2598. data/activesupport/lib/active_support/rails.rb +35 -0
  2599. data/activesupport/lib/active_support/railtie.rb +59 -0
  2600. data/activesupport/lib/active_support/reloader.rb +128 -0
  2601. data/activesupport/lib/active_support/rescuable.rb +174 -0
  2602. data/activesupport/lib/active_support/security_utils.rb +29 -0
  2603. data/activesupport/lib/active_support/string_inquirer.rb +34 -0
  2604. data/activesupport/lib/active_support/subscriber.rb +126 -0
  2605. data/activesupport/lib/active_support/tagged_logging.rb +79 -0
  2606. data/activesupport/lib/active_support/test_case.rb +73 -0
  2607. data/activesupport/lib/active_support/testing/assertions.rb +199 -0
  2608. data/activesupport/lib/active_support/testing/autorun.rb +7 -0
  2609. data/activesupport/lib/active_support/testing/constant_lookup.rb +51 -0
  2610. data/activesupport/lib/active_support/testing/declarative.rb +28 -0
  2611. data/activesupport/lib/active_support/testing/deprecation.rb +39 -0
  2612. data/activesupport/lib/active_support/testing/file_fixtures.rb +36 -0
  2613. data/activesupport/lib/active_support/testing/isolation.rb +108 -0
  2614. data/activesupport/lib/active_support/testing/method_call_assertions.rb +43 -0
  2615. data/activesupport/lib/active_support/testing/setup_and_teardown.rb +52 -0
  2616. data/activesupport/lib/active_support/testing/stream.rb +44 -0
  2617. data/activesupport/lib/active_support/testing/tagged_logging.rb +27 -0
  2618. data/activesupport/lib/active_support/testing/time_helpers.rb +199 -0
  2619. data/activesupport/lib/active_support/time.rb +20 -0
  2620. data/activesupport/lib/active_support/time_with_zone.rb +551 -0
  2621. data/activesupport/lib/active_support/values/time_zone.rb +555 -0
  2622. data/activesupport/lib/active_support/values/unicode_tables.dat +0 -0
  2623. data/activesupport/lib/active_support/version.rb +10 -0
  2624. data/activesupport/lib/active_support/xml_mini.rb +209 -0
  2625. data/activesupport/lib/active_support/xml_mini/jdom.rb +183 -0
  2626. data/activesupport/lib/active_support/xml_mini/libxml.rb +80 -0
  2627. data/activesupport/lib/active_support/xml_mini/libxmlsax.rb +83 -0
  2628. data/activesupport/lib/active_support/xml_mini/nokogiri.rb +83 -0
  2629. data/activesupport/lib/active_support/xml_mini/nokogirisax.rb +86 -0
  2630. data/activesupport/lib/active_support/xml_mini/rexml.rb +130 -0
  2631. data/activesupport/test/abstract_unit.rb +41 -0
  2632. data/activesupport/test/array_inquirer_test.rb +63 -0
  2633. data/activesupport/test/autoload_test.rb +83 -0
  2634. data/activesupport/test/autoloading_fixtures/a/b.rb +4 -0
  2635. data/activesupport/test/autoloading_fixtures/a/c/d.rb +4 -0
  2636. data/activesupport/test/autoloading_fixtures/a/c/em/f.rb +4 -0
  2637. data/activesupport/test/autoloading_fixtures/application.rb +3 -0
  2638. data/activesupport/test/autoloading_fixtures/circular1.rb +8 -0
  2639. data/activesupport/test/autoloading_fixtures/circular2.rb +6 -0
  2640. data/activesupport/test/autoloading_fixtures/class_folder.rb +5 -0
  2641. data/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb +5 -0
  2642. data/activesupport/test/autoloading_fixtures/class_folder/inline_class.rb +4 -0
  2643. data/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb +9 -0
  2644. data/activesupport/test/autoloading_fixtures/conflict.rb +3 -0
  2645. data/activesupport/test/autoloading_fixtures/counting_loader.rb +7 -0
  2646. data/activesupport/test/autoloading_fixtures/cross_site_dependency.rb +4 -0
  2647. data/activesupport/test/autoloading_fixtures/d.rb +4 -0
  2648. data/activesupport/test/autoloading_fixtures/em.rb +4 -0
  2649. data/activesupport/test/autoloading_fixtures/html/some_class.rb +6 -0
  2650. data/activesupport/test/autoloading_fixtures/load_path/loaded_constant.rb +4 -0
  2651. data/activesupport/test/autoloading_fixtures/loads_constant.rb +7 -0
  2652. data/activesupport/test/autoloading_fixtures/module_folder/inline_class.rb +4 -0
  2653. data/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb +6 -0
  2654. data/activesupport/test/autoloading_fixtures/module_folder/nested_sibling.rb +4 -0
  2655. data/activesupport/test/autoloading_fixtures/module_with_custom_const_missing/a/b.rb +3 -0
  2656. data/activesupport/test/autoloading_fixtures/multiple_constant_file.rb +4 -0
  2657. data/activesupport/test/autoloading_fixtures/prepend.rb +10 -0
  2658. data/activesupport/test/autoloading_fixtures/prepend/sub_class_conflict.rb +4 -0
  2659. data/activesupport/test/autoloading_fixtures/raises_arbitrary_exception.rb +6 -0
  2660. data/activesupport/test/autoloading_fixtures/raises_name_error.rb +5 -0
  2661. data/activesupport/test/autoloading_fixtures/raises_no_method_error.rb +5 -0
  2662. data/activesupport/test/autoloading_fixtures/requires_constant.rb +6 -0
  2663. data/activesupport/test/autoloading_fixtures/should_not_be_required.rb +3 -0
  2664. data/activesupport/test/autoloading_fixtures/throws.rb +6 -0
  2665. data/activesupport/test/autoloading_fixtures/typo.rb +3 -0
  2666. data/activesupport/test/benchmarkable_test.rb +78 -0
  2667. data/activesupport/test/broadcast_logger_test.rb +172 -0
  2668. data/activesupport/test/cache/behaviors.rb +9 -0
  2669. data/activesupport/test/cache/behaviors/autoloading_cache_behavior.rb +43 -0
  2670. data/activesupport/test/cache/behaviors/cache_delete_matched_behavior.rb +15 -0
  2671. data/activesupport/test/cache/behaviors/cache_increment_decrement_behavior.rb +23 -0
  2672. data/activesupport/test/cache/behaviors/cache_store_behavior.rb +331 -0
  2673. data/activesupport/test/cache/behaviors/cache_store_version_behavior.rb +88 -0
  2674. data/activesupport/test/cache/behaviors/encoded_key_cache_behavior.rb +36 -0
  2675. data/activesupport/test/cache/behaviors/local_cache_behavior.rb +128 -0
  2676. data/activesupport/test/cache/cache_entry_test.rb +30 -0
  2677. data/activesupport/test/cache/cache_key_test.rb +90 -0
  2678. data/activesupport/test/cache/cache_store_logger_test.rb +36 -0
  2679. data/activesupport/test/cache/cache_store_namespace_test.rb +40 -0
  2680. data/activesupport/test/cache/cache_store_setting_test.rb +68 -0
  2681. data/activesupport/test/cache/cache_store_write_multi_test.rb +62 -0
  2682. data/activesupport/test/cache/local_cache_middleware_test.rb +63 -0
  2683. data/activesupport/test/cache/stores/file_store_test.rb +130 -0
  2684. data/activesupport/test/cache/stores/mem_cache_store_test.rb +76 -0
  2685. data/activesupport/test/cache/stores/memory_store_test.rb +109 -0
  2686. data/activesupport/test/cache/stores/null_store_test.rb +59 -0
  2687. data/activesupport/test/callback_inheritance_test.rb +178 -0
  2688. data/activesupport/test/callbacks_test.rb +1205 -0
  2689. data/activesupport/test/class_cache_test.rb +80 -0
  2690. data/activesupport/test/clean_backtrace_test.rb +76 -0
  2691. data/activesupport/test/clean_logger_test.rb +31 -0
  2692. data/activesupport/test/concern_test.rb +131 -0
  2693. data/activesupport/test/configurable_test.rb +133 -0
  2694. data/activesupport/test/constantize_test_cases.rb +127 -0
  2695. data/activesupport/test/core_ext/array/access_test.rb +38 -0
  2696. data/activesupport/test/core_ext/array/conversions_test.rb +205 -0
  2697. data/activesupport/test/core_ext/array/extract_options_test.rb +47 -0
  2698. data/activesupport/test/core_ext/array/grouping_test.rb +137 -0
  2699. data/activesupport/test/core_ext/array/prepend_append_test.rb +14 -0
  2700. data/activesupport/test/core_ext/array/wrap_test.rb +79 -0
  2701. data/activesupport/test/core_ext/bigdecimal_test.rb +13 -0
  2702. data/activesupport/test/core_ext/class/attribute_test.rb +101 -0
  2703. data/activesupport/test/core_ext/class_test.rb +40 -0
  2704. data/activesupport/test/core_ext/date_and_time_behavior.rb +325 -0
  2705. data/activesupport/test/core_ext/date_and_time_compatibility_test.rb +275 -0
  2706. data/activesupport/test/core_ext/date_ext_test.rb +415 -0
  2707. data/activesupport/test/core_ext/date_time_ext_test.rb +463 -0
  2708. data/activesupport/test/core_ext/digest/uuid_test.rb +26 -0
  2709. data/activesupport/test/core_ext/duration_test.rb +651 -0
  2710. data/activesupport/test/core_ext/enumerable_test.rb +223 -0
  2711. data/activesupport/test/core_ext/file_test.rb +80 -0
  2712. data/activesupport/test/core_ext/hash/transform_keys_test.rb +64 -0
  2713. data/activesupport/test/core_ext/hash/transform_values_test.rb +77 -0
  2714. data/activesupport/test/core_ext/hash_ext_test.rb +1131 -0
  2715. data/activesupport/test/core_ext/integer_ext_test.rb +32 -0
  2716. data/activesupport/test/core_ext/kernel/concern_test.rb +15 -0
  2717. data/activesupport/test/core_ext/kernel_test.rb +53 -0
  2718. data/activesupport/test/core_ext/load_error_test.rb +19 -0
  2719. data/activesupport/test/core_ext/marshal_test.rb +165 -0
  2720. data/activesupport/test/core_ext/module/anonymous_test.rb +16 -0
  2721. data/activesupport/test/core_ext/module/attr_internal_test.rb +55 -0
  2722. data/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb +133 -0
  2723. data/activesupport/test/core_ext/module/attribute_accessor_test.rb +137 -0
  2724. data/activesupport/test/core_ext/module/attribute_aliasing_test.rb +61 -0
  2725. data/activesupport/test/core_ext/module/concerning_test.rb +67 -0
  2726. data/activesupport/test/core_ext/module/introspection_test.rb +39 -0
  2727. data/activesupport/test/core_ext/module/reachable_test.rb +43 -0
  2728. data/activesupport/test/core_ext/module/remove_method_test.rb +59 -0
  2729. data/activesupport/test/core_ext/module_test.rb +443 -0
  2730. data/activesupport/test/core_ext/name_error_test.rb +23 -0
  2731. data/activesupport/test/core_ext/numeric_ext_test.rb +491 -0
  2732. data/activesupport/test/core_ext/object/acts_like_test.rb +35 -0
  2733. data/activesupport/test/core_ext/object/blank_test.rb +36 -0
  2734. data/activesupport/test/core_ext/object/deep_dup_test.rb +59 -0
  2735. data/activesupport/test/core_ext/object/duplicable_test.rb +37 -0
  2736. data/activesupport/test/core_ext/object/inclusion_test.rb +61 -0
  2737. data/activesupport/test/core_ext/object/instance_variables_test.rb +33 -0
  2738. data/activesupport/test/core_ext/object/json_cherry_pick_test.rb +44 -0
  2739. data/activesupport/test/core_ext/object/json_gem_encoding_test.rb +68 -0
  2740. data/activesupport/test/core_ext/object/to_param_test.rb +39 -0
  2741. data/activesupport/test/core_ext/object/to_query_test.rb +84 -0
  2742. data/activesupport/test/core_ext/object/try_test.rb +165 -0
  2743. data/activesupport/test/core_ext/range_ext_test.rb +133 -0
  2744. data/activesupport/test/core_ext/regexp_ext_test.rb +36 -0
  2745. data/activesupport/test/core_ext/secure_random_test.rb +22 -0
  2746. data/activesupport/test/core_ext/string_ext_test.rb +932 -0
  2747. data/activesupport/test/core_ext/time_ext_test.rb +999 -0
  2748. data/activesupport/test/core_ext/time_with_zone_test.rb +1304 -0
  2749. data/activesupport/test/core_ext/uri_ext_test.rb +14 -0
  2750. data/activesupport/test/current_attributes_test.rb +105 -0
  2751. data/activesupport/test/dependencies/check_warnings.rb +4 -0
  2752. data/activesupport/test/dependencies/conflict.rb +3 -0
  2753. data/activesupport/test/dependencies/cross_site_depender.rb +5 -0
  2754. data/activesupport/test/dependencies/mutual_one.rb +6 -0
  2755. data/activesupport/test/dependencies/mutual_two.rb +6 -0
  2756. data/activesupport/test/dependencies/raises_exception.rb +5 -0
  2757. data/activesupport/test/dependencies/raises_exception_without_blame_file.rb +7 -0
  2758. data/activesupport/test/dependencies/requires_nonexistent0.rb +3 -0
  2759. data/activesupport/test/dependencies/requires_nonexistent1.rb +3 -0
  2760. data/activesupport/test/dependencies/service_one.rb +7 -0
  2761. data/activesupport/test/dependencies/service_two.rb +4 -0
  2762. data/activesupport/test/dependencies_test.rb +1077 -0
  2763. data/activesupport/test/dependencies_test_helpers.rb +30 -0
  2764. data/activesupport/test/deprecation/method_wrappers_test.rb +36 -0
  2765. data/activesupport/test/deprecation/proxy_wrappers_test.rb +24 -0
  2766. data/activesupport/test/deprecation_test.rb +430 -0
  2767. data/activesupport/test/descendants_tracker_test_cases.rb +67 -0
  2768. data/activesupport/test/descendants_tracker_with_autoloading_test.rb +36 -0
  2769. data/activesupport/test/descendants_tracker_without_autoloading_test.rb +19 -0
  2770. data/activesupport/test/evented_file_update_checker_test.rb +197 -0
  2771. data/activesupport/test/executor_test.rb +242 -0
  2772. data/activesupport/test/file_fixtures/sample.txt +1 -0
  2773. data/activesupport/test/file_update_checker_shared_tests.rb +284 -0
  2774. data/activesupport/test/file_update_checker_test.rb +21 -0
  2775. data/activesupport/test/fixtures/autoload/another_class.rb +4 -0
  2776. data/activesupport/test/fixtures/autoload/some_class.rb +4 -0
  2777. data/activesupport/test/fixtures/xml/jdom_doctype.dtd +1 -0
  2778. data/activesupport/test/fixtures/xml/jdom_entities.txt +1 -0
  2779. data/activesupport/test/fixtures/xml/jdom_include.txt +1 -0
  2780. data/activesupport/test/gzip_test.rb +45 -0
  2781. data/activesupport/test/hash_with_indifferent_access_test.rb +773 -0
  2782. data/activesupport/test/i18n_test.rb +106 -0
  2783. data/activesupport/test/inflector_test.rb +548 -0
  2784. data/activesupport/test/inflector_test_cases.rb +375 -0
  2785. data/activesupport/test/json/decoding_test.rb +124 -0
  2786. data/activesupport/test/json/encoding_test.rb +477 -0
  2787. data/activesupport/test/json/encoding_test_cases.rb +98 -0
  2788. data/activesupport/test/key_generator_test.rb +79 -0
  2789. data/activesupport/test/lazy_load_hooks_test.rb +140 -0
  2790. data/activesupport/test/log_subscriber_test.rb +126 -0
  2791. data/activesupport/test/logger_test.rb +270 -0
  2792. data/activesupport/test/message_encryptor_test.rb +176 -0
  2793. data/activesupport/test/message_verifier_test.rb +158 -0
  2794. data/activesupport/test/metadata/shared_metadata_tests.rb +93 -0
  2795. data/activesupport/test/multibyte_chars_test.rb +752 -0
  2796. data/activesupport/test/multibyte_conformance_test.rb +110 -0
  2797. data/activesupport/test/multibyte_grapheme_break_conformance_test.rb +62 -0
  2798. data/activesupport/test/multibyte_normalization_conformance_test.rb +112 -0
  2799. data/activesupport/test/multibyte_proxy_test.rb +34 -0
  2800. data/activesupport/test/multibyte_test_helpers.rb +41 -0
  2801. data/activesupport/test/multibyte_unicode_database_test.rb +26 -0
  2802. data/activesupport/test/notifications/evented_notification_test.rb +89 -0
  2803. data/activesupport/test/notifications/instrumenter_test.rb +60 -0
  2804. data/activesupport/test/notifications_test.rb +283 -0
  2805. data/activesupport/test/number_helper_i18n_test.rb +151 -0
  2806. data/activesupport/test/number_helper_test.rb +411 -0
  2807. data/activesupport/test/option_merger_test.rb +97 -0
  2808. data/activesupport/test/ordered_hash_test.rb +324 -0
  2809. data/activesupport/test/ordered_options_test.rb +105 -0
  2810. data/activesupport/test/reloader_test.rb +99 -0
  2811. data/activesupport/test/rescuable_test.rb +176 -0
  2812. data/activesupport/test/safe_buffer_test.rb +182 -0
  2813. data/activesupport/test/security_utils_test.rb +16 -0
  2814. data/activesupport/test/share_lock_test.rb +580 -0
  2815. data/activesupport/test/string_inquirer_test.rb +46 -0
  2816. data/activesupport/test/subscriber_test.rb +56 -0
  2817. data/activesupport/test/tagged_logging_test.rb +117 -0
  2818. data/activesupport/test/test_case_test.rb +339 -0
  2819. data/activesupport/test/testing/constant_lookup_test.rb +78 -0
  2820. data/activesupport/test/testing/file_fixtures_test.rb +32 -0
  2821. data/activesupport/test/testing/method_call_assertions_test.rb +125 -0
  2822. data/activesupport/test/time_travel_test.rb +189 -0
  2823. data/activesupport/test/time_zone_test.rb +738 -0
  2824. data/activesupport/test/time_zone_test_helpers.rb +26 -0
  2825. data/activesupport/test/transliterate_test.rb +54 -0
  2826. data/activesupport/test/xml_mini/jdom_engine_test.rb +53 -0
  2827. data/activesupport/test/xml_mini/libxml_engine_test.rb +21 -0
  2828. data/activesupport/test/xml_mini/libxmlsax_engine_test.rb +16 -0
  2829. data/activesupport/test/xml_mini/nokogiri_engine_test.rb +16 -0
  2830. data/activesupport/test/xml_mini/nokogirisax_engine_test.rb +16 -0
  2831. data/activesupport/test/xml_mini/rexml_engine_test.rb +27 -0
  2832. data/activesupport/test/xml_mini/xml_mini_engine_test.rb +264 -0
  2833. data/activesupport/test/xml_mini_test.rb +355 -0
  2834. data/ci/phantomjs.js +149 -0
  2835. data/ci/travis.rb +187 -0
  2836. data/guides/.document +0 -0
  2837. data/guides/CHANGELOG.md +1 -0
  2838. data/guides/Rakefile +91 -0
  2839. data/guides/assets/images/akshaysurve.jpg +0 -0
  2840. data/guides/assets/images/belongs_to.png +0 -0
  2841. data/guides/assets/images/book_icon.gif +0 -0
  2842. data/guides/assets/images/bullet.gif +0 -0
  2843. data/guides/assets/images/chapters_icon.gif +0 -0
  2844. data/guides/assets/images/check_bullet.gif +0 -0
  2845. data/guides/assets/images/credits_pic_blank.gif +0 -0
  2846. data/guides/assets/images/csrf.png +0 -0
  2847. data/guides/assets/images/edge_badge.png +0 -0
  2848. data/guides/assets/images/favicon.ico +0 -0
  2849. data/guides/assets/images/feature_tile.gif +0 -0
  2850. data/guides/assets/images/footer_tile.gif +0 -0
  2851. data/guides/assets/images/fxn.png +0 -0
  2852. data/guides/assets/images/getting_started/article_with_comments.png +0 -0
  2853. data/guides/assets/images/getting_started/challenge.png +0 -0
  2854. data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
  2855. data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  2856. data/guides/assets/images/getting_started/form_with_errors.png +0 -0
  2857. data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
  2858. data/guides/assets/images/getting_started/new_article.png +0 -0
  2859. data/guides/assets/images/getting_started/rails_welcome.png +0 -0
  2860. data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
  2861. data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
  2862. data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
  2863. data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
  2864. data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
  2865. data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
  2866. data/guides/assets/images/grey_bullet.gif +0 -0
  2867. data/guides/assets/images/habtm.png +0 -0
  2868. data/guides/assets/images/has_many.png +0 -0
  2869. data/guides/assets/images/has_many_through.png +0 -0
  2870. data/guides/assets/images/has_one.png +0 -0
  2871. data/guides/assets/images/has_one_through.png +0 -0
  2872. data/guides/assets/images/header_backdrop.png +0 -0
  2873. data/guides/assets/images/header_tile.gif +0 -0
  2874. data/guides/assets/images/i18n/demo_html_safe.png +0 -0
  2875. data/guides/assets/images/i18n/demo_localized_pirate.png +0 -0
  2876. data/guides/assets/images/i18n/demo_translated_en.png +0 -0
  2877. data/guides/assets/images/i18n/demo_translated_pirate.png +0 -0
  2878. data/guides/assets/images/i18n/demo_translation_missing.png +0 -0
  2879. data/guides/assets/images/i18n/demo_untranslated.png +0 -0
  2880. data/guides/assets/images/icons/README +5 -0
  2881. data/guides/assets/images/icons/callouts/1.png +0 -0
  2882. data/guides/assets/images/icons/callouts/10.png +0 -0
  2883. data/guides/assets/images/icons/callouts/11.png +0 -0
  2884. data/guides/assets/images/icons/callouts/12.png +0 -0
  2885. data/guides/assets/images/icons/callouts/13.png +0 -0
  2886. data/guides/assets/images/icons/callouts/14.png +0 -0
  2887. data/guides/assets/images/icons/callouts/15.png +0 -0
  2888. data/guides/assets/images/icons/callouts/2.png +0 -0
  2889. data/guides/assets/images/icons/callouts/3.png +0 -0
  2890. data/guides/assets/images/icons/callouts/4.png +0 -0
  2891. data/guides/assets/images/icons/callouts/5.png +0 -0
  2892. data/guides/assets/images/icons/callouts/6.png +0 -0
  2893. data/guides/assets/images/icons/callouts/7.png +0 -0
  2894. data/guides/assets/images/icons/callouts/8.png +0 -0
  2895. data/guides/assets/images/icons/callouts/9.png +0 -0
  2896. data/guides/assets/images/icons/caution.png +0 -0
  2897. data/guides/assets/images/icons/example.png +0 -0
  2898. data/guides/assets/images/icons/home.png +0 -0
  2899. data/guides/assets/images/icons/important.png +0 -0
  2900. data/guides/assets/images/icons/next.png +0 -0
  2901. data/guides/assets/images/icons/note.png +0 -0
  2902. data/guides/assets/images/icons/prev.png +0 -0
  2903. data/guides/assets/images/icons/tip.png +0 -0
  2904. data/guides/assets/images/icons/up.png +0 -0
  2905. data/guides/assets/images/icons/warning.png +0 -0
  2906. data/guides/assets/images/nav_arrow.gif +0 -0
  2907. data/guides/assets/images/oscardelben.jpg +0 -0
  2908. data/guides/assets/images/polymorphic.png +0 -0
  2909. data/guides/assets/images/radar.png +0 -0
  2910. data/guides/assets/images/rails4_features.png +0 -0
  2911. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  2912. data/guides/assets/images/rails_guides_logo.gif +0 -0
  2913. data/guides/assets/images/rails_logo_remix.gif +0 -0
  2914. data/guides/assets/images/session_fixation.png +0 -0
  2915. data/guides/assets/images/tab_grey.gif +0 -0
  2916. data/guides/assets/images/tab_info.gif +0 -0
  2917. data/guides/assets/images/tab_note.gif +0 -0
  2918. data/guides/assets/images/tab_red.gif +0 -0
  2919. data/guides/assets/images/tab_yellow.gif +0 -0
  2920. data/guides/assets/images/tab_yellow.png +0 -0
  2921. data/guides/assets/images/vijaydev.jpg +0 -0
  2922. data/guides/assets/javascripts/guides.js +53 -0
  2923. data/guides/assets/javascripts/jquery.min.js +4 -0
  2924. data/guides/assets/javascripts/responsive-tables.js +43 -0
  2925. data/guides/assets/javascripts/syntaxhighlighter.js +20 -0
  2926. data/guides/assets/stylesheets/fixes.css +16 -0
  2927. data/guides/assets/stylesheets/kindle.css +11 -0
  2928. data/guides/assets/stylesheets/main.css +718 -0
  2929. data/guides/assets/stylesheets/print.css +52 -0
  2930. data/guides/assets/stylesheets/reset.css +43 -0
  2931. data/guides/assets/stylesheets/responsive-tables.css +50 -0
  2932. data/guides/assets/stylesheets/style.css +13 -0
  2933. data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +226 -0
  2934. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +116 -0
  2935. data/guides/bug_report_templates/action_controller_gem.rb +58 -0
  2936. data/guides/bug_report_templates/action_controller_master.rb +54 -0
  2937. data/guides/bug_report_templates/active_job_gem.rb +34 -0
  2938. data/guides/bug_report_templates/active_job_master.rb +34 -0
  2939. data/guides/bug_report_templates/active_record_gem.rb +54 -0
  2940. data/guides/bug_report_templates/active_record_master.rb +51 -0
  2941. data/guides/bug_report_templates/active_record_migrations_gem.rb +65 -0
  2942. data/guides/bug_report_templates/active_record_migrations_master.rb +65 -0
  2943. data/guides/bug_report_templates/benchmark.rb +52 -0
  2944. data/guides/bug_report_templates/generic_gem.rb +27 -0
  2945. data/guides/bug_report_templates/generic_master.rb +25 -0
  2946. data/guides/rails_guides.rb +29 -0
  2947. data/guides/rails_guides/generator.rb +208 -0
  2948. data/guides/rails_guides/helpers.rb +55 -0
  2949. data/guides/rails_guides/indexer.rb +70 -0
  2950. data/guides/rails_guides/kindle.rb +116 -0
  2951. data/guides/rails_guides/levenshtein.rb +44 -0
  2952. data/guides/rails_guides/markdown.rb +173 -0
  2953. data/guides/rails_guides/markdown/renderer.rb +123 -0
  2954. data/guides/source/2_2_release_notes.md +436 -0
  2955. data/guides/source/2_3_release_notes.md +623 -0
  2956. data/guides/source/3_0_release_notes.md +612 -0
  2957. data/guides/source/3_1_release_notes.md +561 -0
  2958. data/guides/source/3_2_release_notes.md +570 -0
  2959. data/guides/source/4_0_release_notes.md +284 -0
  2960. data/guides/source/4_1_release_notes.md +732 -0
  2961. data/guides/source/4_2_release_notes.md +890 -0
  2962. data/guides/source/5_0_release_notes.md +1096 -0
  2963. data/guides/source/5_1_release_notes.md +652 -0
  2964. data/guides/source/_license.html.erb +2 -0
  2965. data/guides/source/_welcome.html.erb +25 -0
  2966. data/guides/source/action_cable_overview.md +691 -0
  2967. data/guides/source/action_controller_overview.md +1218 -0
  2968. data/guides/source/action_mailer_basics.md +826 -0
  2969. data/guides/source/action_view_overview.md +1511 -0
  2970. data/guides/source/active_job_basics.md +403 -0
  2971. data/guides/source/active_model_basics.md +505 -0
  2972. data/guides/source/active_record_basics.md +377 -0
  2973. data/guides/source/active_record_callbacks.md +459 -0
  2974. data/guides/source/active_record_migrations.md +1055 -0
  2975. data/guides/source/active_record_postgresql.md +517 -0
  2976. data/guides/source/active_record_querying.md +2048 -0
  2977. data/guides/source/active_record_validations.md +1296 -0
  2978. data/guides/source/active_support_core_extensions.md +3748 -0
  2979. data/guides/source/active_support_instrumentation.md +552 -0
  2980. data/guides/source/api_app.md +426 -0
  2981. data/guides/source/api_documentation_guidelines.md +366 -0
  2982. data/guides/source/asset_pipeline.md +1299 -0
  2983. data/guides/source/association_basics.md +2467 -0
  2984. data/guides/source/autoloading_and_reloading_constants.md +1323 -0
  2985. data/guides/source/caching_with_rails.md +615 -0
  2986. data/guides/source/command_line.md +664 -0
  2987. data/guides/source/configuring.md +1341 -0
  2988. data/guides/source/contributing_to_ruby_on_rails.md +667 -0
  2989. data/guides/source/credits.html.erb +80 -0
  2990. data/guides/source/debugging_rails_applications.md +954 -0
  2991. data/guides/source/development_dependencies_install.md +378 -0
  2992. data/guides/source/documents.yaml +230 -0
  2993. data/guides/source/engines.md +1527 -0
  2994. data/guides/source/form_helpers.md +1023 -0
  2995. data/guides/source/generators.md +716 -0
  2996. data/guides/source/getting_started.md +2100 -0
  2997. data/guides/source/i18n.md +1208 -0
  2998. data/guides/source/index.html.erb +28 -0
  2999. data/guides/source/initialization.md +712 -0
  3000. data/guides/source/kindle/copyright.html.erb +1 -0
  3001. data/guides/source/kindle/layout.html.erb +27 -0
  3002. data/guides/source/kindle/rails_guides.opf.erb +52 -0
  3003. data/guides/source/kindle/toc.html.erb +24 -0
  3004. data/guides/source/kindle/toc.ncx.erb +64 -0
  3005. data/guides/source/kindle/welcome.html.erb +7 -0
  3006. data/guides/source/layout.html.erb +138 -0
  3007. data/guides/source/layouts_and_rendering.md +1330 -0
  3008. data/guides/source/maintenance_policy.md +80 -0
  3009. data/guides/source/plugins.md +484 -0
  3010. data/guides/source/rails_application_templates.md +282 -0
  3011. data/guides/source/rails_on_rack.md +310 -0
  3012. data/guides/source/routing.md +1182 -0
  3013. data/guides/source/ruby_on_rails_guides_guidelines.md +173 -0
  3014. data/guides/source/security.md +1066 -0
  3015. data/guides/source/testing.md +1566 -0
  3016. data/guides/source/upgrading_ruby_on_rails.md +1552 -0
  3017. data/guides/source/working_with_javascript_in_rails.md +550 -0
  3018. data/guides/w3c_validator.rb +98 -0
  3019. data/rails.gemspec +36 -0
  3020. data/railties/.gitignore +1 -0
  3021. data/railties/CHANGELOG.md +129 -0
  3022. data/railties/MIT-LICENSE +20 -0
  3023. data/railties/RDOC_MAIN.rdoc +73 -0
  3024. data/railties/README.rdoc +40 -0
  3025. data/railties/Rakefile +37 -0
  3026. data/railties/bin/test +5 -0
  3027. data/railties/exe/rails +10 -0
  3028. data/railties/lib/minitest/rails_plugin.rb +54 -0
  3029. data/railties/lib/rails.rb +114 -0
  3030. data/railties/lib/rails/all.rb +20 -0
  3031. data/railties/lib/rails/api/generator.rb +37 -0
  3032. data/railties/lib/rails/api/task.rb +185 -0
  3033. data/railties/lib/rails/app_loader.rb +77 -0
  3034. data/railties/lib/rails/app_updater.rb +33 -0
  3035. data/railties/lib/rails/application.rb +531 -0
  3036. data/railties/lib/rails/application/bootstrap.rb +89 -0
  3037. data/railties/lib/rails/application/configuration.rb +252 -0
  3038. data/railties/lib/rails/application/default_middleware_stack.rb +101 -0
  3039. data/railties/lib/rails/application/finisher.rb +196 -0
  3040. data/railties/lib/rails/application/routes_reloader.rb +71 -0
  3041. data/railties/lib/rails/application_controller.rb +18 -0
  3042. data/railties/lib/rails/backtrace_cleaner.rb +34 -0
  3043. data/railties/lib/rails/cli.rb +19 -0
  3044. data/railties/lib/rails/code_statistics.rb +115 -0
  3045. data/railties/lib/rails/code_statistics_calculator.rb +88 -0
  3046. data/railties/lib/rails/command.rb +113 -0
  3047. data/railties/lib/rails/command/actions.rb +44 -0
  3048. data/railties/lib/rails/command/base.rb +157 -0
  3049. data/railties/lib/rails/command/behavior.rb +125 -0
  3050. data/railties/lib/rails/command/environment_argument.rb +47 -0
  3051. data/railties/lib/rails/commands.rb +18 -0
  3052. data/railties/lib/rails/commands/application/application_command.rb +31 -0
  3053. data/railties/lib/rails/commands/console/console_command.rb +100 -0
  3054. data/railties/lib/rails/commands/dbconsole/dbconsole_command.rb +170 -0
  3055. data/railties/lib/rails/commands/destroy/destroy_command.rb +28 -0
  3056. data/railties/lib/rails/commands/generate/generate_command.rb +30 -0
  3057. data/railties/lib/rails/commands/help/USAGE +16 -0
  3058. data/railties/lib/rails/commands/help/help_command.rb +15 -0
  3059. data/railties/lib/rails/commands/new/new_command.rb +19 -0
  3060. data/railties/lib/rails/commands/plugin/plugin_command.rb +45 -0
  3061. data/railties/lib/rails/commands/rake/rake_command.rb +51 -0
  3062. data/railties/lib/rails/commands/runner/USAGE +20 -0
  3063. data/railties/lib/rails/commands/runner/runner_command.rb +53 -0
  3064. data/railties/lib/rails/commands/secrets/USAGE +60 -0
  3065. data/railties/lib/rails/commands/secrets/secrets_command.rb +66 -0
  3066. data/railties/lib/rails/commands/server/server_command.rb +243 -0
  3067. data/railties/lib/rails/commands/test/test_command.rb +37 -0
  3068. data/railties/lib/rails/commands/version/version_command.rb +11 -0
  3069. data/railties/lib/rails/configuration.rb +137 -0
  3070. data/railties/lib/rails/console/app.rb +38 -0
  3071. data/railties/lib/rails/console/helpers.rb +19 -0
  3072. data/railties/lib/rails/dev_caching.rb +44 -0
  3073. data/railties/lib/rails/engine.rb +705 -0
  3074. data/railties/lib/rails/engine/commands.rb +9 -0
  3075. data/railties/lib/rails/engine/configuration.rb +88 -0
  3076. data/railties/lib/rails/engine/railties.rb +23 -0
  3077. data/railties/lib/rails/engine/updater.rb +21 -0
  3078. data/railties/lib/rails/gem_version.rb +17 -0
  3079. data/railties/lib/rails/generators.rb +319 -0
  3080. data/railties/lib/rails/generators/actions.rb +326 -0
  3081. data/railties/lib/rails/generators/actions/create_migration.rb +71 -0
  3082. data/railties/lib/rails/generators/active_model.rb +80 -0
  3083. data/railties/lib/rails/generators/app_base.rb +447 -0
  3084. data/railties/lib/rails/generators/base.rb +417 -0
  3085. data/railties/lib/rails/generators/css/assets/assets_generator.rb +15 -0
  3086. data/railties/lib/rails/generators/css/assets/templates/stylesheet.css +4 -0
  3087. data/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb +18 -0
  3088. data/railties/lib/rails/generators/erb.rb +27 -0
  3089. data/railties/lib/rails/generators/erb/controller/controller_generator.rb +24 -0
  3090. data/railties/lib/rails/generators/erb/controller/templates/view.html.erb +2 -0
  3091. data/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +42 -0
  3092. data/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +13 -0
  3093. data/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb.tt +1 -0
  3094. data/railties/lib/rails/generators/erb/mailer/templates/view.html.erb +5 -0
  3095. data/railties/lib/rails/generators/erb/mailer/templates/view.text.erb +3 -0
  3096. data/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb +33 -0
  3097. data/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb +34 -0
  3098. data/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb +6 -0
  3099. data/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb +31 -0
  3100. data/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb +5 -0
  3101. data/railties/lib/rails/generators/erb/scaffold/templates/show.html.erb +11 -0
  3102. data/railties/lib/rails/generators/generated_attribute.rb +177 -0
  3103. data/railties/lib/rails/generators/js/assets/assets_generator.rb +15 -0
  3104. data/railties/lib/rails/generators/js/assets/templates/javascript.js +2 -0
  3105. data/railties/lib/rails/generators/migration.rb +71 -0
  3106. data/railties/lib/rails/generators/model_helpers.rb +30 -0
  3107. data/railties/lib/rails/generators/named_base.rb +207 -0
  3108. data/railties/lib/rails/generators/rails/app/USAGE +14 -0
  3109. data/railties/lib/rails/generators/rails/app/app_generator.rb +579 -0
  3110. data/railties/lib/rails/generators/rails/app/templates/Gemfile +69 -0
  3111. data/railties/lib/rails/generators/rails/app/templates/README.md +24 -0
  3112. data/railties/lib/rails/generators/rails/app/templates/Rakefile +6 -0
  3113. data/railties/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +5 -0
  3114. data/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +20 -0
  3115. data/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.js +13 -0
  3116. data/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +15 -0
  3117. data/railties/lib/rails/generators/rails/app/templates/app/channels/application_cable/channel.rb +4 -0
  3118. data/railties/lib/rails/generators/rails/app/templates/app/channels/application_cable/connection.rb +4 -0
  3119. data/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt +2 -0
  3120. data/railties/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb +2 -0
  3121. data/railties/lib/rails/generators/rails/app/templates/app/jobs/application_job.rb +2 -0
  3122. data/railties/lib/rails/generators/rails/app/templates/app/mailers/application_mailer.rb +4 -0
  3123. data/railties/lib/rails/generators/rails/app/templates/app/models/application_record.rb +3 -0
  3124. data/railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +23 -0
  3125. data/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +13 -0
  3126. data/railties/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.text.erb.tt +1 -0
  3127. data/railties/lib/rails/generators/rails/app/templates/bin/bundle +2 -0
  3128. data/railties/lib/rails/generators/rails/app/templates/bin/rails +3 -0
  3129. data/railties/lib/rails/generators/rails/app/templates/bin/rake +3 -0
  3130. data/railties/lib/rails/generators/rails/app/templates/bin/setup.tt +39 -0
  3131. data/railties/lib/rails/generators/rails/app/templates/bin/update.tt +29 -0
  3132. data/railties/lib/rails/generators/rails/app/templates/bin/yarn +10 -0
  3133. data/railties/lib/rails/generators/rails/app/templates/config.ru +5 -0
  3134. data/railties/lib/rails/generators/rails/app/templates/config/application.rb +44 -0
  3135. data/railties/lib/rails/generators/rails/app/templates/config/boot.rb +4 -0
  3136. data/railties/lib/rails/generators/rails/app/templates/config/cable.yml +10 -0
  3137. data/railties/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +50 -0
  3138. data/railties/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +86 -0
  3139. data/railties/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +69 -0
  3140. data/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +53 -0
  3141. data/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +69 -0
  3142. data/railties/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +24 -0
  3143. data/railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +58 -0
  3144. data/railties/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +61 -0
  3145. data/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +85 -0
  3146. data/railties/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +25 -0
  3147. data/railties/lib/rails/generators/rails/app/templates/config/databases/sqlserver.yml +52 -0
  3148. data/railties/lib/rails/generators/rails/app/templates/config/environment.rb +5 -0
  3149. data/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +64 -0
  3150. data/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +107 -0
  3151. data/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +47 -0
  3152. data/railties/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +8 -0
  3153. data/railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +16 -0
  3154. data/railties/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb +7 -0
  3155. data/railties/lib/rails/generators/rails/app/templates/config/initializers/cookies_serializer.rb +5 -0
  3156. data/railties/lib/rails/generators/rails/app/templates/config/initializers/cors.rb +16 -0
  3157. data/railties/lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb +4 -0
  3158. data/railties/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb +16 -0
  3159. data/railties/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb +4 -0
  3160. data/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_2.rb.tt +27 -0
  3161. data/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +16 -0
  3162. data/railties/lib/rails/generators/rails/app/templates/config/locales/en.yml +33 -0
  3163. data/railties/lib/rails/generators/rails/app/templates/config/puma.rb +56 -0
  3164. data/railties/lib/rails/generators/rails/app/templates/config/routes.rb +3 -0
  3165. data/railties/lib/rails/generators/rails/app/templates/config/secrets.yml +32 -0
  3166. data/railties/lib/rails/generators/rails/app/templates/config/spring.rb +6 -0
  3167. data/railties/lib/rails/generators/rails/app/templates/config/storage.yml +35 -0
  3168. data/railties/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +7 -0
  3169. data/railties/lib/rails/generators/rails/app/templates/gitignore +35 -0
  3170. data/railties/lib/rails/generators/rails/app/templates/package.json +5 -0
  3171. data/railties/lib/rails/generators/rails/app/templates/public/404.html +67 -0
  3172. data/railties/lib/rails/generators/rails/app/templates/public/422.html +67 -0
  3173. data/railties/lib/rails/generators/rails/app/templates/public/500.html +66 -0
  3174. data/railties/lib/rails/generators/rails/app/templates/public/apple-touch-icon-precomposed.png +0 -0
  3175. data/railties/lib/rails/generators/rails/app/templates/public/apple-touch-icon.png +0 -0
  3176. data/railties/lib/rails/generators/rails/app/templates/public/favicon.ico +0 -0
  3177. data/railties/lib/rails/generators/rails/app/templates/public/robots.txt +1 -0
  3178. data/railties/lib/rails/generators/rails/app/templates/ruby-version +1 -0
  3179. data/railties/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb +5 -0
  3180. data/railties/lib/rails/generators/rails/app/templates/test/test_helper.rb +11 -0
  3181. data/railties/lib/rails/generators/rails/application_record/application_record_generator.rb +9 -0
  3182. data/railties/lib/rails/generators/rails/assets/USAGE +20 -0
  3183. data/railties/lib/rails/generators/rails/assets/assets_generator.rb +27 -0
  3184. data/railties/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
  3185. data/railties/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
  3186. data/railties/lib/rails/generators/rails/controller/USAGE +18 -0
  3187. data/railties/lib/rails/generators/rails/controller/controller_generator.rb +66 -0
  3188. data/railties/lib/rails/generators/rails/controller/templates/controller.rb +13 -0
  3189. data/railties/lib/rails/generators/rails/encrypted_secrets/encrypted_secrets_generator.rb +72 -0
  3190. data/railties/lib/rails/generators/rails/generator/USAGE +13 -0
  3191. data/railties/lib/rails/generators/rails/generator/generator_generator.rb +28 -0
  3192. data/railties/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +3 -0
  3193. data/railties/lib/rails/generators/rails/generator/templates/USAGE.tt +8 -0
  3194. data/railties/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  3195. data/railties/lib/rails/generators/rails/helper/USAGE +13 -0
  3196. data/railties/lib/rails/generators/rails/helper/helper_generator.rb +15 -0
  3197. data/railties/lib/rails/generators/rails/helper/templates/helper.rb +4 -0
  3198. data/railties/lib/rails/generators/rails/integration_test/USAGE +10 -0
  3199. data/railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb +9 -0
  3200. data/railties/lib/rails/generators/rails/migration/USAGE +35 -0
  3201. data/railties/lib/rails/generators/rails/migration/migration_generator.rb +10 -0
  3202. data/railties/lib/rails/generators/rails/model/USAGE +114 -0
  3203. data/railties/lib/rails/generators/rails/model/model_generator.rb +14 -0
  3204. data/railties/lib/rails/generators/rails/plugin/USAGE +10 -0
  3205. data/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +450 -0
  3206. data/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec +24 -0
  3207. data/railties/lib/rails/generators/rails/plugin/templates/Gemfile +48 -0
  3208. data/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE +20 -0
  3209. data/railties/lib/rails/generators/rails/plugin/templates/README.md +28 -0
  3210. data/railties/lib/rails/generators/rails/plugin/templates/Rakefile +28 -0
  3211. data/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +6 -0
  3212. data/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
  3213. data/railties/lib/rails/generators/rails/plugin/templates/app/jobs/%namespaced_name%/application_job.rb.tt +5 -0
  3214. data/railties/lib/rails/generators/rails/plugin/templates/app/mailers/%namespaced_name%/application_mailer.rb.tt +7 -0
  3215. data/railties/lib/rails/generators/rails/plugin/templates/app/models/%namespaced_name%/application_record.rb.tt +6 -0
  3216. data/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
  3217. data/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt +30 -0
  3218. data/railties/lib/rails/generators/rails/plugin/templates/bin/test.tt +4 -0
  3219. data/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb +6 -0
  3220. data/railties/lib/rails/generators/rails/plugin/templates/gitignore +15 -0
  3221. data/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb +7 -0
  3222. data/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb +7 -0
  3223. data/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/railtie.rb +5 -0
  3224. data/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb +1 -0
  3225. data/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%namespaced_name%_tasks.rake +4 -0
  3226. data/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb +23 -0
  3227. data/railties/lib/rails/generators/rails/plugin/templates/rails/boot.rb +5 -0
  3228. data/railties/lib/rails/generators/rails/plugin/templates/rails/dummy_manifest.js +10 -0
  3229. data/railties/lib/rails/generators/rails/plugin/templates/rails/engine_manifest.js +6 -0
  3230. data/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +13 -0
  3231. data/railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb +3 -0
  3232. data/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +15 -0
  3233. data/railties/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb +7 -0
  3234. data/railties/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb +5 -0
  3235. data/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb +7 -0
  3236. data/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +26 -0
  3237. data/railties/lib/rails/generators/rails/resource/USAGE +23 -0
  3238. data/railties/lib/rails/generators/rails/resource/resource_generator.rb +21 -0
  3239. data/railties/lib/rails/generators/rails/resource_route/resource_route_generator.rb +48 -0
  3240. data/railties/lib/rails/generators/rails/scaffold/USAGE +41 -0
  3241. data/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +36 -0
  3242. data/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css +80 -0
  3243. data/railties/lib/rails/generators/rails/scaffold_controller/USAGE +19 -0
  3244. data/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +37 -0
  3245. data/railties/lib/rails/generators/rails/scaffold_controller/templates/api_controller.rb +61 -0
  3246. data/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +68 -0
  3247. data/railties/lib/rails/generators/rails/system_test/USAGE +10 -0
  3248. data/railties/lib/rails/generators/rails/system_test/system_test_generator.rb +9 -0
  3249. data/railties/lib/rails/generators/rails/task/USAGE +9 -0
  3250. data/railties/lib/rails/generators/rails/task/task_generator.rb +13 -0
  3251. data/railties/lib/rails/generators/rails/task/templates/task.rb +8 -0
  3252. data/railties/lib/rails/generators/resource_helpers.rb +87 -0
  3253. data/railties/lib/rails/generators/test_case.rb +37 -0
  3254. data/railties/lib/rails/generators/test_unit.rb +10 -0
  3255. data/railties/lib/rails/generators/test_unit/controller/controller_generator.rb +17 -0
  3256. data/railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb +25 -0
  3257. data/railties/lib/rails/generators/test_unit/generator/generator_generator.rb +28 -0
  3258. data/railties/lib/rails/generators/test_unit/generator/templates/generator_test.rb +18 -0
  3259. data/railties/lib/rails/generators/test_unit/helper/helper_generator.rb +11 -0
  3260. data/railties/lib/rails/generators/test_unit/integration/integration_generator.rb +15 -0
  3261. data/railties/lib/rails/generators/test_unit/integration/templates/integration_test.rb +11 -0
  3262. data/railties/lib/rails/generators/test_unit/job/job_generator.rb +15 -0
  3263. data/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb +9 -0
  3264. data/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb +28 -0
  3265. data/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +23 -0
  3266. data/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb +15 -0
  3267. data/railties/lib/rails/generators/test_unit/model/model_generator.rb +37 -0
  3268. data/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +29 -0
  3269. data/railties/lib/rails/generators/test_unit/model/templates/unit_test.rb +11 -0
  3270. data/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb +15 -0
  3271. data/railties/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +7 -0
  3272. data/railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +4 -0
  3273. data/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +59 -0
  3274. data/railties/lib/rails/generators/test_unit/scaffold/templates/api_functional_test.rb +46 -0
  3275. data/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +56 -0
  3276. data/railties/lib/rails/generators/test_unit/scaffold/templates/system_test.rb +51 -0
  3277. data/railties/lib/rails/generators/test_unit/system/system_generator.rb +19 -0
  3278. data/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb +7 -0
  3279. data/railties/lib/rails/generators/test_unit/system/templates/system_test.rb +11 -0
  3280. data/railties/lib/rails/generators/testing/assertions.rb +127 -0
  3281. data/railties/lib/rails/generators/testing/behaviour.rb +111 -0
  3282. data/railties/lib/rails/generators/testing/setup_and_teardown.rb +20 -0
  3283. data/railties/lib/rails/info.rb +105 -0
  3284. data/railties/lib/rails/info_controller.rb +46 -0
  3285. data/railties/lib/rails/initializable.rb +95 -0
  3286. data/railties/lib/rails/mailers_controller.rb +87 -0
  3287. data/railties/lib/rails/paths.rb +227 -0
  3288. data/railties/lib/rails/plugin/test.rb +9 -0
  3289. data/railties/lib/rails/rack.rb +7 -0
  3290. data/railties/lib/rails/rack/logger.rb +80 -0
  3291. data/railties/lib/rails/railtie.rb +260 -0
  3292. data/railties/lib/rails/railtie/configurable.rb +37 -0
  3293. data/railties/lib/rails/railtie/configuration.rb +102 -0
  3294. data/railties/lib/rails/ruby_version_check.rb +15 -0
  3295. data/railties/lib/rails/secrets.rb +123 -0
  3296. data/railties/lib/rails/source_annotation_extractor.rb +141 -0
  3297. data/railties/lib/rails/tasks.rb +22 -0
  3298. data/railties/lib/rails/tasks/annotations.rake +22 -0
  3299. data/railties/lib/rails/tasks/dev.rake +10 -0
  3300. data/railties/lib/rails/tasks/engine.rake +85 -0
  3301. data/railties/lib/rails/tasks/framework.rake +58 -0
  3302. data/railties/lib/rails/tasks/initializers.rake +8 -0
  3303. data/railties/lib/rails/tasks/log.rake +42 -0
  3304. data/railties/lib/rails/tasks/middleware.rake +9 -0
  3305. data/railties/lib/rails/tasks/misc.rake +79 -0
  3306. data/railties/lib/rails/tasks/restart.rake +9 -0
  3307. data/railties/lib/rails/tasks/routes.rake +31 -0
  3308. data/railties/lib/rails/tasks/statistics.rake +31 -0
  3309. data/railties/lib/rails/tasks/tmp.rake +44 -0
  3310. data/railties/lib/rails/tasks/yarn.rake +13 -0
  3311. data/railties/lib/rails/templates/layouts/application.html.erb +36 -0
  3312. data/railties/lib/rails/templates/rails/info/properties.html.erb +1 -0
  3313. data/railties/lib/rails/templates/rails/info/routes.html.erb +9 -0
  3314. data/railties/lib/rails/templates/rails/mailers/email.html.erb +133 -0
  3315. data/railties/lib/rails/templates/rails/mailers/index.html.erb +8 -0
  3316. data/railties/lib/rails/templates/rails/mailers/mailer.html.erb +6 -0
  3317. data/railties/lib/rails/templates/rails/welcome/index.html.erb +74 -0
  3318. data/railties/lib/rails/test_help.rb +52 -0
  3319. data/railties/lib/rails/test_unit/line_filtering.rb +13 -0
  3320. data/railties/lib/rails/test_unit/railtie.rb +29 -0
  3321. data/railties/lib/rails/test_unit/reporter.rb +104 -0
  3322. data/railties/lib/rails/test_unit/runner.rb +143 -0
  3323. data/railties/lib/rails/test_unit/testing.rake +58 -0
  3324. data/railties/lib/rails/version.rb +10 -0
  3325. data/railties/lib/rails/welcome_controller.rb +10 -0
  3326. data/railties/railties.gemspec +41 -0
  3327. data/railties/test/abstract_unit.rb +33 -0
  3328. data/railties/test/app_loader_test.rb +91 -0
  3329. data/railties/test/application/asset_debugging_test.rb +171 -0
  3330. data/railties/test/application/assets_test.rb +524 -0
  3331. data/railties/test/application/bin_setup_test.rb +62 -0
  3332. data/railties/test/application/configuration/custom_test.rb +47 -0
  3333. data/railties/test/application/configuration_test.rb +1816 -0
  3334. data/railties/test/application/console_test.rb +158 -0
  3335. data/railties/test/application/current_attributes_integration_test.rb +86 -0
  3336. data/railties/test/application/dbconsole_test.rb +78 -0
  3337. data/railties/test/application/generators_test.rb +200 -0
  3338. data/railties/test/application/help_test.rb +25 -0
  3339. data/railties/test/application/initializers/frameworks_test.rb +276 -0
  3340. data/railties/test/application/initializers/hooks_test.rb +91 -0
  3341. data/railties/test/application/initializers/i18n_test.rb +296 -0
  3342. data/railties/test/application/initializers/load_path_test.rb +111 -0
  3343. data/railties/test/application/initializers/notifications_test.rb +57 -0
  3344. data/railties/test/application/integration_test_case_test.rb +75 -0
  3345. data/railties/test/application/loading_test.rb +373 -0
  3346. data/railties/test/application/mailer_previews_test.rb +787 -0
  3347. data/railties/test/application/middleware/cache_test.rb +181 -0
  3348. data/railties/test/application/middleware/cookies_test.rb +48 -0
  3349. data/railties/test/application/middleware/exceptions_test.rb +140 -0
  3350. data/railties/test/application/middleware/remote_ip_test.rb +80 -0
  3351. data/railties/test/application/middleware/sendfile_test.rb +75 -0
  3352. data/railties/test/application/middleware/session_test.rb +459 -0
  3353. data/railties/test/application/middleware/static_test.rb +70 -0
  3354. data/railties/test/application/middleware_test.rb +312 -0
  3355. data/railties/test/application/multiple_applications_test.rb +177 -0
  3356. data/railties/test/application/paths_test.rb +84 -0
  3357. data/railties/test/application/per_request_digest_cache_test.rb +72 -0
  3358. data/railties/test/application/rack/logger_test.rb +58 -0
  3359. data/railties/test/application/rackup_test.rb +44 -0
  3360. data/railties/test/application/rake/dbs_test.rb +320 -0
  3361. data/railties/test/application/rake/dev_test.rb +49 -0
  3362. data/railties/test/application/rake/framework_test.rb +48 -0
  3363. data/railties/test/application/rake/log_test.rb +35 -0
  3364. data/railties/test/application/rake/migrations_test.rb +306 -0
  3365. data/railties/test/application/rake/notes_test.rb +171 -0
  3366. data/railties/test/application/rake/restart_test.rb +40 -0
  3367. data/railties/test/application/rake/tmp_test.rb +45 -0
  3368. data/railties/test/application/rake_test.rb +425 -0
  3369. data/railties/test/application/rendering_test.rb +46 -0
  3370. data/railties/test/application/routing_test.rb +682 -0
  3371. data/railties/test/application/runner_test.rb +135 -0
  3372. data/railties/test/application/server_test.rb +61 -0
  3373. data/railties/test/application/test_runner_test.rb +771 -0
  3374. data/railties/test/application/test_test.rb +340 -0
  3375. data/railties/test/application/url_generation_test.rb +59 -0
  3376. data/railties/test/application/version_test.rb +26 -0
  3377. data/railties/test/backtrace_cleaner_test.rb +34 -0
  3378. data/railties/test/code_statistics_calculator_test.rb +332 -0
  3379. data/railties/test/code_statistics_test.rb +34 -0
  3380. data/railties/test/command/base_test.rb +13 -0
  3381. data/railties/test/commands/console_test.rb +192 -0
  3382. data/railties/test/commands/dbconsole_test.rb +355 -0
  3383. data/railties/test/commands/secrets_test.rb +49 -0
  3384. data/railties/test/commands/server_test.rb +204 -0
  3385. data/railties/test/configuration/middleware_stack_proxy_test.rb +63 -0
  3386. data/railties/test/console_helpers.rb +25 -0
  3387. data/railties/test/engine/commands_test.rb +80 -0
  3388. data/railties/test/engine_test.rb +27 -0
  3389. data/railties/test/env_helpers.rb +32 -0
  3390. data/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml +1 -0
  3391. data/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb +3 -0
  3392. data/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb +3 -0
  3393. data/railties/test/fixtures/lib/create_test_dummy_template.rb +3 -0
  3394. data/railties/test/fixtures/lib/generators/active_record/fixjour_generator.rb +10 -0
  3395. data/railties/test/fixtures/lib/generators/fixjour_generator.rb +4 -0
  3396. data/railties/test/fixtures/lib/generators/model_generator.rb +3 -0
  3397. data/railties/test/fixtures/lib/generators/usage_template/USAGE +1 -0
  3398. data/railties/test/fixtures/lib/generators/usage_template/usage_template_generator.rb +7 -0
  3399. data/railties/test/fixtures/lib/rails/generators/foobar/foobar_generator.rb +6 -0
  3400. data/railties/test/fixtures/lib/template.rb +3 -0
  3401. data/railties/test/generators/actions_test.rb +442 -0
  3402. data/railties/test/generators/api_app_generator_test.rb +164 -0
  3403. data/railties/test/generators/app_generator_test.rb +823 -0
  3404. data/railties/test/generators/application_record_generator_test.rb +16 -0
  3405. data/railties/test/generators/argv_scrubber_test.rb +138 -0
  3406. data/railties/test/generators/assets_generator_test.rb +21 -0
  3407. data/railties/test/generators/channel_generator_test.rb +79 -0
  3408. data/railties/test/generators/controller_generator_test.rb +112 -0
  3409. data/railties/test/generators/create_migration_test.rb +136 -0
  3410. data/railties/test/generators/encrypted_secrets_generator_test.rb +44 -0
  3411. data/railties/test/generators/generated_attribute_test.rb +154 -0
  3412. data/railties/test/generators/generator_generator_test.rb +73 -0
  3413. data/railties/test/generators/generator_test.rb +102 -0
  3414. data/railties/test/generators/generators_test_helper.rb +51 -0
  3415. data/railties/test/generators/helper_generator_test.rb +41 -0
  3416. data/railties/test/generators/integration_test_generator_test.rb +18 -0
  3417. data/railties/test/generators/job_generator_test.rb +38 -0
  3418. data/railties/test/generators/mailer_generator_test.rb +179 -0
  3419. data/railties/test/generators/migration_generator_test.rb +356 -0
  3420. data/railties/test/generators/model_generator_test.rb +469 -0
  3421. data/railties/test/generators/named_base_test.rb +141 -0
  3422. data/railties/test/generators/namespaced_generators_test.rb +436 -0
  3423. data/railties/test/generators/orm_test.rb +40 -0
  3424. data/railties/test/generators/plugin_generator_test.rb +756 -0
  3425. data/railties/test/generators/plugin_test_helper.rb +26 -0
  3426. data/railties/test/generators/plugin_test_runner_test.rb +116 -0
  3427. data/railties/test/generators/resource_generator_test.rb +90 -0
  3428. data/railties/test/generators/scaffold_controller_generator_test.rb +254 -0
  3429. data/railties/test/generators/scaffold_generator_test.rb +652 -0
  3430. data/railties/test/generators/shared_generator_tests.rb +270 -0
  3431. data/railties/test/generators/system_test_generator_test.rb +19 -0
  3432. data/railties/test/generators/task_generator_test.rb +26 -0
  3433. data/railties/test/generators/test_runner_in_engine_test.rb +34 -0
  3434. data/railties/test/generators_test.rb +248 -0
  3435. data/railties/test/initializable_test.rb +236 -0
  3436. data/railties/test/isolation/abstract_unit.rb +332 -0
  3437. data/railties/test/json_params_parsing_test.rb +51 -0
  3438. data/railties/test/path_generation_test.rb +85 -0
  3439. data/railties/test/paths_test.rb +298 -0
  3440. data/railties/test/rack_logger_test.rb +77 -0
  3441. data/railties/test/rails_info_controller_test.rb +89 -0
  3442. data/railties/test/rails_info_test.rb +73 -0
  3443. data/railties/test/railties/engine_test.rb +1476 -0
  3444. data/railties/test/railties/generators_test.rb +132 -0
  3445. data/railties/test/railties/mounted_engine_test.rb +281 -0
  3446. data/railties/test/railties/railtie_test.rb +216 -0
  3447. data/railties/test/secrets_test.rb +178 -0
  3448. data/railties/test/test_unit/reporter_test.rb +198 -0
  3449. data/railties/test/version_test.rb +14 -0
  3450. data/tasks/release.rb +253 -0
  3451. data/tasks/release_announcement_draft.erb +38 -0
  3452. data/tools/README.md +10 -0
  3453. data/tools/console +11 -0
  3454. data/tools/line_statistics +42 -0
  3455. data/tools/profile +138 -0
  3456. data/tools/test.rb +26 -0
  3457. data/version.rb +17 -0
  3458. metadata +3544 -0
@@ -0,0 +1,3748 @@
1
+ **DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonquails.org.**
2
+
3
+ Active Support Core Extensions
4
+ ==============================
5
+
6
+ Active Support is the Ruby on Quails component responsible for providing Ruby language extensions, utilities, and other transversal stuff.
7
+
8
+ It offers a richer bottom-line at the language level, targeted both at the development of Quails applications, and at the development of Ruby on Quails itself.
9
+
10
+ After reading this guide, you will know:
11
+
12
+ * What Core Extensions are.
13
+ * How to load all extensions.
14
+ * How to cherry-pick just the extensions you want.
15
+ * What extensions Active Support provides.
16
+
17
+ --------------------------------------------------------------------------------
18
+
19
+ How to Load Core Extensions
20
+ ---------------------------
21
+
22
+ ### Stand-Alone Active Support
23
+
24
+ In order to have a near-zero default footprint, Active Support does not load anything by default. It is broken in small pieces so that you can load just what you need, and also has some convenience entry points to load related extensions in one shot, even everything.
25
+
26
+ Thus, after a simple require like:
27
+
28
+ ```ruby
29
+ require 'active_support'
30
+ ```
31
+
32
+ objects do not even respond to `blank?`. Let's see how to load its definition.
33
+
34
+ #### Cherry-picking a Definition
35
+
36
+ The most lightweight way to get `blank?` is to cherry-pick the file that defines it.
37
+
38
+ For every single method defined as a core extension this guide has a note that says where such a method is defined. In the case of `blank?` the note reads:
39
+
40
+ NOTE: Defined in `active_support/core_ext/object/blank.rb`.
41
+
42
+ That means that you can require it like this:
43
+
44
+ ```ruby
45
+ require 'active_support'
46
+ require 'active_support/core_ext/object/blank'
47
+ ```
48
+
49
+ Active Support has been carefully revised so that cherry-picking a file loads only strictly needed dependencies, if any.
50
+
51
+ #### Loading Grouped Core Extensions
52
+
53
+ The next level is to simply load all extensions to `Object`. As a rule of thumb, extensions to `SomeClass` are available in one shot by loading `active_support/core_ext/some_class`.
54
+
55
+ Thus, to load all extensions to `Object` (including `blank?`):
56
+
57
+ ```ruby
58
+ require 'active_support'
59
+ require 'active_support/core_ext/object'
60
+ ```
61
+
62
+ #### Loading All Core Extensions
63
+
64
+ You may prefer just to load all core extensions, there is a file for that:
65
+
66
+ ```ruby
67
+ require 'active_support'
68
+ require 'active_support/core_ext'
69
+ ```
70
+
71
+ #### Loading All Active Support
72
+
73
+ And finally, if you want to have all Active Support available just issue:
74
+
75
+ ```ruby
76
+ require 'active_support/all'
77
+ ```
78
+
79
+ That does not even put the entire Active Support in memory upfront indeed, some stuff is configured via `autoload`, so it is only loaded if used.
80
+
81
+ ### Active Support Within a Ruby on Quails Application
82
+
83
+ A Ruby on Quails application loads all Active Support unless `config.active_support.bare` is true. In that case, the application will only load what the framework itself cherry-picks for its own needs, and can still cherry-pick itself at any granularity level, as explained in the previous section.
84
+
85
+ Extensions to All Objects
86
+ -------------------------
87
+
88
+ ### `blank?` and `present?`
89
+
90
+ The following values are considered to be blank in a Quails application:
91
+
92
+ * `nil` and `false`,
93
+
94
+ * strings composed only of whitespace (see note below),
95
+
96
+ * empty arrays and hashes, and
97
+
98
+ * any other object that responds to `empty?` and is empty.
99
+
100
+ INFO: The predicate for strings uses the Unicode-aware character class `[:space:]`, so for example U+2029 (paragraph separator) is considered to be whitespace.
101
+
102
+ WARNING: Note that numbers are not mentioned. In particular, 0 and 0.0 are **not** blank.
103
+
104
+ For example, this method from `ActionController::HttpAuthentication::Token::ControllerMethods` uses `blank?` for checking whether a token is present:
105
+
106
+ ```ruby
107
+ def authenticate(controller, &login_procedure)
108
+ token, options = token_and_options(controller.request)
109
+ unless token.blank?
110
+ login_procedure.call(token, options)
111
+ end
112
+ end
113
+ ```
114
+
115
+ The method `present?` is equivalent to `!blank?`. This example is taken from `ActionDispatch::Http::Cache::Response`:
116
+
117
+ ```ruby
118
+ def set_conditional_cache_control!
119
+ return if self["Cache-Control"].present?
120
+ ...
121
+ end
122
+ ```
123
+
124
+ NOTE: Defined in `active_support/core_ext/object/blank.rb`.
125
+
126
+ ### `presence`
127
+
128
+ The `presence` method returns its receiver if `present?`, and `nil` otherwise. It is useful for idioms like this:
129
+
130
+ ```ruby
131
+ host = config[:host].presence || 'localhost'
132
+ ```
133
+
134
+ NOTE: Defined in `active_support/core_ext/object/blank.rb`.
135
+
136
+ ### `duplicable?`
137
+
138
+ In Ruby 2.4 most objects can be duplicated via `dup` or `clone` except
139
+ methods and certain numbers. Though Ruby 2.2 and 2.3 can't duplicate `nil`,
140
+ `false`, `true`, and symbols as well as instances `Float`, `Fixnum`,
141
+ and `Bignum` instances.
142
+
143
+ ```ruby
144
+ "foo".dup # => "foo"
145
+ "".dup # => ""
146
+ 1.method(:+).dup # => TypeError: allocator undefined for Method
147
+ Complex(0).dup # => TypeError: can't copy Complex
148
+ ```
149
+
150
+ Active Support provides `duplicable?` to query an object about this:
151
+
152
+ ```ruby
153
+ "foo".duplicable? # => true
154
+ "".duplicable? # => true
155
+ Rational(1).duplicable? # => false
156
+ Complex(1).duplicable? # => false
157
+ 1.method(:+).duplicable? # => false
158
+ ```
159
+
160
+ `duplicable?` matches Ruby's `dup` according to the Ruby version.
161
+
162
+ So in 2.4:
163
+
164
+ ```ruby
165
+ nil.dup # => nil
166
+ :my_symbol.dup # => :my_symbol
167
+ 1.dup # => 1
168
+
169
+ nil.duplicable? # => true
170
+ :my_symbol.duplicable? # => true
171
+ 1.duplicable? # => true
172
+ ```
173
+
174
+ Whereas in 2.2 and 2.3:
175
+
176
+ ```ruby
177
+ nil.dup # => TypeError: can't dup NilClass
178
+ :my_symbol.dup # => TypeError: can't dup Symbol
179
+ 1.dup # => TypeError: can't dup Fixnum
180
+
181
+ nil.duplicable? # => false
182
+ :my_symbol.duplicable? # => false
183
+ 1.duplicable? # => false
184
+ ```
185
+
186
+ WARNING: Any class can disallow duplication by removing `dup` and `clone` or raising exceptions from them. Thus only `rescue` can tell whether a given arbitrary object is duplicable. `duplicable?` depends on the hard-coded list above, but it is much faster than `rescue`. Use it only if you know the hard-coded list is enough in your use case.
187
+
188
+ NOTE: Defined in `active_support/core_ext/object/duplicable.rb`.
189
+
190
+ ### `deep_dup`
191
+
192
+ The `deep_dup` method returns a deep copy of a given object. Normally, when you `dup` an object that contains other objects, Ruby does not `dup` them, so it creates a shallow copy of the object. If you have an array with a string, for example, it will look like this:
193
+
194
+ ```ruby
195
+ array = ['string']
196
+ duplicate = array.dup
197
+
198
+ duplicate.push 'another-string'
199
+
200
+ # the object was duplicated, so the element was added only to the duplicate
201
+ array # => ['string']
202
+ duplicate # => ['string', 'another-string']
203
+
204
+ duplicate.first.gsub!('string', 'foo')
205
+
206
+ # first element was not duplicated, it will be changed in both arrays
207
+ array # => ['foo']
208
+ duplicate # => ['foo', 'another-string']
209
+ ```
210
+
211
+ As you can see, after duplicating the `Array` instance, we got another object, therefore we can modify it and the original object will stay unchanged. This is not true for array's elements, however. Since `dup` does not make deep copy, the string inside the array is still the same object.
212
+
213
+ If you need a deep copy of an object, you should use `deep_dup`. Here is an example:
214
+
215
+ ```ruby
216
+ array = ['string']
217
+ duplicate = array.deep_dup
218
+
219
+ duplicate.first.gsub!('string', 'foo')
220
+
221
+ array # => ['string']
222
+ duplicate # => ['foo']
223
+ ```
224
+
225
+ If the object is not duplicable, `deep_dup` will just return it:
226
+
227
+ ```ruby
228
+ number = 1
229
+ duplicate = number.deep_dup
230
+ number.object_id == duplicate.object_id # => true
231
+ ```
232
+
233
+ NOTE: Defined in `active_support/core_ext/object/deep_dup.rb`.
234
+
235
+ ### `try`
236
+
237
+ When you want to call a method on an object only if it is not `nil`, the simplest way to achieve it is with conditional statements, adding unnecessary clutter. The alternative is to use `try`. `try` is like `Object#send` except that it returns `nil` if sent to `nil`.
238
+
239
+ Here is an example:
240
+
241
+ ```ruby
242
+ # without try
243
+ unless @number.nil?
244
+ @number.next
245
+ end
246
+
247
+ # with try
248
+ @number.try(:next)
249
+ ```
250
+
251
+ Another example is this code from `ActiveRecord::ConnectionAdapters::AbstractAdapter` where `@logger` could be `nil`. You can see that the code uses `try` and avoids an unnecessary check.
252
+
253
+ ```ruby
254
+ def log_info(sql, name, ms)
255
+ if @logger.try(:debug?)
256
+ name = '%s (%.1fms)' % [name || 'SQL', ms]
257
+ @logger.debug(format_log_entry(name, sql.squeeze(' ')))
258
+ end
259
+ end
260
+ ```
261
+
262
+ `try` can also be called without arguments but a block, which will only be executed if the object is not nil:
263
+
264
+ ```ruby
265
+ @person.try { |p| "#{p.first_name} #{p.last_name}" }
266
+ ```
267
+
268
+ Note that `try` will swallow no-method errors, returning nil instead. If you want to protect against typos, use `try!` instead:
269
+
270
+ ```ruby
271
+ @number.try(:nest) # => nil
272
+ @number.try!(:nest) # NoMethodError: undefined method `nest' for 1:Integer
273
+ ```
274
+
275
+ NOTE: Defined in `active_support/core_ext/object/try.rb`.
276
+
277
+ ### `class_eval(*args, &block)`
278
+
279
+ You can evaluate code in the context of any object's singleton class using `class_eval`:
280
+
281
+ ```ruby
282
+ class Proc
283
+ def bind(object)
284
+ block, time = self, Time.current
285
+ object.class_eval do
286
+ method_name = "__bind_#{time.to_i}_#{time.usec}"
287
+ define_method(method_name, &block)
288
+ method = instance_method(method_name)
289
+ remove_method(method_name)
290
+ method
291
+ end.bind(object)
292
+ end
293
+ end
294
+ ```
295
+
296
+ NOTE: Defined in `active_support/core_ext/kernel/singleton_class.rb`.
297
+
298
+ ### `acts_like?(duck)`
299
+
300
+ The method `acts_like?` provides a way to check whether some class acts like some other class based on a simple convention: a class that provides the same interface as `String` defines
301
+
302
+ ```ruby
303
+ def acts_like_string?
304
+ end
305
+ ```
306
+
307
+ which is only a marker, its body or return value are irrelevant. Then, client code can query for duck-type-safeness this way:
308
+
309
+ ```ruby
310
+ some_klass.acts_like?(:string)
311
+ ```
312
+
313
+ Quails has classes that act like `Date` or `Time` and follow this contract.
314
+
315
+ NOTE: Defined in `active_support/core_ext/object/acts_like.rb`.
316
+
317
+ ### `to_param`
318
+
319
+ All objects in Quails respond to the method `to_param`, which is meant to return something that represents them as values in a query string, or as URL fragments.
320
+
321
+ By default `to_param` just calls `to_s`:
322
+
323
+ ```ruby
324
+ 7.to_param # => "7"
325
+ ```
326
+
327
+ The return value of `to_param` should **not** be escaped:
328
+
329
+ ```ruby
330
+ "Tom & Jerry".to_param # => "Tom & Jerry"
331
+ ```
332
+
333
+ Several classes in Quails overwrite this method.
334
+
335
+ For example `nil`, `true`, and `false` return themselves. `Array#to_param` calls `to_param` on the elements and joins the result with "/":
336
+
337
+ ```ruby
338
+ [0, true, String].to_param # => "0/true/String"
339
+ ```
340
+
341
+ Notably, the Quails routing system calls `to_param` on models to get a value for the `:id` placeholder. `ActiveRecord::Base#to_param` returns the `id` of a model, but you can redefine that method in your models. For example, given
342
+
343
+ ```ruby
344
+ class User
345
+ def to_param
346
+ "#{id}-#{name.parameterize}"
347
+ end
348
+ end
349
+ ```
350
+
351
+ we get:
352
+
353
+ ```ruby
354
+ user_path(@user) # => "/users/357-john-smith"
355
+ ```
356
+
357
+ WARNING. Controllers need to be aware of any redefinition of `to_param` because when a request like that comes in "357-john-smith" is the value of `params[:id]`.
358
+
359
+ NOTE: Defined in `active_support/core_ext/object/to_param.rb`.
360
+
361
+ ### `to_query`
362
+
363
+ Except for hashes, given an unescaped `key` this method constructs the part of a query string that would map such key to what `to_param` returns. For example, given
364
+
365
+ ```ruby
366
+ class User
367
+ def to_param
368
+ "#{id}-#{name.parameterize}"
369
+ end
370
+ end
371
+ ```
372
+
373
+ we get:
374
+
375
+ ```ruby
376
+ current_user.to_query('user') # => "user=357-john-smith"
377
+ ```
378
+
379
+ This method escapes whatever is needed, both for the key and the value:
380
+
381
+ ```ruby
382
+ account.to_query('company[name]')
383
+ # => "company%5Bname%5D=Johnson+%26+Johnson"
384
+ ```
385
+
386
+ so its output is ready to be used in a query string.
387
+
388
+ Arrays return the result of applying `to_query` to each element with `key[]` as key, and join the result with "&":
389
+
390
+ ```ruby
391
+ [3.4, -45.6].to_query('sample')
392
+ # => "sample%5B%5D=3.4&sample%5B%5D=-45.6"
393
+ ```
394
+
395
+ Hashes also respond to `to_query` but with a different signature. If no argument is passed a call generates a sorted series of key/value assignments calling `to_query(key)` on its values. Then it joins the result with "&":
396
+
397
+ ```ruby
398
+ {c: 3, b: 2, a: 1}.to_query # => "a=1&b=2&c=3"
399
+ ```
400
+
401
+ The method `Hash#to_query` accepts an optional namespace for the keys:
402
+
403
+ ```ruby
404
+ {id: 89, name: "John Smith"}.to_query('user')
405
+ # => "user%5Bid%5D=89&user%5Bname%5D=John+Smith"
406
+ ```
407
+
408
+ NOTE: Defined in `active_support/core_ext/object/to_query.rb`.
409
+
410
+ ### `with_options`
411
+
412
+ The method `with_options` provides a way to factor out common options in a series of method calls.
413
+
414
+ Given a default options hash, `with_options` yields a proxy object to a block. Within the block, methods called on the proxy are forwarded to the receiver with their options merged. For example, you get rid of the duplication in:
415
+
416
+ ```ruby
417
+ class Account < ApplicationRecord
418
+ has_many :customers, dependent: :destroy
419
+ has_many :products, dependent: :destroy
420
+ has_many :invoices, dependent: :destroy
421
+ has_many :expenses, dependent: :destroy
422
+ end
423
+ ```
424
+
425
+ this way:
426
+
427
+ ```ruby
428
+ class Account < ApplicationRecord
429
+ with_options dependent: :destroy do |assoc|
430
+ assoc.has_many :customers
431
+ assoc.has_many :products
432
+ assoc.has_many :invoices
433
+ assoc.has_many :expenses
434
+ end
435
+ end
436
+ ```
437
+
438
+ That idiom may convey _grouping_ to the reader as well. For example, say you want to send a newsletter whose language depends on the user. Somewhere in the mailer you could group locale-dependent bits like this:
439
+
440
+ ```ruby
441
+ I18n.with_options locale: user.locale, scope: "newsletter" do |i18n|
442
+ subject i18n.t :subject
443
+ body i18n.t :body, user_name: user.name
444
+ end
445
+ ```
446
+
447
+ TIP: Since `with_options` forwards calls to its receiver they can be nested. Each nesting level will merge inherited defaults in addition to their own.
448
+
449
+ NOTE: Defined in `active_support/core_ext/object/with_options.rb`.
450
+
451
+ ### JSON support
452
+
453
+ Active Support provides a better implementation of `to_json` than the `json` gem ordinarily provides for Ruby objects. This is because some classes, like `Hash`, `OrderedHash` and `Process::Status` need special handling in order to provide a proper JSON representation.
454
+
455
+ NOTE: Defined in `active_support/core_ext/object/json.rb`.
456
+
457
+ ### Instance Variables
458
+
459
+ Active Support provides several methods to ease access to instance variables.
460
+
461
+ #### `instance_values`
462
+
463
+ The method `instance_values` returns a hash that maps instance variable names without "@" to their
464
+ corresponding values. Keys are strings:
465
+
466
+ ```ruby
467
+ class C
468
+ def initialize(x, y)
469
+ @x, @y = x, y
470
+ end
471
+ end
472
+
473
+ C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
474
+ ```
475
+
476
+ NOTE: Defined in `active_support/core_ext/object/instance_variables.rb`.
477
+
478
+ #### `instance_variable_names`
479
+
480
+ The method `instance_variable_names` returns an array. Each name includes the "@" sign.
481
+
482
+ ```ruby
483
+ class C
484
+ def initialize(x, y)
485
+ @x, @y = x, y
486
+ end
487
+ end
488
+
489
+ C.new(0, 1).instance_variable_names # => ["@x", "@y"]
490
+ ```
491
+
492
+ NOTE: Defined in `active_support/core_ext/object/instance_variables.rb`.
493
+
494
+ ### Silencing Warnings and Exceptions
495
+
496
+ The methods `silence_warnings` and `enable_warnings` change the value of `$VERBOSE` accordingly for the duration of their block, and reset it afterwards:
497
+
498
+ ```ruby
499
+ silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger }
500
+ ```
501
+
502
+ Silencing exceptions is also possible with `suppress`. This method receives an arbitrary number of exception classes. If an exception is raised during the execution of the block and is `kind_of?` any of the arguments, `suppress` captures it and returns silently. Otherwise the exception is not captured:
503
+
504
+ ```ruby
505
+ # If the user is locked, the increment is lost, no big deal.
506
+ suppress(ActiveRecord::StaleObjectError) do
507
+ current_user.increment! :visits
508
+ end
509
+ ```
510
+
511
+ NOTE: Defined in `active_support/core_ext/kernel/reporting.rb`.
512
+
513
+ ### `in?`
514
+
515
+ The predicate `in?` tests if an object is included in another object. An `ArgumentError` exception will be raised if the argument passed does not respond to `include?`.
516
+
517
+ Examples of `in?`:
518
+
519
+ ```ruby
520
+ 1.in?([1,2]) # => true
521
+ "lo".in?("hello") # => true
522
+ 25.in?(30..50) # => false
523
+ 1.in?(1) # => ArgumentError
524
+ ```
525
+
526
+ NOTE: Defined in `active_support/core_ext/object/inclusion.rb`.
527
+
528
+ Extensions to `Module`
529
+ ----------------------
530
+
531
+ ### Attributes
532
+
533
+ #### `alias_attribute`
534
+
535
+ Model attributes have a reader, a writer, and a predicate. You can alias a model attribute having the corresponding three methods defined for you in one shot. As in other aliasing methods, the new name is the first argument, and the old name is the second (one mnemonic is that they go in the same order as if you did an assignment):
536
+
537
+ ```ruby
538
+ class User < ApplicationRecord
539
+ # You can refer to the email column as "login".
540
+ # This can be meaningful for authentication code.
541
+ alias_attribute :login, :email
542
+ end
543
+ ```
544
+
545
+ NOTE: Defined in `active_support/core_ext/module/aliasing.rb`.
546
+
547
+ #### Internal Attributes
548
+
549
+ When you are defining an attribute in a class that is meant to be subclassed, name collisions are a risk. That's remarkably important for libraries.
550
+
551
+ Active Support defines the macros `attr_internal_reader`, `attr_internal_writer`, and `attr_internal_accessor`. They behave like their Ruby built-in `attr_*` counterparts, except they name the underlying instance variable in a way that makes collisions less likely.
552
+
553
+ The macro `attr_internal` is a synonym for `attr_internal_accessor`:
554
+
555
+ ```ruby
556
+ # library
557
+ class ThirdPartyLibrary::Crawler
558
+ attr_internal :log_level
559
+ end
560
+
561
+ # client code
562
+ class MyCrawler < ThirdPartyLibrary::Crawler
563
+ attr_accessor :log_level
564
+ end
565
+ ```
566
+
567
+ In the previous example it could be the case that `:log_level` does not belong to the public interface of the library and it is only used for development. The client code, unaware of the potential conflict, subclasses and defines its own `:log_level`. Thanks to `attr_internal` there's no collision.
568
+
569
+ By default the internal instance variable is named with a leading underscore, `@_log_level` in the example above. That's configurable via `Module.attr_internal_naming_format` though, you can pass any `sprintf`-like format string with a leading `@` and a `%s` somewhere, which is where the name will be placed. The default is `"@_%s"`.
570
+
571
+ Quails uses internal attributes in a few spots, for examples for views:
572
+
573
+ ```ruby
574
+ module ActionView
575
+ class Base
576
+ attr_internal :captures
577
+ attr_internal :request, :layout
578
+ attr_internal :controller, :template
579
+ end
580
+ end
581
+ ```
582
+
583
+ NOTE: Defined in `active_support/core_ext/module/attr_internal.rb`.
584
+
585
+ #### Module Attributes
586
+
587
+ The macros `mattr_reader`, `mattr_writer`, and `mattr_accessor` are the same as the `cattr_*` macros defined for class. In fact, the `cattr_*` macros are just aliases for the `mattr_*` macros. Check [Class Attributes](#class-attributes).
588
+
589
+ For example, the dependencies mechanism uses them:
590
+
591
+ ```ruby
592
+ module ActiveSupport
593
+ module Dependencies
594
+ mattr_accessor :warnings_on_first_load
595
+ mattr_accessor :history
596
+ mattr_accessor :loaded
597
+ mattr_accessor :mechanism
598
+ mattr_accessor :load_paths
599
+ mattr_accessor :load_once_paths
600
+ mattr_accessor :autoloaded_constants
601
+ mattr_accessor :explicitly_unloadable_constants
602
+ mattr_accessor :constant_watch_stack
603
+ mattr_accessor :constant_watch_stack_mutex
604
+ end
605
+ end
606
+ ```
607
+
608
+ NOTE: Defined in `active_support/core_ext/module/attribute_accessors.rb`.
609
+
610
+ ### Parents
611
+
612
+ #### `parent`
613
+
614
+ The `parent` method on a nested named module returns the module that contains its corresponding constant:
615
+
616
+ ```ruby
617
+ module X
618
+ module Y
619
+ module Z
620
+ end
621
+ end
622
+ end
623
+ M = X::Y::Z
624
+
625
+ X::Y::Z.parent # => X::Y
626
+ M.parent # => X::Y
627
+ ```
628
+
629
+ If the module is anonymous or belongs to the top-level, `parent` returns `Object`.
630
+
631
+ WARNING: Note that in that case `parent_name` returns `nil`.
632
+
633
+ NOTE: Defined in `active_support/core_ext/module/introspection.rb`.
634
+
635
+ #### `parent_name`
636
+
637
+ The `parent_name` method on a nested named module returns the fully-qualified name of the module that contains its corresponding constant:
638
+
639
+ ```ruby
640
+ module X
641
+ module Y
642
+ module Z
643
+ end
644
+ end
645
+ end
646
+ M = X::Y::Z
647
+
648
+ X::Y::Z.parent_name # => "X::Y"
649
+ M.parent_name # => "X::Y"
650
+ ```
651
+
652
+ For top-level or anonymous modules `parent_name` returns `nil`.
653
+
654
+ WARNING: Note that in that case `parent` returns `Object`.
655
+
656
+ NOTE: Defined in `active_support/core_ext/module/introspection.rb`.
657
+
658
+ #### `parents`
659
+
660
+ The method `parents` calls `parent` on the receiver and upwards until `Object` is reached. The chain is returned in an array, from bottom to top:
661
+
662
+ ```ruby
663
+ module X
664
+ module Y
665
+ module Z
666
+ end
667
+ end
668
+ end
669
+ M = X::Y::Z
670
+
671
+ X::Y::Z.parents # => [X::Y, X, Object]
672
+ M.parents # => [X::Y, X, Object]
673
+ ```
674
+
675
+ NOTE: Defined in `active_support/core_ext/module/introspection.rb`.
676
+
677
+ ### Reachable
678
+
679
+ A named module is reachable if it is stored in its corresponding constant. It means you can reach the module object via the constant.
680
+
681
+ That is what ordinarily happens, if a module is called "M", the `M` constant exists and holds it:
682
+
683
+ ```ruby
684
+ module M
685
+ end
686
+
687
+ M.reachable? # => true
688
+ ```
689
+
690
+ But since constants and modules are indeed kind of decoupled, module objects can become unreachable:
691
+
692
+ ```ruby
693
+ module M
694
+ end
695
+
696
+ orphan = Object.send(:remove_const, :M)
697
+
698
+ # The module object is orphan now but it still has a name.
699
+ orphan.name # => "M"
700
+
701
+ # You cannot reach it via the constant M because it does not even exist.
702
+ orphan.reachable? # => false
703
+
704
+ # Let's define a module called "M" again.
705
+ module M
706
+ end
707
+
708
+ # The constant M exists now again, and it stores a module
709
+ # object called "M", but it is a new instance.
710
+ orphan.reachable? # => false
711
+ ```
712
+
713
+ NOTE: Defined in `active_support/core_ext/module/reachable.rb`.
714
+
715
+ ### Anonymous
716
+
717
+ A module may or may not have a name:
718
+
719
+ ```ruby
720
+ module M
721
+ end
722
+ M.name # => "M"
723
+
724
+ N = Module.new
725
+ N.name # => "N"
726
+
727
+ Module.new.name # => nil
728
+ ```
729
+
730
+ You can check whether a module has a name with the predicate `anonymous?`:
731
+
732
+ ```ruby
733
+ module M
734
+ end
735
+ M.anonymous? # => false
736
+
737
+ Module.new.anonymous? # => true
738
+ ```
739
+
740
+ Note that being unreachable does not imply being anonymous:
741
+
742
+ ```ruby
743
+ module M
744
+ end
745
+
746
+ m = Object.send(:remove_const, :M)
747
+
748
+ m.reachable? # => false
749
+ m.anonymous? # => false
750
+ ```
751
+
752
+ though an anonymous module is unreachable by definition.
753
+
754
+ NOTE: Defined in `active_support/core_ext/module/anonymous.rb`.
755
+
756
+ ### Method Delegation
757
+
758
+ #### `delegate`
759
+
760
+ The macro `delegate` offers an easy way to forward methods.
761
+
762
+ Let's imagine that users in some application have login information in the `User` model but name and other data in a separate `Profile` model:
763
+
764
+ ```ruby
765
+ class User < ApplicationRecord
766
+ has_one :profile
767
+ end
768
+ ```
769
+
770
+ With that configuration you get a user's name via their profile, `user.profile.name`, but it could be handy to still be able to access such attribute directly:
771
+
772
+ ```ruby
773
+ class User < ApplicationRecord
774
+ has_one :profile
775
+
776
+ def name
777
+ profile.name
778
+ end
779
+ end
780
+ ```
781
+
782
+ That is what `delegate` does for you:
783
+
784
+ ```ruby
785
+ class User < ApplicationRecord
786
+ has_one :profile
787
+
788
+ delegate :name, to: :profile
789
+ end
790
+ ```
791
+
792
+ It is shorter, and the intention more obvious.
793
+
794
+ The method must be public in the target.
795
+
796
+ The `delegate` macro accepts several methods:
797
+
798
+ ```ruby
799
+ delegate :name, :age, :address, :twitter, to: :profile
800
+ ```
801
+
802
+ When interpolated into a string, the `:to` option should become an expression that evaluates to the object the method is delegated to. Typically a string or symbol. Such an expression is evaluated in the context of the receiver:
803
+
804
+ ```ruby
805
+ # delegates to the Quails constant
806
+ delegate :logger, to: :Quails
807
+
808
+ # delegates to the receiver's class
809
+ delegate :table_name, to: :class
810
+ ```
811
+
812
+ WARNING: If the `:prefix` option is `true` this is less generic, see below.
813
+
814
+ By default, if the delegation raises `NoMethodError` and the target is `nil` the exception is propagated. You can ask that `nil` is returned instead with the `:allow_nil` option:
815
+
816
+ ```ruby
817
+ delegate :name, to: :profile, allow_nil: true
818
+ ```
819
+
820
+ With `:allow_nil` the call `user.name` returns `nil` if the user has no profile.
821
+
822
+ The option `:prefix` adds a prefix to the name of the generated method. This may be handy for example to get a better name:
823
+
824
+ ```ruby
825
+ delegate :street, to: :address, prefix: true
826
+ ```
827
+
828
+ The previous example generates `address_street` rather than `street`.
829
+
830
+ WARNING: Since in this case the name of the generated method is composed of the target object and target method names, the `:to` option must be a method name.
831
+
832
+ A custom prefix may also be configured:
833
+
834
+ ```ruby
835
+ delegate :size, to: :attachment, prefix: :avatar
836
+ ```
837
+
838
+ In the previous example the macro generates `avatar_size` rather than `size`.
839
+
840
+ NOTE: Defined in `active_support/core_ext/module/delegation.rb`
841
+
842
+ #### `delegate_missing_to`
843
+
844
+ Imagine you would like to delegate everything missing from the `User` object,
845
+ to the `Profile` one. The `delegate_missing_to` macro lets you implement this
846
+ in a breeze:
847
+
848
+ ```ruby
849
+ class User < ApplicationRecord
850
+ has_one :profile
851
+
852
+ delegate_missing_to :profile
853
+ end
854
+ ```
855
+
856
+ The target can be anything callable within the object, e.g. instance variables,
857
+ methods, constants, etc. Only the public methods of the target are delegated.
858
+
859
+ NOTE: Defined in `active_support/core_ext/module/delegation.rb`.
860
+
861
+ ### Redefining Methods
862
+
863
+ There are cases where you need to define a method with `define_method`, but don't know whether a method with that name already exists. If it does, a warning is issued if they are enabled. No big deal, but not clean either.
864
+
865
+ The method `redefine_method` prevents such a potential warning, removing the existing method before if needed.
866
+
867
+ NOTE: Defined in `active_support/core_ext/module/remove_method.rb`.
868
+
869
+ Extensions to `Class`
870
+ ---------------------
871
+
872
+ ### Class Attributes
873
+
874
+ #### `class_attribute`
875
+
876
+ The method `class_attribute` declares one or more inheritable class attributes that can be overridden at any level down the hierarchy.
877
+
878
+ ```ruby
879
+ class A
880
+ class_attribute :x
881
+ end
882
+
883
+ class B < A; end
884
+
885
+ class C < B; end
886
+
887
+ A.x = :a
888
+ B.x # => :a
889
+ C.x # => :a
890
+
891
+ B.x = :b
892
+ A.x # => :a
893
+ C.x # => :b
894
+
895
+ C.x = :c
896
+ A.x # => :a
897
+ B.x # => :b
898
+ ```
899
+
900
+ For example `ActionMailer::Base` defines:
901
+
902
+ ```ruby
903
+ class_attribute :default_params
904
+ self.default_params = {
905
+ mime_version: "1.0",
906
+ charset: "UTF-8",
907
+ content_type: "text/plain",
908
+ parts_order: [ "text/plain", "text/enriched", "text/html" ]
909
+ }.freeze
910
+ ```
911
+
912
+ They can also be accessed and overridden at the instance level.
913
+
914
+ ```ruby
915
+ A.x = 1
916
+
917
+ a1 = A.new
918
+ a2 = A.new
919
+ a2.x = 2
920
+
921
+ a1.x # => 1, comes from A
922
+ a2.x # => 2, overridden in a2
923
+ ```
924
+
925
+ The generation of the writer instance method can be prevented by setting the option `:instance_writer` to `false`.
926
+
927
+ ```ruby
928
+ module ActiveRecord
929
+ class Base
930
+ class_attribute :table_name_prefix, instance_writer: false, default: "my"
931
+ end
932
+ end
933
+ ```
934
+
935
+ A model may find that option useful as a way to prevent mass-assignment from setting the attribute.
936
+
937
+ The generation of the reader instance method can be prevented by setting the option `:instance_reader` to `false`.
938
+
939
+ ```ruby
940
+ class A
941
+ class_attribute :x, instance_reader: false
942
+ end
943
+
944
+ A.new.x = 1
945
+ A.new.x # NoMethodError
946
+ ```
947
+
948
+ For convenience `class_attribute` also defines an instance predicate which is the double negation of what the instance reader returns. In the examples above it would be called `x?`.
949
+
950
+ When `:instance_reader` is `false`, the instance predicate returns a `NoMethodError` just like the reader method.
951
+
952
+ If you do not want the instance predicate, pass `instance_predicate: false` and it will not be defined.
953
+
954
+ NOTE: Defined in `active_support/core_ext/class/attribute.rb`.
955
+
956
+ #### `cattr_reader`, `cattr_writer`, and `cattr_accessor`
957
+
958
+ The macros `cattr_reader`, `cattr_writer`, and `cattr_accessor` are analogous to their `attr_*` counterparts but for classes. They initialize a class variable to `nil` unless it already exists, and generate the corresponding class methods to access it:
959
+
960
+ ```ruby
961
+ class MysqlAdapter < AbstractAdapter
962
+ # Generates class methods to access @@emulate_booleans.
963
+ cattr_accessor :emulate_booleans, default: true
964
+ end
965
+ ```
966
+
967
+ Instance methods are created as well for convenience, they are just proxies to the class attribute. So, instances can change the class attribute, but cannot override it as it happens with `class_attribute` (see above). For example given
968
+
969
+ ```ruby
970
+ module ActionView
971
+ class Base
972
+ cattr_accessor :field_error_proc, default: Proc.new { ... }
973
+ end
974
+ end
975
+ ```
976
+
977
+ we can access `field_error_proc` in views.
978
+
979
+ Also, you can pass a block to `cattr_*` to set up the attribute with a default value:
980
+
981
+ ```ruby
982
+ class MysqlAdapter < AbstractAdapter
983
+ # Generates class methods to access @@emulate_booleans with default value of true.
984
+ cattr_accessor :emulate_booleans, default: true
985
+ end
986
+ ```
987
+
988
+ The generation of the reader instance method can be prevented by setting `:instance_reader` to `false` and the generation of the writer instance method can be prevented by setting `:instance_writer` to `false`. Generation of both methods can be prevented by setting `:instance_accessor` to `false`. In all cases, the value must be exactly `false` and not any false value.
989
+
990
+ ```ruby
991
+ module A
992
+ class B
993
+ # No first_name instance reader is generated.
994
+ cattr_accessor :first_name, instance_reader: false
995
+ # No last_name= instance writer is generated.
996
+ cattr_accessor :last_name, instance_writer: false
997
+ # No surname instance reader or surname= writer is generated.
998
+ cattr_accessor :surname, instance_accessor: false
999
+ end
1000
+ end
1001
+ ```
1002
+
1003
+ A model may find it useful to set `:instance_accessor` to `false` as a way to prevent mass-assignment from setting the attribute.
1004
+
1005
+ NOTE: Defined in `active_support/core_ext/module/attribute_accessors.rb`.
1006
+
1007
+ ### Subclasses & Descendants
1008
+
1009
+ #### `subclasses`
1010
+
1011
+ The `subclasses` method returns the subclasses of the receiver:
1012
+
1013
+ ```ruby
1014
+ class C; end
1015
+ C.subclasses # => []
1016
+
1017
+ class B < C; end
1018
+ C.subclasses # => [B]
1019
+
1020
+ class A < B; end
1021
+ C.subclasses # => [B]
1022
+
1023
+ class D < C; end
1024
+ C.subclasses # => [B, D]
1025
+ ```
1026
+
1027
+ The order in which these classes are returned is unspecified.
1028
+
1029
+ NOTE: Defined in `active_support/core_ext/class/subclasses.rb`.
1030
+
1031
+ #### `descendants`
1032
+
1033
+ The `descendants` method returns all classes that are `<` than its receiver:
1034
+
1035
+ ```ruby
1036
+ class C; end
1037
+ C.descendants # => []
1038
+
1039
+ class B < C; end
1040
+ C.descendants # => [B]
1041
+
1042
+ class A < B; end
1043
+ C.descendants # => [B, A]
1044
+
1045
+ class D < C; end
1046
+ C.descendants # => [B, A, D]
1047
+ ```
1048
+
1049
+ The order in which these classes are returned is unspecified.
1050
+
1051
+ NOTE: Defined in `active_support/core_ext/class/subclasses.rb`.
1052
+
1053
+ Extensions to `String`
1054
+ ----------------------
1055
+
1056
+ ### Output Safety
1057
+
1058
+ #### Motivation
1059
+
1060
+ Inserting data into HTML templates needs extra care. For example, you can't just interpolate `@review.title` verbatim into an HTML page. For one thing, if the review title is "Flanagan & Matz rules!" the output won't be well-formed because an ampersand has to be escaped as "&amp;amp;". What's more, depending on the application, that may be a big security hole because users can inject malicious HTML setting a hand-crafted review title. Check out the section about cross-site scripting in the [Security guide](security.html#cross-site-scripting-xss) for further information about the risks.
1061
+
1062
+ #### Safe Strings
1063
+
1064
+ Active Support has the concept of _(html) safe_ strings. A safe string is one that is marked as being insertable into HTML as is. It is trusted, no matter whether it has been escaped or not.
1065
+
1066
+ Strings are considered to be _unsafe_ by default:
1067
+
1068
+ ```ruby
1069
+ "".html_safe? # => false
1070
+ ```
1071
+
1072
+ You can obtain a safe string from a given one with the `html_safe` method:
1073
+
1074
+ ```ruby
1075
+ s = "".html_safe
1076
+ s.html_safe? # => true
1077
+ ```
1078
+
1079
+ It is important to understand that `html_safe` performs no escaping whatsoever, it is just an assertion:
1080
+
1081
+ ```ruby
1082
+ s = "<script>...</script>".html_safe
1083
+ s.html_safe? # => true
1084
+ s # => "<script>...</script>"
1085
+ ```
1086
+
1087
+ It is your responsibility to ensure calling `html_safe` on a particular string is fine.
1088
+
1089
+ If you append onto a safe string, either in-place with `concat`/`<<`, or with `+`, the result is a safe string. Unsafe arguments are escaped:
1090
+
1091
+ ```ruby
1092
+ "".html_safe + "<" # => "&lt;"
1093
+ ```
1094
+
1095
+ Safe arguments are directly appended:
1096
+
1097
+ ```ruby
1098
+ "".html_safe + "<".html_safe # => "<"
1099
+ ```
1100
+
1101
+ These methods should not be used in ordinary views. Unsafe values are automatically escaped:
1102
+
1103
+ ```erb
1104
+ <%= @review.title %> <%# fine, escaped if needed %>
1105
+ ```
1106
+
1107
+ To insert something verbatim use the `raw` helper rather than calling `html_safe`:
1108
+
1109
+ ```erb
1110
+ <%= raw @cms.current_template %> <%# inserts @cms.current_template as is %>
1111
+ ```
1112
+
1113
+ or, equivalently, use `<%==`:
1114
+
1115
+ ```erb
1116
+ <%== @cms.current_template %> <%# inserts @cms.current_template as is %>
1117
+ ```
1118
+
1119
+ The `raw` helper calls `html_safe` for you:
1120
+
1121
+ ```ruby
1122
+ def raw(stringish)
1123
+ stringish.to_s.html_safe
1124
+ end
1125
+ ```
1126
+
1127
+ NOTE: Defined in `active_support/core_ext/string/output_safety.rb`.
1128
+
1129
+ #### Transformation
1130
+
1131
+ As a rule of thumb, except perhaps for concatenation as explained above, any method that may change a string gives you an unsafe string. These are `downcase`, `gsub`, `strip`, `chomp`, `underscore`, etc.
1132
+
1133
+ In the case of in-place transformations like `gsub!` the receiver itself becomes unsafe.
1134
+
1135
+ INFO: The safety bit is lost always, no matter whether the transformation actually changed something.
1136
+
1137
+ #### Conversion and Coercion
1138
+
1139
+ Calling `to_s` on a safe string returns a safe string, but coercion with `to_str` returns an unsafe string.
1140
+
1141
+ #### Copying
1142
+
1143
+ Calling `dup` or `clone` on safe strings yields safe strings.
1144
+
1145
+ ### `remove`
1146
+
1147
+ The method `remove` will remove all occurrences of the pattern:
1148
+
1149
+ ```ruby
1150
+ "Hello World".remove(/Hello /) # => "World"
1151
+ ```
1152
+
1153
+ There's also the destructive version `String#remove!`.
1154
+
1155
+ NOTE: Defined in `active_support/core_ext/string/filters.rb`.
1156
+
1157
+ ### `squish`
1158
+
1159
+ The method `squish` strips leading and trailing whitespace, and substitutes runs of whitespace with a single space each:
1160
+
1161
+ ```ruby
1162
+ " \n foo\n\r \t bar \n".squish # => "foo bar"
1163
+ ```
1164
+
1165
+ There's also the destructive version `String#squish!`.
1166
+
1167
+ Note that it handles both ASCII and Unicode whitespace.
1168
+
1169
+ NOTE: Defined in `active_support/core_ext/string/filters.rb`.
1170
+
1171
+ ### `truncate`
1172
+
1173
+ The method `truncate` returns a copy of its receiver truncated after a given `length`:
1174
+
1175
+ ```ruby
1176
+ "Oh dear! Oh dear! I shall be late!".truncate(20)
1177
+ # => "Oh dear! Oh dear!..."
1178
+ ```
1179
+
1180
+ Ellipsis can be customized with the `:omission` option:
1181
+
1182
+ ```ruby
1183
+ "Oh dear! Oh dear! I shall be late!".truncate(20, omission: '&hellip;')
1184
+ # => "Oh dear! Oh &hellip;"
1185
+ ```
1186
+
1187
+ Note in particular that truncation takes into account the length of the omission string.
1188
+
1189
+ Pass a `:separator` to truncate the string at a natural break:
1190
+
1191
+ ```ruby
1192
+ "Oh dear! Oh dear! I shall be late!".truncate(18)
1193
+ # => "Oh dear! Oh dea..."
1194
+ "Oh dear! Oh dear! I shall be late!".truncate(18, separator: ' ')
1195
+ # => "Oh dear! Oh..."
1196
+ ```
1197
+
1198
+ The option `:separator` can be a regexp:
1199
+
1200
+ ```ruby
1201
+ "Oh dear! Oh dear! I shall be late!".truncate(18, separator: /\s/)
1202
+ # => "Oh dear! Oh..."
1203
+ ```
1204
+
1205
+ In above examples "dear" gets cut first, but then `:separator` prevents it.
1206
+
1207
+ NOTE: Defined in `active_support/core_ext/string/filters.rb`.
1208
+
1209
+ ### `truncate_words`
1210
+
1211
+ The method `truncate_words` returns a copy of its receiver truncated after a given number of words:
1212
+
1213
+ ```ruby
1214
+ "Oh dear! Oh dear! I shall be late!".truncate_words(4)
1215
+ # => "Oh dear! Oh dear!..."
1216
+ ```
1217
+
1218
+ Ellipsis can be customized with the `:omission` option:
1219
+
1220
+ ```ruby
1221
+ "Oh dear! Oh dear! I shall be late!".truncate_words(4, omission: '&hellip;')
1222
+ # => "Oh dear! Oh dear!&hellip;"
1223
+ ```
1224
+
1225
+ Pass a `:separator` to truncate the string at a natural break:
1226
+
1227
+ ```ruby
1228
+ "Oh dear! Oh dear! I shall be late!".truncate_words(3, separator: '!')
1229
+ # => "Oh dear! Oh dear! I shall be late..."
1230
+ ```
1231
+
1232
+ The option `:separator` can be a regexp:
1233
+
1234
+ ```ruby
1235
+ "Oh dear! Oh dear! I shall be late!".truncate_words(4, separator: /\s/)
1236
+ # => "Oh dear! Oh dear!..."
1237
+ ```
1238
+
1239
+ NOTE: Defined in `active_support/core_ext/string/filters.rb`.
1240
+
1241
+ ### `inquiry`
1242
+
1243
+ The `inquiry` method converts a string into a `StringInquirer` object making equality checks prettier.
1244
+
1245
+ ```ruby
1246
+ "production".inquiry.production? # => true
1247
+ "active".inquiry.inactive? # => false
1248
+ ```
1249
+
1250
+ ### `starts_with?` and `ends_with?`
1251
+
1252
+ Active Support defines 3rd person aliases of `String#start_with?` and `String#end_with?`:
1253
+
1254
+ ```ruby
1255
+ "foo".starts_with?("f") # => true
1256
+ "foo".ends_with?("o") # => true
1257
+ ```
1258
+
1259
+ NOTE: Defined in `active_support/core_ext/string/starts_ends_with.rb`.
1260
+
1261
+ ### `strip_heredoc`
1262
+
1263
+ The method `strip_heredoc` strips indentation in heredocs.
1264
+
1265
+ For example in
1266
+
1267
+ ```ruby
1268
+ if options[:usage]
1269
+ puts <<-USAGE.strip_heredoc
1270
+ This command does such and such.
1271
+
1272
+ Supported options are:
1273
+ -h This message
1274
+ ...
1275
+ USAGE
1276
+ end
1277
+ ```
1278
+
1279
+ the user would see the usage message aligned against the left margin.
1280
+
1281
+ Technically, it looks for the least indented line in the whole string, and removes
1282
+ that amount of leading whitespace.
1283
+
1284
+ NOTE: Defined in `active_support/core_ext/string/strip.rb`.
1285
+
1286
+ ### `indent`
1287
+
1288
+ Indents the lines in the receiver:
1289
+
1290
+ ```ruby
1291
+ <<EOS.indent(2)
1292
+ def some_method
1293
+ some_code
1294
+ end
1295
+ EOS
1296
+ # =>
1297
+ def some_method
1298
+ some_code
1299
+ end
1300
+ ```
1301
+
1302
+ The second argument, `indent_string`, specifies which indent string to use. The default is `nil`, which tells the method to make an educated guess peeking at the first indented line, and fallback to a space if there is none.
1303
+
1304
+ ```ruby
1305
+ " foo".indent(2) # => " foo"
1306
+ "foo\n\t\tbar".indent(2) # => "\t\tfoo\n\t\t\t\tbar"
1307
+ "foo".indent(2, "\t") # => "\t\tfoo"
1308
+ ```
1309
+
1310
+ While `indent_string` is typically one space or tab, it may be any string.
1311
+
1312
+ The third argument, `indent_empty_lines`, is a flag that says whether empty lines should be indented. Default is false.
1313
+
1314
+ ```ruby
1315
+ "foo\n\nbar".indent(2) # => " foo\n\n bar"
1316
+ "foo\n\nbar".indent(2, nil, true) # => " foo\n \n bar"
1317
+ ```
1318
+
1319
+ The `indent!` method performs indentation in-place.
1320
+
1321
+ NOTE: Defined in `active_support/core_ext/string/indent.rb`.
1322
+
1323
+ ### Access
1324
+
1325
+ #### `at(position)`
1326
+
1327
+ Returns the character of the string at position `position`:
1328
+
1329
+ ```ruby
1330
+ "hello".at(0) # => "h"
1331
+ "hello".at(4) # => "o"
1332
+ "hello".at(-1) # => "o"
1333
+ "hello".at(10) # => nil
1334
+ ```
1335
+
1336
+ NOTE: Defined in `active_support/core_ext/string/access.rb`.
1337
+
1338
+ #### `from(position)`
1339
+
1340
+ Returns the substring of the string starting at position `position`:
1341
+
1342
+ ```ruby
1343
+ "hello".from(0) # => "hello"
1344
+ "hello".from(2) # => "llo"
1345
+ "hello".from(-2) # => "lo"
1346
+ "hello".from(10) # => nil
1347
+ ```
1348
+
1349
+ NOTE: Defined in `active_support/core_ext/string/access.rb`.
1350
+
1351
+ #### `to(position)`
1352
+
1353
+ Returns the substring of the string up to position `position`:
1354
+
1355
+ ```ruby
1356
+ "hello".to(0) # => "h"
1357
+ "hello".to(2) # => "hel"
1358
+ "hello".to(-2) # => "hell"
1359
+ "hello".to(10) # => "hello"
1360
+ ```
1361
+
1362
+ NOTE: Defined in `active_support/core_ext/string/access.rb`.
1363
+
1364
+ #### `first(limit = 1)`
1365
+
1366
+ The call `str.first(n)` is equivalent to `str.to(n-1)` if `n` > 0, and returns an empty string for `n` == 0.
1367
+
1368
+ NOTE: Defined in `active_support/core_ext/string/access.rb`.
1369
+
1370
+ #### `last(limit = 1)`
1371
+
1372
+ The call `str.last(n)` is equivalent to `str.from(-n)` if `n` > 0, and returns an empty string for `n` == 0.
1373
+
1374
+ NOTE: Defined in `active_support/core_ext/string/access.rb`.
1375
+
1376
+ ### Inflections
1377
+
1378
+ #### `pluralize`
1379
+
1380
+ The method `pluralize` returns the plural of its receiver:
1381
+
1382
+ ```ruby
1383
+ "table".pluralize # => "tables"
1384
+ "ruby".pluralize # => "rubies"
1385
+ "equipment".pluralize # => "equipment"
1386
+ ```
1387
+
1388
+ As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Built-in rules can be extended in `config/initializers/inflections.rb`. That file is generated by the `quails` command and has instructions in comments.
1389
+
1390
+ `pluralize` can also take an optional `count` parameter. If `count == 1` the singular form will be returned. For any other value of `count` the plural form will be returned:
1391
+
1392
+ ```ruby
1393
+ "dude".pluralize(0) # => "dudes"
1394
+ "dude".pluralize(1) # => "dude"
1395
+ "dude".pluralize(2) # => "dudes"
1396
+ ```
1397
+
1398
+ Active Record uses this method to compute the default table name that corresponds to a model:
1399
+
1400
+ ```ruby
1401
+ # active_record/model_schema.rb
1402
+ def undecorated_table_name(class_name = base_class.name)
1403
+ table_name = class_name.to_s.demodulize.underscore
1404
+ pluralize_table_names ? table_name.pluralize : table_name
1405
+ end
1406
+ ```
1407
+
1408
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1409
+
1410
+ #### `singularize`
1411
+
1412
+ The inverse of `pluralize`:
1413
+
1414
+ ```ruby
1415
+ "tables".singularize # => "table"
1416
+ "rubies".singularize # => "ruby"
1417
+ "equipment".singularize # => "equipment"
1418
+ ```
1419
+
1420
+ Associations compute the name of the corresponding default associated class using this method:
1421
+
1422
+ ```ruby
1423
+ # active_record/reflection.rb
1424
+ def derive_class_name
1425
+ class_name = name.to_s.camelize
1426
+ class_name = class_name.singularize if collection?
1427
+ class_name
1428
+ end
1429
+ ```
1430
+
1431
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1432
+
1433
+ #### `camelize`
1434
+
1435
+ The method `camelize` returns its receiver in camel case:
1436
+
1437
+ ```ruby
1438
+ "product".camelize # => "Product"
1439
+ "admin_user".camelize # => "AdminUser"
1440
+ ```
1441
+
1442
+ As a rule of thumb you can think of this method as the one that transforms paths into Ruby class or module names, where slashes separate namespaces:
1443
+
1444
+ ```ruby
1445
+ "backoffice/session".camelize # => "Backoffice::Session"
1446
+ ```
1447
+
1448
+ For example, Action Pack uses this method to load the class that provides a certain session store:
1449
+
1450
+ ```ruby
1451
+ # action_controller/metal/session_management.rb
1452
+ def session_store=(store)
1453
+ @@session_store = store.is_a?(Symbol) ?
1454
+ ActionDispatch::Session.const_get(store.to_s.camelize) :
1455
+ store
1456
+ end
1457
+ ```
1458
+
1459
+ `camelize` accepts an optional argument, it can be `:upper` (default), or `:lower`. With the latter the first letter becomes lowercase:
1460
+
1461
+ ```ruby
1462
+ "visual_effect".camelize(:lower) # => "visualEffect"
1463
+ ```
1464
+
1465
+ That may be handy to compute method names in a language that follows that convention, for example JavaScript.
1466
+
1467
+ INFO: As a rule of thumb you can think of `camelize` as the inverse of `underscore`, though there are cases where that does not hold: `"SSLError".underscore.camelize` gives back `"SslError"`. To support cases such as this, Active Support allows you to specify acronyms in `config/initializers/inflections.rb`:
1468
+
1469
+ ```ruby
1470
+ ActiveSupport::Inflector.inflections do |inflect|
1471
+ inflect.acronym 'SSL'
1472
+ end
1473
+
1474
+ "SSLError".underscore.camelize # => "SSLError"
1475
+ ```
1476
+
1477
+ `camelize` is aliased to `camelcase`.
1478
+
1479
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1480
+
1481
+ #### `underscore`
1482
+
1483
+ The method `underscore` goes the other way around, from camel case to paths:
1484
+
1485
+ ```ruby
1486
+ "Product".underscore # => "product"
1487
+ "AdminUser".underscore # => "admin_user"
1488
+ ```
1489
+
1490
+ Also converts "::" back to "/":
1491
+
1492
+ ```ruby
1493
+ "Backoffice::Session".underscore # => "backoffice/session"
1494
+ ```
1495
+
1496
+ and understands strings that start with lowercase:
1497
+
1498
+ ```ruby
1499
+ "visualEffect".underscore # => "visual_effect"
1500
+ ```
1501
+
1502
+ `underscore` accepts no argument though.
1503
+
1504
+ Quails class and module autoloading uses `underscore` to infer the relative path without extension of a file that would define a given missing constant:
1505
+
1506
+ ```ruby
1507
+ # active_support/dependencies.rb
1508
+ def load_missing_constant(from_mod, const_name)
1509
+ ...
1510
+ qualified_name = qualified_name_for from_mod, const_name
1511
+ path_suffix = qualified_name.underscore
1512
+ ...
1513
+ end
1514
+ ```
1515
+
1516
+ INFO: As a rule of thumb you can think of `underscore` as the inverse of `camelize`, though there are cases where that does not hold. For example, `"SSLError".underscore.camelize` gives back `"SslError"`.
1517
+
1518
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1519
+
1520
+ #### `titleize`
1521
+
1522
+ The method `titleize` capitalizes the words in the receiver:
1523
+
1524
+ ```ruby
1525
+ "alice in wonderland".titleize # => "Alice In Wonderland"
1526
+ "fermat's enigma".titleize # => "Fermat's Enigma"
1527
+ ```
1528
+
1529
+ `titleize` is aliased to `titlecase`.
1530
+
1531
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1532
+
1533
+ #### `dasherize`
1534
+
1535
+ The method `dasherize` replaces the underscores in the receiver with dashes:
1536
+
1537
+ ```ruby
1538
+ "name".dasherize # => "name"
1539
+ "contact_data".dasherize # => "contact-data"
1540
+ ```
1541
+
1542
+ The XML serializer of models uses this method to dasherize node names:
1543
+
1544
+ ```ruby
1545
+ # active_model/serializers/xml.rb
1546
+ def reformat_name(name)
1547
+ name = name.camelize if camelize?
1548
+ dasherize? ? name.dasherize : name
1549
+ end
1550
+ ```
1551
+
1552
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1553
+
1554
+ #### `demodulize`
1555
+
1556
+ Given a string with a qualified constant name, `demodulize` returns the very constant name, that is, the rightmost part of it:
1557
+
1558
+ ```ruby
1559
+ "Product".demodulize # => "Product"
1560
+ "Backoffice::UsersController".demodulize # => "UsersController"
1561
+ "Admin::Hotel::ReservationUtils".demodulize # => "ReservationUtils"
1562
+ "::Inflections".demodulize # => "Inflections"
1563
+ "".demodulize # => ""
1564
+
1565
+ ```
1566
+
1567
+ Active Record for example uses this method to compute the name of a counter cache column:
1568
+
1569
+ ```ruby
1570
+ # active_record/reflection.rb
1571
+ def counter_cache_column
1572
+ if options[:counter_cache] == true
1573
+ "#{active_record.name.demodulize.underscore.pluralize}_count"
1574
+ elsif options[:counter_cache]
1575
+ options[:counter_cache]
1576
+ end
1577
+ end
1578
+ ```
1579
+
1580
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1581
+
1582
+ #### `deconstantize`
1583
+
1584
+ Given a string with a qualified constant reference expression, `deconstantize` removes the rightmost segment, generally leaving the name of the constant's container:
1585
+
1586
+ ```ruby
1587
+ "Product".deconstantize # => ""
1588
+ "Backoffice::UsersController".deconstantize # => "Backoffice"
1589
+ "Admin::Hotel::ReservationUtils".deconstantize # => "Admin::Hotel"
1590
+ ```
1591
+
1592
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1593
+
1594
+ #### `parameterize`
1595
+
1596
+ The method `parameterize` normalizes its receiver in a way that can be used in pretty URLs.
1597
+
1598
+ ```ruby
1599
+ "John Smith".parameterize # => "john-smith"
1600
+ "Kurt Gödel".parameterize # => "kurt-godel"
1601
+ ```
1602
+
1603
+ To preserve the case of the string, set the `preserve_case` argument to true. By default, `preserve_case` is set to false.
1604
+
1605
+ ```ruby
1606
+ "John Smith".parameterize(preserve_case: true) # => "John-Smith"
1607
+ "Kurt Gödel".parameterize(preserve_case: true) # => "Kurt-Godel"
1608
+ ```
1609
+
1610
+ To use a custom separator, override the `separator` argument.
1611
+
1612
+ ```ruby
1613
+ "John Smith".parameterize(separator: "_") # => "john\_smith"
1614
+ "Kurt Gödel".parameterize(separator: "_") # => "kurt\_godel"
1615
+ ```
1616
+
1617
+ In fact, the result string is wrapped in an instance of `ActiveSupport::Multibyte::Chars`.
1618
+
1619
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1620
+
1621
+ #### `tableize`
1622
+
1623
+ The method `tableize` is `underscore` followed by `pluralize`.
1624
+
1625
+ ```ruby
1626
+ "Person".tableize # => "people"
1627
+ "Invoice".tableize # => "invoices"
1628
+ "InvoiceLine".tableize # => "invoice_lines"
1629
+ ```
1630
+
1631
+ As a rule of thumb, `tableize` returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight `tableize` indeed, because it also demodulizes the class name and checks a few options that may affect the returned string.
1632
+
1633
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1634
+
1635
+ #### `classify`
1636
+
1637
+ The method `classify` is the inverse of `tableize`. It gives you the class name corresponding to a table name:
1638
+
1639
+ ```ruby
1640
+ "people".classify # => "Person"
1641
+ "invoices".classify # => "Invoice"
1642
+ "invoice_lines".classify # => "InvoiceLine"
1643
+ ```
1644
+
1645
+ The method understands qualified table names:
1646
+
1647
+ ```ruby
1648
+ "highrise_production.companies".classify # => "Company"
1649
+ ```
1650
+
1651
+ Note that `classify` returns a class name as a string. You can get the actual class object invoking `constantize` on it, explained next.
1652
+
1653
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1654
+
1655
+ #### `constantize`
1656
+
1657
+ The method `constantize` resolves the constant reference expression in its receiver:
1658
+
1659
+ ```ruby
1660
+ "Integer".constantize # => Integer
1661
+
1662
+ module M
1663
+ X = 1
1664
+ end
1665
+ "M::X".constantize # => 1
1666
+ ```
1667
+
1668
+ If the string evaluates to no known constant, or its content is not even a valid constant name, `constantize` raises `NameError`.
1669
+
1670
+ Constant name resolution by `constantize` starts always at the top-level `Object` even if there is no leading "::".
1671
+
1672
+ ```ruby
1673
+ X = :in_Object
1674
+ module M
1675
+ X = :in_M
1676
+
1677
+ X # => :in_M
1678
+ "::X".constantize # => :in_Object
1679
+ "X".constantize # => :in_Object (!)
1680
+ end
1681
+ ```
1682
+
1683
+ So, it is in general not equivalent to what Ruby would do in the same spot, had a real constant be evaluated.
1684
+
1685
+ Mailer test cases obtain the mailer being tested from the name of the test class using `constantize`:
1686
+
1687
+ ```ruby
1688
+ # action_mailer/test_case.rb
1689
+ def determine_default_mailer(name)
1690
+ name.sub(/Test$/, '').constantize
1691
+ rescue NameError => e
1692
+ raise NonInferrableMailerError.new(name)
1693
+ end
1694
+ ```
1695
+
1696
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1697
+
1698
+ #### `humanize`
1699
+
1700
+ The method `humanize` tweaks an attribute name for display to end users.
1701
+
1702
+ Specifically performs these transformations:
1703
+
1704
+ * Applies human inflection rules to the argument.
1705
+ * Deletes leading underscores, if any.
1706
+ * Removes a "_id" suffix if present.
1707
+ * Replaces underscores with spaces, if any.
1708
+ * Downcases all words except acronyms.
1709
+ * Capitalizes the first word.
1710
+
1711
+ The capitalization of the first word can be turned off by setting the
1712
+ `:capitalize` option to false (default is true).
1713
+
1714
+ ```ruby
1715
+ "name".humanize # => "Name"
1716
+ "author_id".humanize # => "Author"
1717
+ "author_id".humanize(capitalize: false) # => "author"
1718
+ "comments_count".humanize # => "Comments count"
1719
+ "_id".humanize # => "Id"
1720
+ ```
1721
+
1722
+ If "SSL" was defined to be an acronym:
1723
+
1724
+ ```ruby
1725
+ 'ssl_error'.humanize # => "SSL error"
1726
+ ```
1727
+
1728
+ The helper method `full_messages` uses `humanize` as a fallback to include
1729
+ attribute names:
1730
+
1731
+ ```ruby
1732
+ def full_messages
1733
+ map { |attribute, message| full_message(attribute, message) }
1734
+ end
1735
+
1736
+ def full_message
1737
+ ...
1738
+ attr_name = attribute.to_s.tr('.', '_').humanize
1739
+ attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
1740
+ ...
1741
+ end
1742
+ ```
1743
+
1744
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1745
+
1746
+ #### `foreign_key`
1747
+
1748
+ The method `foreign_key` gives a foreign key column name from a class name. To do so it demodulizes, underscores, and adds "_id":
1749
+
1750
+ ```ruby
1751
+ "User".foreign_key # => "user_id"
1752
+ "InvoiceLine".foreign_key # => "invoice_line_id"
1753
+ "Admin::Session".foreign_key # => "session_id"
1754
+ ```
1755
+
1756
+ Pass a false argument if you do not want the underscore in "_id":
1757
+
1758
+ ```ruby
1759
+ "User".foreign_key(false) # => "userid"
1760
+ ```
1761
+
1762
+ Associations use this method to infer foreign keys, for example `has_one` and `has_many` do this:
1763
+
1764
+ ```ruby
1765
+ # active_record/associations.rb
1766
+ foreign_key = options[:foreign_key] || reflection.active_record.name.foreign_key
1767
+ ```
1768
+
1769
+ NOTE: Defined in `active_support/core_ext/string/inflections.rb`.
1770
+
1771
+ ### Conversions
1772
+
1773
+ #### `to_date`, `to_time`, `to_datetime`
1774
+
1775
+ The methods `to_date`, `to_time`, and `to_datetime` are basically convenience wrappers around `Date._parse`:
1776
+
1777
+ ```ruby
1778
+ "2010-07-27".to_date # => Tue, 27 Jul 2010
1779
+ "2010-07-27 23:37:00".to_time # => 2010-07-27 23:37:00 +0200
1780
+ "2010-07-27 23:37:00".to_datetime # => Tue, 27 Jul 2010 23:37:00 +0000
1781
+ ```
1782
+
1783
+ `to_time` receives an optional argument `:utc` or `:local`, to indicate which time zone you want the time in:
1784
+
1785
+ ```ruby
1786
+ "2010-07-27 23:42:00".to_time(:utc) # => 2010-07-27 23:42:00 UTC
1787
+ "2010-07-27 23:42:00".to_time(:local) # => 2010-07-27 23:42:00 +0200
1788
+ ```
1789
+
1790
+ Default is `:utc`.
1791
+
1792
+ Please refer to the documentation of `Date._parse` for further details.
1793
+
1794
+ INFO: The three of them return `nil` for blank receivers.
1795
+
1796
+ NOTE: Defined in `active_support/core_ext/string/conversions.rb`.
1797
+
1798
+ Extensions to `Numeric`
1799
+ -----------------------
1800
+
1801
+ ### Bytes
1802
+
1803
+ All numbers respond to these methods:
1804
+
1805
+ ```ruby
1806
+ bytes
1807
+ kilobytes
1808
+ megabytes
1809
+ gigabytes
1810
+ terabytes
1811
+ petabytes
1812
+ exabytes
1813
+ ```
1814
+
1815
+ They return the corresponding amount of bytes, using a conversion factor of 1024:
1816
+
1817
+ ```ruby
1818
+ 2.kilobytes # => 2048
1819
+ 3.megabytes # => 3145728
1820
+ 3.5.gigabytes # => 3758096384
1821
+ -4.exabytes # => -4611686018427387904
1822
+ ```
1823
+
1824
+ Singular forms are aliased so you are able to say:
1825
+
1826
+ ```ruby
1827
+ 1.megabyte # => 1048576
1828
+ ```
1829
+
1830
+ NOTE: Defined in `active_support/core_ext/numeric/bytes.rb`.
1831
+
1832
+ ### Time
1833
+
1834
+ Enables the use of time calculations and declarations, like `45.minutes + 2.hours + 4.years`.
1835
+
1836
+ These methods use Time#advance for precise date calculations when using from_now, ago, etc.
1837
+ as well as adding or subtracting their results from a Time object. For example:
1838
+
1839
+ ```ruby
1840
+ # equivalent to Time.current.advance(months: 1)
1841
+ 1.month.from_now
1842
+
1843
+ # equivalent to Time.current.advance(years: 2)
1844
+ 2.years.from_now
1845
+
1846
+ # equivalent to Time.current.advance(months: 4, years: 5)
1847
+ (4.months + 5.years).from_now
1848
+ ```
1849
+
1850
+ NOTE: Defined in `active_support/core_ext/numeric/time.rb`.
1851
+
1852
+ ### Formatting
1853
+
1854
+ Enables the formatting of numbers in a variety of ways.
1855
+
1856
+ Produce a string representation of a number as a telephone number:
1857
+
1858
+ ```ruby
1859
+ 5551234.to_s(:phone)
1860
+ # => 555-1234
1861
+ 1235551234.to_s(:phone)
1862
+ # => 123-555-1234
1863
+ 1235551234.to_s(:phone, area_code: true)
1864
+ # => (123) 555-1234
1865
+ 1235551234.to_s(:phone, delimiter: " ")
1866
+ # => 123 555 1234
1867
+ 1235551234.to_s(:phone, area_code: true, extension: 555)
1868
+ # => (123) 555-1234 x 555
1869
+ 1235551234.to_s(:phone, country_code: 1)
1870
+ # => +1-123-555-1234
1871
+ ```
1872
+
1873
+ Produce a string representation of a number as currency:
1874
+
1875
+ ```ruby
1876
+ 1234567890.50.to_s(:currency) # => $1,234,567,890.50
1877
+ 1234567890.506.to_s(:currency) # => $1,234,567,890.51
1878
+ 1234567890.506.to_s(:currency, precision: 3) # => $1,234,567,890.506
1879
+ ```
1880
+
1881
+ Produce a string representation of a number as a percentage:
1882
+
1883
+ ```ruby
1884
+ 100.to_s(:percentage)
1885
+ # => 100.000%
1886
+ 100.to_s(:percentage, precision: 0)
1887
+ # => 100%
1888
+ 1000.to_s(:percentage, delimiter: '.', separator: ',')
1889
+ # => 1.000,000%
1890
+ 302.24398923423.to_s(:percentage, precision: 5)
1891
+ # => 302.24399%
1892
+ ```
1893
+
1894
+ Produce a string representation of a number in delimited form:
1895
+
1896
+ ```ruby
1897
+ 12345678.to_s(:delimited) # => 12,345,678
1898
+ 12345678.05.to_s(:delimited) # => 12,345,678.05
1899
+ 12345678.to_s(:delimited, delimiter: ".") # => 12.345.678
1900
+ 12345678.to_s(:delimited, delimiter: ",") # => 12,345,678
1901
+ 12345678.05.to_s(:delimited, separator: " ") # => 12,345,678 05
1902
+ ```
1903
+
1904
+ Produce a string representation of a number rounded to a precision:
1905
+
1906
+ ```ruby
1907
+ 111.2345.to_s(:rounded) # => 111.235
1908
+ 111.2345.to_s(:rounded, precision: 2) # => 111.23
1909
+ 13.to_s(:rounded, precision: 5) # => 13.00000
1910
+ 389.32314.to_s(:rounded, precision: 0) # => 389
1911
+ 111.2345.to_s(:rounded, significant: true) # => 111
1912
+ ```
1913
+
1914
+ Produce a string representation of a number as a human-readable number of bytes:
1915
+
1916
+ ```ruby
1917
+ 123.to_s(:human_size) # => 123 Bytes
1918
+ 1234.to_s(:human_size) # => 1.21 KB
1919
+ 12345.to_s(:human_size) # => 12.1 KB
1920
+ 1234567.to_s(:human_size) # => 1.18 MB
1921
+ 1234567890.to_s(:human_size) # => 1.15 GB
1922
+ 1234567890123.to_s(:human_size) # => 1.12 TB
1923
+ 1234567890123456.to_s(:human_size) # => 1.1 PB
1924
+ 1234567890123456789.to_s(:human_size) # => 1.07 EB
1925
+ ```
1926
+
1927
+ Produce a string representation of a number in human-readable words:
1928
+
1929
+ ```ruby
1930
+ 123.to_s(:human) # => "123"
1931
+ 1234.to_s(:human) # => "1.23 Thousand"
1932
+ 12345.to_s(:human) # => "12.3 Thousand"
1933
+ 1234567.to_s(:human) # => "1.23 Million"
1934
+ 1234567890.to_s(:human) # => "1.23 Billion"
1935
+ 1234567890123.to_s(:human) # => "1.23 Trillion"
1936
+ 1234567890123456.to_s(:human) # => "1.23 Quadrillion"
1937
+ ```
1938
+
1939
+ NOTE: Defined in `active_support/core_ext/numeric/conversions.rb`.
1940
+
1941
+ Extensions to `Integer`
1942
+ -----------------------
1943
+
1944
+ ### `multiple_of?`
1945
+
1946
+ The method `multiple_of?` tests whether an integer is multiple of the argument:
1947
+
1948
+ ```ruby
1949
+ 2.multiple_of?(1) # => true
1950
+ 1.multiple_of?(2) # => false
1951
+ ```
1952
+
1953
+ NOTE: Defined in `active_support/core_ext/integer/multiple.rb`.
1954
+
1955
+ ### `ordinal`
1956
+
1957
+ The method `ordinal` returns the ordinal suffix string corresponding to the receiver integer:
1958
+
1959
+ ```ruby
1960
+ 1.ordinal # => "st"
1961
+ 2.ordinal # => "nd"
1962
+ 53.ordinal # => "rd"
1963
+ 2009.ordinal # => "th"
1964
+ -21.ordinal # => "st"
1965
+ -134.ordinal # => "th"
1966
+ ```
1967
+
1968
+ NOTE: Defined in `active_support/core_ext/integer/inflections.rb`.
1969
+
1970
+ ### `ordinalize`
1971
+
1972
+ The method `ordinalize` returns the ordinal string corresponding to the receiver integer. In comparison, note that the `ordinal` method returns **only** the suffix string.
1973
+
1974
+ ```ruby
1975
+ 1.ordinalize # => "1st"
1976
+ 2.ordinalize # => "2nd"
1977
+ 53.ordinalize # => "53rd"
1978
+ 2009.ordinalize # => "2009th"
1979
+ -21.ordinalize # => "-21st"
1980
+ -134.ordinalize # => "-134th"
1981
+ ```
1982
+
1983
+ NOTE: Defined in `active_support/core_ext/integer/inflections.rb`.
1984
+
1985
+ Extensions to `BigDecimal`
1986
+ --------------------------
1987
+ ### `to_s`
1988
+
1989
+ The method `to_s` provides a default specifier of "F". This means that a simple call to `to_s` will result in floating point representation instead of engineering notation:
1990
+
1991
+ ```ruby
1992
+ BigDecimal.new(5.00, 6).to_s # => "5.0"
1993
+ ```
1994
+
1995
+ and that symbol specifiers are also supported:
1996
+
1997
+ ```ruby
1998
+ BigDecimal.new(5.00, 6).to_s(:db) # => "5.0"
1999
+ ```
2000
+
2001
+ Engineering notation is still supported:
2002
+
2003
+ ```ruby
2004
+ BigDecimal.new(5.00, 6).to_s("e") # => "0.5E1"
2005
+ ```
2006
+
2007
+ Extensions to `Enumerable`
2008
+ --------------------------
2009
+
2010
+ ### `sum`
2011
+
2012
+ The method `sum` adds the elements of an enumerable:
2013
+
2014
+ ```ruby
2015
+ [1, 2, 3].sum # => 6
2016
+ (1..100).sum # => 5050
2017
+ ```
2018
+
2019
+ Addition only assumes the elements respond to `+`:
2020
+
2021
+ ```ruby
2022
+ [[1, 2], [2, 3], [3, 4]].sum # => [1, 2, 2, 3, 3, 4]
2023
+ %w(foo bar baz).sum # => "foobarbaz"
2024
+ {a: 1, b: 2, c: 3}.sum # => [:b, 2, :c, 3, :a, 1]
2025
+ ```
2026
+
2027
+ The sum of an empty collection is zero by default, but this is customizable:
2028
+
2029
+ ```ruby
2030
+ [].sum # => 0
2031
+ [].sum(1) # => 1
2032
+ ```
2033
+
2034
+ If a block is given, `sum` becomes an iterator that yields the elements of the collection and sums the returned values:
2035
+
2036
+ ```ruby
2037
+ (1..5).sum {|n| n * 2 } # => 30
2038
+ [2, 4, 6, 8, 10].sum # => 30
2039
+ ```
2040
+
2041
+ The sum of an empty receiver can be customized in this form as well:
2042
+
2043
+ ```ruby
2044
+ [].sum(1) {|n| n**3} # => 1
2045
+ ```
2046
+
2047
+ NOTE: Defined in `active_support/core_ext/enumerable.rb`.
2048
+
2049
+ ### `index_by`
2050
+
2051
+ The method `index_by` generates a hash with the elements of an enumerable indexed by some key.
2052
+
2053
+ It iterates through the collection and passes each element to a block. The element will be keyed by the value returned by the block:
2054
+
2055
+ ```ruby
2056
+ invoices.index_by(&:number)
2057
+ # => {'2009-032' => <Invoice ...>, '2009-008' => <Invoice ...>, ...}
2058
+ ```
2059
+
2060
+ WARNING. Keys should normally be unique. If the block returns the same value for different elements no collection is built for that key. The last item will win.
2061
+
2062
+ NOTE: Defined in `active_support/core_ext/enumerable.rb`.
2063
+
2064
+ ### `many?`
2065
+
2066
+ The method `many?` is shorthand for `collection.size > 1`:
2067
+
2068
+ ```erb
2069
+ <% if pages.many? %>
2070
+ <%= pagination_links %>
2071
+ <% end %>
2072
+ ```
2073
+
2074
+ If an optional block is given, `many?` only takes into account those elements that return true:
2075
+
2076
+ ```ruby
2077
+ @see_more = videos.many? {|video| video.category == params[:category]}
2078
+ ```
2079
+
2080
+ NOTE: Defined in `active_support/core_ext/enumerable.rb`.
2081
+
2082
+ ### `exclude?`
2083
+
2084
+ The predicate `exclude?` tests whether a given object does **not** belong to the collection. It is the negation of the built-in `include?`:
2085
+
2086
+ ```ruby
2087
+ to_visit << node if visited.exclude?(node)
2088
+ ```
2089
+
2090
+ NOTE: Defined in `active_support/core_ext/enumerable.rb`.
2091
+
2092
+ ### `without`
2093
+
2094
+ The method `without` returns a copy of an enumerable with the specified elements
2095
+ removed:
2096
+
2097
+ ```ruby
2098
+ ["David", "Rafael", "Aaron", "Todd"].without("Aaron", "Todd") # => ["David", "Rafael"]
2099
+ ```
2100
+
2101
+ NOTE: Defined in `active_support/core_ext/enumerable.rb`.
2102
+
2103
+ ### `pluck`
2104
+
2105
+ The method `pluck` returns an array based on the given key:
2106
+
2107
+ ```ruby
2108
+ [{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name) # => ["David", "Rafael", "Aaron"]
2109
+ ```
2110
+
2111
+ NOTE: Defined in `active_support/core_ext/enumerable.rb`.
2112
+
2113
+ Extensions to `Array`
2114
+ ---------------------
2115
+
2116
+ ### Accessing
2117
+
2118
+ Active Support augments the API of arrays to ease certain ways of accessing them. For example, `to` returns the subarray of elements up to the one at the passed index:
2119
+
2120
+ ```ruby
2121
+ %w(a b c d).to(2) # => ["a", "b", "c"]
2122
+ [].to(7) # => []
2123
+ ```
2124
+
2125
+ Similarly, `from` returns the tail from the element at the passed index to the end. If the index is greater than the length of the array, it returns an empty array.
2126
+
2127
+ ```ruby
2128
+ %w(a b c d).from(2) # => ["c", "d"]
2129
+ %w(a b c d).from(10) # => []
2130
+ [].from(0) # => []
2131
+ ```
2132
+
2133
+ The methods `second`, `third`, `fourth`, and `fifth` return the corresponding element, as do `second_to_last` and `third_to_last` (`first` and `last` are built-in). Thanks to social wisdom and positive constructiveness all around, `forty_two` is also available.
2134
+
2135
+ ```ruby
2136
+ %w(a b c d).third # => "c"
2137
+ %w(a b c d).fifth # => nil
2138
+ ```
2139
+
2140
+ NOTE: Defined in `active_support/core_ext/array/access.rb`.
2141
+
2142
+ ### Adding Elements
2143
+
2144
+ #### `prepend`
2145
+
2146
+ This method is an alias of `Array#unshift`.
2147
+
2148
+ ```ruby
2149
+ %w(a b c d).prepend('e') # => ["e", "a", "b", "c", "d"]
2150
+ [].prepend(10) # => [10]
2151
+ ```
2152
+
2153
+ NOTE: Defined in `active_support/core_ext/array/prepend_and_append.rb`.
2154
+
2155
+ #### `append`
2156
+
2157
+ This method is an alias of `Array#<<`.
2158
+
2159
+ ```ruby
2160
+ %w(a b c d).append('e') # => ["a", "b", "c", "d", "e"]
2161
+ [].append([1,2]) # => [[1, 2]]
2162
+ ```
2163
+
2164
+ NOTE: Defined in `active_support/core_ext/array/prepend_and_append.rb`.
2165
+
2166
+ ### Options Extraction
2167
+
2168
+ When the last argument in a method call is a hash, except perhaps for a `&block` argument, Ruby allows you to omit the brackets:
2169
+
2170
+ ```ruby
2171
+ User.exists?(email: params[:email])
2172
+ ```
2173
+
2174
+ That syntactic sugar is used a lot in Quails to avoid positional arguments where there would be too many, offering instead interfaces that emulate named parameters. In particular it is very idiomatic to use a trailing hash for options.
2175
+
2176
+ If a method expects a variable number of arguments and uses `*` in its declaration, however, such an options hash ends up being an item of the array of arguments, where it loses its role.
2177
+
2178
+ In those cases, you may give an options hash a distinguished treatment with `extract_options!`. This method checks the type of the last item of an array. If it is a hash it pops it and returns it, otherwise it returns an empty hash.
2179
+
2180
+ Let's see for example the definition of the `caches_action` controller macro:
2181
+
2182
+ ```ruby
2183
+ def caches_action(*actions)
2184
+ return unless cache_configured?
2185
+ options = actions.extract_options!
2186
+ ...
2187
+ end
2188
+ ```
2189
+
2190
+ This method receives an arbitrary number of action names, and an optional hash of options as last argument. With the call to `extract_options!` you obtain the options hash and remove it from `actions` in a simple and explicit way.
2191
+
2192
+ NOTE: Defined in `active_support/core_ext/array/extract_options.rb`.
2193
+
2194
+ ### Conversions
2195
+
2196
+ #### `to_sentence`
2197
+
2198
+ The method `to_sentence` turns an array into a string containing a sentence that enumerates its items:
2199
+
2200
+ ```ruby
2201
+ %w().to_sentence # => ""
2202
+ %w(Earth).to_sentence # => "Earth"
2203
+ %w(Earth Wind).to_sentence # => "Earth and Wind"
2204
+ %w(Earth Wind Fire).to_sentence # => "Earth, Wind, and Fire"
2205
+ ```
2206
+
2207
+ This method accepts three options:
2208
+
2209
+ * `:two_words_connector`: What is used for arrays of length 2. Default is " and ".
2210
+ * `:words_connector`: What is used to join the elements of arrays with 3 or more elements, except for the last two. Default is ", ".
2211
+ * `:last_word_connector`: What is used to join the last items of an array with 3 or more elements. Default is ", and ".
2212
+
2213
+ The defaults for these options can be localized, their keys are:
2214
+
2215
+ | Option | I18n key |
2216
+ | ---------------------- | ----------------------------------- |
2217
+ | `:two_words_connector` | `support.array.two_words_connector` |
2218
+ | `:words_connector` | `support.array.words_connector` |
2219
+ | `:last_word_connector` | `support.array.last_word_connector` |
2220
+
2221
+ NOTE: Defined in `active_support/core_ext/array/conversions.rb`.
2222
+
2223
+ #### `to_formatted_s`
2224
+
2225
+ The method `to_formatted_s` acts like `to_s` by default.
2226
+
2227
+ If the array contains items that respond to `id`, however, the symbol
2228
+ `:db` may be passed as argument. That's typically used with
2229
+ collections of Active Record objects. Returned strings are:
2230
+
2231
+ ```ruby
2232
+ [].to_formatted_s(:db) # => "null"
2233
+ [user].to_formatted_s(:db) # => "8456"
2234
+ invoice.lines.to_formatted_s(:db) # => "23,567,556,12"
2235
+ ```
2236
+
2237
+ Integers in the example above are supposed to come from the respective calls to `id`.
2238
+
2239
+ NOTE: Defined in `active_support/core_ext/array/conversions.rb`.
2240
+
2241
+ #### `to_xml`
2242
+
2243
+ The method `to_xml` returns a string containing an XML representation of its receiver:
2244
+
2245
+ ```ruby
2246
+ Contributor.limit(2).order(:rank).to_xml
2247
+ # =>
2248
+ # <?xml version="1.0" encoding="UTF-8"?>
2249
+ # <contributors type="array">
2250
+ # <contributor>
2251
+ # <id type="integer">4356</id>
2252
+ # <name>Jeremy Kemper</name>
2253
+ # <rank type="integer">1</rank>
2254
+ # <url-id>jeremy-kemper</url-id>
2255
+ # </contributor>
2256
+ # <contributor>
2257
+ # <id type="integer">4404</id>
2258
+ # <name>David Heinemeier Hansson</name>
2259
+ # <rank type="integer">2</rank>
2260
+ # <url-id>david-heinemeier-hansson</url-id>
2261
+ # </contributor>
2262
+ # </contributors>
2263
+ ```
2264
+
2265
+ To do so it sends `to_xml` to every item in turn, and collects the results under a root node. All items must respond to `to_xml`, an exception is raised otherwise.
2266
+
2267
+ By default, the name of the root element is the underscored and dasherized plural of the name of the class of the first item, provided the rest of elements belong to that type (checked with `is_a?`) and they are not hashes. In the example above that's "contributors".
2268
+
2269
+ If there's any element that does not belong to the type of the first one the root node becomes "objects":
2270
+
2271
+ ```ruby
2272
+ [Contributor.first, Commit.first].to_xml
2273
+ # =>
2274
+ # <?xml version="1.0" encoding="UTF-8"?>
2275
+ # <objects type="array">
2276
+ # <object>
2277
+ # <id type="integer">4583</id>
2278
+ # <name>Aaron Batalion</name>
2279
+ # <rank type="integer">53</rank>
2280
+ # <url-id>aaron-batalion</url-id>
2281
+ # </object>
2282
+ # <object>
2283
+ # <author>Joshua Peek</author>
2284
+ # <authored-timestamp type="datetime">2009-09-02T16:44:36Z</authored-timestamp>
2285
+ # <branch>origin/master</branch>
2286
+ # <committed-timestamp type="datetime">2009-09-02T16:44:36Z</committed-timestamp>
2287
+ # <committer>Joshua Peek</committer>
2288
+ # <git-show nil="true"></git-show>
2289
+ # <id type="integer">190316</id>
2290
+ # <imported-from-svn type="boolean">false</imported-from-svn>
2291
+ # <message>Kill AMo observing wrap_with_notifications since ARes was only using it</message>
2292
+ # <sha1>723a47bfb3708f968821bc969a9a3fc873a3ed58</sha1>
2293
+ # </object>
2294
+ # </objects>
2295
+ ```
2296
+
2297
+ If the receiver is an array of hashes the root element is by default also "objects":
2298
+
2299
+ ```ruby
2300
+ [{a: 1, b: 2}, {c: 3}].to_xml
2301
+ # =>
2302
+ # <?xml version="1.0" encoding="UTF-8"?>
2303
+ # <objects type="array">
2304
+ # <object>
2305
+ # <b type="integer">2</b>
2306
+ # <a type="integer">1</a>
2307
+ # </object>
2308
+ # <object>
2309
+ # <c type="integer">3</c>
2310
+ # </object>
2311
+ # </objects>
2312
+ ```
2313
+
2314
+ WARNING. If the collection is empty the root element is by default "nil-classes". That's a gotcha, for example the root element of the list of contributors above would not be "contributors" if the collection was empty, but "nil-classes". You may use the `:root` option to ensure a consistent root element.
2315
+
2316
+ The name of children nodes is by default the name of the root node singularized. In the examples above we've seen "contributor" and "object". The option `:children` allows you to set these node names.
2317
+
2318
+ The default XML builder is a fresh instance of `Builder::XmlMarkup`. You can configure your own builder via the `:builder` option. The method also accepts options like `:dasherize` and friends, they are forwarded to the builder:
2319
+
2320
+ ```ruby
2321
+ Contributor.limit(2).order(:rank).to_xml(skip_types: true)
2322
+ # =>
2323
+ # <?xml version="1.0" encoding="UTF-8"?>
2324
+ # <contributors>
2325
+ # <contributor>
2326
+ # <id>4356</id>
2327
+ # <name>Jeremy Kemper</name>
2328
+ # <rank>1</rank>
2329
+ # <url-id>jeremy-kemper</url-id>
2330
+ # </contributor>
2331
+ # <contributor>
2332
+ # <id>4404</id>
2333
+ # <name>David Heinemeier Hansson</name>
2334
+ # <rank>2</rank>
2335
+ # <url-id>david-heinemeier-hansson</url-id>
2336
+ # </contributor>
2337
+ # </contributors>
2338
+ ```
2339
+
2340
+ NOTE: Defined in `active_support/core_ext/array/conversions.rb`.
2341
+
2342
+ ### Wrapping
2343
+
2344
+ The method `Array.wrap` wraps its argument in an array unless it is already an array (or array-like).
2345
+
2346
+ Specifically:
2347
+
2348
+ * If the argument is `nil` an empty array is returned.
2349
+ * Otherwise, if the argument responds to `to_ary` it is invoked, and if the value of `to_ary` is not `nil`, it is returned.
2350
+ * Otherwise, an array with the argument as its single element is returned.
2351
+
2352
+ ```ruby
2353
+ Array.wrap(nil) # => []
2354
+ Array.wrap([1, 2, 3]) # => [1, 2, 3]
2355
+ Array.wrap(0) # => [0]
2356
+ ```
2357
+
2358
+ This method is similar in purpose to `Kernel#Array`, but there are some differences:
2359
+
2360
+ * If the argument responds to `to_ary` the method is invoked. `Kernel#Array` moves on to try `to_a` if the returned value is `nil`, but `Array.wrap` returns an array with the argument as its single element right away.
2361
+ * If the returned value from `to_ary` is neither `nil` nor an `Array` object, `Kernel#Array` raises an exception, while `Array.wrap` does not, it just returns the value.
2362
+ * It does not call `to_a` on the argument, if the argument does not respond to `to_ary` it returns an array with the argument as its single element.
2363
+
2364
+ The last point is particularly worth comparing for some enumerables:
2365
+
2366
+ ```ruby
2367
+ Array.wrap(foo: :bar) # => [{:foo=>:bar}]
2368
+ Array(foo: :bar) # => [[:foo, :bar]]
2369
+ ```
2370
+
2371
+ There's also a related idiom that uses the splat operator:
2372
+
2373
+ ```ruby
2374
+ [*object]
2375
+ ```
2376
+
2377
+ which in Ruby 1.8 returns `[nil]` for `nil`, and calls to `Array(object)` otherwise. (Please if you know the exact behavior in 1.9 contact fxn.)
2378
+
2379
+ Thus, in this case the behavior is different for `nil`, and the differences with `Kernel#Array` explained above apply to the rest of `object`s.
2380
+
2381
+ NOTE: Defined in `active_support/core_ext/array/wrap.rb`.
2382
+
2383
+ ### Duplicating
2384
+
2385
+ The method `Array#deep_dup` duplicates itself and all objects inside
2386
+ recursively with Active Support method `Object#deep_dup`. It works like `Array#map` with sending `deep_dup` method to each object inside.
2387
+
2388
+ ```ruby
2389
+ array = [1, [2, 3]]
2390
+ dup = array.deep_dup
2391
+ dup[1][2] = 4
2392
+ array[1][2] == nil # => true
2393
+ ```
2394
+
2395
+ NOTE: Defined in `active_support/core_ext/object/deep_dup.rb`.
2396
+
2397
+ ### Grouping
2398
+
2399
+ #### `in_groups_of(number, fill_with = nil)`
2400
+
2401
+ The method `in_groups_of` splits an array into consecutive groups of a certain size. It returns an array with the groups:
2402
+
2403
+ ```ruby
2404
+ [1, 2, 3].in_groups_of(2) # => [[1, 2], [3, nil]]
2405
+ ```
2406
+
2407
+ or yields them in turn if a block is passed:
2408
+
2409
+ ```html+erb
2410
+ <% sample.in_groups_of(3) do |a, b, c| %>
2411
+ <tr>
2412
+ <td><%= a %></td>
2413
+ <td><%= b %></td>
2414
+ <td><%= c %></td>
2415
+ </tr>
2416
+ <% end %>
2417
+ ```
2418
+
2419
+ The first example shows `in_groups_of` fills the last group with as many `nil` elements as needed to have the requested size. You can change this padding value using the second optional argument:
2420
+
2421
+ ```ruby
2422
+ [1, 2, 3].in_groups_of(2, 0) # => [[1, 2], [3, 0]]
2423
+ ```
2424
+
2425
+ And you can tell the method not to fill the last group passing `false`:
2426
+
2427
+ ```ruby
2428
+ [1, 2, 3].in_groups_of(2, false) # => [[1, 2], [3]]
2429
+ ```
2430
+
2431
+ As a consequence `false` can't be a used as a padding value.
2432
+
2433
+ NOTE: Defined in `active_support/core_ext/array/grouping.rb`.
2434
+
2435
+ #### `in_groups(number, fill_with = nil)`
2436
+
2437
+ The method `in_groups` splits an array into a certain number of groups. The method returns an array with the groups:
2438
+
2439
+ ```ruby
2440
+ %w(1 2 3 4 5 6 7).in_groups(3)
2441
+ # => [["1", "2", "3"], ["4", "5", nil], ["6", "7", nil]]
2442
+ ```
2443
+
2444
+ or yields them in turn if a block is passed:
2445
+
2446
+ ```ruby
2447
+ %w(1 2 3 4 5 6 7).in_groups(3) {|group| p group}
2448
+ ["1", "2", "3"]
2449
+ ["4", "5", nil]
2450
+ ["6", "7", nil]
2451
+ ```
2452
+
2453
+ The examples above show that `in_groups` fills some groups with a trailing `nil` element as needed. A group can get at most one of these extra elements, the rightmost one if any. And the groups that have them are always the last ones.
2454
+
2455
+ You can change this padding value using the second optional argument:
2456
+
2457
+ ```ruby
2458
+ %w(1 2 3 4 5 6 7).in_groups(3, "0")
2459
+ # => [["1", "2", "3"], ["4", "5", "0"], ["6", "7", "0"]]
2460
+ ```
2461
+
2462
+ And you can tell the method not to fill the smaller groups passing `false`:
2463
+
2464
+ ```ruby
2465
+ %w(1 2 3 4 5 6 7).in_groups(3, false)
2466
+ # => [["1", "2", "3"], ["4", "5"], ["6", "7"]]
2467
+ ```
2468
+
2469
+ As a consequence `false` can't be a used as a padding value.
2470
+
2471
+ NOTE: Defined in `active_support/core_ext/array/grouping.rb`.
2472
+
2473
+ #### `split(value = nil)`
2474
+
2475
+ The method `split` divides an array by a separator and returns the resulting chunks.
2476
+
2477
+ If a block is passed the separators are those elements of the array for which the block returns true:
2478
+
2479
+ ```ruby
2480
+ (-5..5).to_a.split { |i| i.multiple_of?(4) }
2481
+ # => [[-5], [-3, -2, -1], [1, 2, 3], [5]]
2482
+ ```
2483
+
2484
+ Otherwise, the value received as argument, which defaults to `nil`, is the separator:
2485
+
2486
+ ```ruby
2487
+ [0, 1, -5, 1, 1, "foo", "bar"].split(1)
2488
+ # => [[0], [-5], [], ["foo", "bar"]]
2489
+ ```
2490
+
2491
+ TIP: Observe in the previous example that consecutive separators result in empty arrays.
2492
+
2493
+ NOTE: Defined in `active_support/core_ext/array/grouping.rb`.
2494
+
2495
+ Extensions to `Hash`
2496
+ --------------------
2497
+
2498
+ ### Conversions
2499
+
2500
+ #### `to_xml`
2501
+
2502
+ The method `to_xml` returns a string containing an XML representation of its receiver:
2503
+
2504
+ ```ruby
2505
+ {"foo" => 1, "bar" => 2}.to_xml
2506
+ # =>
2507
+ # <?xml version="1.0" encoding="UTF-8"?>
2508
+ # <hash>
2509
+ # <foo type="integer">1</foo>
2510
+ # <bar type="integer">2</bar>
2511
+ # </hash>
2512
+ ```
2513
+
2514
+ To do so, the method loops over the pairs and builds nodes that depend on the _values_. Given a pair `key`, `value`:
2515
+
2516
+ * If `value` is a hash there's a recursive call with `key` as `:root`.
2517
+
2518
+ * If `value` is an array there's a recursive call with `key` as `:root`, and `key` singularized as `:children`.
2519
+
2520
+ * If `value` is a callable object it must expect one or two arguments. Depending on the arity, the callable is invoked with the `options` hash as first argument with `key` as `:root`, and `key` singularized as second argument. Its return value becomes a new node.
2521
+
2522
+ * If `value` responds to `to_xml` the method is invoked with `key` as `:root`.
2523
+
2524
+ * Otherwise, a node with `key` as tag is created with a string representation of `value` as text node. If `value` is `nil` an attribute "nil" set to "true" is added. Unless the option `:skip_types` exists and is true, an attribute "type" is added as well according to the following mapping:
2525
+
2526
+ ```ruby
2527
+ XML_TYPE_NAMES = {
2528
+ "Symbol" => "symbol",
2529
+ "Integer" => "integer",
2530
+ "BigDecimal" => "decimal",
2531
+ "Float" => "float",
2532
+ "TrueClass" => "boolean",
2533
+ "FalseClass" => "boolean",
2534
+ "Date" => "date",
2535
+ "DateTime" => "datetime",
2536
+ "Time" => "datetime"
2537
+ }
2538
+ ```
2539
+
2540
+ By default the root node is "hash", but that's configurable via the `:root` option.
2541
+
2542
+ The default XML builder is a fresh instance of `Builder::XmlMarkup`. You can configure your own builder with the `:builder` option. The method also accepts options like `:dasherize` and friends, they are forwarded to the builder.
2543
+
2544
+ NOTE: Defined in `active_support/core_ext/hash/conversions.rb`.
2545
+
2546
+ ### Merging
2547
+
2548
+ Ruby has a built-in method `Hash#merge` that merges two hashes:
2549
+
2550
+ ```ruby
2551
+ {a: 1, b: 1}.merge(a: 0, c: 2)
2552
+ # => {:a=>0, :b=>1, :c=>2}
2553
+ ```
2554
+
2555
+ Active Support defines a few more ways of merging hashes that may be convenient.
2556
+
2557
+ #### `reverse_merge` and `reverse_merge!`
2558
+
2559
+ In case of collision the key in the hash of the argument wins in `merge`. You can support option hashes with default values in a compact way with this idiom:
2560
+
2561
+ ```ruby
2562
+ options = {length: 30, omission: "..."}.merge(options)
2563
+ ```
2564
+
2565
+ Active Support defines `reverse_merge` in case you prefer this alternative notation:
2566
+
2567
+ ```ruby
2568
+ options = options.reverse_merge(length: 30, omission: "...")
2569
+ ```
2570
+
2571
+ And a bang version `reverse_merge!` that performs the merge in place:
2572
+
2573
+ ```ruby
2574
+ options.reverse_merge!(length: 30, omission: "...")
2575
+ ```
2576
+
2577
+ WARNING. Take into account that `reverse_merge!` may change the hash in the caller, which may or may not be a good idea.
2578
+
2579
+ NOTE: Defined in `active_support/core_ext/hash/reverse_merge.rb`.
2580
+
2581
+ #### `reverse_update`
2582
+
2583
+ The method `reverse_update` is an alias for `reverse_merge!`, explained above.
2584
+
2585
+ WARNING. Note that `reverse_update` has no bang.
2586
+
2587
+ NOTE: Defined in `active_support/core_ext/hash/reverse_merge.rb`.
2588
+
2589
+ #### `deep_merge` and `deep_merge!`
2590
+
2591
+ As you can see in the previous example if a key is found in both hashes the value in the one in the argument wins.
2592
+
2593
+ Active Support defines `Hash#deep_merge`. In a deep merge, if a key is found in both hashes and their values are hashes in turn, then their _merge_ becomes the value in the resulting hash:
2594
+
2595
+ ```ruby
2596
+ {a: {b: 1}}.deep_merge(a: {c: 2})
2597
+ # => {:a=>{:b=>1, :c=>2}}
2598
+ ```
2599
+
2600
+ The method `deep_merge!` performs a deep merge in place.
2601
+
2602
+ NOTE: Defined in `active_support/core_ext/hash/deep_merge.rb`.
2603
+
2604
+ ### Deep duplicating
2605
+
2606
+ The method `Hash#deep_dup` duplicates itself and all keys and values
2607
+ inside recursively with Active Support method `Object#deep_dup`. It works like `Enumerator#each_with_object` with sending `deep_dup` method to each pair inside.
2608
+
2609
+ ```ruby
2610
+ hash = { a: 1, b: { c: 2, d: [3, 4] } }
2611
+
2612
+ dup = hash.deep_dup
2613
+ dup[:b][:e] = 5
2614
+ dup[:b][:d] << 5
2615
+
2616
+ hash[:b][:e] == nil # => true
2617
+ hash[:b][:d] == [3, 4] # => true
2618
+ ```
2619
+
2620
+ NOTE: Defined in `active_support/core_ext/object/deep_dup.rb`.
2621
+
2622
+ ### Working with Keys
2623
+
2624
+ #### `except` and `except!`
2625
+
2626
+ The method `except` returns a hash with the keys in the argument list removed, if present:
2627
+
2628
+ ```ruby
2629
+ {a: 1, b: 2}.except(:a) # => {:b=>2}
2630
+ ```
2631
+
2632
+ If the receiver responds to `convert_key`, the method is called on each of the arguments. This allows `except` to play nice with hashes with indifferent access for instance:
2633
+
2634
+ ```ruby
2635
+ {a: 1}.with_indifferent_access.except(:a) # => {}
2636
+ {a: 1}.with_indifferent_access.except("a") # => {}
2637
+ ```
2638
+
2639
+ There's also the bang variant `except!` that removes keys in the very receiver.
2640
+
2641
+ NOTE: Defined in `active_support/core_ext/hash/except.rb`.
2642
+
2643
+ #### `transform_keys` and `transform_keys!`
2644
+
2645
+ The method `transform_keys` accepts a block and returns a hash that has applied the block operations to each of the keys in the receiver:
2646
+
2647
+ ```ruby
2648
+ {nil => nil, 1 => 1, a: :a}.transform_keys { |key| key.to_s.upcase }
2649
+ # => {"" => nil, "1" => 1, "A" => :a}
2650
+ ```
2651
+
2652
+ In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
2653
+
2654
+ ```ruby
2655
+ {"a" => 1, a: 2}.transform_keys { |key| key.to_s.upcase }
2656
+ # The result could either be
2657
+ # => {"A"=>2}
2658
+ # or
2659
+ # => {"A"=>1}
2660
+ ```
2661
+
2662
+ This method may be useful for example to build specialized conversions. For instance `stringify_keys` and `symbolize_keys` use `transform_keys` to perform their key conversions:
2663
+
2664
+ ```ruby
2665
+ def stringify_keys
2666
+ transform_keys { |key| key.to_s }
2667
+ end
2668
+ ...
2669
+ def symbolize_keys
2670
+ transform_keys { |key| key.to_sym rescue key }
2671
+ end
2672
+ ```
2673
+
2674
+ There's also the bang variant `transform_keys!` that applies the block operations to keys in the very receiver.
2675
+
2676
+ Besides that, one can use `deep_transform_keys` and `deep_transform_keys!` to perform the block operation on all the keys in the given hash and all the hashes nested into it. An example of the result is:
2677
+
2678
+ ```ruby
2679
+ {nil => nil, 1 => 1, nested: {a: 3, 5 => 5}}.deep_transform_keys { |key| key.to_s.upcase }
2680
+ # => {""=>nil, "1"=>1, "NESTED"=>{"A"=>3, "5"=>5}}
2681
+ ```
2682
+
2683
+ NOTE: Defined in `active_support/core_ext/hash/keys.rb`.
2684
+
2685
+ #### `stringify_keys` and `stringify_keys!`
2686
+
2687
+ The method `stringify_keys` returns a hash that has a stringified version of the keys in the receiver. It does so by sending `to_s` to them:
2688
+
2689
+ ```ruby
2690
+ {nil => nil, 1 => 1, a: :a}.stringify_keys
2691
+ # => {"" => nil, "1" => 1, "a" => :a}
2692
+ ```
2693
+
2694
+ In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
2695
+
2696
+ ```ruby
2697
+ {"a" => 1, a: 2}.stringify_keys
2698
+ # The result could either be
2699
+ # => {"a"=>2}
2700
+ # or
2701
+ # => {"a"=>1}
2702
+ ```
2703
+
2704
+ This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionView::Helpers::FormHelper` defines:
2705
+
2706
+ ```ruby
2707
+ def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
2708
+ options = options.stringify_keys
2709
+ options["type"] = "checkbox"
2710
+ ...
2711
+ end
2712
+ ```
2713
+
2714
+ The second line can safely access the "type" key, and let the user to pass either `:type` or "type".
2715
+
2716
+ There's also the bang variant `stringify_keys!` that stringifies keys in the very receiver.
2717
+
2718
+ Besides that, one can use `deep_stringify_keys` and `deep_stringify_keys!` to stringify all the keys in the given hash and all the hashes nested into it. An example of the result is:
2719
+
2720
+ ```ruby
2721
+ {nil => nil, 1 => 1, nested: {a: 3, 5 => 5}}.deep_stringify_keys
2722
+ # => {""=>nil, "1"=>1, "nested"=>{"a"=>3, "5"=>5}}
2723
+ ```
2724
+
2725
+ NOTE: Defined in `active_support/core_ext/hash/keys.rb`.
2726
+
2727
+ #### `symbolize_keys` and `symbolize_keys!`
2728
+
2729
+ The method `symbolize_keys` returns a hash that has a symbolized version of the keys in the receiver, where possible. It does so by sending `to_sym` to them:
2730
+
2731
+ ```ruby
2732
+ {nil => nil, 1 => 1, "a" => "a"}.symbolize_keys
2733
+ # => {nil=>nil, 1=>1, :a=>"a"}
2734
+ ```
2735
+
2736
+ WARNING. Note in the previous example only one key was symbolized.
2737
+
2738
+ In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
2739
+
2740
+ ```ruby
2741
+ {"a" => 1, a: 2}.symbolize_keys
2742
+ # The result could either be
2743
+ # => {:a=>2}
2744
+ # or
2745
+ # => {:a=>1}
2746
+ ```
2747
+
2748
+ This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionController::UrlRewriter` defines
2749
+
2750
+ ```ruby
2751
+ def rewrite_path(options)
2752
+ options = options.symbolize_keys
2753
+ options.update(options[:params].symbolize_keys) if options[:params]
2754
+ ...
2755
+ end
2756
+ ```
2757
+
2758
+ The second line can safely access the `:params` key, and let the user to pass either `:params` or "params".
2759
+
2760
+ There's also the bang variant `symbolize_keys!` that symbolizes keys in the very receiver.
2761
+
2762
+ Besides that, one can use `deep_symbolize_keys` and `deep_symbolize_keys!` to symbolize all the keys in the given hash and all the hashes nested into it. An example of the result is:
2763
+
2764
+ ```ruby
2765
+ {nil => nil, 1 => 1, "nested" => {"a" => 3, 5 => 5}}.deep_symbolize_keys
2766
+ # => {nil=>nil, 1=>1, nested:{a:3, 5=>5}}
2767
+ ```
2768
+
2769
+ NOTE: Defined in `active_support/core_ext/hash/keys.rb`.
2770
+
2771
+ #### `to_options` and `to_options!`
2772
+
2773
+ The methods `to_options` and `to_options!` are respectively aliases of `symbolize_keys` and `symbolize_keys!`.
2774
+
2775
+ NOTE: Defined in `active_support/core_ext/hash/keys.rb`.
2776
+
2777
+ #### `assert_valid_keys`
2778
+
2779
+ The method `assert_valid_keys` receives an arbitrary number of arguments, and checks whether the receiver has any key outside that white list. If it does `ArgumentError` is raised.
2780
+
2781
+ ```ruby
2782
+ {a: 1}.assert_valid_keys(:a) # passes
2783
+ {a: 1}.assert_valid_keys("a") # ArgumentError
2784
+ ```
2785
+
2786
+ Active Record does not accept unknown options when building associations, for example. It implements that control via `assert_valid_keys`.
2787
+
2788
+ NOTE: Defined in `active_support/core_ext/hash/keys.rb`.
2789
+
2790
+ ### Working with Values
2791
+
2792
+ #### `transform_values` && `transform_values!`
2793
+
2794
+ The method `transform_values` accepts a block and returns a hash that has applied the block operations to each of the values in the receiver.
2795
+
2796
+ ```ruby
2797
+ { nil => nil, 1 => 1, :x => :a }.transform_values { |value| value.to_s.upcase }
2798
+ # => {nil=>"", 1=>"1", :x=>"A"}
2799
+ ```
2800
+ There's also the bang variant `transform_values!` that applies the block operations to values in the very receiver.
2801
+
2802
+ NOTE: Defined in `active_support/core_ext/hash/transform_values.rb`.
2803
+
2804
+ ### Slicing
2805
+
2806
+ Ruby has built-in support for taking slices out of strings and arrays. Active Support extends slicing to hashes:
2807
+
2808
+ ```ruby
2809
+ {a: 1, b: 2, c: 3}.slice(:a, :c)
2810
+ # => {:a=>1, :c=>3}
2811
+
2812
+ {a: 1, b: 2, c: 3}.slice(:b, :X)
2813
+ # => {:b=>2} # non-existing keys are ignored
2814
+ ```
2815
+
2816
+ If the receiver responds to `convert_key` keys are normalized:
2817
+
2818
+ ```ruby
2819
+ {a: 1, b: 2}.with_indifferent_access.slice("a")
2820
+ # => {:a=>1}
2821
+ ```
2822
+
2823
+ NOTE. Slicing may come in handy for sanitizing option hashes with a white list of keys.
2824
+
2825
+ There's also `slice!` which in addition to perform a slice in place returns what's removed:
2826
+
2827
+ ```ruby
2828
+ hash = {a: 1, b: 2}
2829
+ rest = hash.slice!(:a) # => {:b=>2}
2830
+ hash # => {:a=>1}
2831
+ ```
2832
+
2833
+ NOTE: Defined in `active_support/core_ext/hash/slice.rb`.
2834
+
2835
+ ### Extracting
2836
+
2837
+ The method `extract!` removes and returns the key/value pairs matching the given keys.
2838
+
2839
+ ```ruby
2840
+ hash = {a: 1, b: 2}
2841
+ rest = hash.extract!(:a) # => {:a=>1}
2842
+ hash # => {:b=>2}
2843
+ ```
2844
+
2845
+ The method `extract!` returns the same subclass of Hash, that the receiver is.
2846
+
2847
+ ```ruby
2848
+ hash = {a: 1, b: 2}.with_indifferent_access
2849
+ rest = hash.extract!(:a).class
2850
+ # => ActiveSupport::HashWithIndifferentAccess
2851
+ ```
2852
+
2853
+ NOTE: Defined in `active_support/core_ext/hash/slice.rb`.
2854
+
2855
+ ### Indifferent Access
2856
+
2857
+ The method `with_indifferent_access` returns an `ActiveSupport::HashWithIndifferentAccess` out of its receiver:
2858
+
2859
+ ```ruby
2860
+ {a: 1}.with_indifferent_access["a"] # => 1
2861
+ ```
2862
+
2863
+ NOTE: Defined in `active_support/core_ext/hash/indifferent_access.rb`.
2864
+
2865
+ ### Compacting
2866
+
2867
+ The methods `compact` and `compact!` return a Hash without items with `nil` value.
2868
+
2869
+ ```ruby
2870
+ {a: 1, b: 2, c: nil}.compact # => {a: 1, b: 2}
2871
+ ```
2872
+
2873
+ NOTE: Defined in `active_support/core_ext/hash/compact.rb`.
2874
+
2875
+ Extensions to `Regexp`
2876
+ ----------------------
2877
+
2878
+ ### `multiline?`
2879
+
2880
+ The method `multiline?` says whether a regexp has the `/m` flag set, that is, whether the dot matches newlines.
2881
+
2882
+ ```ruby
2883
+ %r{.}.multiline? # => false
2884
+ %r{.}m.multiline? # => true
2885
+
2886
+ Regexp.new('.').multiline? # => false
2887
+ Regexp.new('.', Regexp::MULTILINE).multiline? # => true
2888
+ ```
2889
+
2890
+ Quails uses this method in a single place, also in the routing code. Multiline regexps are disallowed for route requirements and this flag eases enforcing that constraint.
2891
+
2892
+ ```ruby
2893
+ def assign_route_options(segments, defaults, requirements)
2894
+ ...
2895
+ if requirement.multiline?
2896
+ raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}"
2897
+ end
2898
+ ...
2899
+ end
2900
+ ```
2901
+
2902
+ NOTE: Defined in `active_support/core_ext/regexp.rb`.
2903
+
2904
+ ### `match?`
2905
+
2906
+ Quails implements `Regexp#match?` for Ruby versions prior to 2.4:
2907
+
2908
+ ```ruby
2909
+ /oo/.match?('foo') # => true
2910
+ /oo/.match?('bar') # => false
2911
+ /oo/.match?('foo', 1) # => true
2912
+ ```
2913
+
2914
+ The backport has the same interface and lack of side-effects in the caller like
2915
+ not setting `$1` and friends, but it does not have the speed benefits. Its
2916
+ purpose is to be able to write 2.4 compatible code. Quails itself uses this
2917
+ predicate internally for example.
2918
+
2919
+ Active Support defines `Regexp#match?` only if not present, so code running
2920
+ under 2.4 or later does run the original one and gets the performance boost.
2921
+
2922
+ Extensions to `Range`
2923
+ ---------------------
2924
+
2925
+ ### `to_s`
2926
+
2927
+ Active Support extends the method `Range#to_s` so that it understands an optional format argument. As of this writing the only supported non-default format is `:db`:
2928
+
2929
+ ```ruby
2930
+ (Date.today..Date.tomorrow).to_s
2931
+ # => "2009-10-25..2009-10-26"
2932
+
2933
+ (Date.today..Date.tomorrow).to_s(:db)
2934
+ # => "BETWEEN '2009-10-25' AND '2009-10-26'"
2935
+ ```
2936
+
2937
+ As the example depicts, the `:db` format generates a `BETWEEN` SQL clause. That is used by Active Record in its support for range values in conditions.
2938
+
2939
+ NOTE: Defined in `active_support/core_ext/range/conversions.rb`.
2940
+
2941
+ ### `include?`
2942
+
2943
+ The methods `Range#include?` and `Range#===` say whether some value falls between the ends of a given instance:
2944
+
2945
+ ```ruby
2946
+ (2..3).include?(Math::E) # => true
2947
+ ```
2948
+
2949
+ Active Support extends these methods so that the argument may be another range in turn. In that case we test whether the ends of the argument range belong to the receiver themselves:
2950
+
2951
+ ```ruby
2952
+ (1..10).include?(3..7) # => true
2953
+ (1..10).include?(0..7) # => false
2954
+ (1..10).include?(3..11) # => false
2955
+ (1...9).include?(3..9) # => false
2956
+
2957
+ (1..10) === (3..7) # => true
2958
+ (1..10) === (0..7) # => false
2959
+ (1..10) === (3..11) # => false
2960
+ (1...9) === (3..9) # => false
2961
+ ```
2962
+
2963
+ NOTE: Defined in `active_support/core_ext/range/include_range.rb`.
2964
+
2965
+ ### `overlaps?`
2966
+
2967
+ The method `Range#overlaps?` says whether any two given ranges have non-void intersection:
2968
+
2969
+ ```ruby
2970
+ (1..10).overlaps?(7..11) # => true
2971
+ (1..10).overlaps?(0..7) # => true
2972
+ (1..10).overlaps?(11..27) # => false
2973
+ ```
2974
+
2975
+ NOTE: Defined in `active_support/core_ext/range/overlaps.rb`.
2976
+
2977
+ Extensions to `Date`
2978
+ --------------------
2979
+
2980
+ ### Calculations
2981
+
2982
+ NOTE: All the following methods are defined in `active_support/core_ext/date/calculations.rb`.
2983
+
2984
+ INFO: The following calculation methods have edge cases in October 1582, since days 5..14 just do not exist. This guide does not document their behavior around those days for brevity, but it is enough to say that they do what you would expect. That is, `Date.new(1582, 10, 4).tomorrow` returns `Date.new(1582, 10, 15)` and so on. Please check `test/core_ext/date_ext_test.rb` in the Active Support test suite for expected behavior.
2985
+
2986
+ #### `Date.current`
2987
+
2988
+ Active Support defines `Date.current` to be today in the current time zone. That's like `Date.today`, except that it honors the user time zone, if defined. It also defines `Date.yesterday` and `Date.tomorrow`, and the instance predicates `past?`, `today?`, `future?`, `on_weekday?` and `on_weekend?`, all of them relative to `Date.current`.
2989
+
2990
+ When making Date comparisons using methods which honor the user time zone, make sure to use `Date.current` and not `Date.today`. There are cases where the user time zone might be in the future compared to the system time zone, which `Date.today` uses by default. This means `Date.today` may equal `Date.yesterday`.
2991
+
2992
+ #### Named dates
2993
+
2994
+ ##### `prev_year`, `next_year`
2995
+
2996
+ In Ruby 1.9 `prev_year` and `next_year` return a date with the same day/month in the last or next year:
2997
+
2998
+ ```ruby
2999
+ d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
3000
+ d.prev_year # => Fri, 08 May 2009
3001
+ d.next_year # => Sun, 08 May 2011
3002
+ ```
3003
+
3004
+ If date is the 29th of February of a leap year, you obtain the 28th:
3005
+
3006
+ ```ruby
3007
+ d = Date.new(2000, 2, 29) # => Tue, 29 Feb 2000
3008
+ d.prev_year # => Sun, 28 Feb 1999
3009
+ d.next_year # => Wed, 28 Feb 2001
3010
+ ```
3011
+
3012
+ `prev_year` is aliased to `last_year`.
3013
+
3014
+ ##### `prev_month`, `next_month`
3015
+
3016
+ In Ruby 1.9 `prev_month` and `next_month` return the date with the same day in the last or next month:
3017
+
3018
+ ```ruby
3019
+ d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
3020
+ d.prev_month # => Thu, 08 Apr 2010
3021
+ d.next_month # => Tue, 08 Jun 2010
3022
+ ```
3023
+
3024
+ If such a day does not exist, the last day of the corresponding month is returned:
3025
+
3026
+ ```ruby
3027
+ Date.new(2000, 5, 31).prev_month # => Sun, 30 Apr 2000
3028
+ Date.new(2000, 3, 31).prev_month # => Tue, 29 Feb 2000
3029
+ Date.new(2000, 5, 31).next_month # => Fri, 30 Jun 2000
3030
+ Date.new(2000, 1, 31).next_month # => Tue, 29 Feb 2000
3031
+ ```
3032
+
3033
+ `prev_month` is aliased to `last_month`.
3034
+
3035
+ ##### `prev_quarter`, `next_quarter`
3036
+
3037
+ Same as `prev_month` and `next_month`. It returns the date with the same day in the previous or next quarter:
3038
+
3039
+ ```ruby
3040
+ t = Time.local(2010, 5, 8) # => Sat, 08 May 2010
3041
+ t.prev_quarter # => Mon, 08 Feb 2010
3042
+ t.next_quarter # => Sun, 08 Aug 2010
3043
+ ```
3044
+
3045
+ If such a day does not exist, the last day of the corresponding month is returned:
3046
+
3047
+ ```ruby
3048
+ Time.local(2000, 7, 31).prev_quarter # => Sun, 30 Apr 2000
3049
+ Time.local(2000, 5, 31).prev_quarter # => Tue, 29 Feb 2000
3050
+ Time.local(2000, 10, 31).prev_quarter # => Mon, 30 Oct 2000
3051
+ Time.local(2000, 11, 31).next_quarter # => Wed, 28 Feb 2001
3052
+ ```
3053
+
3054
+ `prev_quarter` is aliased to `last_quarter`.
3055
+
3056
+ ##### `beginning_of_week`, `end_of_week`
3057
+
3058
+ The methods `beginning_of_week` and `end_of_week` return the dates for the
3059
+ beginning and end of the week, respectively. Weeks are assumed to start on
3060
+ Monday, but that can be changed passing an argument, setting thread local
3061
+ `Date.beginning_of_week` or `config.beginning_of_week`.
3062
+
3063
+ ```ruby
3064
+ d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
3065
+ d.beginning_of_week # => Mon, 03 May 2010
3066
+ d.beginning_of_week(:sunday) # => Sun, 02 May 2010
3067
+ d.end_of_week # => Sun, 09 May 2010
3068
+ d.end_of_week(:sunday) # => Sat, 08 May 2010
3069
+ ```
3070
+
3071
+ `beginning_of_week` is aliased to `at_beginning_of_week` and `end_of_week` is aliased to `at_end_of_week`.
3072
+
3073
+ ##### `monday`, `sunday`
3074
+
3075
+ The methods `monday` and `sunday` return the dates for the previous Monday and
3076
+ next Sunday, respectively.
3077
+
3078
+ ```ruby
3079
+ d = Date.new(2010, 5, 8) # => Sat, 08 May 2010
3080
+ d.monday # => Mon, 03 May 2010
3081
+ d.sunday # => Sun, 09 May 2010
3082
+
3083
+ d = Date.new(2012, 9, 10) # => Mon, 10 Sep 2012
3084
+ d.monday # => Mon, 10 Sep 2012
3085
+
3086
+ d = Date.new(2012, 9, 16) # => Sun, 16 Sep 2012
3087
+ d.sunday # => Sun, 16 Sep 2012
3088
+ ```
3089
+
3090
+ ##### `prev_week`, `next_week`
3091
+
3092
+ The method `next_week` receives a symbol with a day name in English (default is the thread local `Date.beginning_of_week`, or `config.beginning_of_week`, or `:monday`) and it returns the date corresponding to that day.
3093
+
3094
+ ```ruby
3095
+ d = Date.new(2010, 5, 9) # => Sun, 09 May 2010
3096
+ d.next_week # => Mon, 10 May 2010
3097
+ d.next_week(:saturday) # => Sat, 15 May 2010
3098
+ ```
3099
+
3100
+ The method `prev_week` is analogous:
3101
+
3102
+ ```ruby
3103
+ d.prev_week # => Mon, 26 Apr 2010
3104
+ d.prev_week(:saturday) # => Sat, 01 May 2010
3105
+ d.prev_week(:friday) # => Fri, 30 Apr 2010
3106
+ ```
3107
+
3108
+ `prev_week` is aliased to `last_week`.
3109
+
3110
+ Both `next_week` and `prev_week` work as expected when `Date.beginning_of_week` or `config.beginning_of_week` are set.
3111
+
3112
+ ##### `beginning_of_month`, `end_of_month`
3113
+
3114
+ The methods `beginning_of_month` and `end_of_month` return the dates for the beginning and end of the month:
3115
+
3116
+ ```ruby
3117
+ d = Date.new(2010, 5, 9) # => Sun, 09 May 2010
3118
+ d.beginning_of_month # => Sat, 01 May 2010
3119
+ d.end_of_month # => Mon, 31 May 2010
3120
+ ```
3121
+
3122
+ `beginning_of_month` is aliased to `at_beginning_of_month`, and `end_of_month` is aliased to `at_end_of_month`.
3123
+
3124
+ ##### `beginning_of_quarter`, `end_of_quarter`
3125
+
3126
+ The methods `beginning_of_quarter` and `end_of_quarter` return the dates for the beginning and end of the quarter of the receiver's calendar year:
3127
+
3128
+ ```ruby
3129
+ d = Date.new(2010, 5, 9) # => Sun, 09 May 2010
3130
+ d.beginning_of_quarter # => Thu, 01 Apr 2010
3131
+ d.end_of_quarter # => Wed, 30 Jun 2010
3132
+ ```
3133
+
3134
+ `beginning_of_quarter` is aliased to `at_beginning_of_quarter`, and `end_of_quarter` is aliased to `at_end_of_quarter`.
3135
+
3136
+ ##### `beginning_of_year`, `end_of_year`
3137
+
3138
+ The methods `beginning_of_year` and `end_of_year` return the dates for the beginning and end of the year:
3139
+
3140
+ ```ruby
3141
+ d = Date.new(2010, 5, 9) # => Sun, 09 May 2010
3142
+ d.beginning_of_year # => Fri, 01 Jan 2010
3143
+ d.end_of_year # => Fri, 31 Dec 2010
3144
+ ```
3145
+
3146
+ `beginning_of_year` is aliased to `at_beginning_of_year`, and `end_of_year` is aliased to `at_end_of_year`.
3147
+
3148
+ #### Other Date Computations
3149
+
3150
+ ##### `years_ago`, `years_since`
3151
+
3152
+ The method `years_ago` receives a number of years and returns the same date those many years ago:
3153
+
3154
+ ```ruby
3155
+ date = Date.new(2010, 6, 7)
3156
+ date.years_ago(10) # => Wed, 07 Jun 2000
3157
+ ```
3158
+
3159
+ `years_since` moves forward in time:
3160
+
3161
+ ```ruby
3162
+ date = Date.new(2010, 6, 7)
3163
+ date.years_since(10) # => Sun, 07 Jun 2020
3164
+ ```
3165
+
3166
+ If such a day does not exist, the last day of the corresponding month is returned:
3167
+
3168
+ ```ruby
3169
+ Date.new(2012, 2, 29).years_ago(3) # => Sat, 28 Feb 2009
3170
+ Date.new(2012, 2, 29).years_since(3) # => Sat, 28 Feb 2015
3171
+ ```
3172
+
3173
+ ##### `months_ago`, `months_since`
3174
+
3175
+ The methods `months_ago` and `months_since` work analogously for months:
3176
+
3177
+ ```ruby
3178
+ Date.new(2010, 4, 30).months_ago(2) # => Sun, 28 Feb 2010
3179
+ Date.new(2010, 4, 30).months_since(2) # => Wed, 30 Jun 2010
3180
+ ```
3181
+
3182
+ If such a day does not exist, the last day of the corresponding month is returned:
3183
+
3184
+ ```ruby
3185
+ Date.new(2010, 4, 30).months_ago(2) # => Sun, 28 Feb 2010
3186
+ Date.new(2009, 12, 31).months_since(2) # => Sun, 28 Feb 2010
3187
+ ```
3188
+
3189
+ ##### `weeks_ago`
3190
+
3191
+ The method `weeks_ago` works analogously for weeks:
3192
+
3193
+ ```ruby
3194
+ Date.new(2010, 5, 24).weeks_ago(1) # => Mon, 17 May 2010
3195
+ Date.new(2010, 5, 24).weeks_ago(2) # => Mon, 10 May 2010
3196
+ ```
3197
+
3198
+ ##### `advance`
3199
+
3200
+ The most generic way to jump to other days is `advance`. This method receives a hash with keys `:years`, `:months`, `:weeks`, `:days`, and returns a date advanced as much as the present keys indicate:
3201
+
3202
+ ```ruby
3203
+ date = Date.new(2010, 6, 6)
3204
+ date.advance(years: 1, weeks: 2) # => Mon, 20 Jun 2011
3205
+ date.advance(months: 2, days: -2) # => Wed, 04 Aug 2010
3206
+ ```
3207
+
3208
+ Note in the previous example that increments may be negative.
3209
+
3210
+ To perform the computation the method first increments years, then months, then weeks, and finally days. This order is important towards the end of months. Say for example we are at the end of February of 2010, and we want to move one month and one day forward.
3211
+
3212
+ The method `advance` advances first one month, and then one day, the result is:
3213
+
3214
+ ```ruby
3215
+ Date.new(2010, 2, 28).advance(months: 1, days: 1)
3216
+ # => Sun, 29 Mar 2010
3217
+ ```
3218
+
3219
+ While if it did it the other way around the result would be different:
3220
+
3221
+ ```ruby
3222
+ Date.new(2010, 2, 28).advance(days: 1).advance(months: 1)
3223
+ # => Thu, 01 Apr 2010
3224
+ ```
3225
+
3226
+ #### Changing Components
3227
+
3228
+ The method `change` allows you to get a new date which is the same as the receiver except for the given year, month, or day:
3229
+
3230
+ ```ruby
3231
+ Date.new(2010, 12, 23).change(year: 2011, month: 11)
3232
+ # => Wed, 23 Nov 2011
3233
+ ```
3234
+
3235
+ This method is not tolerant to non-existing dates, if the change is invalid `ArgumentError` is raised:
3236
+
3237
+ ```ruby
3238
+ Date.new(2010, 1, 31).change(month: 2)
3239
+ # => ArgumentError: invalid date
3240
+ ```
3241
+
3242
+ #### Durations
3243
+
3244
+ Durations can be added to and subtracted from dates:
3245
+
3246
+ ```ruby
3247
+ d = Date.current
3248
+ # => Mon, 09 Aug 2010
3249
+ d + 1.year
3250
+ # => Tue, 09 Aug 2011
3251
+ d - 3.hours
3252
+ # => Sun, 08 Aug 2010 21:00:00 UTC +00:00
3253
+ ```
3254
+
3255
+ They translate to calls to `since` or `advance`. For example here we get the correct jump in the calendar reform:
3256
+
3257
+ ```ruby
3258
+ Date.new(1582, 10, 4) + 1.day
3259
+ # => Fri, 15 Oct 1582
3260
+ ```
3261
+
3262
+ #### Timestamps
3263
+
3264
+ INFO: The following methods return a `Time` object if possible, otherwise a `DateTime`. If set, they honor the user time zone.
3265
+
3266
+ ##### `beginning_of_day`, `end_of_day`
3267
+
3268
+ The method `beginning_of_day` returns a timestamp at the beginning of the day (00:00:00):
3269
+
3270
+ ```ruby
3271
+ date = Date.new(2010, 6, 7)
3272
+ date.beginning_of_day # => Mon Jun 07 00:00:00 +0200 2010
3273
+ ```
3274
+
3275
+ The method `end_of_day` returns a timestamp at the end of the day (23:59:59):
3276
+
3277
+ ```ruby
3278
+ date = Date.new(2010, 6, 7)
3279
+ date.end_of_day # => Mon Jun 07 23:59:59 +0200 2010
3280
+ ```
3281
+
3282
+ `beginning_of_day` is aliased to `at_beginning_of_day`, `midnight`, `at_midnight`.
3283
+
3284
+ ##### `beginning_of_hour`, `end_of_hour`
3285
+
3286
+ The method `beginning_of_hour` returns a timestamp at the beginning of the hour (hh:00:00):
3287
+
3288
+ ```ruby
3289
+ date = DateTime.new(2010, 6, 7, 19, 55, 25)
3290
+ date.beginning_of_hour # => Mon Jun 07 19:00:00 +0200 2010
3291
+ ```
3292
+
3293
+ The method `end_of_hour` returns a timestamp at the end of the hour (hh:59:59):
3294
+
3295
+ ```ruby
3296
+ date = DateTime.new(2010, 6, 7, 19, 55, 25)
3297
+ date.end_of_hour # => Mon Jun 07 19:59:59 +0200 2010
3298
+ ```
3299
+
3300
+ `beginning_of_hour` is aliased to `at_beginning_of_hour`.
3301
+
3302
+ ##### `beginning_of_minute`, `end_of_minute`
3303
+
3304
+ The method `beginning_of_minute` returns a timestamp at the beginning of the minute (hh:mm:00):
3305
+
3306
+ ```ruby
3307
+ date = DateTime.new(2010, 6, 7, 19, 55, 25)
3308
+ date.beginning_of_minute # => Mon Jun 07 19:55:00 +0200 2010
3309
+ ```
3310
+
3311
+ The method `end_of_minute` returns a timestamp at the end of the minute (hh:mm:59):
3312
+
3313
+ ```ruby
3314
+ date = DateTime.new(2010, 6, 7, 19, 55, 25)
3315
+ date.end_of_minute # => Mon Jun 07 19:55:59 +0200 2010
3316
+ ```
3317
+
3318
+ `beginning_of_minute` is aliased to `at_beginning_of_minute`.
3319
+
3320
+ INFO: `beginning_of_hour`, `end_of_hour`, `beginning_of_minute` and `end_of_minute` are implemented for `Time` and `DateTime` but **not** `Date` as it does not make sense to request the beginning or end of an hour or minute on a `Date` instance.
3321
+
3322
+ ##### `ago`, `since`
3323
+
3324
+ The method `ago` receives a number of seconds as argument and returns a timestamp those many seconds ago from midnight:
3325
+
3326
+ ```ruby
3327
+ date = Date.current # => Fri, 11 Jun 2010
3328
+ date.ago(1) # => Thu, 10 Jun 2010 23:59:59 EDT -04:00
3329
+ ```
3330
+
3331
+ Similarly, `since` moves forward:
3332
+
3333
+ ```ruby
3334
+ date = Date.current # => Fri, 11 Jun 2010
3335
+ date.since(1) # => Fri, 11 Jun 2010 00:00:01 EDT -04:00
3336
+ ```
3337
+
3338
+ #### Other Time Computations
3339
+
3340
+ ### Conversions
3341
+
3342
+ Extensions to `DateTime`
3343
+ ------------------------
3344
+
3345
+ WARNING: `DateTime` is not aware of DST rules and so some of these methods have edge cases when a DST change is going on. For example `seconds_since_midnight` might not return the real amount in such a day.
3346
+
3347
+ ### Calculations
3348
+
3349
+ NOTE: All the following methods are defined in `active_support/core_ext/date_time/calculations.rb`.
3350
+
3351
+ The class `DateTime` is a subclass of `Date` so by loading `active_support/core_ext/date/calculations.rb` you inherit these methods and their aliases, except that they will always return datetimes:
3352
+
3353
+ ```ruby
3354
+ yesterday
3355
+ tomorrow
3356
+ beginning_of_week (at_beginning_of_week)
3357
+ end_of_week (at_end_of_week)
3358
+ monday
3359
+ sunday
3360
+ weeks_ago
3361
+ prev_week (last_week)
3362
+ next_week
3363
+ months_ago
3364
+ months_since
3365
+ beginning_of_month (at_beginning_of_month)
3366
+ end_of_month (at_end_of_month)
3367
+ prev_month (last_month)
3368
+ next_month
3369
+ beginning_of_quarter (at_beginning_of_quarter)
3370
+ end_of_quarter (at_end_of_quarter)
3371
+ beginning_of_year (at_beginning_of_year)
3372
+ end_of_year (at_end_of_year)
3373
+ years_ago
3374
+ years_since
3375
+ prev_year (last_year)
3376
+ next_year
3377
+ on_weekday?
3378
+ on_weekend?
3379
+ ```
3380
+
3381
+ The following methods are reimplemented so you do **not** need to load `active_support/core_ext/date/calculations.rb` for these ones:
3382
+
3383
+ ```ruby
3384
+ beginning_of_day (midnight, at_midnight, at_beginning_of_day)
3385
+ end_of_day
3386
+ ago
3387
+ since (in)
3388
+ ```
3389
+
3390
+ On the other hand, `advance` and `change` are also defined and support more options, they are documented below.
3391
+
3392
+ The following methods are only implemented in `active_support/core_ext/date_time/calculations.rb` as they only make sense when used with a `DateTime` instance:
3393
+
3394
+ ```ruby
3395
+ beginning_of_hour (at_beginning_of_hour)
3396
+ end_of_hour
3397
+ ```
3398
+
3399
+ #### Named Datetimes
3400
+
3401
+ ##### `DateTime.current`
3402
+
3403
+ Active Support defines `DateTime.current` to be like `Time.now.to_datetime`, except that it honors the user time zone, if defined. It also defines `DateTime.yesterday` and `DateTime.tomorrow`, and the instance predicates `past?`, and `future?` relative to `DateTime.current`.
3404
+
3405
+ #### Other Extensions
3406
+
3407
+ ##### `seconds_since_midnight`
3408
+
3409
+ The method `seconds_since_midnight` returns the number of seconds since midnight:
3410
+
3411
+ ```ruby
3412
+ now = DateTime.current # => Mon, 07 Jun 2010 20:26:36 +0000
3413
+ now.seconds_since_midnight # => 73596
3414
+ ```
3415
+
3416
+ ##### `utc`
3417
+
3418
+ The method `utc` gives you the same datetime in the receiver expressed in UTC.
3419
+
3420
+ ```ruby
3421
+ now = DateTime.current # => Mon, 07 Jun 2010 19:27:52 -0400
3422
+ now.utc # => Mon, 07 Jun 2010 23:27:52 +0000
3423
+ ```
3424
+
3425
+ This method is also aliased as `getutc`.
3426
+
3427
+ ##### `utc?`
3428
+
3429
+ The predicate `utc?` says whether the receiver has UTC as its time zone:
3430
+
3431
+ ```ruby
3432
+ now = DateTime.now # => Mon, 07 Jun 2010 19:30:47 -0400
3433
+ now.utc? # => false
3434
+ now.utc.utc? # => true
3435
+ ```
3436
+
3437
+ ##### `advance`
3438
+
3439
+ The most generic way to jump to another datetime is `advance`. This method receives a hash with keys `:years`, `:months`, `:weeks`, `:days`, `:hours`, `:minutes`, and `:seconds`, and returns a datetime advanced as much as the present keys indicate.
3440
+
3441
+ ```ruby
3442
+ d = DateTime.current
3443
+ # => Thu, 05 Aug 2010 11:33:31 +0000
3444
+ d.advance(years: 1, months: 1, days: 1, hours: 1, minutes: 1, seconds: 1)
3445
+ # => Tue, 06 Sep 2011 12:34:32 +0000
3446
+ ```
3447
+
3448
+ This method first computes the destination date passing `:years`, `:months`, `:weeks`, and `:days` to `Date#advance` documented above. After that, it adjusts the time calling `since` with the number of seconds to advance. This order is relevant, a different ordering would give different datetimes in some edge-cases. The example in `Date#advance` applies, and we can extend it to show order relevance related to the time bits.
3449
+
3450
+ If we first move the date bits (that have also a relative order of processing, as documented before), and then the time bits we get for example the following computation:
3451
+
3452
+ ```ruby
3453
+ d = DateTime.new(2010, 2, 28, 23, 59, 59)
3454
+ # => Sun, 28 Feb 2010 23:59:59 +0000
3455
+ d.advance(months: 1, seconds: 1)
3456
+ # => Mon, 29 Mar 2010 00:00:00 +0000
3457
+ ```
3458
+
3459
+ but if we computed them the other way around, the result would be different:
3460
+
3461
+ ```ruby
3462
+ d.advance(seconds: 1).advance(months: 1)
3463
+ # => Thu, 01 Apr 2010 00:00:00 +0000
3464
+ ```
3465
+
3466
+ WARNING: Since `DateTime` is not DST-aware you can end up in a non-existing point in time with no warning or error telling you so.
3467
+
3468
+ #### Changing Components
3469
+
3470
+ The method `change` allows you to get a new datetime which is the same as the receiver except for the given options, which may include `:year`, `:month`, `:day`, `:hour`, `:min`, `:sec`, `:offset`, `:start`:
3471
+
3472
+ ```ruby
3473
+ now = DateTime.current
3474
+ # => Tue, 08 Jun 2010 01:56:22 +0000
3475
+ now.change(year: 2011, offset: Rational(-6, 24))
3476
+ # => Wed, 08 Jun 2011 01:56:22 -0600
3477
+ ```
3478
+
3479
+ If hours are zeroed, then minutes and seconds are too (unless they have given values):
3480
+
3481
+ ```ruby
3482
+ now.change(hour: 0)
3483
+ # => Tue, 08 Jun 2010 00:00:00 +0000
3484
+ ```
3485
+
3486
+ Similarly, if minutes are zeroed, then seconds are too (unless it has given a value):
3487
+
3488
+ ```ruby
3489
+ now.change(min: 0)
3490
+ # => Tue, 08 Jun 2010 01:00:00 +0000
3491
+ ```
3492
+
3493
+ This method is not tolerant to non-existing dates, if the change is invalid `ArgumentError` is raised:
3494
+
3495
+ ```ruby
3496
+ DateTime.current.change(month: 2, day: 30)
3497
+ # => ArgumentError: invalid date
3498
+ ```
3499
+
3500
+ #### Durations
3501
+
3502
+ Durations can be added to and subtracted from datetimes:
3503
+
3504
+ ```ruby
3505
+ now = DateTime.current
3506
+ # => Mon, 09 Aug 2010 23:15:17 +0000
3507
+ now + 1.year
3508
+ # => Tue, 09 Aug 2011 23:15:17 +0000
3509
+ now - 1.week
3510
+ # => Mon, 02 Aug 2010 23:15:17 +0000
3511
+ ```
3512
+
3513
+ They translate to calls to `since` or `advance`. For example here we get the correct jump in the calendar reform:
3514
+
3515
+ ```ruby
3516
+ DateTime.new(1582, 10, 4, 23) + 1.hour
3517
+ # => Fri, 15 Oct 1582 00:00:00 +0000
3518
+ ```
3519
+
3520
+ Extensions to `Time`
3521
+ --------------------
3522
+
3523
+ ### Calculations
3524
+
3525
+ NOTE: All the following methods are defined in `active_support/core_ext/time/calculations.rb`.
3526
+
3527
+ Active Support adds to `Time` many of the methods available for `DateTime`:
3528
+
3529
+ ```ruby
3530
+ past?
3531
+ today?
3532
+ future?
3533
+ yesterday
3534
+ tomorrow
3535
+ seconds_since_midnight
3536
+ change
3537
+ advance
3538
+ ago
3539
+ since (in)
3540
+ beginning_of_day (midnight, at_midnight, at_beginning_of_day)
3541
+ end_of_day
3542
+ beginning_of_hour (at_beginning_of_hour)
3543
+ end_of_hour
3544
+ beginning_of_week (at_beginning_of_week)
3545
+ end_of_week (at_end_of_week)
3546
+ monday
3547
+ sunday
3548
+ weeks_ago
3549
+ prev_week (last_week)
3550
+ next_week
3551
+ months_ago
3552
+ months_since
3553
+ beginning_of_month (at_beginning_of_month)
3554
+ end_of_month (at_end_of_month)
3555
+ prev_month (last_month)
3556
+ next_month
3557
+ beginning_of_quarter (at_beginning_of_quarter)
3558
+ end_of_quarter (at_end_of_quarter)
3559
+ beginning_of_year (at_beginning_of_year)
3560
+ end_of_year (at_end_of_year)
3561
+ years_ago
3562
+ years_since
3563
+ prev_year (last_year)
3564
+ next_year
3565
+ on_weekday?
3566
+ on_weekend?
3567
+ ```
3568
+
3569
+ They are analogous. Please refer to their documentation above and take into account the following differences:
3570
+
3571
+ * `change` accepts an additional `:usec` option.
3572
+ * `Time` understands DST, so you get correct DST calculations as in
3573
+
3574
+ ```ruby
3575
+ Time.zone_default
3576
+ # => #<ActiveSupport::TimeZone:0x7f73654d4f38 @utc_offset=nil, @name="Madrid", ...>
3577
+
3578
+ # In Barcelona, 2010/03/28 02:00 +0100 becomes 2010/03/28 03:00 +0200 due to DST.
3579
+ t = Time.local(2010, 3, 28, 1, 59, 59)
3580
+ # => Sun Mar 28 01:59:59 +0100 2010
3581
+ t.advance(seconds: 1)
3582
+ # => Sun Mar 28 03:00:00 +0200 2010
3583
+ ```
3584
+
3585
+ * If `since` or `ago` jump to a time that can't be expressed with `Time` a `DateTime` object is returned instead.
3586
+
3587
+ #### `Time.current`
3588
+
3589
+ Active Support defines `Time.current` to be today in the current time zone. That's like `Time.now`, except that it honors the user time zone, if defined. It also defines the instance predicates `past?`, `today?`, and `future?`, all of them relative to `Time.current`.
3590
+
3591
+ When making Time comparisons using methods which honor the user time zone, make sure to use `Time.current` instead of `Time.now`. There are cases where the user time zone might be in the future compared to the system time zone, which `Time.now` uses by default. This means `Time.now.to_date` may equal `Date.yesterday`.
3592
+
3593
+ #### `all_day`, `all_week`, `all_month`, `all_quarter` and `all_year`
3594
+
3595
+ The method `all_day` returns a range representing the whole day of the current time.
3596
+
3597
+ ```ruby
3598
+ now = Time.current
3599
+ # => Mon, 09 Aug 2010 23:20:05 UTC +00:00
3600
+ now.all_day
3601
+ # => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Mon, 09 Aug 2010 23:59:59 UTC +00:00
3602
+ ```
3603
+
3604
+ Analogously, `all_week`, `all_month`, `all_quarter` and `all_year` all serve the purpose of generating time ranges.
3605
+
3606
+ ```ruby
3607
+ now = Time.current
3608
+ # => Mon, 09 Aug 2010 23:20:05 UTC +00:00
3609
+ now.all_week
3610
+ # => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Sun, 15 Aug 2010 23:59:59 UTC +00:00
3611
+ now.all_week(:sunday)
3612
+ # => Sun, 16 Sep 2012 00:00:00 UTC +00:00..Sat, 22 Sep 2012 23:59:59 UTC +00:00
3613
+ now.all_month
3614
+ # => Sat, 01 Aug 2010 00:00:00 UTC +00:00..Tue, 31 Aug 2010 23:59:59 UTC +00:00
3615
+ now.all_quarter
3616
+ # => Thu, 01 Jul 2010 00:00:00 UTC +00:00..Thu, 30 Sep 2010 23:59:59 UTC +00:00
3617
+ now.all_year
3618
+ # => Fri, 01 Jan 2010 00:00:00 UTC +00:00..Fri, 31 Dec 2010 23:59:59 UTC +00:00
3619
+ ```
3620
+
3621
+ ### Time Constructors
3622
+
3623
+ Active Support defines `Time.current` to be `Time.zone.now` if there's a user time zone defined, with fallback to `Time.now`:
3624
+
3625
+ ```ruby
3626
+ Time.zone_default
3627
+ # => #<ActiveSupport::TimeZone:0x7f73654d4f38 @utc_offset=nil, @name="Madrid", ...>
3628
+ Time.current
3629
+ # => Fri, 06 Aug 2010 17:11:58 CEST +02:00
3630
+ ```
3631
+
3632
+ Analogously to `DateTime`, the predicates `past?`, and `future?` are relative to `Time.current`.
3633
+
3634
+ If the time to be constructed lies beyond the range supported by `Time` in the runtime platform, usecs are discarded and a `DateTime` object is returned instead.
3635
+
3636
+ #### Durations
3637
+
3638
+ Durations can be added to and subtracted from time objects:
3639
+
3640
+ ```ruby
3641
+ now = Time.current
3642
+ # => Mon, 09 Aug 2010 23:20:05 UTC +00:00
3643
+ now + 1.year
3644
+ # => Tue, 09 Aug 2011 23:21:11 UTC +00:00
3645
+ now - 1.week
3646
+ # => Mon, 02 Aug 2010 23:21:11 UTC +00:00
3647
+ ```
3648
+
3649
+ They translate to calls to `since` or `advance`. For example here we get the correct jump in the calendar reform:
3650
+
3651
+ ```ruby
3652
+ Time.utc(1582, 10, 3) + 5.days
3653
+ # => Mon Oct 18 00:00:00 UTC 1582
3654
+ ```
3655
+
3656
+ Extensions to `File`
3657
+ --------------------
3658
+
3659
+ ### `atomic_write`
3660
+
3661
+ With the class method `File.atomic_write` you can write to a file in a way that will prevent any reader from seeing half-written content.
3662
+
3663
+ The name of the file is passed as an argument, and the method yields a file handle opened for writing. Once the block is done `atomic_write` closes the file handle and completes its job.
3664
+
3665
+ For example, Action Pack uses this method to write asset cache files like `all.css`:
3666
+
3667
+ ```ruby
3668
+ File.atomic_write(joined_asset_path) do |cache|
3669
+ cache.write(join_asset_file_contents(asset_paths))
3670
+ end
3671
+ ```
3672
+
3673
+ To accomplish this `atomic_write` creates a temporary file. That's the file the code in the block actually writes to. On completion, the temporary file is renamed, which is an atomic operation on POSIX systems. If the target file exists `atomic_write` overwrites it and keeps owners and permissions. However there are a few cases where `atomic_write` cannot change the file ownership or permissions, this error is caught and skipped over trusting in the user/filesystem to ensure the file is accessible to the processes that need it.
3674
+
3675
+ NOTE. Due to the chmod operation `atomic_write` performs, if the target file has an ACL set on it this ACL will be recalculated/modified.
3676
+
3677
+ WARNING. Note you can't append with `atomic_write`.
3678
+
3679
+ The auxiliary file is written in a standard directory for temporary files, but you can pass a directory of your choice as second argument.
3680
+
3681
+ NOTE: Defined in `active_support/core_ext/file/atomic.rb`.
3682
+
3683
+ Extensions to `Marshal`
3684
+ -----------------------
3685
+
3686
+ ### `load`
3687
+
3688
+ Active Support adds constant autoloading support to `load`.
3689
+
3690
+ For example, the file cache store deserializes this way:
3691
+
3692
+ ```ruby
3693
+ File.open(file_name) { |f| Marshal.load(f) }
3694
+ ```
3695
+
3696
+ If the cached data refers to a constant that is unknown at that point, the autoloading mechanism is triggered and if it succeeds the deserialization is retried transparently.
3697
+
3698
+ WARNING. If the argument is an `IO` it needs to respond to `rewind` to be able to retry. Regular files respond to `rewind`.
3699
+
3700
+ NOTE: Defined in `active_support/core_ext/marshal.rb`.
3701
+
3702
+ Extensions to `NameError`
3703
+ -------------------------
3704
+
3705
+ Active Support adds `missing_name?` to `NameError`, which tests whether the exception was raised because of the name passed as argument.
3706
+
3707
+ The name may be given as a symbol or string. A symbol is tested against the bare constant name, a string is against the fully-qualified constant name.
3708
+
3709
+ TIP: A symbol can represent a fully-qualified constant name as in `:"ActiveRecord::Base"`, so the behavior for symbols is defined for convenience, not because it has to be that way technically.
3710
+
3711
+ For example, when an action of `ArticlesController` is called Quails tries optimistically to use `ArticlesHelper`. It is OK that the helper module does not exist, so if an exception for that constant name is raised it should be silenced. But it could be the case that `articles_helper.rb` raises a `NameError` due to an actual unknown constant. That should be reraised. The method `missing_name?` provides a way to distinguish both cases:
3712
+
3713
+ ```ruby
3714
+ def default_helper_module!
3715
+ module_name = name.sub(/Controller$/, '')
3716
+ module_path = module_name.underscore
3717
+ helper module_path
3718
+ rescue LoadError => e
3719
+ raise e unless e.is_missing? "helpers/#{module_path}_helper"
3720
+ rescue NameError => e
3721
+ raise e unless e.missing_name? "#{module_name}Helper"
3722
+ end
3723
+ ```
3724
+
3725
+ NOTE: Defined in `active_support/core_ext/name_error.rb`.
3726
+
3727
+ Extensions to `LoadError`
3728
+ -------------------------
3729
+
3730
+ Active Support adds `is_missing?` to `LoadError`.
3731
+
3732
+ Given a path name `is_missing?` tests whether the exception was raised due to that particular file (except perhaps for the ".rb" extension).
3733
+
3734
+ For example, when an action of `ArticlesController` is called Quails tries to load `articles_helper.rb`, but that file may not exist. That's fine, the helper module is not mandatory so Quails silences a load error. But it could be the case that the helper module does exist and in turn requires another library that is missing. In that case Quails must reraise the exception. The method `is_missing?` provides a way to distinguish both cases:
3735
+
3736
+ ```ruby
3737
+ def default_helper_module!
3738
+ module_name = name.sub(/Controller$/, '')
3739
+ module_path = module_name.underscore
3740
+ helper module_path
3741
+ rescue LoadError => e
3742
+ raise e unless e.is_missing? "helpers/#{module_path}_helper"
3743
+ rescue NameError => e
3744
+ raise e unless e.missing_name? "#{module_name}Helper"
3745
+ end
3746
+ ```
3747
+
3748
+ NOTE: Defined in `active_support/core_ext/load_error.rb`.