vibes-bj 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1379) hide show
  1. data/HISTORY +83 -0
  2. data/LICENSE +1 -0
  3. data/README +318 -0
  4. data/Rakefile +21 -0
  5. data/TODO +53 -0
  6. data/VERSION +1 -0
  7. data/bin/bj +692 -0
  8. data/gemspec.rb +30 -0
  9. data/init.rb +1 -0
  10. data/install.rb +214 -0
  11. data/lib/bj.rb +85 -0
  12. data/lib/bj/api.rb +164 -0
  13. data/lib/bj/bj.rb +72 -0
  14. data/lib/bj/errors.rb +4 -0
  15. data/lib/bj/joblist.rb +112 -0
  16. data/lib/bj/logger.rb +50 -0
  17. data/lib/bj/runner.rb +369 -0
  18. data/lib/bj/stdext.rb +86 -0
  19. data/lib/bj/table.rb +426 -0
  20. data/lib/bj/util.rb +133 -0
  21. data/plugin/HISTORY +3 -0
  22. data/plugin/README +142 -0
  23. data/plugin/Rakefile +22 -0
  24. data/plugin/init.rb +33 -0
  25. data/plugin/install.rb +95 -0
  26. data/plugin/script/bj +55 -0
  27. data/plugin/tasks/bj_tasks.rake +4 -0
  28. data/plugin/test/bj_test.rb +8 -0
  29. data/plugin/uninstall.rb +1 -0
  30. data/spec/bj.rb +80 -0
  31. data/spec/helper.rb +85 -0
  32. data/spec/rails_root/README +256 -0
  33. data/spec/rails_root/Rakefile +10 -0
  34. data/spec/rails_root/app/controllers/application.rb +15 -0
  35. data/spec/rails_root/app/helpers/application_helper.rb +3 -0
  36. data/spec/rails_root/config/boot.rb +109 -0
  37. data/spec/rails_root/config/database.yml +23 -0
  38. data/spec/rails_root/config/environment.rb +67 -0
  39. data/spec/rails_root/config/environments/development.rb +17 -0
  40. data/spec/rails_root/config/environments/production.rb +22 -0
  41. data/spec/rails_root/config/environments/test.rb +22 -0
  42. data/spec/rails_root/config/initializers/inflections.rb +10 -0
  43. data/spec/rails_root/config/initializers/mime_types.rb +5 -0
  44. data/spec/rails_root/config/initializers/new_rails_defaults.rb +15 -0
  45. data/spec/rails_root/config/routes.rb +41 -0
  46. data/spec/rails_root/db/development.sqlite3 +0 -0
  47. data/spec/rails_root/db/migrate/20080909151517_bj_migration0.rb +8 -0
  48. data/spec/rails_root/db/schema.rb +62 -0
  49. data/spec/rails_root/doc/README_FOR_APP +2 -0
  50. data/spec/rails_root/log/development.log +141 -0
  51. data/spec/rails_root/log/production.log +0 -0
  52. data/spec/rails_root/log/server.log +0 -0
  53. data/spec/rails_root/log/test.log +0 -0
  54. data/spec/rails_root/public/404.html +30 -0
  55. data/spec/rails_root/public/422.html +30 -0
  56. data/spec/rails_root/public/500.html +30 -0
  57. data/spec/rails_root/public/dispatch.cgi +10 -0
  58. data/spec/rails_root/public/dispatch.fcgi +24 -0
  59. data/spec/rails_root/public/dispatch.rb +10 -0
  60. data/spec/rails_root/public/favicon.ico +0 -0
  61. data/spec/rails_root/public/images/rails.png +0 -0
  62. data/spec/rails_root/public/index.html +274 -0
  63. data/spec/rails_root/public/javascripts/application.js +2 -0
  64. data/spec/rails_root/public/javascripts/controls.js +963 -0
  65. data/spec/rails_root/public/javascripts/dragdrop.js +972 -0
  66. data/spec/rails_root/public/javascripts/effects.js +1120 -0
  67. data/spec/rails_root/public/javascripts/prototype.js +4225 -0
  68. data/spec/rails_root/public/robots.txt +5 -0
  69. data/spec/rails_root/script/about +3 -0
  70. data/spec/rails_root/script/bj +679 -0
  71. data/spec/rails_root/script/console +3 -0
  72. data/spec/rails_root/script/dbconsole +3 -0
  73. data/spec/rails_root/script/destroy +3 -0
  74. data/spec/rails_root/script/generate +3 -0
  75. data/spec/rails_root/script/performance/benchmarker +3 -0
  76. data/spec/rails_root/script/performance/profiler +3 -0
  77. data/spec/rails_root/script/performance/request +3 -0
  78. data/spec/rails_root/script/plugin +3 -0
  79. data/spec/rails_root/script/process/inspector +3 -0
  80. data/spec/rails_root/script/process/reaper +3 -0
  81. data/spec/rails_root/script/process/spawner +3 -0
  82. data/spec/rails_root/script/runner +3 -0
  83. data/spec/rails_root/script/server +3 -0
  84. data/spec/rails_root/test/test_helper.rb +38 -0
  85. data/spec/rails_root/vendor/plugins/bj/HISTORY +3 -0
  86. data/spec/rails_root/vendor/plugins/bj/README +142 -0
  87. data/spec/rails_root/vendor/plugins/bj/Rakefile +22 -0
  88. data/spec/rails_root/vendor/plugins/bj/bin/bj +679 -0
  89. data/spec/rails_root/vendor/plugins/bj/init.rb +33 -0
  90. data/spec/rails_root/vendor/plugins/bj/install.rb +95 -0
  91. data/spec/rails_root/vendor/plugins/bj/lib/arrayfields.rb +435 -0
  92. data/spec/rails_root/vendor/plugins/bj/lib/attributes.rb +118 -0
  93. data/spec/rails_root/vendor/plugins/bj/lib/bj.rb +87 -0
  94. data/spec/rails_root/vendor/plugins/bj/lib/bj/api.rb +161 -0
  95. data/spec/rails_root/vendor/plugins/bj/lib/bj/attributes.rb +120 -0
  96. data/spec/rails_root/vendor/plugins/bj/lib/bj/bj.rb +72 -0
  97. data/spec/rails_root/vendor/plugins/bj/lib/bj/errors.rb +4 -0
  98. data/spec/rails_root/vendor/plugins/bj/lib/bj/joblist.rb +112 -0
  99. data/spec/rails_root/vendor/plugins/bj/lib/bj/logger.rb +50 -0
  100. data/spec/rails_root/vendor/plugins/bj/lib/bj/runner.rb +357 -0
  101. data/spec/rails_root/vendor/plugins/bj/lib/bj/stdext.rb +86 -0
  102. data/spec/rails_root/vendor/plugins/bj/lib/bj/table.rb +384 -0
  103. data/spec/rails_root/vendor/plugins/bj/lib/bj/util.rb +111 -0
  104. data/spec/rails_root/vendor/plugins/bj/lib/fattr.rb +153 -0
  105. data/spec/rails_root/vendor/plugins/bj/lib/main.rb +60 -0
  106. data/spec/rails_root/vendor/plugins/bj/lib/main/base.rb +515 -0
  107. data/spec/rails_root/vendor/plugins/bj/lib/main/cast.rb +100 -0
  108. data/spec/rails_root/vendor/plugins/bj/lib/main/factories.rb +20 -0
  109. data/spec/rails_root/vendor/plugins/bj/lib/main/getoptlong.rb +470 -0
  110. data/spec/rails_root/vendor/plugins/bj/lib/main/logger.rb +51 -0
  111. data/spec/rails_root/vendor/plugins/bj/lib/main/mode.rb +42 -0
  112. data/spec/rails_root/vendor/plugins/bj/lib/main/parameter.rb +685 -0
  113. data/spec/rails_root/vendor/plugins/bj/lib/main/softspoken.rb +12 -0
  114. data/spec/rails_root/vendor/plugins/bj/lib/main/stdext.rb +38 -0
  115. data/spec/rails_root/vendor/plugins/bj/lib/main/usage.rb +211 -0
  116. data/spec/rails_root/vendor/plugins/bj/lib/main/util.rb +91 -0
  117. data/spec/rails_root/vendor/plugins/bj/lib/orderedautohash.rb +25 -0
  118. data/spec/rails_root/vendor/plugins/bj/lib/orderedhash.rb +189 -0
  119. data/spec/rails_root/vendor/plugins/bj/lib/systemu.rb +299 -0
  120. data/spec/rails_root/vendor/plugins/bj/script/bj +55 -0
  121. data/spec/rails_root/vendor/plugins/bj/tasks/bj_tasks.rake +4 -0
  122. data/spec/rails_root/vendor/plugins/bj/test/bj_test.rb +8 -0
  123. data/spec/rails_root/vendor/plugins/bj/uninstall.rb +1 -0
  124. data/spec/rails_root/vendor/rails/actionmailer/CHANGELOG +336 -0
  125. data/spec/rails_root/vendor/rails/actionmailer/MIT-LICENSE +21 -0
  126. data/spec/rails_root/vendor/rails/actionmailer/README +149 -0
  127. data/spec/rails_root/vendor/rails/actionmailer/Rakefile +97 -0
  128. data/spec/rails_root/vendor/rails/actionmailer/install.rb +30 -0
  129. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer.rb +52 -0
  130. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb +30 -0
  131. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/base.rb +646 -0
  132. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/helpers.rb +111 -0
  133. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/mail_helper.rb +19 -0
  134. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/part.rb +110 -0
  135. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/part_container.rb +51 -0
  136. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/quoting.rb +61 -0
  137. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/test_case.rb +64 -0
  138. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/test_helper.rb +67 -0
  139. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/utils.rb +8 -0
  140. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor.rb +14 -0
  141. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +1466 -0
  142. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail.rb +5 -0
  143. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/address.rb +426 -0
  144. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/attachments.rb +46 -0
  145. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/base64.rb +46 -0
  146. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/compat.rb +41 -0
  147. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/config.rb +67 -0
  148. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/core_extensions.rb +63 -0
  149. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/encode.rb +581 -0
  150. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/header.rb +960 -0
  151. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/index.rb +9 -0
  152. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/interface.rb +1130 -0
  153. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/loader.rb +3 -0
  154. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mail.rb +578 -0
  155. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mailbox.rb +495 -0
  156. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/main.rb +6 -0
  157. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mbox.rb +3 -0
  158. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/net.rb +248 -0
  159. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/obsolete.rb +132 -0
  160. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/parser.rb +1476 -0
  161. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/port.rb +379 -0
  162. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/quoting.rb +118 -0
  163. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/require_arch.rb +58 -0
  164. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/scanner.rb +49 -0
  165. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/scanner_r.rb +261 -0
  166. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/stringio.rb +280 -0
  167. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/utils.rb +337 -0
  168. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/version.rb +39 -0
  169. data/spec/rails_root/vendor/rails/actionmailer/lib/action_mailer/version.rb +9 -0
  170. data/spec/rails_root/vendor/rails/actionmailer/lib/actionmailer.rb +1 -0
  171. data/spec/rails_root/vendor/rails/actionmailer/test/abstract_unit.rb +49 -0
  172. data/spec/rails_root/vendor/rails/actionmailer/test/delivery_method_test.rb +51 -0
  173. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/first_mailer/share.erb +1 -0
  174. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_example_helper.erb +1 -0
  175. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper.erb +1 -0
  176. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper_method.erb +1 -0
  177. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_mail_helper.erb +5 -0
  178. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/helpers/example_helper.rb +5 -0
  179. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb +1 -0
  180. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email +14 -0
  181. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email10 +20 -0
  182. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email12 +32 -0
  183. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email13 +29 -0
  184. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email2 +114 -0
  185. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email3 +70 -0
  186. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email4 +59 -0
  187. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email5 +19 -0
  188. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email6 +20 -0
  189. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email7 +66 -0
  190. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email8 +47 -0
  191. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email9 +28 -0
  192. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email_quoted_with_0d0a +14 -0
  193. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email_with_invalid_characters_in_content_type +104 -0
  194. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email_with_nested_attachment +100 -0
  195. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
  196. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/second_mailer/share.erb +1 -0
  197. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/templates/signed_up.erb +3 -0
  198. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/_subtemplate.text.plain.erb +1 -0
  199. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.html.haml +6 -0
  200. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.plain.haml +6 -0
  201. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb +1 -0
  202. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb +10 -0
  203. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb +2 -0
  204. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb +1 -0
  205. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/included_subtemplate.text.plain.erb +1 -0
  206. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/rxml_template.builder +2 -0
  207. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/rxml_template.rxml +2 -0
  208. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up.erb +3 -0
  209. data/spec/rails_root/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb +5 -0
  210. data/spec/rails_root/vendor/rails/actionmailer/test/mail_helper_test.rb +95 -0
  211. data/spec/rails_root/vendor/rails/actionmailer/test/mail_render_test.rb +122 -0
  212. data/spec/rails_root/vendor/rails/actionmailer/test/mail_service_test.rb +979 -0
  213. data/spec/rails_root/vendor/rails/actionmailer/test/quoting_test.rb +98 -0
  214. data/spec/rails_root/vendor/rails/actionmailer/test/test_helper_test.rb +129 -0
  215. data/spec/rails_root/vendor/rails/actionmailer/test/tmail_test.rb +22 -0
  216. data/spec/rails_root/vendor/rails/actionmailer/test/url_test.rb +76 -0
  217. data/spec/rails_root/vendor/rails/actionpack/CHANGELOG +4798 -0
  218. data/spec/rails_root/vendor/rails/actionpack/MIT-LICENSE +21 -0
  219. data/spec/rails_root/vendor/rails/actionpack/README +469 -0
  220. data/spec/rails_root/vendor/rails/actionpack/RUNNING_UNIT_TESTS +24 -0
  221. data/spec/rails_root/vendor/rails/actionpack/Rakefile +154 -0
  222. data/spec/rails_root/vendor/rails/actionpack/install.rb +30 -0
  223. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller.rb +79 -0
  224. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions.rb +69 -0
  225. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +39 -0
  226. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +20 -0
  227. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +172 -0
  228. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +146 -0
  229. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +643 -0
  230. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/assertions/tag_assertions.rb +130 -0
  231. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/base.rb +1270 -0
  232. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/benchmarking.rb +94 -0
  233. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/caching.rb +72 -0
  234. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/caching/actions.rb +144 -0
  235. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/caching/fragments.rb +138 -0
  236. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/caching/pages.rb +154 -0
  237. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb +18 -0
  238. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb +97 -0
  239. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cgi_ext.rb +16 -0
  240. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cgi_ext/cookie.rb +110 -0
  241. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cgi_ext/query_extension.rb +22 -0
  242. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cgi_ext/session.rb +73 -0
  243. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cgi_ext/stdinput.rb +24 -0
  244. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +223 -0
  245. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/components.rb +166 -0
  246. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/cookies.rb +96 -0
  247. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/dispatcher.rb +162 -0
  248. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/filters.rb +643 -0
  249. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/flash.rb +172 -0
  250. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/headers.rb +31 -0
  251. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/helpers.rb +221 -0
  252. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/http_authentication.rb +124 -0
  253. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/integration.rb +634 -0
  254. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/layout.rb +310 -0
  255. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/mime_responds.rb +174 -0
  256. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/mime_type.rb +182 -0
  257. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/mime_types.rb +20 -0
  258. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb +178 -0
  259. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/record_identifier.rb +97 -0
  260. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/request.rb +761 -0
  261. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb +140 -0
  262. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/request_profiler.rb +169 -0
  263. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/rescue.rb +258 -0
  264. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/resources.rb +572 -0
  265. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/response.rb +76 -0
  266. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing.rb +383 -0
  267. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/builder.rb +204 -0
  268. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/optimisations.rb +120 -0
  269. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/recognition_optimisation.rb +158 -0
  270. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/route.rb +240 -0
  271. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb +435 -0
  272. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/routing_ext.rb +46 -0
  273. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/routing/segments.rb +283 -0
  274. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/session/active_record_store.rb +340 -0
  275. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb +166 -0
  276. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/session/drb_server.rb +32 -0
  277. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/session/drb_store.rb +35 -0
  278. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/session/mem_cache_store.rb +98 -0
  279. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/session_management.rb +158 -0
  280. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/status_codes.rb +88 -0
  281. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/streaming.rb +155 -0
  282. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
  283. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/_trace.erb +26 -0
  284. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/diagnostics.erb +11 -0
  285. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.erb +29 -0
  286. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/missing_template.erb +2 -0
  287. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/routing_error.erb +10 -0
  288. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/template_error.erb +21 -0
  289. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/templates/rescues/unknown_action.erb +2 -0
  290. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/test_case.rb +83 -0
  291. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/test_process.rb +524 -0
  292. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +142 -0
  293. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb +68 -0
  294. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +530 -0
  295. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
  296. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb +828 -0
  297. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +105 -0
  298. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
  299. data/spec/rails_root/vendor/rails/actionpack/lib/action_controller/verification.rb +130 -0
  300. data/spec/rails_root/vendor/rails/actionpack/lib/action_pack.rb +24 -0
  301. data/spec/rails_root/vendor/rails/actionpack/lib/action_pack/version.rb +9 -0
  302. data/spec/rails_root/vendor/rails/actionpack/lib/action_view.rb +45 -0
  303. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/base.rb +343 -0
  304. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +276 -0
  305. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +611 -0
  306. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +143 -0
  307. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb +33 -0
  308. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb +40 -0
  309. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb +161 -0
  310. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +711 -0
  311. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +31 -0
  312. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +763 -0
  313. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +457 -0
  314. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +459 -0
  315. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb +217 -0
  316. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/javascripts/controls.js +963 -0
  317. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/javascripts/dragdrop.js +972 -0
  318. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/javascripts/effects.js +1120 -0
  319. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/javascripts/prototype.js +4225 -0
  320. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +186 -0
  321. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +1300 -0
  322. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/record_identification_helper.rb +20 -0
  323. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/record_tag_helper.rb +59 -0
  324. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/sanitize_helper.rb +229 -0
  325. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +225 -0
  326. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +133 -0
  327. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +507 -0
  328. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +575 -0
  329. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/inline_template.rb +20 -0
  330. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/partial_template.rb +70 -0
  331. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/partials.rb +158 -0
  332. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template.rb +127 -0
  333. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_error.rb +110 -0
  334. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_finder.rb +177 -0
  335. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handler.rb +34 -0
  336. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb +27 -0
  337. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb +128 -0
  338. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb +56 -0
  339. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb +27 -0
  340. data/spec/rails_root/vendor/rails/actionpack/lib/action_view/test_case.rb +58 -0
  341. data/spec/rails_root/vendor/rails/actionpack/lib/actionpack.rb +1 -0
  342. data/spec/rails_root/vendor/rails/actionpack/test/abstract_unit.rb +36 -0
  343. data/spec/rails_root/vendor/rails/actionpack/test/active_record_unit.rb +105 -0
  344. data/spec/rails_root/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +141 -0
  345. data/spec/rails_root/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb +191 -0
  346. data/spec/rails_root/vendor/rails/actionpack/test/adv_attr_test.rb +20 -0
  347. data/spec/rails_root/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +524 -0
  348. data/spec/rails_root/vendor/rails/actionpack/test/controller/addresses_render_test.rb +43 -0
  349. data/spec/rails_root/vendor/rails/actionpack/test/controller/assert_select_test.rb +689 -0
  350. data/spec/rails_root/vendor/rails/actionpack/test/controller/base_test.rb +183 -0
  351. data/spec/rails_root/vendor/rails/actionpack/test/controller/benchmark_test.rb +32 -0
  352. data/spec/rails_root/vendor/rails/actionpack/test/controller/caching_test.rb +610 -0
  353. data/spec/rails_root/vendor/rails/actionpack/test/controller/capture_test.rb +89 -0
  354. data/spec/rails_root/vendor/rails/actionpack/test/controller/cgi_test.rb +116 -0
  355. data/spec/rails_root/vendor/rails/actionpack/test/controller/components_test.rb +140 -0
  356. data/spec/rails_root/vendor/rails/actionpack/test/controller/content_type_test.rb +139 -0
  357. data/spec/rails_root/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
  358. data/spec/rails_root/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
  359. data/spec/rails_root/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
  360. data/spec/rails_root/vendor/rails/actionpack/test/controller/cookie_test.rb +146 -0
  361. data/spec/rails_root/vendor/rails/actionpack/test/controller/custom_handler_test.rb +45 -0
  362. data/spec/rails_root/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +37 -0
  363. data/spec/rails_root/vendor/rails/actionpack/test/controller/dispatcher_test.rb +105 -0
  364. data/spec/rails_root/vendor/rails/actionpack/test/controller/fake_controllers.rb +33 -0
  365. data/spec/rails_root/vendor/rails/actionpack/test/controller/fake_models.rb +11 -0
  366. data/spec/rails_root/vendor/rails/actionpack/test/controller/filter_params_test.rb +49 -0
  367. data/spec/rails_root/vendor/rails/actionpack/test/controller/filters_test.rb +881 -0
  368. data/spec/rails_root/vendor/rails/actionpack/test/controller/flash_test.rb +146 -0
  369. data/spec/rails_root/vendor/rails/actionpack/test/controller/header_test.rb +14 -0
  370. data/spec/rails_root/vendor/rails/actionpack/test/controller/helper_test.rb +210 -0
  371. data/spec/rails_root/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb +123 -0
  372. data/spec/rails_root/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb +68 -0
  373. data/spec/rails_root/vendor/rails/actionpack/test/controller/html-scanner/sanitizer_test.rb +259 -0
  374. data/spec/rails_root/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb +238 -0
  375. data/spec/rails_root/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb +50 -0
  376. data/spec/rails_root/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb +131 -0
  377. data/spec/rails_root/vendor/rails/actionpack/test/controller/http_authentication_test.rb +54 -0
  378. data/spec/rails_root/vendor/rails/actionpack/test/controller/integration_test.rb +252 -0
  379. data/spec/rails_root/vendor/rails/actionpack/test/controller/integration_upload_test.rb +43 -0
  380. data/spec/rails_root/vendor/rails/actionpack/test/controller/layout_test.rb +259 -0
  381. data/spec/rails_root/vendor/rails/actionpack/test/controller/mime_responds_test.rb +538 -0
  382. data/spec/rails_root/vendor/rails/actionpack/test/controller/mime_type_test.rb +84 -0
  383. data/spec/rails_root/vendor/rails/actionpack/test/controller/new_render_test.rb +926 -0
  384. data/spec/rails_root/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb +141 -0
  385. data/spec/rails_root/vendor/rails/actionpack/test/controller/record_identifier_test.rb +139 -0
  386. data/spec/rails_root/vendor/rails/actionpack/test/controller/redirect_test.rb +289 -0
  387. data/spec/rails_root/vendor/rails/actionpack/test/controller/render_test.rb +527 -0
  388. data/spec/rails_root/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +313 -0
  389. data/spec/rails_root/vendor/rails/actionpack/test/controller/request_test.rb +922 -0
  390. data/spec/rails_root/vendor/rails/actionpack/test/controller/rescue_test.rb +517 -0
  391. data/spec/rails_root/vendor/rails/actionpack/test/controller/resources_test.rb +875 -0
  392. data/spec/rails_root/vendor/rails/actionpack/test/controller/routing_test.rb +2415 -0
  393. data/spec/rails_root/vendor/rails/actionpack/test/controller/selector_test.rb +628 -0
  394. data/spec/rails_root/vendor/rails/actionpack/test/controller/send_file_test.rb +138 -0
  395. data/spec/rails_root/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +258 -0
  396. data/spec/rails_root/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb +181 -0
  397. data/spec/rails_root/vendor/rails/actionpack/test/controller/session_fixation_test.rb +89 -0
  398. data/spec/rails_root/vendor/rails/actionpack/test/controller/session_management_test.rb +178 -0
  399. data/spec/rails_root/vendor/rails/actionpack/test/controller/test_test.rb +686 -0
  400. data/spec/rails_root/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +310 -0
  401. data/spec/rails_root/vendor/rails/actionpack/test/controller/verification_test.rb +253 -0
  402. data/spec/rails_root/vendor/rails/actionpack/test/controller/view_paths_test.rb +140 -0
  403. data/spec/rails_root/vendor/rails/actionpack/test/controller/webservice_test.rb +229 -0
  404. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/addresses/list.erb +1 -0
  405. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/bad_customers/_bad_customer.html.erb +1 -0
  406. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/companies.yml +24 -0
  407. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/company.rb +10 -0
  408. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +1 -0
  409. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml +1 -0
  410. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs +1 -0
  411. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml +1 -0
  412. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/customers/_customer.html.erb +1 -0
  413. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql +49 -0
  414. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/developer.rb +9 -0
  415. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/developers.yml +21 -0
  416. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/developers_projects.yml +13 -0
  417. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb +1 -0
  418. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/functional_caching/_partial.erb +3 -0
  419. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/functional_caching/fragment_cached.html.erb +2 -0
  420. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/functional_caching/html_fragment_cached_with_partial.html.erb +1 -0
  421. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +1 -0
  422. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/good_customers/_good_customer.html.erb +1 -0
  423. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +5 -0
  424. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +3 -0
  425. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
  426. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
  427. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
  428. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
  429. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
  430. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
  431. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
  432. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml +1 -0
  433. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layouts/block_with_layout.erb +3 -0
  434. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layouts/builder.builder +3 -0
  435. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layouts/partial_with_layout.erb +3 -0
  436. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layouts/standard.erb +1 -0
  437. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb +2 -0
  438. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/layouts/yield.erb +2 -0
  439. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/mascot.rb +3 -0
  440. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/mascots.yml +4 -0
  441. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/mascots/_mascot.html.erb +1 -0
  442. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/binary_file +0 -0
  443. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/boundary_problem_file +10 -0
  444. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param +5 -0
  445. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +10 -0
  446. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/mixed_files +0 -0
  447. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg +0 -0
  448. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +5 -0
  449. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/multipart/text_file +10 -0
  450. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb +1 -0
  451. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb +1 -0
  452. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb +1 -0
  453. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
  454. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb +1 -0
  455. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb +1 -0
  456. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb +1 -0
  457. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
  458. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/project.rb +3 -0
  459. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/projects.yml +7 -0
  460. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/404.html +1 -0
  461. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/500.html +1 -0
  462. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/images/rails.png +0 -0
  463. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js +1 -0
  464. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js +1 -0
  465. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/controls.js +1 -0
  466. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/dragdrop.js +1 -0
  467. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/effects.js +1 -0
  468. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/prototype.js +1 -0
  469. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js +1 -0
  470. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/javascripts/version.1.0.js +1 -0
  471. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css +1 -0
  472. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css +1 -0
  473. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/public/stylesheets/version.1.0.css +1 -0
  474. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/replies.yml +15 -0
  475. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/reply.rb +7 -0
  476. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
  477. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs +1 -0
  478. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
  479. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
  480. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
  481. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
  482. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
  483. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
  484. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb +1 -0
  485. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs +1 -0
  486. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
  487. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
  488. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +1 -0
  489. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
  490. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb +1 -0
  491. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/shared.html.erb +1 -0
  492. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb +5 -0
  493. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_customer.erb +1 -0
  494. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_customer_counter.erb +1 -0
  495. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb +1 -0
  496. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_form.erb +1 -0
  497. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb +1 -0
  498. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb +2 -0
  499. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_hello.builder +1 -0
  500. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_labelling_form.erb +1 -0
  501. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb +3 -0
  502. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_partial.erb +1 -0
  503. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb +1 -0
  504. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb +1 -0
  505. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
  506. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb +1 -0
  507. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_person.erb +2 -0
  508. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/_raise.html.erb +1 -0
  509. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb +2 -0
  510. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/block_content_for.erb +2 -0
  511. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
  512. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/capturing.erb +4 -0
  513. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/content_for.erb +2 -0
  514. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb +3 -0
  515. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb +2 -0
  516. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs +2 -0
  517. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
  518. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs +6 -0
  519. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/erb_content_for.erb +2 -0
  520. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb +1 -0
  521. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder +1 -0
  522. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
  523. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
  524. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/greeting.erb +1 -0
  525. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/greeting.js.rjs +1 -0
  526. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/hello.builder +4 -0
  527. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/hello_world.erb +1 -0
  528. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder +3 -0
  529. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder +4 -0
  530. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb +1 -0
  531. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder +11 -0
  532. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/list.erb +1 -0
  533. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder +4 -0
  534. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb +4 -0
  535. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb +1 -0
  536. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb +1 -0
  537. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb +1 -0
  538. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb +9 -0
  539. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb +1 -0
  540. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/topic.rb +3 -0
  541. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/topics.yml +22 -0
  542. data/spec/rails_root/vendor/rails/actionpack/test/fixtures/topics/_topic.html.erb +1 -0
  543. data/spec/rails_root/vendor/rails/actionpack/test/template/active_record_helper_test.rb +268 -0
  544. data/spec/rails_root/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +525 -0
  545. data/spec/rails_root/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +179 -0
  546. data/spec/rails_root/vendor/rails/actionpack/test/template/benchmark_helper_test.rb +60 -0
  547. data/spec/rails_root/vendor/rails/actionpack/test/template/date_helper_test.rb +1740 -0
  548. data/spec/rails_root/vendor/rails/actionpack/test/template/erb_util_test.rb +24 -0
  549. data/spec/rails_root/vendor/rails/actionpack/test/template/form_helper_test.rb +918 -0
  550. data/spec/rails_root/vendor/rails/actionpack/test/template/form_options_helper_test.rb +1336 -0
  551. data/spec/rails_root/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +259 -0
  552. data/spec/rails_root/vendor/rails/actionpack/test/template/javascript_helper_test.rb +109 -0
  553. data/spec/rails_root/vendor/rails/actionpack/test/template/number_helper_test.rb +97 -0
  554. data/spec/rails_root/vendor/rails/actionpack/test/template/prototype_helper_test.rb +614 -0
  555. data/spec/rails_root/vendor/rails/actionpack/test/template/record_tag_helper_test.rb +54 -0
  556. data/spec/rails_root/vendor/rails/actionpack/test/template/sanitize_helper_test.rb +48 -0
  557. data/spec/rails_root/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb +90 -0
  558. data/spec/rails_root/vendor/rails/actionpack/test/template/tag_helper_test.rb +77 -0
  559. data/spec/rails_root/vendor/rails/actionpack/test/template/template_finder_test.rb +73 -0
  560. data/spec/rails_root/vendor/rails/actionpack/test/template/template_object_test.rb +95 -0
  561. data/spec/rails_root/vendor/rails/actionpack/test/template/test_test.rb +56 -0
  562. data/spec/rails_root/vendor/rails/actionpack/test/template/text_helper_test.rb +366 -0
  563. data/spec/rails_root/vendor/rails/actionpack/test/template/url_helper_test.rb +534 -0
  564. data/spec/rails_root/vendor/rails/actionpack/test/testing_sandbox.rb +15 -0
  565. data/spec/rails_root/vendor/rails/activerecord/CHANGELOG +5719 -0
  566. data/spec/rails_root/vendor/rails/activerecord/README +351 -0
  567. data/spec/rails_root/vendor/rails/activerecord/RUNNING_UNIT_TESTS +36 -0
  568. data/spec/rails_root/vendor/rails/activerecord/Rakefile +247 -0
  569. data/spec/rails_root/vendor/rails/activerecord/examples/associations.png +0 -0
  570. data/spec/rails_root/vendor/rails/activerecord/install.rb +30 -0
  571. data/spec/rails_root/vendor/rails/activerecord/lib/active_record.rb +82 -0
  572. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/aggregations.rb +189 -0
  573. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/association_preload.rb +277 -0
  574. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations.rb +1994 -0
  575. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +365 -0
  576. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +224 -0
  577. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +58 -0
  578. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +49 -0
  579. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +112 -0
  580. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +109 -0
  581. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +254 -0
  582. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb +98 -0
  583. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +28 -0
  584. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/attribute_methods.rb +379 -0
  585. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/base.rb +2726 -0
  586. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/calculations.rb +275 -0
  587. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/callbacks.rb +312 -0
  588. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +309 -0
  589. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +176 -0
  590. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +93 -0
  591. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
  592. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +661 -0
  593. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +421 -0
  594. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +169 -0
  595. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +530 -0
  596. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +948 -0
  597. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
  598. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +406 -0
  599. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/dirty.rb +158 -0
  600. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/fixtures.rb +997 -0
  601. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb +147 -0
  602. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb +77 -0
  603. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/migration.rb +496 -0
  604. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/named_scope.rb +163 -0
  605. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/observer.rb +195 -0
  606. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/query_cache.rb +21 -0
  607. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/reflection.rb +239 -0
  608. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/schema.rb +51 -0
  609. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +171 -0
  610. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/serialization.rb +98 -0
  611. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +80 -0
  612. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +338 -0
  613. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/test_case.rb +36 -0
  614. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/timestamp.rb +41 -0
  615. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/transactions.rb +130 -0
  616. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/validations.rb +961 -0
  617. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/vendor/db2.rb +362 -0
  618. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/vendor/mysql.rb +1214 -0
  619. data/spec/rails_root/vendor/rails/activerecord/lib/active_record/version.rb +9 -0
  620. data/spec/rails_root/vendor/rails/activerecord/lib/activerecord.rb +1 -0
  621. data/spec/rails_root/vendor/rails/activerecord/test/assets/example.log +1 -0
  622. data/spec/rails_root/vendor/rails/activerecord/test/assets/flowers.jpg +0 -0
  623. data/spec/rails_root/vendor/rails/activerecord/test/cases/aaa_create_tables_test.rb +24 -0
  624. data/spec/rails_root/vendor/rails/activerecord/test/cases/active_schema_test_mysql.rb +95 -0
  625. data/spec/rails_root/vendor/rails/activerecord/test/cases/active_schema_test_postgresql.rb +24 -0
  626. data/spec/rails_root/vendor/rails/activerecord/test/cases/adapter_test.rb +127 -0
  627. data/spec/rails_root/vendor/rails/activerecord/test/cases/adapter_test_sqlserver.rb +95 -0
  628. data/spec/rails_root/vendor/rails/activerecord/test/cases/aggregations_test.rb +128 -0
  629. data/spec/rails_root/vendor/rails/activerecord/test/cases/ar_schema_test.rb +33 -0
  630. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +412 -0
  631. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/callbacks_test.rb +161 -0
  632. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/cascaded_eager_loading_test.rb +111 -0
  633. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +83 -0
  634. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/eager_singularization_test.rb +145 -0
  635. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/eager_test.rb +612 -0
  636. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/extension_test.rb +47 -0
  637. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +684 -0
  638. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +932 -0
  639. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +190 -0
  640. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb +323 -0
  641. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +74 -0
  642. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +88 -0
  643. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +707 -0
  644. data/spec/rails_root/vendor/rails/activerecord/test/cases/associations_test.rb +262 -0
  645. data/spec/rails_root/vendor/rails/activerecord/test/cases/attribute_methods_test.rb +238 -0
  646. data/spec/rails_root/vendor/rails/activerecord/test/cases/base_test.rb +1974 -0
  647. data/spec/rails_root/vendor/rails/activerecord/test/cases/binary_test.rb +34 -0
  648. data/spec/rails_root/vendor/rails/activerecord/test/cases/calculations_test.rb +271 -0
  649. data/spec/rails_root/vendor/rails/activerecord/test/cases/callbacks_test.rb +400 -0
  650. data/spec/rails_root/vendor/rails/activerecord/test/cases/class_inheritable_attributes_test.rb +32 -0
  651. data/spec/rails_root/vendor/rails/activerecord/test/cases/column_alias_test.rb +17 -0
  652. data/spec/rails_root/vendor/rails/activerecord/test/cases/connection_test_firebird.rb +8 -0
  653. data/spec/rails_root/vendor/rails/activerecord/test/cases/connection_test_mysql.rb +30 -0
  654. data/spec/rails_root/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +69 -0
  655. data/spec/rails_root/vendor/rails/activerecord/test/cases/datatype_test_postgresql.rb +203 -0
  656. data/spec/rails_root/vendor/rails/activerecord/test/cases/date_time_test.rb +37 -0
  657. data/spec/rails_root/vendor/rails/activerecord/test/cases/default_test_firebird.rb +16 -0
  658. data/spec/rails_root/vendor/rails/activerecord/test/cases/defaults_test.rb +69 -0
  659. data/spec/rails_root/vendor/rails/activerecord/test/cases/deprecated_finder_test.rb +30 -0
  660. data/spec/rails_root/vendor/rails/activerecord/test/cases/dirty_test.rb +163 -0
  661. data/spec/rails_root/vendor/rails/activerecord/test/cases/finder_respond_to_test.rb +76 -0
  662. data/spec/rails_root/vendor/rails/activerecord/test/cases/finder_test.rb +883 -0
  663. data/spec/rails_root/vendor/rails/activerecord/test/cases/fixtures_test.rb +626 -0
  664. data/spec/rails_root/vendor/rails/activerecord/test/cases/helper.rb +47 -0
  665. data/spec/rails_root/vendor/rails/activerecord/test/cases/inheritance_test.rb +255 -0
  666. data/spec/rails_root/vendor/rails/activerecord/test/cases/invalid_date_test.rb +24 -0
  667. data/spec/rails_root/vendor/rails/activerecord/test/cases/json_serialization_test.rb +205 -0
  668. data/spec/rails_root/vendor/rails/activerecord/test/cases/lifecycle_test.rb +140 -0
  669. data/spec/rails_root/vendor/rails/activerecord/test/cases/locking_test.rb +289 -0
  670. data/spec/rails_root/vendor/rails/activerecord/test/cases/method_scoping_test.rb +452 -0
  671. data/spec/rails_root/vendor/rails/activerecord/test/cases/migration_test.rb +1319 -0
  672. data/spec/rails_root/vendor/rails/activerecord/test/cases/migration_test_firebird.rb +124 -0
  673. data/spec/rails_root/vendor/rails/activerecord/test/cases/mixin_test.rb +96 -0
  674. data/spec/rails_root/vendor/rails/activerecord/test/cases/modules_test.rb +39 -0
  675. data/spec/rails_root/vendor/rails/activerecord/test/cases/multiple_db_test.rb +60 -0
  676. data/spec/rails_root/vendor/rails/activerecord/test/cases/named_scope_test.rb +157 -0
  677. data/spec/rails_root/vendor/rails/activerecord/test/cases/pk_test.rb +101 -0
  678. data/spec/rails_root/vendor/rails/activerecord/test/cases/query_cache_test.rb +126 -0
  679. data/spec/rails_root/vendor/rails/activerecord/test/cases/readonly_test.rb +107 -0
  680. data/spec/rails_root/vendor/rails/activerecord/test/cases/reflection_test.rb +176 -0
  681. data/spec/rails_root/vendor/rails/activerecord/test/cases/reserved_word_test_mysql.rb +176 -0
  682. data/spec/rails_root/vendor/rails/activerecord/test/cases/schema_authorization_test_postgresql.rb +75 -0
  683. data/spec/rails_root/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +138 -0
  684. data/spec/rails_root/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +102 -0
  685. data/spec/rails_root/vendor/rails/activerecord/test/cases/serialization_test.rb +47 -0
  686. data/spec/rails_root/vendor/rails/activerecord/test/cases/synonym_test_oracle.rb +17 -0
  687. data/spec/rails_root/vendor/rails/activerecord/test/cases/table_name_test_sqlserver.rb +23 -0
  688. data/spec/rails_root/vendor/rails/activerecord/test/cases/threaded_connections_test.rb +48 -0
  689. data/spec/rails_root/vendor/rails/activerecord/test/cases/transactions_test.rb +307 -0
  690. data/spec/rails_root/vendor/rails/activerecord/test/cases/unconnected_test.rb +32 -0
  691. data/spec/rails_root/vendor/rails/activerecord/test/cases/validations_test.rb +1509 -0
  692. data/spec/rails_root/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +202 -0
  693. data/spec/rails_root/vendor/rails/activerecord/test/config.rb +5 -0
  694. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_db2/connection.rb +25 -0
  695. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_firebird/connection.rb +26 -0
  696. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb +27 -0
  697. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_mysql/connection.rb +27 -0
  698. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_openbase/connection.rb +21 -0
  699. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_oracle/connection.rb +27 -0
  700. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb +21 -0
  701. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb +25 -0
  702. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb +25 -0
  703. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
  704. data/spec/rails_root/vendor/rails/activerecord/test/connections/native_sybase/connection.rb +23 -0
  705. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/accounts.yml +28 -0
  706. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/all/developers.yml +0 -0
  707. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/all/people.csv +0 -0
  708. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/all/tasks.yml +0 -0
  709. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/author_addresses.yml +5 -0
  710. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/author_favorites.yml +4 -0
  711. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/authors.yml +9 -0
  712. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/binaries.yml +132 -0
  713. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/books.yml +7 -0
  714. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/categories.yml +14 -0
  715. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml +9 -0
  716. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
  717. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/categories_ordered.yml +7 -0
  718. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/categories_posts.yml +23 -0
  719. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/categorizations.yml +17 -0
  720. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/clubs.yml +6 -0
  721. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/comments.yml +59 -0
  722. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/companies.yml +55 -0
  723. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/computers.yml +4 -0
  724. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/courses.yml +7 -0
  725. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/customers.yml +17 -0
  726. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/developers.yml +21 -0
  727. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/developers_projects.yml +17 -0
  728. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/edges.yml +6 -0
  729. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/entrants.yml +14 -0
  730. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml +3 -0
  731. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml +2 -0
  732. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/funny_jokes.yml +10 -0
  733. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/items.yml +4 -0
  734. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/jobs.yml +7 -0
  735. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/legacy_things.yml +3 -0
  736. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/mateys.yml +4 -0
  737. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/members.yml +4 -0
  738. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/memberships.yml +20 -0
  739. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/minimalistics.yml +2 -0
  740. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml +6 -0
  741. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/mixins.yml +29 -0
  742. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/movies.yml +7 -0
  743. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv +1 -0
  744. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml +1 -0
  745. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml +1 -0
  746. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml +1 -0
  747. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/owners.yml +7 -0
  748. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/parrots.yml +27 -0
  749. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml +7 -0
  750. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/people.yml +6 -0
  751. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/pets.yml +14 -0
  752. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/pirates.yml +9 -0
  753. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/posts.yml +49 -0
  754. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/price_estimates.yml +7 -0
  755. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/projects.yml +7 -0
  756. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/readers.yml +9 -0
  757. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/references.yml +17 -0
  758. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml +5 -0
  759. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml +11 -0
  760. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml +14 -0
  761. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml +8 -0
  762. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml +7 -0
  763. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/ships.yml +5 -0
  764. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/sponsors.yml +9 -0
  765. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/subscribers.yml +7 -0
  766. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/subscriptions.yml +12 -0
  767. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/taggings.yml +28 -0
  768. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/tags.yml +7 -0
  769. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/tasks.yml +7 -0
  770. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/topics.yml +42 -0
  771. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/treasures.yml +10 -0
  772. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/vertices.yml +4 -0
  773. data/spec/rails_root/vendor/rails/activerecord/test/fixtures/warehouse-things.yml +3 -0
  774. data/spec/rails_root/vendor/rails/activerecord/test/migrations/decimal/1_give_me_big_numbers.rb +15 -0
  775. data/spec/rails_root/vendor/rails/activerecord/test/migrations/duplicate/1_people_have_last_names.rb +9 -0
  776. data/spec/rails_root/vendor/rails/activerecord/test/migrations/duplicate/2_we_need_reminders.rb +12 -0
  777. data/spec/rails_root/vendor/rails/activerecord/test/migrations/duplicate/3_foo.rb +7 -0
  778. data/spec/rails_root/vendor/rails/activerecord/test/migrations/duplicate/3_innocent_jointable.rb +12 -0
  779. data/spec/rails_root/vendor/rails/activerecord/test/migrations/duplicate_names/20080507052938_chunky.rb +7 -0
  780. data/spec/rails_root/vendor/rails/activerecord/test/migrations/duplicate_names/20080507053028_chunky.rb +7 -0
  781. data/spec/rails_root/vendor/rails/activerecord/test/migrations/interleaved/pass_1/3_innocent_jointable.rb +12 -0
  782. data/spec/rails_root/vendor/rails/activerecord/test/migrations/interleaved/pass_2/1_people_have_last_names.rb +9 -0
  783. data/spec/rails_root/vendor/rails/activerecord/test/migrations/interleaved/pass_2/3_innocent_jointable.rb +12 -0
  784. data/spec/rails_root/vendor/rails/activerecord/test/migrations/interleaved/pass_3/1_people_have_last_names.rb +9 -0
  785. data/spec/rails_root/vendor/rails/activerecord/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +8 -0
  786. data/spec/rails_root/vendor/rails/activerecord/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +12 -0
  787. data/spec/rails_root/vendor/rails/activerecord/test/migrations/missing/1000_people_have_middle_names.rb +9 -0
  788. data/spec/rails_root/vendor/rails/activerecord/test/migrations/missing/1_people_have_last_names.rb +9 -0
  789. data/spec/rails_root/vendor/rails/activerecord/test/migrations/missing/3_we_need_reminders.rb +12 -0
  790. data/spec/rails_root/vendor/rails/activerecord/test/migrations/missing/4_innocent_jointable.rb +12 -0
  791. data/spec/rails_root/vendor/rails/activerecord/test/migrations/valid/1_people_have_last_names.rb +9 -0
  792. data/spec/rails_root/vendor/rails/activerecord/test/migrations/valid/2_we_need_reminders.rb +12 -0
  793. data/spec/rails_root/vendor/rails/activerecord/test/migrations/valid/3_innocent_jointable.rb +12 -0
  794. data/spec/rails_root/vendor/rails/activerecord/test/models/author.rb +133 -0
  795. data/spec/rails_root/vendor/rails/activerecord/test/models/auto_id.rb +4 -0
  796. data/spec/rails_root/vendor/rails/activerecord/test/models/binary.rb +2 -0
  797. data/spec/rails_root/vendor/rails/activerecord/test/models/book.rb +4 -0
  798. data/spec/rails_root/vendor/rails/activerecord/test/models/categorization.rb +5 -0
  799. data/spec/rails_root/vendor/rails/activerecord/test/models/category.rb +29 -0
  800. data/spec/rails_root/vendor/rails/activerecord/test/models/citation.rb +6 -0
  801. data/spec/rails_root/vendor/rails/activerecord/test/models/club.rb +7 -0
  802. data/spec/rails_root/vendor/rails/activerecord/test/models/column_name.rb +3 -0
  803. data/spec/rails_root/vendor/rails/activerecord/test/models/comment.rb +25 -0
  804. data/spec/rails_root/vendor/rails/activerecord/test/models/company.rb +123 -0
  805. data/spec/rails_root/vendor/rails/activerecord/test/models/company_in_module.rb +61 -0
  806. data/spec/rails_root/vendor/rails/activerecord/test/models/computer.rb +3 -0
  807. data/spec/rails_root/vendor/rails/activerecord/test/models/contact.rb +16 -0
  808. data/spec/rails_root/vendor/rails/activerecord/test/models/course.rb +3 -0
  809. data/spec/rails_root/vendor/rails/activerecord/test/models/customer.rb +55 -0
  810. data/spec/rails_root/vendor/rails/activerecord/test/models/default.rb +2 -0
  811. data/spec/rails_root/vendor/rails/activerecord/test/models/developer.rb +76 -0
  812. data/spec/rails_root/vendor/rails/activerecord/test/models/edge.rb +5 -0
  813. data/spec/rails_root/vendor/rails/activerecord/test/models/entrant.rb +3 -0
  814. data/spec/rails_root/vendor/rails/activerecord/test/models/guid.rb +2 -0
  815. data/spec/rails_root/vendor/rails/activerecord/test/models/item.rb +7 -0
  816. data/spec/rails_root/vendor/rails/activerecord/test/models/job.rb +5 -0
  817. data/spec/rails_root/vendor/rails/activerecord/test/models/joke.rb +3 -0
  818. data/spec/rails_root/vendor/rails/activerecord/test/models/keyboard.rb +3 -0
  819. data/spec/rails_root/vendor/rails/activerecord/test/models/legacy_thing.rb +3 -0
  820. data/spec/rails_root/vendor/rails/activerecord/test/models/matey.rb +4 -0
  821. data/spec/rails_root/vendor/rails/activerecord/test/models/member.rb +9 -0
  822. data/spec/rails_root/vendor/rails/activerecord/test/models/membership.rb +9 -0
  823. data/spec/rails_root/vendor/rails/activerecord/test/models/minimalistic.rb +2 -0
  824. data/spec/rails_root/vendor/rails/activerecord/test/models/mixed_case_monkey.rb +3 -0
  825. data/spec/rails_root/vendor/rails/activerecord/test/models/movie.rb +5 -0
  826. data/spec/rails_root/vendor/rails/activerecord/test/models/order.rb +4 -0
  827. data/spec/rails_root/vendor/rails/activerecord/test/models/owner.rb +4 -0
  828. data/spec/rails_root/vendor/rails/activerecord/test/models/parrot.rb +13 -0
  829. data/spec/rails_root/vendor/rails/activerecord/test/models/person.rb +10 -0
  830. data/spec/rails_root/vendor/rails/activerecord/test/models/pet.rb +4 -0
  831. data/spec/rails_root/vendor/rails/activerecord/test/models/pirate.rb +9 -0
  832. data/spec/rails_root/vendor/rails/activerecord/test/models/post.rb +80 -0
  833. data/spec/rails_root/vendor/rails/activerecord/test/models/price_estimate.rb +3 -0
  834. data/spec/rails_root/vendor/rails/activerecord/test/models/project.rb +29 -0
  835. data/spec/rails_root/vendor/rails/activerecord/test/models/reader.rb +4 -0
  836. data/spec/rails_root/vendor/rails/activerecord/test/models/reference.rb +4 -0
  837. data/spec/rails_root/vendor/rails/activerecord/test/models/reply.rb +39 -0
  838. data/spec/rails_root/vendor/rails/activerecord/test/models/ship.rb +3 -0
  839. data/spec/rails_root/vendor/rails/activerecord/test/models/sponsor.rb +4 -0
  840. data/spec/rails_root/vendor/rails/activerecord/test/models/subject.rb +4 -0
  841. data/spec/rails_root/vendor/rails/activerecord/test/models/subscriber.rb +8 -0
  842. data/spec/rails_root/vendor/rails/activerecord/test/models/subscription.rb +4 -0
  843. data/spec/rails_root/vendor/rails/activerecord/test/models/tag.rb +7 -0
  844. data/spec/rails_root/vendor/rails/activerecord/test/models/tagging.rb +10 -0
  845. data/spec/rails_root/vendor/rails/activerecord/test/models/task.rb +3 -0
  846. data/spec/rails_root/vendor/rails/activerecord/test/models/topic.rb +65 -0
  847. data/spec/rails_root/vendor/rails/activerecord/test/models/treasure.rb +6 -0
  848. data/spec/rails_root/vendor/rails/activerecord/test/models/vertex.rb +9 -0
  849. data/spec/rails_root/vendor/rails/activerecord/test/models/warehouse_thing.rb +5 -0
  850. data/spec/rails_root/vendor/rails/activerecord/test/schema/mysql_specific_schema.rb +12 -0
  851. data/spec/rails_root/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +103 -0
  852. data/spec/rails_root/vendor/rails/activerecord/test/schema/schema.rb +421 -0
  853. data/spec/rails_root/vendor/rails/activerecord/test/schema/schema2.rb +6 -0
  854. data/spec/rails_root/vendor/rails/activerecord/test/schema/sqlite_specific_schema.rb +25 -0
  855. data/spec/rails_root/vendor/rails/activerecord/test/schema/sqlserver_specific_schema.rb +5 -0
  856. data/spec/rails_root/vendor/rails/activeresource/CHANGELOG +246 -0
  857. data/spec/rails_root/vendor/rails/activeresource/README +165 -0
  858. data/spec/rails_root/vendor/rails/activeresource/Rakefile +135 -0
  859. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource.rb +47 -0
  860. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/base.rb +1014 -0
  861. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/connection.rb +207 -0
  862. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/custom_methods.rb +119 -0
  863. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/formats.rb +14 -0
  864. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +23 -0
  865. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb +34 -0
  866. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/http_mock.rb +217 -0
  867. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/validations.rb +288 -0
  868. data/spec/rails_root/vendor/rails/activeresource/lib/active_resource/version.rb +9 -0
  869. data/spec/rails_root/vendor/rails/activeresource/lib/activeresource.rb +1 -0
  870. data/spec/rails_root/vendor/rails/activeresource/test/abstract_unit.rb +22 -0
  871. data/spec/rails_root/vendor/rails/activeresource/test/authorization_test.rb +122 -0
  872. data/spec/rails_root/vendor/rails/activeresource/test/base/custom_methods_test.rb +99 -0
  873. data/spec/rails_root/vendor/rails/activeresource/test/base/equality_test.rb +43 -0
  874. data/spec/rails_root/vendor/rails/activeresource/test/base/load_test.rb +146 -0
  875. data/spec/rails_root/vendor/rails/activeresource/test/base_errors_test.rb +48 -0
  876. data/spec/rails_root/vendor/rails/activeresource/test/base_test.rb +791 -0
  877. data/spec/rails_root/vendor/rails/activeresource/test/connection_test.rb +190 -0
  878. data/spec/rails_root/vendor/rails/activeresource/test/fixtures/beast.rb +14 -0
  879. data/spec/rails_root/vendor/rails/activeresource/test/fixtures/person.rb +3 -0
  880. data/spec/rails_root/vendor/rails/activeresource/test/fixtures/street_address.rb +4 -0
  881. data/spec/rails_root/vendor/rails/activeresource/test/format_test.rb +83 -0
  882. data/spec/rails_root/vendor/rails/activeresource/test/setter_trap.rb +27 -0
  883. data/spec/rails_root/vendor/rails/activesupport/CHANGELOG +1181 -0
  884. data/spec/rails_root/vendor/rails/activesupport/README +43 -0
  885. data/spec/rails_root/vendor/rails/activesupport/lib/active_support.rb +55 -0
  886. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/base64.rb +22 -0
  887. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/basic_object.rb +24 -0
  888. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/buffered_logger.rb +121 -0
  889. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/cache.rb +145 -0
  890. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb +15 -0
  891. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/cache/drb_store.rb +15 -0
  892. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/cache/file_store.rb +70 -0
  893. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +100 -0
  894. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/cache/memory_store.rb +38 -0
  895. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/callbacks.rb +275 -0
  896. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/clean_logger.rb +127 -0
  897. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext.rb +4 -0
  898. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array.rb +13 -0
  899. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb +26 -0
  900. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +178 -0
  901. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb +20 -0
  902. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb +63 -0
  903. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb +12 -0
  904. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/base64.rb +4 -0
  905. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/base64/encoding.rb +13 -0
  906. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb +12 -0
  907. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb +6 -0
  908. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb +41 -0
  909. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +53 -0
  910. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb +5 -0
  911. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
  912. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/class.rb +4 -0
  913. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
  914. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +46 -0
  915. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  916. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb +50 -0
  917. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date.rb +10 -0
  918. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb +13 -0
  919. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +215 -0
  920. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb +107 -0
  921. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb +12 -0
  922. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb +112 -0
  923. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb +96 -0
  924. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb +37 -0
  925. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +69 -0
  926. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb +41 -0
  927. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/file.rb +21 -0
  928. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/float.rb +5 -0
  929. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb +24 -0
  930. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb +13 -0
  931. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +259 -0
  932. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb +19 -0
  933. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb +24 -0
  934. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +137 -0
  935. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb +52 -0
  936. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +28 -0
  937. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb +28 -0
  938. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb +7 -0
  939. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb +29 -0
  940. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb +20 -0
  941. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb +5 -0
  942. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  943. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  944. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +13 -0
  945. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb +59 -0
  946. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb +24 -0
  947. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb +38 -0
  948. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb +16 -0
  949. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module.rb +8 -0
  950. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb +70 -0
  951. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  952. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  953. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
  954. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +64 -0
  955. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb +30 -0
  956. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +75 -0
  957. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb +23 -0
  958. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb +17 -0
  959. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb +9 -0
  960. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +44 -0
  961. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  962. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb +91 -0
  963. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/object.rb +4 -0
  964. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb +14 -0
  965. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb +58 -0
  966. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  967. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb +59 -0
  968. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb +7 -0
  969. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
  970. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb +12 -0
  971. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/process.rb +1 -0
  972. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/process/daemon.rb +25 -0
  973. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range.rb +11 -0
  974. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb +32 -0
  975. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb +27 -0
  976. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb +30 -0
  977. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb +15 -0
  978. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +18 -0
  979. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +82 -0
  980. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb +28 -0
  981. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/filters.rb +26 -0
  982. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb +148 -0
  983. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb +21 -0
  984. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
  985. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/unicode.rb +68 -0
  986. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb +11 -0
  987. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb +14 -0
  988. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/test.rb +1 -0
  989. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/test/unit/assertions.rb +64 -0
  990. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/time.rb +21 -0
  991. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb +13 -0
  992. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +276 -0
  993. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb +89 -0
  994. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/core_ext/time/zones.rb +86 -0
  995. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/dependencies.rb +552 -0
  996. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/deprecation.rb +205 -0
  997. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/duration.rb +96 -0
  998. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/gzip.rb +25 -0
  999. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/inflections.rb +53 -0
  1000. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/inflector.rb +308 -0
  1001. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json.rb +23 -0
  1002. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/decoding.rb +63 -0
  1003. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +14 -0
  1004. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +14 -0
  1005. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +12 -0
  1006. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +5 -0
  1007. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +47 -0
  1008. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +5 -0
  1009. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +5 -0
  1010. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +6 -0
  1011. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +5 -0
  1012. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +36 -0
  1013. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +5 -0
  1014. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +14 -0
  1015. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +5 -0
  1016. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/encoding.rb +37 -0
  1017. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/json/variable.rb +10 -0
  1018. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte.rb +9 -0
  1019. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +137 -0
  1020. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/generators/generate_tables.rb +149 -0
  1021. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/handlers/passthru_handler.rb +9 -0
  1022. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb +564 -0
  1023. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +43 -0
  1024. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/option_merger.rb +25 -0
  1025. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +43 -0
  1026. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/ordered_options.rb +17 -0
  1027. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/test_case.rb +13 -0
  1028. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/testing/default.rb +9 -0
  1029. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb +93 -0
  1030. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +283 -0
  1031. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/values/time_zone.rb +394 -0
  1032. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat +0 -0
  1033. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor.rb +26 -0
  1034. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  1035. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  1036. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  1037. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  1038. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  1039. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  1040. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  1041. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  1042. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/memcache-client-1.5.0/memcache.rb +849 -0
  1043. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo.rb +33 -0
  1044. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/data_timezone.rb +47 -0
  1045. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/data_timezone_info.rb +226 -0
  1046. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Algiers.rb +55 -0
  1047. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Cairo.rb +219 -0
  1048. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Casablanca.rb +38 -0
  1049. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Harare.rb +18 -0
  1050. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  1051. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  1052. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  1053. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  1054. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Argentina/San_Juan.rb +170 -0
  1055. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Bogota.rb +23 -0
  1056. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Caracas.rb +23 -0
  1057. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Chicago.rb +283 -0
  1058. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Chihuahua.rb +136 -0
  1059. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Denver.rb +204 -0
  1060. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Godthab.rb +161 -0
  1061. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Guatemala.rb +27 -0
  1062. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Halifax.rb +274 -0
  1063. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  1064. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Juneau.rb +194 -0
  1065. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/La_Paz.rb +22 -0
  1066. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Lima.rb +35 -0
  1067. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  1068. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Mazatlan.rb +139 -0
  1069. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Mexico_City.rb +144 -0
  1070. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Monterrey.rb +131 -0
  1071. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/New_York.rb +282 -0
  1072. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Phoenix.rb +30 -0
  1073. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Regina.rb +74 -0
  1074. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Santiago.rb +205 -0
  1075. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/St_Johns.rb +288 -0
  1076. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/America/Tijuana.rb +196 -0
  1077. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Almaty.rb +67 -0
  1078. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  1079. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Baku.rb +161 -0
  1080. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  1081. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  1082. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  1083. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  1084. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  1085. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  1086. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  1087. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kabul.rb +20 -0
  1088. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  1089. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Karachi.rb +28 -0
  1090. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  1091. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  1092. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  1093. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  1094. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  1095. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Magadan.rb +163 -0
  1096. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Muscat.rb +18 -0
  1097. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  1098. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  1099. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  1100. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Seoul.rb +34 -0
  1101. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  1102. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Singapore.rb +33 -0
  1103. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Taipei.rb +59 -0
  1104. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  1105. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  1106. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tehran.rb +121 -0
  1107. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  1108. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  1109. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  1110. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  1111. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  1112. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  1113. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  1114. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  1115. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  1116. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  1117. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  1118. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  1119. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Darwin.rb +29 -0
  1120. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Hobart.rb +193 -0
  1121. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  1122. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Perth.rb +37 -0
  1123. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Australia/Sydney.rb +185 -0
  1124. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Etc/UTC.rb +16 -0
  1125. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  1126. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Athens.rb +185 -0
  1127. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  1128. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Berlin.rb +188 -0
  1129. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  1130. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Brussels.rb +232 -0
  1131. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  1132. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Budapest.rb +197 -0
  1133. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  1134. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Dublin.rb +276 -0
  1135. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  1136. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  1137. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Kiev.rb +168 -0
  1138. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  1139. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  1140. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/London.rb +288 -0
  1141. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Madrid.rb +211 -0
  1142. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Minsk.rb +170 -0
  1143. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Moscow.rb +181 -0
  1144. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Paris.rb +232 -0
  1145. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Prague.rb +187 -0
  1146. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Riga.rb +176 -0
  1147. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Rome.rb +215 -0
  1148. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  1149. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Skopje.rb +13 -0
  1150. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Sofia.rb +173 -0
  1151. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  1152. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  1153. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Vienna.rb +183 -0
  1154. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  1155. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  1156. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  1157. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  1158. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  1159. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Guam.rb +22 -0
  1160. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  1161. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  1162. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Midway.rb +25 -0
  1163. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  1164. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  1165. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  1166. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  1167. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/info_timezone.rb +52 -0
  1168. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/linked_timezone.rb +51 -0
  1169. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/linked_timezone_info.rb +44 -0
  1170. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/offset_rationals.rb +95 -0
  1171. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/time_or_datetime.rb +292 -0
  1172. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone.rb +508 -0
  1173. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_definition.rb +56 -0
  1174. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_info.rb +40 -0
  1175. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_offset_info.rb +94 -0
  1176. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_period.rb +198 -0
  1177. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_transition_info.rb +138 -0
  1178. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
  1179. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/version.rb +9 -0
  1180. data/spec/rails_root/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +58 -0
  1181. data/spec/rails_root/vendor/rails/activesupport/lib/activesupport.rb +1 -0
  1182. data/spec/rails_root/vendor/rails/railties/CHANGELOG +2027 -0
  1183. data/spec/rails_root/vendor/rails/railties/MIT-LICENSE +20 -0
  1184. data/spec/rails_root/vendor/rails/railties/README +256 -0
  1185. data/spec/rails_root/vendor/rails/railties/Rakefile +349 -0
  1186. data/spec/rails_root/vendor/rails/railties/bin/about +3 -0
  1187. data/spec/rails_root/vendor/rails/railties/bin/console +3 -0
  1188. data/spec/rails_root/vendor/rails/railties/bin/dbconsole +3 -0
  1189. data/spec/rails_root/vendor/rails/railties/bin/destroy +3 -0
  1190. data/spec/rails_root/vendor/rails/railties/bin/generate +3 -0
  1191. data/spec/rails_root/vendor/rails/railties/bin/performance/benchmarker +3 -0
  1192. data/spec/rails_root/vendor/rails/railties/bin/performance/profiler +3 -0
  1193. data/spec/rails_root/vendor/rails/railties/bin/performance/request +3 -0
  1194. data/spec/rails_root/vendor/rails/railties/bin/plugin +3 -0
  1195. data/spec/rails_root/vendor/rails/railties/bin/process/inspector +3 -0
  1196. data/spec/rails_root/vendor/rails/railties/bin/process/reaper +3 -0
  1197. data/spec/rails_root/vendor/rails/railties/bin/process/spawner +3 -0
  1198. data/spec/rails_root/vendor/rails/railties/bin/rails +19 -0
  1199. data/spec/rails_root/vendor/rails/railties/bin/runner +3 -0
  1200. data/spec/rails_root/vendor/rails/railties/bin/server +3 -0
  1201. data/spec/rails_root/vendor/rails/railties/builtin/rails_info/rails/info.rb +125 -0
  1202. data/spec/rails_root/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb +9 -0
  1203. data/spec/rails_root/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb +2 -0
  1204. data/spec/rails_root/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb +2 -0
  1205. data/spec/rails_root/vendor/rails/railties/configs/apache.conf +40 -0
  1206. data/spec/rails_root/vendor/rails/railties/configs/databases/frontbase.yml +28 -0
  1207. data/spec/rails_root/vendor/rails/railties/configs/databases/mysql.yml +54 -0
  1208. data/spec/rails_root/vendor/rails/railties/configs/databases/oracle.yml +39 -0
  1209. data/spec/rails_root/vendor/rails/railties/configs/databases/postgresql.yml +48 -0
  1210. data/spec/rails_root/vendor/rails/railties/configs/databases/sqlite2.yml +16 -0
  1211. data/spec/rails_root/vendor/rails/railties/configs/databases/sqlite3.yml +19 -0
  1212. data/spec/rails_root/vendor/rails/railties/configs/empty.log +0 -0
  1213. data/spec/rails_root/vendor/rails/railties/configs/initializers/inflections.rb +10 -0
  1214. data/spec/rails_root/vendor/rails/railties/configs/initializers/mime_types.rb +5 -0
  1215. data/spec/rails_root/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +15 -0
  1216. data/spec/rails_root/vendor/rails/railties/configs/lighttpd.conf +54 -0
  1217. data/spec/rails_root/vendor/rails/railties/configs/routes.rb +41 -0
  1218. data/spec/rails_root/vendor/rails/railties/dispatches/dispatch.fcgi +24 -0
  1219. data/spec/rails_root/vendor/rails/railties/dispatches/dispatch.rb +10 -0
  1220. data/spec/rails_root/vendor/rails/railties/dispatches/gateway.cgi +97 -0
  1221. data/spec/rails_root/vendor/rails/railties/doc/README_FOR_APP +2 -0
  1222. data/spec/rails_root/vendor/rails/railties/environments/boot.rb +109 -0
  1223. data/spec/rails_root/vendor/rails/railties/environments/development.rb +17 -0
  1224. data/spec/rails_root/vendor/rails/railties/environments/environment.rb +67 -0
  1225. data/spec/rails_root/vendor/rails/railties/environments/production.rb +22 -0
  1226. data/spec/rails_root/vendor/rails/railties/environments/test.rb +22 -0
  1227. data/spec/rails_root/vendor/rails/railties/fresh_rakefile +10 -0
  1228. data/spec/rails_root/vendor/rails/railties/helpers/application.rb +15 -0
  1229. data/spec/rails_root/vendor/rails/railties/helpers/application_helper.rb +3 -0
  1230. data/spec/rails_root/vendor/rails/railties/helpers/test_helper.rb +38 -0
  1231. data/spec/rails_root/vendor/rails/railties/html/404.html +30 -0
  1232. data/spec/rails_root/vendor/rails/railties/html/422.html +30 -0
  1233. data/spec/rails_root/vendor/rails/railties/html/500.html +30 -0
  1234. data/spec/rails_root/vendor/rails/railties/html/favicon.ico +0 -0
  1235. data/spec/rails_root/vendor/rails/railties/html/images/rails.png +0 -0
  1236. data/spec/rails_root/vendor/rails/railties/html/index.html +274 -0
  1237. data/spec/rails_root/vendor/rails/railties/html/javascripts/application.js +2 -0
  1238. data/spec/rails_root/vendor/rails/railties/html/javascripts/controls.js +963 -0
  1239. data/spec/rails_root/vendor/rails/railties/html/javascripts/dragdrop.js +972 -0
  1240. data/spec/rails_root/vendor/rails/railties/html/javascripts/effects.js +1120 -0
  1241. data/spec/rails_root/vendor/rails/railties/html/javascripts/prototype.js +4225 -0
  1242. data/spec/rails_root/vendor/rails/railties/html/robots.txt +5 -0
  1243. data/spec/rails_root/vendor/rails/railties/lib/code_statistics.rb +107 -0
  1244. data/spec/rails_root/vendor/rails/railties/lib/commands.rb +17 -0
  1245. data/spec/rails_root/vendor/rails/railties/lib/commands/about.rb +2 -0
  1246. data/spec/rails_root/vendor/rails/railties/lib/commands/console.rb +32 -0
  1247. data/spec/rails_root/vendor/rails/railties/lib/commands/dbconsole.rb +65 -0
  1248. data/spec/rails_root/vendor/rails/railties/lib/commands/destroy.rb +6 -0
  1249. data/spec/rails_root/vendor/rails/railties/lib/commands/generate.rb +6 -0
  1250. data/spec/rails_root/vendor/rails/railties/lib/commands/ncgi/listener +86 -0
  1251. data/spec/rails_root/vendor/rails/railties/lib/commands/ncgi/tracker +69 -0
  1252. data/spec/rails_root/vendor/rails/railties/lib/commands/performance/benchmarker.rb +24 -0
  1253. data/spec/rails_root/vendor/rails/railties/lib/commands/performance/profiler.rb +50 -0
  1254. data/spec/rails_root/vendor/rails/railties/lib/commands/performance/request.rb +6 -0
  1255. data/spec/rails_root/vendor/rails/railties/lib/commands/plugin.rb +950 -0
  1256. data/spec/rails_root/vendor/rails/railties/lib/commands/process/inspector.rb +68 -0
  1257. data/spec/rails_root/vendor/rails/railties/lib/commands/process/reaper.rb +149 -0
  1258. data/spec/rails_root/vendor/rails/railties/lib/commands/process/spawner.rb +219 -0
  1259. data/spec/rails_root/vendor/rails/railties/lib/commands/process/spinner.rb +57 -0
  1260. data/spec/rails_root/vendor/rails/railties/lib/commands/runner.rb +48 -0
  1261. data/spec/rails_root/vendor/rails/railties/lib/commands/server.rb +39 -0
  1262. data/spec/rails_root/vendor/rails/railties/lib/commands/servers/base.rb +31 -0
  1263. data/spec/rails_root/vendor/rails/railties/lib/commands/servers/lighttpd.rb +94 -0
  1264. data/spec/rails_root/vendor/rails/railties/lib/commands/servers/mongrel.rb +69 -0
  1265. data/spec/rails_root/vendor/rails/railties/lib/commands/servers/new_mongrel.rb +16 -0
  1266. data/spec/rails_root/vendor/rails/railties/lib/commands/servers/webrick.rb +66 -0
  1267. data/spec/rails_root/vendor/rails/railties/lib/commands/update.rb +4 -0
  1268. data/spec/rails_root/vendor/rails/railties/lib/console_app.rb +30 -0
  1269. data/spec/rails_root/vendor/rails/railties/lib/console_sandbox.rb +6 -0
  1270. data/spec/rails_root/vendor/rails/railties/lib/console_with_helpers.rb +26 -0
  1271. data/spec/rails_root/vendor/rails/railties/lib/dispatcher.rb +24 -0
  1272. data/spec/rails_root/vendor/rails/railties/lib/fcgi_handler.rb +239 -0
  1273. data/spec/rails_root/vendor/rails/railties/lib/initializer.rb +900 -0
  1274. data/spec/rails_root/vendor/rails/railties/lib/rails/gem_builder.rb +21 -0
  1275. data/spec/rails_root/vendor/rails/railties/lib/rails/gem_dependency.rb +124 -0
  1276. data/spec/rails_root/vendor/rails/railties/lib/rails/mongrel_server/commands.rb +342 -0
  1277. data/spec/rails_root/vendor/rails/railties/lib/rails/mongrel_server/handler.rb +55 -0
  1278. data/spec/rails_root/vendor/rails/railties/lib/rails/plugin.rb +115 -0
  1279. data/spec/rails_root/vendor/rails/railties/lib/rails/plugin/loader.rb +152 -0
  1280. data/spec/rails_root/vendor/rails/railties/lib/rails/plugin/locator.rb +99 -0
  1281. data/spec/rails_root/vendor/rails/railties/lib/rails/version.rb +9 -0
  1282. data/spec/rails_root/vendor/rails/railties/lib/rails_generator.rb +43 -0
  1283. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/base.rb +263 -0
  1284. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/commands.rb +607 -0
  1285. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generated_attribute.rb +42 -0
  1286. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE +9 -0
  1287. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +178 -0
  1288. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE +29 -0
  1289. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb +37 -0
  1290. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb +7 -0
  1291. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb +8 -0
  1292. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb +2 -0
  1293. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb +2 -0
  1294. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE +8 -0
  1295. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +16 -0
  1296. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +10 -0
  1297. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE +16 -0
  1298. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb +30 -0
  1299. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb +3 -0
  1300. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
  1301. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb +15 -0
  1302. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +21 -0
  1303. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb +3 -0
  1304. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
  1305. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE +29 -0
  1306. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb +20 -0
  1307. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb +11 -0
  1308. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE +27 -0
  1309. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +45 -0
  1310. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml +19 -0
  1311. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb +16 -0
  1312. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
  1313. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb +8 -0
  1314. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE +13 -0
  1315. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
  1316. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
  1317. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb +8 -0
  1318. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE +25 -0
  1319. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +39 -0
  1320. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +20 -0
  1321. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README +13 -0
  1322. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +22 -0
  1323. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE +8 -0
  1324. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb +8 -0
  1325. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -0
  1326. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb +1 -0
  1327. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -0
  1328. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake +4 -0
  1329. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
  1330. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +8 -0
  1331. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE +23 -0
  1332. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +74 -0
  1333. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
  1334. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb +8 -0
  1335. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
  1336. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE +25 -0
  1337. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +93 -0
  1338. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +85 -0
  1339. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +45 -0
  1340. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb +2 -0
  1341. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +17 -0
  1342. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css +54 -0
  1343. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +18 -0
  1344. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +24 -0
  1345. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +17 -0
  1346. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +10 -0
  1347. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE +10 -0
  1348. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +18 -0
  1349. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb +16 -0
  1350. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/lookup.rb +248 -0
  1351. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/manifest.rb +53 -0
  1352. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/options.rb +150 -0
  1353. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/scripts.rb +89 -0
  1354. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb +30 -0
  1355. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/scripts/generate.rb +7 -0
  1356. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/scripts/update.rb +12 -0
  1357. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb +164 -0
  1358. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/simple_logger.rb +46 -0
  1359. data/spec/rails_root/vendor/rails/railties/lib/rails_generator/spec.rb +44 -0
  1360. data/spec/rails_root/vendor/rails/railties/lib/railties_path.rb +1 -0
  1361. data/spec/rails_root/vendor/rails/railties/lib/ruby_version_check.rb +17 -0
  1362. data/spec/rails_root/vendor/rails/railties/lib/rubyprof_ext.rb +35 -0
  1363. data/spec/rails_root/vendor/rails/railties/lib/source_annotation_extractor.rb +102 -0
  1364. data/spec/rails_root/vendor/rails/railties/lib/tasks/annotations.rake +23 -0
  1365. data/spec/rails_root/vendor/rails/railties/lib/tasks/databases.rake +387 -0
  1366. data/spec/rails_root/vendor/rails/railties/lib/tasks/documentation.rake +80 -0
  1367. data/spec/rails_root/vendor/rails/railties/lib/tasks/framework.rake +114 -0
  1368. data/spec/rails_root/vendor/rails/railties/lib/tasks/gems.rake +64 -0
  1369. data/spec/rails_root/vendor/rails/railties/lib/tasks/log.rake +9 -0
  1370. data/spec/rails_root/vendor/rails/railties/lib/tasks/misc.rake +57 -0
  1371. data/spec/rails_root/vendor/rails/railties/lib/tasks/rails.rb +8 -0
  1372. data/spec/rails_root/vendor/rails/railties/lib/tasks/routes.rake +17 -0
  1373. data/spec/rails_root/vendor/rails/railties/lib/tasks/statistics.rake +18 -0
  1374. data/spec/rails_root/vendor/rails/railties/lib/tasks/testing.rake +118 -0
  1375. data/spec/rails_root/vendor/rails/railties/lib/tasks/tmp.rake +37 -0
  1376. data/spec/rails_root/vendor/rails/railties/lib/test_help.rb +28 -0
  1377. data/spec/rails_root/vendor/rails/railties/lib/webrick_server.rb +165 -0
  1378. data/todo.yml +23 -0
  1379. metadata +2443 -0
@@ -0,0 +1,2726 @@
1
+ require 'yaml'
2
+ require 'set'
3
+
4
+ module ActiveRecord #:nodoc:
5
+ # Generic Active Record exception class.
6
+ class ActiveRecordError < StandardError
7
+ end
8
+
9
+ # Raised when the single-table inheritance mechanism failes to locate the subclass
10
+ # (for example due to improper usage of column that +inheritance_column+ points to).
11
+ class SubclassNotFound < ActiveRecordError #:nodoc:
12
+ end
13
+
14
+ # Raised when an object assigned to an association has an incorrect type.
15
+ #
16
+ # class Ticket < ActiveRecord::Base
17
+ # has_many :patches
18
+ # end
19
+ #
20
+ # class Patch < ActiveRecord::Base
21
+ # belongs_to :ticket
22
+ # end
23
+ #
24
+ # # Comments are not patches, this assignment raises AssociationTypeMismatch.
25
+ # @ticket.patches << Comment.new(:content => "Please attach tests to your patch.")
26
+ class AssociationTypeMismatch < ActiveRecordError
27
+ end
28
+
29
+ # Raised when unserialized object's type mismatches one specified for serializable field.
30
+ class SerializationTypeMismatch < ActiveRecordError
31
+ end
32
+
33
+ # Raised when adapter not specified on connection (or configuration file <tt>config/database.yml</tt> misses adapter field).
34
+ class AdapterNotSpecified < ActiveRecordError
35
+ end
36
+
37
+ # Raised when Active Record cannot find database adapter specified in <tt>config/database.yml</tt> or programmatically.
38
+ class AdapterNotFound < ActiveRecordError
39
+ end
40
+
41
+ # Raised when connection to the database could not been established (for example when <tt>connection=</tt> is given a nil object).
42
+ class ConnectionNotEstablished < ActiveRecordError
43
+ end
44
+
45
+ # Raised when Active Record cannot find record by given id or set of ids.
46
+ class RecordNotFound < ActiveRecordError
47
+ end
48
+
49
+ # Raised by ActiveRecord::Base.save! and ActiveRecord::Base.create! methods when record cannot be
50
+ # saved because record is invalid.
51
+ class RecordNotSaved < ActiveRecordError
52
+ end
53
+
54
+ # Raised when SQL statement cannot be executed by the database (for example, it's often the case for MySQL when Ruby driver used is too old).
55
+ class StatementInvalid < ActiveRecordError
56
+ end
57
+
58
+ # Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example, when using +find+ method)
59
+ # does not match number of expected variables.
60
+ #
61
+ # For example, in
62
+ #
63
+ # Location.find :all, :conditions => ["lat = ? AND lng = ?", 53.7362]
64
+ #
65
+ # two placeholders are given but only one variable to fill them.
66
+ class PreparedStatementInvalid < ActiveRecordError
67
+ end
68
+
69
+ # Raised on attempt to save stale record. Record is stale when it's being saved in another query after
70
+ # instantiation, for example, when two users edit the same wiki page and one starts editing and saves
71
+ # the page before the other.
72
+ #
73
+ # Read more about optimistic locking in ActiveRecord::Locking module RDoc.
74
+ class StaleObjectError < ActiveRecordError
75
+ end
76
+
77
+ # Raised when association is being configured improperly or
78
+ # user tries to use offset and limit together with has_many or has_and_belongs_to_many associations.
79
+ class ConfigurationError < ActiveRecordError
80
+ end
81
+
82
+ # Raised on attempt to update record that is instantiated as read only.
83
+ class ReadOnlyRecord < ActiveRecordError
84
+ end
85
+
86
+ # Used by Active Record transaction mechanism to distinguish rollback from other exceptional situations.
87
+ # You can use it to roll your transaction back explicitly in the block passed to +transaction+ method.
88
+ class Rollback < ActiveRecordError
89
+ end
90
+
91
+ # Raised when attribute has a name reserved by Active Record (when attribute has name of one of Active Record instance methods).
92
+ class DangerousAttributeError < ActiveRecordError
93
+ end
94
+
95
+ # Raised when you've tried to access a column which wasn't loaded by your finder.
96
+ # Typically this is because <tt>:select</tt> has been specified.
97
+ class MissingAttributeError < NoMethodError
98
+ end
99
+
100
+ # Raised when an error occured while doing a mass assignment to an attribute through the
101
+ # <tt>attributes=</tt> method. The exception has an +attribute+ property that is the name of the
102
+ # offending attribute.
103
+ class AttributeAssignmentError < ActiveRecordError
104
+ attr_reader :exception, :attribute
105
+ def initialize(message, exception, attribute)
106
+ @exception = exception
107
+ @attribute = attribute
108
+ @message = message
109
+ end
110
+ end
111
+
112
+ # Raised when there are multiple errors while doing a mass assignment through the +attributes+
113
+ # method. The exception has an +errors+ property that contains an array of AttributeAssignmentError
114
+ # objects, each corresponding to the error while assigning to an attribute.
115
+ class MultiparameterAssignmentErrors < ActiveRecordError
116
+ attr_reader :errors
117
+ def initialize(errors)
118
+ @errors = errors
119
+ end
120
+ end
121
+
122
+ # Active Record objects don't specify their attributes directly, but rather infer them from the table definition with
123
+ # which they're linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change
124
+ # is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain
125
+ # database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
126
+ #
127
+ # See the mapping rules in table_name and the full example in link:files/README.html for more insight.
128
+ #
129
+ # == Creation
130
+ #
131
+ # Active Records accept constructor parameters either in a hash or as a block. The hash method is especially useful when
132
+ # you're receiving the data from somewhere else, like an HTTP request. It works like this:
133
+ #
134
+ # user = User.new(:name => "David", :occupation => "Code Artist")
135
+ # user.name # => "David"
136
+ #
137
+ # You can also use block initialization:
138
+ #
139
+ # user = User.new do |u|
140
+ # u.name = "David"
141
+ # u.occupation = "Code Artist"
142
+ # end
143
+ #
144
+ # And of course you can just create a bare object and specify the attributes after the fact:
145
+ #
146
+ # user = User.new
147
+ # user.name = "David"
148
+ # user.occupation = "Code Artist"
149
+ #
150
+ # == Conditions
151
+ #
152
+ # Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement.
153
+ # The array form is to be used when the condition input is tainted and requires sanitization. The string form can
154
+ # be used for statements that don't involve tainted data. The hash form works much like the array form, except
155
+ # only equality and range is possible. Examples:
156
+ #
157
+ # class User < ActiveRecord::Base
158
+ # def self.authenticate_unsafely(user_name, password)
159
+ # find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'")
160
+ # end
161
+ #
162
+ # def self.authenticate_safely(user_name, password)
163
+ # find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ])
164
+ # end
165
+ #
166
+ # def self.authenticate_safely_simply(user_name, password)
167
+ # find(:first, :conditions => { :user_name => user_name, :password => password })
168
+ # end
169
+ # end
170
+ #
171
+ # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query and is thus susceptible to SQL-injection
172
+ # attacks if the <tt>user_name</tt> and +password+ parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and
173
+ # <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+ before inserting them in the query,
174
+ # which will ensure that an attacker can't escape the query and fake the login (or worse).
175
+ #
176
+ # When using multiple parameters in the conditions, it can easily become hard to read exactly what the fourth or fifth
177
+ # question mark is supposed to represent. In those cases, you can resort to named bind variables instead. That's done by replacing
178
+ # the question marks with symbols and supplying a hash with values for the matching symbol keys:
179
+ #
180
+ # Company.find(:first, :conditions => [
181
+ # "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
182
+ # { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' }
183
+ # ])
184
+ #
185
+ # Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND
186
+ # operator. For instance:
187
+ #
188
+ # Student.find(:all, :conditions => { :first_name => "Harvey", :status => 1 })
189
+ # Student.find(:all, :conditions => params[:student])
190
+ #
191
+ # A range may be used in the hash to use the SQL BETWEEN operator:
192
+ #
193
+ # Student.find(:all, :conditions => { :grade => 9..12 })
194
+ #
195
+ # An array may be used in the hash to use the SQL IN operator:
196
+ #
197
+ # Student.find(:all, :conditions => { :grade => [9,11,12] })
198
+ #
199
+ # == Overwriting default accessors
200
+ #
201
+ # All column values are automatically available through basic accessors on the Active Record object, but sometimes you
202
+ # want to specialize this behavior. This can be done by overwriting the default accessors (using the same
203
+ # name as the attribute) and calling <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually change things.
204
+ # Example:
205
+ #
206
+ # class Song < ActiveRecord::Base
207
+ # # Uses an integer of seconds to hold the length of the song
208
+ #
209
+ # def length=(minutes)
210
+ # write_attribute(:length, minutes.to_i * 60)
211
+ # end
212
+ #
213
+ # def length
214
+ # read_attribute(:length) / 60
215
+ # end
216
+ # end
217
+ #
218
+ # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt> instead of <tt>write_attribute(:attribute, value)</tt> and
219
+ # <tt>read_attribute(:attribute)</tt> as a shorter form.
220
+ #
221
+ # == Attribute query methods
222
+ #
223
+ # In addition to the basic accessors, query methods are also automatically available on the Active Record object.
224
+ # Query methods allow you to test whether an attribute value is present.
225
+ #
226
+ # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
227
+ # to determine whether the user has a name:
228
+ #
229
+ # user = User.new(:name => "David")
230
+ # user.name? # => true
231
+ #
232
+ # anonymous = User.new(:name => "")
233
+ # anonymous.name? # => false
234
+ #
235
+ # == Accessing attributes before they have been typecasted
236
+ #
237
+ # Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first.
238
+ # That can be done by using the <tt><attribute>_before_type_cast</tt> accessors that all attributes have. For example, if your Account model
239
+ # has a <tt>balance</tt> attribute, you can call <tt>account.balance_before_type_cast</tt> or <tt>account.id_before_type_cast</tt>.
240
+ #
241
+ # This is especially useful in validation situations where the user might supply a string for an integer field and you want to display
242
+ # the original string back in an error message. Accessing the attribute normally would typecast the string to 0, which isn't what you
243
+ # want.
244
+ #
245
+ # == Dynamic attribute-based finders
246
+ #
247
+ # Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects by simple queries without turning to SQL. They work by
248
+ # appending the name of an attribute to <tt>find_by_</tt> or <tt>find_all_by_</tt>, so you get finders like <tt>Person.find_by_user_name</tt>,
249
+ # <tt>Person.find_all_by_last_name</tt>, and <tt>Payment.find_by_transaction_id</tt>. So instead of writing
250
+ # <tt>Person.find(:first, :conditions => ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
251
+ # And instead of writing <tt>Person.find(:all, :conditions => ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>.
252
+ #
253
+ # It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
254
+ # <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing
255
+ # <tt>Person.find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt>, you just do
256
+ # <tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
257
+ #
258
+ # It's even possible to use all the additional parameters to find. For example, the full interface for <tt>Payment.find_all_by_amount</tt>
259
+ # is actually <tt>Payment.find_all_by_amount(amount, options)</tt>. And the full interface to <tt>Person.find_by_user_name</tt> is
260
+ # actually <tt>Person.find_by_user_name(user_name, options)</tt>. So you could call <tt>Payment.find_all_by_amount(50, :order => "created_on")</tt>.
261
+ #
262
+ # The same dynamic finder style can be used to create the object if it doesn't already exist. This dynamic finder is called with
263
+ # <tt>find_or_create_by_</tt> and will return the object if it already exists and otherwise creates it, then returns it. Protected attributes won't be set unless they are given in a block. For example:
264
+ #
265
+ # # No 'Summer' tag exists
266
+ # Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
267
+ #
268
+ # # Now the 'Summer' tag does exist
269
+ # Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
270
+ #
271
+ # # Now 'Bob' exist and is an 'admin'
272
+ # User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true }
273
+ #
274
+ # Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without saving it first. Protected attributes won't be setted unless they are given in a block. For example:
275
+ #
276
+ # # No 'Winter' tag exists
277
+ # winter = Tag.find_or_initialize_by_name("Winter")
278
+ # winter.new_record? # true
279
+ #
280
+ # To find by a subset of the attributes to be used for instantiating a new object, pass a hash instead of
281
+ # a list of parameters. For example:
282
+ #
283
+ # Tag.find_or_create_by_name(:name => "rails", :creator => current_user)
284
+ #
285
+ # That will either find an existing tag named "rails", or create a new one while setting the user that created it.
286
+ #
287
+ # == Saving arrays, hashes, and other non-mappable objects in text columns
288
+ #
289
+ # Active Record can serialize any object in text columns using YAML. To do so, you must specify this with a call to the class method +serialize+.
290
+ # This makes it possible to store arrays, hashes, and other non-mappable objects without doing any additional work. Example:
291
+ #
292
+ # class User < ActiveRecord::Base
293
+ # serialize :preferences
294
+ # end
295
+ #
296
+ # user = User.create(:preferences => { "background" => "black", "display" => large })
297
+ # User.find(user.id).preferences # => { "background" => "black", "display" => large }
298
+ #
299
+ # You can also specify a class option as the second parameter that'll raise an exception if a serialized object is retrieved as a
300
+ # descendent of a class not in the hierarchy. Example:
301
+ #
302
+ # class User < ActiveRecord::Base
303
+ # serialize :preferences, Hash
304
+ # end
305
+ #
306
+ # user = User.create(:preferences => %w( one two three ))
307
+ # User.find(user.id).preferences # raises SerializationTypeMismatch
308
+ #
309
+ # == Single table inheritance
310
+ #
311
+ # Active Record allows inheritance by storing the name of the class in a column that by default is named "type" (can be changed
312
+ # by overwriting <tt>Base.inheritance_column</tt>). This means that an inheritance looking like this:
313
+ #
314
+ # class Company < ActiveRecord::Base; end
315
+ # class Firm < Company; end
316
+ # class Client < Company; end
317
+ # class PriorityClient < Client; end
318
+ #
319
+ # When you do <tt>Firm.create(:name => "37signals")</tt>, this record will be saved in the companies table with type = "Firm". You can then
320
+ # fetch this row again using <tt>Company.find(:first, "name = '37signals'")</tt> and it will return a Firm object.
321
+ #
322
+ # If you don't have a type column defined in your table, single-table inheritance won't be triggered. In that case, it'll work just
323
+ # like normal subclasses with no special magic for differentiating between them or reloading the right type with find.
324
+ #
325
+ # Note, all the attributes for all the cases are kept in the same table. Read more:
326
+ # http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html
327
+ #
328
+ # == Connection to multiple databases in different models
329
+ #
330
+ # Connections are usually created through ActiveRecord::Base.establish_connection and retrieved by ActiveRecord::Base.connection.
331
+ # All classes inheriting from ActiveRecord::Base will use this connection. But you can also set a class-specific connection.
332
+ # For example, if Course is an ActiveRecord::Base, but resides in a different database, you can just say <tt>Course.establish_connection</tt>
333
+ # and Course and all of its subclasses will use this connection instead.
334
+ #
335
+ # This feature is implemented by keeping a connection pool in ActiveRecord::Base that is a Hash indexed by the class. If a connection is
336
+ # requested, the retrieve_connection method will go up the class-hierarchy until a connection is found in the connection pool.
337
+ #
338
+ # == Exceptions
339
+ #
340
+ # * ActiveRecordError - Generic error class and superclass of all other errors raised by Active Record.
341
+ # * AdapterNotSpecified - The configuration hash used in <tt>establish_connection</tt> didn't include an
342
+ # <tt>:adapter</tt> key.
343
+ # * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a non-existent adapter
344
+ # (or a bad spelling of an existing one).
345
+ # * AssociationTypeMismatch - The object assigned to the association wasn't of the type specified in the association definition.
346
+ # * SerializationTypeMismatch - The serialized object wasn't of the class specified as the second parameter.
347
+ # * ConnectionNotEstablished+ - No connection has been established. Use <tt>establish_connection</tt> before querying.
348
+ # * RecordNotFound - No record responded to the +find+ method. Either the row with the given ID doesn't exist
349
+ # or the row didn't meet the additional restrictions. Some +find+ calls do not raise this exception to signal
350
+ # nothing was found, please check its documentation for further details.
351
+ # * StatementInvalid - The database server rejected the SQL statement. The precise error is added in the message.
352
+ # * MultiparameterAssignmentErrors - Collection of errors that occurred during a mass assignment using the
353
+ # <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of AttributeAssignmentError
354
+ # objects that should be inspected to determine which attributes triggered the errors.
355
+ # * AttributeAssignmentError - An error occurred while doing a mass assignment through the <tt>attributes=</tt> method.
356
+ # You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
357
+ #
358
+ # *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level).
359
+ # So it's possible to assign a logger to the class through <tt>Base.logger=</tt> which will then be used by all
360
+ # instances in the current object space.
361
+ class Base
362
+ # Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed
363
+ # on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+.
364
+ cattr_accessor :logger, :instance_writer => false
365
+
366
+ def self.inherited(child) #:nodoc:
367
+ @@subclasses[self] ||= []
368
+ @@subclasses[self] << child
369
+ super
370
+ end
371
+
372
+ def self.reset_subclasses #:nodoc:
373
+ nonreloadables = []
374
+ subclasses.each do |klass|
375
+ unless Dependencies.autoloaded? klass
376
+ nonreloadables << klass
377
+ next
378
+ end
379
+ klass.instance_variables.each { |var| klass.send(:remove_instance_variable, var) }
380
+ klass.instance_methods(false).each { |m| klass.send :undef_method, m }
381
+ end
382
+ @@subclasses = {}
383
+ nonreloadables.each { |klass| (@@subclasses[klass.superclass] ||= []) << klass }
384
+ end
385
+
386
+ @@subclasses = {}
387
+
388
+ cattr_accessor :configurations, :instance_writer => false
389
+ @@configurations = {}
390
+
391
+ # Accessor for the prefix type that will be prepended to every primary key column name. The options are :table_name and
392
+ # :table_name_with_underscore. If the first is specified, the Product class will look for "productid" instead of "id" as
393
+ # the primary column. If the latter is specified, the Product class will look for "product_id" instead of "id". Remember
394
+ # that this is a global setting for all Active Records.
395
+ cattr_accessor :primary_key_prefix_type, :instance_writer => false
396
+ @@primary_key_prefix_type = nil
397
+
398
+ # Accessor for the name of the prefix string to prepend to every table name. So if set to "basecamp_", all
399
+ # table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace
400
+ # for tables in a shared database. By default, the prefix is the empty string.
401
+ cattr_accessor :table_name_prefix, :instance_writer => false
402
+ @@table_name_prefix = ""
403
+
404
+ # Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp",
405
+ # "people_basecamp"). By default, the suffix is the empty string.
406
+ cattr_accessor :table_name_suffix, :instance_writer => false
407
+ @@table_name_suffix = ""
408
+
409
+ # Indicates whether table names should be the pluralized versions of the corresponding class names.
410
+ # If true, the default table name for a Product class will be +products+. If false, it would just be +product+.
411
+ # See table_name for the full rules on table/class naming. This is true, by default.
412
+ cattr_accessor :pluralize_table_names, :instance_writer => false
413
+ @@pluralize_table_names = true
414
+
415
+ # Determines whether to use ANSI codes to colorize the logging statements committed by the connection adapter. These colors
416
+ # make it much easier to overview things during debugging (when used through a reader like +tail+ and on a black background), but
417
+ # may complicate matters if you use software like syslog. This is true, by default.
418
+ cattr_accessor :colorize_logging, :instance_writer => false
419
+ @@colorize_logging = true
420
+
421
+ # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database.
422
+ # This is set to :local by default.
423
+ cattr_accessor :default_timezone, :instance_writer => false
424
+ @@default_timezone = :local
425
+
426
+ # Determines whether to use a connection for each thread, or a single shared connection for all threads.
427
+ # Defaults to false. If you're writing a threaded application, set to true
428
+ # and periodically call verify_active_connections! to clear out connections
429
+ # assigned to stale threads.
430
+ cattr_accessor :allow_concurrency, :instance_writer => false
431
+ @@allow_concurrency = false
432
+
433
+ # Specifies the format to use when dumping the database schema with Rails'
434
+ # Rakefile. If :sql, the schema is dumped as (potentially database-
435
+ # specific) SQL statements. If :ruby, the schema is dumped as an
436
+ # ActiveRecord::Schema file which can be loaded into any database that
437
+ # supports migrations. Use :ruby if you want to have different database
438
+ # adapters for, e.g., your development and test environments.
439
+ cattr_accessor :schema_format , :instance_writer => false
440
+ @@schema_format = :ruby
441
+
442
+ # Determine whether to store the full constant name including namespace when using STI
443
+ superclass_delegating_accessor :store_full_sti_class
444
+ self.store_full_sti_class = false
445
+
446
+ class << self # Class methods
447
+ # Find operates with four different retrieval approaches:
448
+ #
449
+ # * Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]).
450
+ # If no record can be found for all of the listed ids, then RecordNotFound will be raised.
451
+ # * Find first - This will return the first record matched by the options used. These options can either be specific
452
+ # conditions or merely an order. If no record can be matched, +nil+ is returned. Use
453
+ # <tt>Model.find(:first, *args)</tt> or its shortcut <tt>Model.first(*args)</tt>.
454
+ # * Find last - This will return the last record matched by the options used. These options can either be specific
455
+ # conditions or merely an order. If no record can be matched, +nil+ is returned. Use
456
+ # <tt>Model.find(:last, *args)</tt> or its shortcut <tt>Model.last(*args)</tt>.
457
+ # * Find all - This will return all the records matched by the options used.
458
+ # If no records are found, an empty array is returned. Use
459
+ # <tt>Model.find(:all, *args)</tt> or its shortcut <tt>Model.all(*args)</tt>.
460
+ #
461
+ # All approaches accept an options hash as their last parameter.
462
+ #
463
+ # ==== Attributes
464
+ #
465
+ # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1" or <tt>[ "user_name = ?", username ]</tt>. See conditions in the intro.
466
+ # * <tt>:order</tt> - An SQL fragment like "created_at DESC, name".
467
+ # * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause.
468
+ # * <tt>:limit</tt> - An integer determining the limit on the number of rows that should be returned.
469
+ # * <tt>:offset</tt> - An integer determining the offset from where the rows should be fetched. So at 5, it would skip rows 0 through 4.
470
+ # * <tt>:joins</tt> - Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed)
471
+ # or named associations in the same form used for the <tt>:include</tt> option, which will perform an <tt>INNER JOIN</tt> on the associated table(s).
472
+ # If the value is a string, then the records will be returned read-only since they will have attributes that do not correspond to the table's columns.
473
+ # Pass <tt>:readonly => false</tt> to override.
474
+ # * <tt>:include</tt> - Names associations that should be loaded alongside. The symbols named refer
475
+ # to already defined associations. See eager loading under Associations.
476
+ # * <tt>:select</tt> - By default, this is "*" as in "SELECT * FROM", but can be changed if you, for example, want to do a join but not
477
+ # include the joined columns.
478
+ # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an alternate table name (or even the name
479
+ # of a database view).
480
+ # * <tt>:readonly</tt> - Mark the returned records read-only so they cannot be saved or updated.
481
+ # * <tt>:lock</tt> - An SQL fragment like "FOR UPDATE" or "LOCK IN SHARE MODE".
482
+ # <tt>:lock => true</tt> gives connection's default exclusive lock, usually "FOR UPDATE".
483
+ #
484
+ # ==== Examples
485
+ #
486
+ # # find by id
487
+ # Person.find(1) # returns the object for ID = 1
488
+ # Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6)
489
+ # Person.find([7, 17]) # returns an array for objects with IDs in (7, 17)
490
+ # Person.find([1]) # returns an array for the object with ID = 1
491
+ # Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
492
+ #
493
+ # Note that returned records may not be in the same order as the ids you
494
+ # provide since database rows are unordered. Give an explicit <tt>:order</tt>
495
+ # to ensure the results are sorted.
496
+ #
497
+ # ==== Examples
498
+ #
499
+ # # find first
500
+ # Person.find(:first) # returns the first object fetched by SELECT * FROM people
501
+ # Person.find(:first, :conditions => [ "user_name = ?", user_name])
502
+ # Person.find(:first, :order => "created_on DESC", :offset => 5)
503
+ #
504
+ # # find last
505
+ # Person.find(:last) # returns the last object fetched by SELECT * FROM people
506
+ # Person.find(:last, :conditions => [ "user_name = ?", user_name])
507
+ # Person.find(:last, :order => "created_on DESC", :offset => 5)
508
+ #
509
+ # # find all
510
+ # Person.find(:all) # returns an array of objects for all the rows fetched by SELECT * FROM people
511
+ # Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
512
+ # Person.find(:all, :conditions => { :friends => ["Bob", "Steve", "Fred"] }
513
+ # Person.find(:all, :offset => 10, :limit => 10)
514
+ # Person.find(:all, :include => [ :account, :friends ])
515
+ # Person.find(:all, :group => "category")
516
+ #
517
+ # Example for find with a lock: Imagine two concurrent transactions:
518
+ # each will read <tt>person.visits == 2</tt>, add 1 to it, and save, resulting
519
+ # in two saves of <tt>person.visits = 3</tt>. By locking the row, the second
520
+ # transaction has to wait until the first is finished; we get the
521
+ # expected <tt>person.visits == 4</tt>.
522
+ #
523
+ # Person.transaction do
524
+ # person = Person.find(1, :lock => true)
525
+ # person.visits += 1
526
+ # person.save!
527
+ # end
528
+ def find(*args)
529
+ options = args.extract_options!
530
+ validate_find_options(options)
531
+ set_readonly_option!(options)
532
+
533
+ case args.first
534
+ when :first then find_initial(options)
535
+ when :last then find_last(options)
536
+ when :all then find_every(options)
537
+ else find_from_ids(args, options)
538
+ end
539
+ end
540
+
541
+ # A convenience wrapper for <tt>find(:first, *args)</tt>. You can pass in all the
542
+ # same arguments to this method as you can to <tt>find(:first)</tt>.
543
+ def first(*args)
544
+ find(:first, *args)
545
+ end
546
+
547
+ # A convenience wrapper for <tt>find(:last, *args)</tt>. You can pass in all the
548
+ # same arguments to this method as you can to <tt>find(:last)</tt>.
549
+ def last(*args)
550
+ find(:last, *args)
551
+ end
552
+
553
+ # This is an alias for find(:all). You can pass in all the same arguments to this method as you can
554
+ # to find(:all)
555
+ def all(*args)
556
+ find(:all, *args)
557
+ end
558
+
559
+ # Executes a custom SQL query against your database and returns all the results. The results will
560
+ # be returned as an array with columns requested encapsulated as attributes of the model you call
561
+ # this method from. If you call +Product.find_by_sql+ then the results will be returned in a Product
562
+ # object with the attributes you specified in the SQL query.
563
+ #
564
+ # If you call a complicated SQL query which spans multiple tables the columns specified by the
565
+ # SELECT will be attributes of the model, whether or not they are columns of the corresponding
566
+ # table.
567
+ #
568
+ # The +sql+ parameter is a full SQL query as a string. It will be called as is, there will be
569
+ # no database agnostic conversions performed. This should be a last resort because using, for example,
570
+ # MySQL specific terms will lock you to using that particular database engine or require you to
571
+ # change your call if you switch engines
572
+ #
573
+ # ==== Examples
574
+ # # A simple SQL query spanning multiple tables
575
+ # Post.find_by_sql "SELECT p.title, c.author FROM posts p, comments c WHERE p.id = c.post_id"
576
+ # > [#<Post:0x36bff9c @attributes={"title"=>"Ruby Meetup", "first_name"=>"Quentin"}>, ...]
577
+ #
578
+ # # You can use the same string replacement techniques as you can with ActiveRecord#find
579
+ # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
580
+ # > [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...]
581
+ def find_by_sql(sql)
582
+ connection.select_all(sanitize_sql(sql), "#{name} Load").collect! { |record| instantiate(record) }
583
+ end
584
+
585
+ # Checks whether a record exists in the database that matches conditions given. These conditions
586
+ # can either be a single integer representing a primary key id to be found, or a condition to be
587
+ # matched like using ActiveRecord#find.
588
+ #
589
+ # The +id_or_conditions+ parameter can be an Integer or a String if you want to search the primary key
590
+ # column of the table for a matching id, or if you're looking to match against a condition you can use
591
+ # an Array or a Hash.
592
+ #
593
+ # Possible gotcha: You can't pass in a condition as a string e.g. "name = 'Jamie'", this would be
594
+ # sanitized and then queried against the primary key column as "id = 'name = \'Jamie"
595
+ #
596
+ # ==== Examples
597
+ # Person.exists?(5)
598
+ # Person.exists?('5')
599
+ # Person.exists?(:name => "David")
600
+ # Person.exists?(['name LIKE ?', "%#{query}%"])
601
+ def exists?(id_or_conditions)
602
+ connection.select_all(
603
+ construct_finder_sql(
604
+ :select => "#{quoted_table_name}.#{primary_key}",
605
+ :conditions => expand_id_conditions(id_or_conditions),
606
+ :limit => 1
607
+ ),
608
+ "#{name} Exists"
609
+ ).size > 0
610
+ end
611
+
612
+ # Creates an object (or multiple objects) and saves it to the database, if validations pass.
613
+ # The resulting object is returned whether the object was saved successfully to the database or not.
614
+ #
615
+ # The +attributes+ parameter can be either be a Hash or an Array of Hashes. These Hashes describe the
616
+ # attributes on the objects that are to be created.
617
+ #
618
+ # ==== Examples
619
+ # # Create a single new object
620
+ # User.create(:first_name => 'Jamie')
621
+ #
622
+ # # Create an Array of new objects
623
+ # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }])
624
+ #
625
+ # # Create a single object and pass it into a block to set other attributes.
626
+ # User.create(:first_name => 'Jamie') do |u|
627
+ # u.is_admin = false
628
+ # end
629
+ #
630
+ # # Creating an Array of new objects using a block, where the block is executed for each object:
631
+ # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u|
632
+ # u.is_admin = false
633
+ # end
634
+ def create(attributes = nil, &block)
635
+ if attributes.is_a?(Array)
636
+ attributes.collect { |attr| create(attr, &block) }
637
+ else
638
+ object = new(attributes)
639
+ yield(object) if block_given?
640
+ object.save
641
+ object
642
+ end
643
+ end
644
+
645
+ # Updates an object (or multiple objects) and saves it to the database, if validations pass.
646
+ # The resulting object is returned whether the object was saved successfully to the database or not.
647
+ #
648
+ # ==== Attributes
649
+ #
650
+ # * +id+ - This should be the id or an array of ids to be updated.
651
+ # * +attributes+ - This should be a Hash of attributes to be set on the object, or an array of Hashes.
652
+ #
653
+ # ==== Examples
654
+ #
655
+ # # Updating one record:
656
+ # Person.update(15, { :user_name => 'Samuel', :group => 'expert' })
657
+ #
658
+ # # Updating multiple records:
659
+ # people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } }
660
+ # Person.update(people.keys, people.values)
661
+ def update(id, attributes)
662
+ if id.is_a?(Array)
663
+ idx = -1
664
+ id.collect { |one_id| idx += 1; update(one_id, attributes[idx]) }
665
+ else
666
+ object = find(id)
667
+ object.update_attributes(attributes)
668
+ object
669
+ end
670
+ end
671
+
672
+ # Delete an object (or multiple objects) where the +id+ given matches the primary_key. A SQL +DELETE+ command
673
+ # is executed on the database which means that no callbacks are fired off running this. This is an efficient method
674
+ # of deleting records that don't need cleaning up after or other actions to be taken.
675
+ #
676
+ # Objects are _not_ instantiated with this method.
677
+ #
678
+ # ==== Attributes
679
+ #
680
+ # * +id+ - Can be either an Integer or an Array of Integers.
681
+ #
682
+ # ==== Examples
683
+ #
684
+ # # Delete a single object
685
+ # Todo.delete(1)
686
+ #
687
+ # # Delete multiple objects
688
+ # todos = [1,2,3]
689
+ # Todo.delete(todos)
690
+ def delete(id)
691
+ delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ])
692
+ end
693
+
694
+ # Destroy an object (or multiple objects) that has the given id, the object is instantiated first,
695
+ # therefore all callbacks and filters are fired off before the object is deleted. This method is
696
+ # less efficient than ActiveRecord#delete but allows cleanup methods and other actions to be run.
697
+ #
698
+ # This essentially finds the object (or multiple objects) with the given id, creates a new object
699
+ # from the attributes, and then calls destroy on it.
700
+ #
701
+ # ==== Attributes
702
+ #
703
+ # * +id+ - Can be either an Integer or an Array of Integers.
704
+ #
705
+ # ==== Examples
706
+ #
707
+ # # Destroy a single object
708
+ # Todo.destroy(1)
709
+ #
710
+ # # Destroy multiple objects
711
+ # todos = [1,2,3]
712
+ # Todo.destroy(todos)
713
+ def destroy(id)
714
+ if id.is_a?(Array)
715
+ id.map { |one_id| destroy(one_id) }
716
+ else
717
+ find(id).destroy
718
+ end
719
+ end
720
+
721
+ # Updates all records with details given if they match a set of conditions supplied, limits and order can
722
+ # also be supplied.
723
+ #
724
+ # ==== Attributes
725
+ #
726
+ # * +updates+ - A String of column and value pairs that will be set on any records that match conditions.
727
+ # * +conditions+ - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ].
728
+ # See conditions in the intro for more info.
729
+ # * +options+ - Additional options are <tt>:limit</tt> and/or <tt>:order</tt>, see the examples for usage.
730
+ #
731
+ # ==== Examples
732
+ #
733
+ # # Update all billing objects with the 3 different attributes given
734
+ # Billing.update_all( "category = 'authorized', approved = 1, author = 'David'" )
735
+ #
736
+ # # Update records that match our conditions
737
+ # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'" )
738
+ #
739
+ # # Update records that match our conditions but limit it to 5 ordered by date
740
+ # Billing.update_all( "author = 'David'", "title LIKE '%Rails%'",
741
+ # :order => 'created_at', :limit => 5 )
742
+ def update_all(updates, conditions = nil, options = {})
743
+ sql = "UPDATE #{quoted_table_name} SET #{sanitize_sql_for_assignment(updates)} "
744
+ scope = scope(:find)
745
+ add_conditions!(sql, conditions, scope)
746
+ add_order!(sql, options[:order], nil)
747
+ add_limit!(sql, options, nil)
748
+ connection.update(sql, "#{name} Update")
749
+ end
750
+
751
+ # Destroys the records matching +conditions+ by instantiating each record and calling the destroy method.
752
+ # This means at least 2*N database queries to destroy N records, so avoid destroy_all if you are deleting
753
+ # many records. If you want to simply delete records without worrying about dependent associations or
754
+ # callbacks, use the much faster +delete_all+ method instead.
755
+ #
756
+ # ==== Attributes
757
+ #
758
+ # * +conditions+ - Conditions are specified the same way as with +find+ method.
759
+ #
760
+ # ==== Example
761
+ #
762
+ # Person.destroy_all "last_login < '2004-04-04'"
763
+ #
764
+ # This loads and destroys each person one by one, including its dependent associations and before_ and
765
+ # after_destroy callbacks.
766
+ def destroy_all(conditions = nil)
767
+ find(:all, :conditions => conditions).each { |object| object.destroy }
768
+ end
769
+
770
+ # Deletes the records matching +conditions+ without instantiating the records first, and hence not
771
+ # calling the destroy method and invoking callbacks. This is a single SQL query, much more efficient
772
+ # than destroy_all.
773
+ #
774
+ # ==== Attributes
775
+ #
776
+ # * +conditions+ - Conditions are specified the same way as with +find+ method.
777
+ #
778
+ # ==== Example
779
+ #
780
+ # Post.delete_all "person_id = 5 AND (category = 'Something' OR category = 'Else')"
781
+ #
782
+ # This deletes the affected posts all at once with a single DELETE query. If you need to destroy dependent
783
+ # associations or call your before_ or after_destroy callbacks, use the +destroy_all+ method instead.
784
+ def delete_all(conditions = nil)
785
+ sql = "DELETE FROM #{quoted_table_name} "
786
+ add_conditions!(sql, conditions, scope(:find))
787
+ connection.delete(sql, "#{name} Delete all")
788
+ end
789
+
790
+ # Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part.
791
+ # The use of this method should be restricted to complicated SQL queries that can't be executed
792
+ # using the ActiveRecord::Calculations class methods. Look into those before using this.
793
+ #
794
+ # ==== Attributes
795
+ #
796
+ # * +sql+ - An SQL statement which should return a count query from the database, see the example below.
797
+ #
798
+ # ==== Examples
799
+ #
800
+ # Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
801
+ def count_by_sql(sql)
802
+ sql = sanitize_conditions(sql)
803
+ connection.select_value(sql, "#{name} Count").to_i
804
+ end
805
+
806
+ # A generic "counter updater" implementation, intended primarily to be
807
+ # used by increment_counter and decrement_counter, but which may also
808
+ # be useful on its own. It simply does a direct SQL update for the record
809
+ # with the given ID, altering the given hash of counters by the amount
810
+ # given by the corresponding value:
811
+ #
812
+ # ==== Attributes
813
+ #
814
+ # * +id+ - The id of the object you wish to update a counter on.
815
+ # * +counters+ - An Array of Hashes containing the names of the fields
816
+ # to update as keys and the amount to update the field by as values.
817
+ #
818
+ # ==== Examples
819
+ #
820
+ # # For the Post with id of 5, decrement the comment_count by 1, and
821
+ # # increment the action_count by 1
822
+ # Post.update_counters 5, :comment_count => -1, :action_count => 1
823
+ # # Executes the following SQL:
824
+ # # UPDATE posts
825
+ # # SET comment_count = comment_count - 1,
826
+ # # action_count = action_count + 1
827
+ # # WHERE id = 5
828
+ def update_counters(id, counters)
829
+ updates = counters.inject([]) { |list, (counter_name, increment)|
830
+ sign = increment < 0 ? "-" : "+"
831
+ list << "#{connection.quote_column_name(counter_name)} = #{connection.quote_column_name(counter_name)} #{sign} #{increment.abs}"
832
+ }.join(", ")
833
+ update_all(updates, "#{connection.quote_column_name(primary_key)} = #{quote_value(id)}")
834
+ end
835
+
836
+ # Increment a number field by one, usually representing a count.
837
+ #
838
+ # This is used for caching aggregate values, so that they don't need to be computed every time.
839
+ # For example, a DiscussionBoard may cache post_count and comment_count otherwise every time the board is
840
+ # shown it would have to run an SQL query to find how many posts and comments there are.
841
+ #
842
+ # ==== Attributes
843
+ #
844
+ # * +counter_name+ - The name of the field that should be incremented.
845
+ # * +id+ - The id of the object that should be incremented.
846
+ #
847
+ # ==== Examples
848
+ #
849
+ # # Increment the post_count column for the record with an id of 5
850
+ # DiscussionBoard.increment_counter(:post_count, 5)
851
+ def increment_counter(counter_name, id)
852
+ update_counters(id, counter_name => 1)
853
+ end
854
+
855
+ # Decrement a number field by one, usually representing a count.
856
+ #
857
+ # This works the same as increment_counter but reduces the column value by 1 instead of increasing it.
858
+ #
859
+ # ==== Attributes
860
+ #
861
+ # * +counter_name+ - The name of the field that should be decremented.
862
+ # * +id+ - The id of the object that should be decremented.
863
+ #
864
+ # ==== Examples
865
+ #
866
+ # # Decrement the post_count column for the record with an id of 5
867
+ # DiscussionBoard.decrement_counter(:post_count, 5)
868
+ def decrement_counter(counter_name, id)
869
+ update_counters(id, counter_name => -1)
870
+ end
871
+
872
+
873
+ # Attributes named in this macro are protected from mass-assignment,
874
+ # such as <tt>new(attributes)</tt>,
875
+ # <tt>update_attributes(attributes)</tt>, or
876
+ # <tt>attributes=(attributes)</tt>.
877
+ #
878
+ # Mass-assignment to these attributes will simply be ignored, to assign
879
+ # to them you can use direct writer methods. This is meant to protect
880
+ # sensitive attributes from being overwritten by malicious users
881
+ # tampering with URLs or forms.
882
+ #
883
+ # class Customer < ActiveRecord::Base
884
+ # attr_protected :credit_rating
885
+ # end
886
+ #
887
+ # customer = Customer.new("name" => David, "credit_rating" => "Excellent")
888
+ # customer.credit_rating # => nil
889
+ # customer.attributes = { "description" => "Jolly fellow", "credit_rating" => "Superb" }
890
+ # customer.credit_rating # => nil
891
+ #
892
+ # customer.credit_rating = "Average"
893
+ # customer.credit_rating # => "Average"
894
+ #
895
+ # To start from an all-closed default and enable attributes as needed,
896
+ # have a look at +attr_accessible+.
897
+ def attr_protected(*attributes)
898
+ write_inheritable_attribute("attr_protected", Set.new(attributes.map(&:to_s)) + (protected_attributes || []))
899
+ end
900
+
901
+ # Returns an array of all the attributes that have been protected from mass-assignment.
902
+ def protected_attributes # :nodoc:
903
+ read_inheritable_attribute("attr_protected")
904
+ end
905
+
906
+ # Specifies a white list of model attributes that can be set via
907
+ # mass-assignment, such as <tt>new(attributes)</tt>,
908
+ # <tt>update_attributes(attributes)</tt>, or
909
+ # <tt>attributes=(attributes)</tt>
910
+ #
911
+ # This is the opposite of the +attr_protected+ macro: Mass-assignment
912
+ # will only set attributes in this list, to assign to the rest of
913
+ # attributes you can use direct writer methods. This is meant to protect
914
+ # sensitive attributes from being overwritten by malicious users
915
+ # tampering with URLs or forms. If you'd rather start from an all-open
916
+ # default and restrict attributes as needed, have a look at
917
+ # +attr_protected+.
918
+ #
919
+ # class Customer < ActiveRecord::Base
920
+ # attr_accessible :name, :nickname
921
+ # end
922
+ #
923
+ # customer = Customer.new(:name => "David", :nickname => "Dave", :credit_rating => "Excellent")
924
+ # customer.credit_rating # => nil
925
+ # customer.attributes = { :name => "Jolly fellow", :credit_rating => "Superb" }
926
+ # customer.credit_rating # => nil
927
+ #
928
+ # customer.credit_rating = "Average"
929
+ # customer.credit_rating # => "Average"
930
+ def attr_accessible(*attributes)
931
+ write_inheritable_attribute("attr_accessible", Set.new(attributes.map(&:to_s)) + (accessible_attributes || []))
932
+ end
933
+
934
+ # Returns an array of all the attributes that have been made accessible to mass-assignment.
935
+ def accessible_attributes # :nodoc:
936
+ read_inheritable_attribute("attr_accessible")
937
+ end
938
+
939
+ # Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards.
940
+ def attr_readonly(*attributes)
941
+ write_inheritable_attribute("attr_readonly", Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
942
+ end
943
+
944
+ # Returns an array of all the attributes that have been specified as readonly.
945
+ def readonly_attributes
946
+ read_inheritable_attribute("attr_readonly")
947
+ end
948
+
949
+ # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,
950
+ # then specify the name of that attribute using this method and it will be handled automatically.
951
+ # The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that
952
+ # class on retrieval or SerializationTypeMismatch will be raised.
953
+ #
954
+ # ==== Attributes
955
+ #
956
+ # * +attr_name+ - The field name that should be serialized.
957
+ # * +class_name+ - Optional, class name that the object type should be equal to.
958
+ #
959
+ # ==== Example
960
+ # # Serialize a preferences attribute
961
+ # class User
962
+ # serialize :preferences
963
+ # end
964
+ def serialize(attr_name, class_name = Object)
965
+ serialized_attributes[attr_name.to_s] = class_name
966
+ end
967
+
968
+ # Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
969
+ def serialized_attributes
970
+ read_inheritable_attribute("attr_serialized") or write_inheritable_attribute("attr_serialized", {})
971
+ end
972
+
973
+
974
+ # Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending
975
+ # directly from ActiveRecord::Base. So if the hierarchy looks like: Reply < Message < ActiveRecord::Base, then Message is used
976
+ # to guess the table name even when called on Reply. The rules used to do the guess are handled by the Inflector class
977
+ # in Active Support, which knows almost all common English inflections. You can add new inflections in config/initializers/inflections.rb.
978
+ #
979
+ # Nested classes are given table names prefixed by the singular form of
980
+ # the parent's table name. Enclosing modules are not considered.
981
+ #
982
+ # ==== Examples
983
+ #
984
+ # class Invoice < ActiveRecord::Base; end;
985
+ # file class table_name
986
+ # invoice.rb Invoice invoices
987
+ #
988
+ # class Invoice < ActiveRecord::Base; class Lineitem < ActiveRecord::Base; end; end;
989
+ # file class table_name
990
+ # invoice.rb Invoice::Lineitem invoice_lineitems
991
+ #
992
+ # module Invoice; class Lineitem < ActiveRecord::Base; end; end;
993
+ # file class table_name
994
+ # invoice/lineitem.rb Invoice::Lineitem lineitems
995
+ #
996
+ # Additionally, the class-level +table_name_prefix+ is prepended and the
997
+ # +table_name_suffix+ is appended. So if you have "myapp_" as a prefix,
998
+ # the table name guess for an Invoice class becomes "myapp_invoices".
999
+ # Invoice::Lineitem becomes "myapp_invoice_lineitems".
1000
+ #
1001
+ # You can also overwrite this class method to allow for unguessable
1002
+ # links, such as a Mouse class with a link to a "mice" table. Example:
1003
+ #
1004
+ # class Mouse < ActiveRecord::Base
1005
+ # set_table_name "mice"
1006
+ # end
1007
+ def table_name
1008
+ reset_table_name
1009
+ end
1010
+
1011
+ def reset_table_name #:nodoc:
1012
+ base = base_class
1013
+
1014
+ name =
1015
+ # STI subclasses always use their superclass' table.
1016
+ unless self == base
1017
+ base.table_name
1018
+ else
1019
+ # Nested classes are prefixed with singular parent table name.
1020
+ if parent < ActiveRecord::Base && !parent.abstract_class?
1021
+ contained = parent.table_name
1022
+ contained = contained.singularize if parent.pluralize_table_names
1023
+ contained << '_'
1024
+ end
1025
+ name = "#{table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}"
1026
+ end
1027
+
1028
+ set_table_name(name)
1029
+ name
1030
+ end
1031
+
1032
+ # Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
1033
+ # primary_key_prefix_type setting, though.
1034
+ def primary_key
1035
+ reset_primary_key
1036
+ end
1037
+
1038
+ def reset_primary_key #:nodoc:
1039
+ key = get_primary_key(base_class.name)
1040
+ set_primary_key(key)
1041
+ key
1042
+ end
1043
+
1044
+ def get_primary_key(base_name) #:nodoc:
1045
+ key = 'id'
1046
+ case primary_key_prefix_type
1047
+ when :table_name
1048
+ key = base_name.to_s.foreign_key(false)
1049
+ when :table_name_with_underscore
1050
+ key = base_name.to_s.foreign_key
1051
+ end
1052
+ key
1053
+ end
1054
+
1055
+ # Defines the column name for use with single table inheritance
1056
+ # -- can be set in subclasses like so: self.inheritance_column = "type_id"
1057
+ def inheritance_column
1058
+ @inheritance_column ||= "type".freeze
1059
+ end
1060
+
1061
+ # Lazy-set the sequence name to the connection's default. This method
1062
+ # is only ever called once since set_sequence_name overrides it.
1063
+ def sequence_name #:nodoc:
1064
+ reset_sequence_name
1065
+ end
1066
+
1067
+ def reset_sequence_name #:nodoc:
1068
+ default = connection.default_sequence_name(table_name, primary_key)
1069
+ set_sequence_name(default)
1070
+ default
1071
+ end
1072
+
1073
+ # Sets the table name to use to the given value, or (if the value
1074
+ # is nil or false) to the value returned by the given block.
1075
+ #
1076
+ # class Project < ActiveRecord::Base
1077
+ # set_table_name "project"
1078
+ # end
1079
+ def set_table_name(value = nil, &block)
1080
+ define_attr_method :table_name, value, &block
1081
+ end
1082
+ alias :table_name= :set_table_name
1083
+
1084
+ # Sets the name of the primary key column to use to the given value,
1085
+ # or (if the value is nil or false) to the value returned by the given
1086
+ # block.
1087
+ #
1088
+ # class Project < ActiveRecord::Base
1089
+ # set_primary_key "sysid"
1090
+ # end
1091
+ def set_primary_key(value = nil, &block)
1092
+ define_attr_method :primary_key, value, &block
1093
+ end
1094
+ alias :primary_key= :set_primary_key
1095
+
1096
+ # Sets the name of the inheritance column to use to the given value,
1097
+ # or (if the value # is nil or false) to the value returned by the
1098
+ # given block.
1099
+ #
1100
+ # class Project < ActiveRecord::Base
1101
+ # set_inheritance_column do
1102
+ # original_inheritance_column + "_id"
1103
+ # end
1104
+ # end
1105
+ def set_inheritance_column(value = nil, &block)
1106
+ define_attr_method :inheritance_column, value, &block
1107
+ end
1108
+ alias :inheritance_column= :set_inheritance_column
1109
+
1110
+ # Sets the name of the sequence to use when generating ids to the given
1111
+ # value, or (if the value is nil or false) to the value returned by the
1112
+ # given block. This is required for Oracle and is useful for any
1113
+ # database which relies on sequences for primary key generation.
1114
+ #
1115
+ # If a sequence name is not explicitly set when using Oracle or Firebird,
1116
+ # it will default to the commonly used pattern of: #{table_name}_seq
1117
+ #
1118
+ # If a sequence name is not explicitly set when using PostgreSQL, it
1119
+ # will discover the sequence corresponding to your primary key for you.
1120
+ #
1121
+ # class Project < ActiveRecord::Base
1122
+ # set_sequence_name "projectseq" # default would have been "project_seq"
1123
+ # end
1124
+ def set_sequence_name(value = nil, &block)
1125
+ define_attr_method :sequence_name, value, &block
1126
+ end
1127
+ alias :sequence_name= :set_sequence_name
1128
+
1129
+ # Turns the +table_name+ back into a class name following the reverse rules of +table_name+.
1130
+ def class_name(table_name = table_name) # :nodoc:
1131
+ # remove any prefix and/or suffix from the table name
1132
+ class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize
1133
+ class_name = class_name.singularize if pluralize_table_names
1134
+ class_name
1135
+ end
1136
+
1137
+ # Indicates whether the table associated with this class exists
1138
+ def table_exists?
1139
+ connection.table_exists?(table_name)
1140
+ end
1141
+
1142
+ # Returns an array of column objects for the table associated with this class.
1143
+ def columns
1144
+ unless defined?(@columns) && @columns
1145
+ @columns = connection.columns(table_name, "#{name} Columns")
1146
+ @columns.each { |column| column.primary = column.name == primary_key }
1147
+ end
1148
+ @columns
1149
+ end
1150
+
1151
+ # Returns a hash of column objects for the table associated with this class.
1152
+ def columns_hash
1153
+ @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash }
1154
+ end
1155
+
1156
+ # Returns an array of column names as strings.
1157
+ def column_names
1158
+ @column_names ||= columns.map { |column| column.name }
1159
+ end
1160
+
1161
+ # Returns an array of column objects where the primary id, all columns ending in "_id" or "_count",
1162
+ # and columns used for single table inheritance have been removed.
1163
+ def content_columns
1164
+ @content_columns ||= columns.reject { |c| c.primary || c.name =~ /(_id|_count)$/ || c.name == inheritance_column }
1165
+ end
1166
+
1167
+ # Returns a hash of all the methods added to query each of the columns in the table with the name of the method as the key
1168
+ # and true as the value. This makes it possible to do O(1) lookups in respond_to? to check if a given method for attribute
1169
+ # is available.
1170
+ def column_methods_hash #:nodoc:
1171
+ @dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr|
1172
+ attr_name = attr.to_s
1173
+ methods[attr.to_sym] = attr_name
1174
+ methods["#{attr}=".to_sym] = attr_name
1175
+ methods["#{attr}?".to_sym] = attr_name
1176
+ methods["#{attr}_before_type_cast".to_sym] = attr_name
1177
+ methods
1178
+ end
1179
+ end
1180
+
1181
+ # Resets all the cached information about columns, which will cause them to be reloaded on the next request.
1182
+ def reset_column_information
1183
+ generated_methods.each { |name| undef_method(name) }
1184
+ @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = @inheritance_column = nil
1185
+ end
1186
+
1187
+ def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc:
1188
+ subclasses.each { |klass| klass.reset_inheritable_attributes; klass.reset_column_information }
1189
+ end
1190
+
1191
+ # Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example:
1192
+ # Person.human_attribute_name("first_name") # => "First name"
1193
+ # Deprecated in favor of just calling "first_name".humanize
1194
+ def human_attribute_name(attribute_key_name) #:nodoc:
1195
+ attribute_key_name.humanize
1196
+ end
1197
+
1198
+ # True if this isn't a concrete subclass needing a STI type condition.
1199
+ def descends_from_active_record?
1200
+ if superclass.abstract_class?
1201
+ superclass.descends_from_active_record?
1202
+ else
1203
+ superclass == Base || !columns_hash.include?(inheritance_column)
1204
+ end
1205
+ end
1206
+
1207
+ def finder_needs_type_condition? #:nodoc:
1208
+ # This is like this because benchmarking justifies the strange :false stuff
1209
+ :true == (@finder_needs_type_condition ||= descends_from_active_record? ? :false : :true)
1210
+ end
1211
+
1212
+ # Returns a string like 'Post id:integer, title:string, body:text'
1213
+ def inspect
1214
+ if self == Base
1215
+ super
1216
+ elsif abstract_class?
1217
+ "#{super}(abstract)"
1218
+ elsif table_exists?
1219
+ attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
1220
+ "#{super}(#{attr_list})"
1221
+ else
1222
+ "#{super}(Table doesn't exist)"
1223
+ end
1224
+ end
1225
+
1226
+
1227
+ def quote_value(value, column = nil) #:nodoc:
1228
+ connection.quote(value,column)
1229
+ end
1230
+
1231
+ # Used to sanitize objects before they're used in an SQL SELECT statement. Delegates to <tt>connection.quote</tt>.
1232
+ def sanitize(object) #:nodoc:
1233
+ connection.quote(object)
1234
+ end
1235
+
1236
+ # Log and benchmark multiple statements in a single block. Example:
1237
+ #
1238
+ # Project.benchmark("Creating project") do
1239
+ # project = Project.create("name" => "stuff")
1240
+ # project.create_manager("name" => "David")
1241
+ # project.milestones << Milestone.find(:all)
1242
+ # end
1243
+ #
1244
+ # The benchmark is only recorded if the current level of the logger is less than or equal to the <tt>log_level</tt>,
1245
+ # which makes it easy to include benchmarking statements in production software that will remain inexpensive because
1246
+ # the benchmark will only be conducted if the log level is low enough.
1247
+ #
1248
+ # The logging of the multiple statements is turned off unless <tt>use_silence</tt> is set to false.
1249
+ def benchmark(title, log_level = Logger::DEBUG, use_silence = true)
1250
+ if logger && logger.level <= log_level
1251
+ result = nil
1252
+ seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield }
1253
+ logger.add(log_level, "#{title} (#{'%.5f' % seconds})")
1254
+ result
1255
+ else
1256
+ yield
1257
+ end
1258
+ end
1259
+
1260
+ # Silences the logger for the duration of the block.
1261
+ def silence
1262
+ old_logger_level, logger.level = logger.level, Logger::ERROR if logger
1263
+ yield
1264
+ ensure
1265
+ logger.level = old_logger_level if logger
1266
+ end
1267
+
1268
+ # Overwrite the default class equality method to provide support for association proxies.
1269
+ def ===(object)
1270
+ object.is_a?(self)
1271
+ end
1272
+
1273
+ # Returns the base AR subclass that this class descends from. If A
1274
+ # extends AR::Base, A.base_class will return A. If B descends from A
1275
+ # through some arbitrarily deep hierarchy, B.base_class will return A.
1276
+ def base_class
1277
+ class_of_active_record_descendant(self)
1278
+ end
1279
+
1280
+ # Set this to true if this is an abstract class (see <tt>abstract_class?</tt>).
1281
+ attr_accessor :abstract_class
1282
+
1283
+ # Returns whether this class is a base AR class. If A is a base class and
1284
+ # B descends from A, then B.base_class will return B.
1285
+ def abstract_class?
1286
+ defined?(@abstract_class) && @abstract_class == true
1287
+ end
1288
+
1289
+ def respond_to?(method_id, include_private = false)
1290
+ if match = matches_dynamic_finder?(method_id) || matches_dynamic_finder_with_initialize_or_create?(method_id)
1291
+ return true if all_attributes_exists?(extract_attribute_names_from_match(match))
1292
+ end
1293
+ super
1294
+ end
1295
+
1296
+ def sti_name
1297
+ store_full_sti_class ? name : name.demodulize
1298
+ end
1299
+
1300
+ private
1301
+ def find_initial(options)
1302
+ options.update(:limit => 1)
1303
+ find_every(options).first
1304
+ end
1305
+
1306
+ def find_last(options)
1307
+ order = options[:order]
1308
+
1309
+ if order
1310
+ order = reverse_sql_order(order)
1311
+ elsif !scoped?(:find, :order)
1312
+ order = "#{table_name}.#{primary_key} DESC"
1313
+ end
1314
+
1315
+ if scoped?(:find, :order)
1316
+ scoped_order = reverse_sql_order(scope(:find, :order))
1317
+ scoped_methods.select { |s| s[:find].update(:order => scoped_order) }
1318
+ end
1319
+
1320
+ find_initial(options.merge({ :order => order }))
1321
+ end
1322
+
1323
+ def reverse_sql_order(order_query)
1324
+ reversed_query = order_query.split(/,/).each { |s|
1325
+ if s.match(/\s(asc|ASC)$/)
1326
+ s.gsub!(/\s(asc|ASC)$/, ' DESC')
1327
+ elsif s.match(/\s(desc|DESC)$/)
1328
+ s.gsub!(/\s(desc|DESC)$/, ' ASC')
1329
+ elsif !s.match(/\s(asc|ASC|desc|DESC)$/)
1330
+ s.concat(' DESC')
1331
+ end
1332
+ }.join(',')
1333
+ end
1334
+
1335
+ def find_every(options)
1336
+ include_associations = merge_includes(scope(:find, :include), options[:include])
1337
+
1338
+ if include_associations.any? && references_eager_loaded_tables?(options)
1339
+ records = find_with_associations(options)
1340
+ else
1341
+ records = find_by_sql(construct_finder_sql(options))
1342
+ if include_associations.any?
1343
+ preload_associations(records, include_associations)
1344
+ end
1345
+ end
1346
+
1347
+ records.each { |record| record.readonly! } if options[:readonly]
1348
+
1349
+ records
1350
+ end
1351
+
1352
+ def find_from_ids(ids, options)
1353
+ expects_array = ids.first.kind_of?(Array)
1354
+ return ids.first if expects_array && ids.first.empty?
1355
+
1356
+ ids = ids.flatten.compact.uniq
1357
+
1358
+ case ids.size
1359
+ when 0
1360
+ raise RecordNotFound, "Couldn't find #{name} without an ID"
1361
+ when 1
1362
+ result = find_one(ids.first, options)
1363
+ expects_array ? [ result ] : result
1364
+ else
1365
+ find_some(ids, options)
1366
+ end
1367
+ end
1368
+
1369
+ def find_one(id, options)
1370
+ conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
1371
+ options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} = #{quote_value(id,columns_hash[primary_key])}#{conditions}"
1372
+
1373
+ # Use find_every(options).first since the primary key condition
1374
+ # already ensures we have a single record. Using find_initial adds
1375
+ # a superfluous :limit => 1.
1376
+ if result = find_every(options).first
1377
+ result
1378
+ else
1379
+ raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}"
1380
+ end
1381
+ end
1382
+
1383
+ def find_some(ids, options)
1384
+ conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
1385
+ ids_list = ids.map { |id| quote_value(id,columns_hash[primary_key]) }.join(',')
1386
+ options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} IN (#{ids_list})#{conditions}"
1387
+
1388
+ result = find_every(options)
1389
+
1390
+ # Determine expected size from limit and offset, not just ids.size.
1391
+ expected_size =
1392
+ if options[:limit] && ids.size > options[:limit]
1393
+ options[:limit]
1394
+ else
1395
+ ids.size
1396
+ end
1397
+
1398
+ # 11 ids with limit 3, offset 9 should give 2 results.
1399
+ if options[:offset] && (ids.size - options[:offset] < expected_size)
1400
+ expected_size = ids.size - options[:offset]
1401
+ end
1402
+
1403
+ if result.size == expected_size
1404
+ result
1405
+ else
1406
+ raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})"
1407
+ end
1408
+ end
1409
+
1410
+ # Finder methods must instantiate through this method to work with the
1411
+ # single-table inheritance model that makes it possible to create
1412
+ # objects of different types from the same table.
1413
+ def instantiate(record)
1414
+ object =
1415
+ if subclass_name = record[inheritance_column]
1416
+ # No type given.
1417
+ if subclass_name.empty?
1418
+ allocate
1419
+
1420
+ else
1421
+ # Ignore type if no column is present since it was probably
1422
+ # pulled in from a sloppy join.
1423
+ unless columns_hash.include?(inheritance_column)
1424
+ allocate
1425
+
1426
+ else
1427
+ begin
1428
+ compute_type(subclass_name).allocate
1429
+ rescue NameError
1430
+ raise SubclassNotFound,
1431
+ "The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " +
1432
+ "This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
1433
+ "Please rename this column if you didn't intend it to be used for storing the inheritance class " +
1434
+ "or overwrite #{self.to_s}.inheritance_column to use another column for that information."
1435
+ end
1436
+ end
1437
+ end
1438
+ else
1439
+ allocate
1440
+ end
1441
+
1442
+ object.instance_variable_set("@attributes", record)
1443
+ object.instance_variable_set("@attributes_cache", Hash.new)
1444
+
1445
+ if object.respond_to_without_attributes?(:after_find)
1446
+ object.send(:callback, :after_find)
1447
+ end
1448
+
1449
+ if object.respond_to_without_attributes?(:after_initialize)
1450
+ object.send(:callback, :after_initialize)
1451
+ end
1452
+
1453
+ object
1454
+ end
1455
+
1456
+ # Nest the type name in the same module as this class.
1457
+ # Bar is "MyApp::Business::Bar" relative to MyApp::Business::Foo
1458
+ def type_name_with_module(type_name)
1459
+ if store_full_sti_class
1460
+ type_name
1461
+ else
1462
+ (/^::/ =~ type_name) ? type_name : "#{parent.name}::#{type_name}"
1463
+ end
1464
+ end
1465
+
1466
+ def construct_finder_sql(options)
1467
+ scope = scope(:find)
1468
+ sql = "SELECT #{options[:select] || (scope && scope[:select]) || (options[:joins] && quoted_table_name + '.*') || '*'} "
1469
+ sql << "FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} "
1470
+
1471
+ add_joins!(sql, options, scope)
1472
+ add_conditions!(sql, options[:conditions], scope)
1473
+
1474
+ add_group!(sql, options[:group], scope)
1475
+ add_order!(sql, options[:order], scope)
1476
+ add_limit!(sql, options, scope)
1477
+ add_lock!(sql, options, scope)
1478
+
1479
+ sql
1480
+ end
1481
+
1482
+ # Merges includes so that the result is a valid +include+
1483
+ def merge_includes(first, second)
1484
+ (safe_to_array(first) + safe_to_array(second)).uniq
1485
+ end
1486
+
1487
+ # Merges conditions so that the result is a valid +condition+
1488
+ def merge_conditions(*conditions)
1489
+ segments = []
1490
+
1491
+ conditions.each do |condition|
1492
+ unless condition.blank?
1493
+ sql = sanitize_sql(condition)
1494
+ segments << sql unless sql.blank?
1495
+ end
1496
+ end
1497
+
1498
+ "(#{segments.join(') AND (')})" unless segments.empty?
1499
+ end
1500
+
1501
+ # Object#to_a is deprecated, though it does have the desired behavior
1502
+ def safe_to_array(o)
1503
+ case o
1504
+ when NilClass
1505
+ []
1506
+ when Array
1507
+ o
1508
+ else
1509
+ [o]
1510
+ end
1511
+ end
1512
+
1513
+ def add_order!(sql, order, scope = :auto)
1514
+ scope = scope(:find) if :auto == scope
1515
+ scoped_order = scope[:order] if scope
1516
+ if order
1517
+ sql << " ORDER BY #{order}"
1518
+ sql << ", #{scoped_order}" if scoped_order
1519
+ else
1520
+ sql << " ORDER BY #{scoped_order}" if scoped_order
1521
+ end
1522
+ end
1523
+
1524
+ def add_group!(sql, group, scope = :auto)
1525
+ if group
1526
+ sql << " GROUP BY #{group}"
1527
+ else
1528
+ scope = scope(:find) if :auto == scope
1529
+ if scope && (scoped_group = scope[:group])
1530
+ sql << " GROUP BY #{scoped_group}"
1531
+ end
1532
+ end
1533
+ end
1534
+
1535
+ # The optional scope argument is for the current <tt>:find</tt> scope.
1536
+ def add_limit!(sql, options, scope = :auto)
1537
+ scope = scope(:find) if :auto == scope
1538
+
1539
+ if scope
1540
+ options[:limit] ||= scope[:limit]
1541
+ options[:offset] ||= scope[:offset]
1542
+ end
1543
+
1544
+ connection.add_limit_offset!(sql, options)
1545
+ end
1546
+
1547
+ # The optional scope argument is for the current <tt>:find</tt> scope.
1548
+ # The <tt>:lock</tt> option has precedence over a scoped <tt>:lock</tt>.
1549
+ def add_lock!(sql, options, scope = :auto)
1550
+ scope = scope(:find) if :auto == scope
1551
+ options = options.reverse_merge(:lock => scope[:lock]) if scope
1552
+ connection.add_lock!(sql, options)
1553
+ end
1554
+
1555
+ # The optional scope argument is for the current <tt>:find</tt> scope.
1556
+ def add_joins!(sql, options, scope = :auto)
1557
+ scope = scope(:find) if :auto == scope
1558
+ [(scope && scope[:joins]), options[:joins]].each do |join|
1559
+ case join
1560
+ when Symbol, Hash, Array
1561
+ join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, join, nil)
1562
+ sql << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} "
1563
+ else
1564
+ sql << " #{join} "
1565
+ end
1566
+ end
1567
+ end
1568
+
1569
+ # Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed.
1570
+ # The optional scope argument is for the current <tt>:find</tt> scope.
1571
+ def add_conditions!(sql, conditions, scope = :auto)
1572
+ scope = scope(:find) if :auto == scope
1573
+ conditions = [conditions]
1574
+ conditions << scope[:conditions] if scope
1575
+ conditions << type_condition if finder_needs_type_condition?
1576
+ merged_conditions = merge_conditions(*conditions)
1577
+ sql << "WHERE #{merged_conditions} " unless merged_conditions.blank?
1578
+ end
1579
+
1580
+ def type_condition
1581
+ quoted_inheritance_column = connection.quote_column_name(inheritance_column)
1582
+ type_condition = subclasses.inject("#{quoted_table_name}.#{quoted_inheritance_column} = '#{sti_name}' ") do |condition, subclass|
1583
+ condition << "OR #{quoted_table_name}.#{quoted_inheritance_column} = '#{subclass.sti_name}' "
1584
+ end
1585
+
1586
+ " (#{type_condition}) "
1587
+ end
1588
+
1589
+ # Guesses the table name, but does not decorate it with prefix and suffix information.
1590
+ def undecorated_table_name(class_name = base_class.name)
1591
+ table_name = class_name.to_s.demodulize.underscore
1592
+ table_name = table_name.pluralize if pluralize_table_names
1593
+ table_name
1594
+ end
1595
+
1596
+ # Enables dynamic finders like find_by_user_name(user_name) and find_by_user_name_and_password(user_name, password) that are turned into
1597
+ # find(:first, :conditions => ["user_name = ?", user_name]) and find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])
1598
+ # respectively. Also works for find(:all) by using find_all_by_amount(50) that is turned into find(:all, :conditions => ["amount = ?", 50]).
1599
+ #
1600
+ # It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount
1601
+ # is actually find_all_by_amount(amount, options).
1602
+ #
1603
+ # This also enables you to initialize a record if it is not found, such as find_or_initialize_by_amount(amount)
1604
+ # or find_or_create_by_user_and_password(user, password).
1605
+ #
1606
+ # Each dynamic finder or initializer/creator is also defined in the class after it is first invoked, so that future
1607
+ # attempts to use it do not run through method_missing.
1608
+ def method_missing(method_id, *arguments)
1609
+ if match = matches_dynamic_finder?(method_id)
1610
+ finder = determine_finder(match)
1611
+
1612
+ attribute_names = extract_attribute_names_from_match(match)
1613
+ super unless all_attributes_exists?(attribute_names)
1614
+
1615
+ self.class_eval %{
1616
+ def self.#{method_id}(*args)
1617
+ options = args.extract_options!
1618
+ attributes = construct_attributes_from_arguments([:#{attribute_names.join(',:')}], args)
1619
+ finder_options = { :conditions => attributes }
1620
+ validate_find_options(options)
1621
+ set_readonly_option!(options)
1622
+
1623
+ if options[:conditions]
1624
+ with_scope(:find => finder_options) do
1625
+ ActiveSupport::Deprecation.silence { send(:#{finder}, options) }
1626
+ end
1627
+ else
1628
+ ActiveSupport::Deprecation.silence { send(:#{finder}, options.merge(finder_options)) }
1629
+ end
1630
+ end
1631
+ }, __FILE__, __LINE__
1632
+ send(method_id, *arguments)
1633
+ elsif match = matches_dynamic_finder_with_initialize_or_create?(method_id)
1634
+ instantiator = determine_instantiator(match)
1635
+ attribute_names = extract_attribute_names_from_match(match)
1636
+ super unless all_attributes_exists?(attribute_names)
1637
+
1638
+ self.class_eval %{
1639
+ def self.#{method_id}(*args)
1640
+ guard_protected_attributes = false
1641
+
1642
+ if args[0].is_a?(Hash)
1643
+ guard_protected_attributes = true
1644
+ attributes = args[0].with_indifferent_access
1645
+ find_attributes = attributes.slice(*[:#{attribute_names.join(',:')}])
1646
+ else
1647
+ find_attributes = attributes = construct_attributes_from_arguments([:#{attribute_names.join(',:')}], args)
1648
+ end
1649
+
1650
+ options = { :conditions => find_attributes }
1651
+ set_readonly_option!(options)
1652
+
1653
+ record = find_initial(options)
1654
+
1655
+ if record.nil?
1656
+ record = self.new { |r| r.send(:attributes=, attributes, guard_protected_attributes) }
1657
+ #{'yield(record) if block_given?'}
1658
+ #{'record.save' if instantiator == :create}
1659
+ record
1660
+ else
1661
+ record
1662
+ end
1663
+ end
1664
+ }, __FILE__, __LINE__
1665
+ send(method_id, *arguments)
1666
+ else
1667
+ super
1668
+ end
1669
+ end
1670
+
1671
+ def matches_dynamic_finder?(method_id)
1672
+ /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(method_id.to_s)
1673
+ end
1674
+
1675
+ def matches_dynamic_finder_with_initialize_or_create?(method_id)
1676
+ /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/.match(method_id.to_s)
1677
+ end
1678
+
1679
+ def determine_finder(match)
1680
+ match.captures.first == 'all_by' ? :find_every : :find_initial
1681
+ end
1682
+
1683
+ def determine_instantiator(match)
1684
+ match.captures.first == 'initialize' ? :new : :create
1685
+ end
1686
+
1687
+ def extract_attribute_names_from_match(match)
1688
+ match.captures.last.split('_and_')
1689
+ end
1690
+
1691
+ def construct_attributes_from_arguments(attribute_names, arguments)
1692
+ attributes = {}
1693
+ attribute_names.each_with_index { |name, idx| attributes[name] = arguments[idx] }
1694
+ attributes
1695
+ end
1696
+
1697
+ # Similar in purpose to +expand_hash_conditions_for_aggregates+.
1698
+ def expand_attribute_names_for_aggregates(attribute_names)
1699
+ expanded_attribute_names = []
1700
+ attribute_names.each do |attribute_name|
1701
+ unless (aggregation = reflect_on_aggregation(attribute_name.to_sym)).nil?
1702
+ aggregate_mapping(aggregation).each do |field_attr, aggregate_attr|
1703
+ expanded_attribute_names << field_attr
1704
+ end
1705
+ else
1706
+ expanded_attribute_names << attribute_name
1707
+ end
1708
+ end
1709
+ expanded_attribute_names
1710
+ end
1711
+
1712
+ def all_attributes_exists?(attribute_names)
1713
+ attribute_names = expand_attribute_names_for_aggregates(attribute_names)
1714
+ attribute_names.all? { |name| column_methods_hash.include?(name.to_sym) }
1715
+ end
1716
+
1717
+ def attribute_condition(argument)
1718
+ case argument
1719
+ when nil then "IS ?"
1720
+ when Array, ActiveRecord::Associations::AssociationCollection then "IN (?)"
1721
+ when Range then "BETWEEN ? AND ?"
1722
+ else "= ?"
1723
+ end
1724
+ end
1725
+
1726
+ # Interpret Array and Hash as conditions and anything else as an id.
1727
+ def expand_id_conditions(id_or_conditions)
1728
+ case id_or_conditions
1729
+ when Array, Hash then id_or_conditions
1730
+ else sanitize_sql(primary_key => id_or_conditions)
1731
+ end
1732
+ end
1733
+
1734
+
1735
+ # Defines an "attribute" method (like +inheritance_column+ or
1736
+ # +table_name+). A new (class) method will be created with the
1737
+ # given name. If a value is specified, the new method will
1738
+ # return that value (as a string). Otherwise, the given block
1739
+ # will be used to compute the value of the method.
1740
+ #
1741
+ # The original method will be aliased, with the new name being
1742
+ # prefixed with "original_". This allows the new method to
1743
+ # access the original value.
1744
+ #
1745
+ # Example:
1746
+ #
1747
+ # class A < ActiveRecord::Base
1748
+ # define_attr_method :primary_key, "sysid"
1749
+ # define_attr_method( :inheritance_column ) do
1750
+ # original_inheritance_column + "_id"
1751
+ # end
1752
+ # end
1753
+ def define_attr_method(name, value=nil, &block)
1754
+ sing = class << self; self; end
1755
+ sing.send :alias_method, "original_#{name}", name
1756
+ if block_given?
1757
+ sing.send :define_method, name, &block
1758
+ else
1759
+ # use eval instead of a block to work around a memory leak in dev
1760
+ # mode in fcgi
1761
+ sing.class_eval "def #{name}; #{value.to_s.inspect}; end"
1762
+ end
1763
+ end
1764
+
1765
+ protected
1766
+ # Scope parameters to method calls within the block. Takes a hash of method_name => parameters hash.
1767
+ # method_name may be <tt>:find</tt> or <tt>:create</tt>. <tt>:find</tt> parameters may include the <tt>:conditions</tt>, <tt>:joins</tt>,
1768
+ # <tt>:include</tt>, <tt>:offset</tt>, <tt>:limit</tt>, and <tt>:readonly</tt> options. <tt>:create</tt> parameters are an attributes hash.
1769
+ #
1770
+ # class Article < ActiveRecord::Base
1771
+ # def self.create_with_scope
1772
+ # with_scope(:find => { :conditions => "blog_id = 1" }, :create => { :blog_id => 1 }) do
1773
+ # find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1
1774
+ # a = create(1)
1775
+ # a.blog_id # => 1
1776
+ # end
1777
+ # end
1778
+ # end
1779
+ #
1780
+ # In nested scopings, all previous parameters are overwritten by the innermost rule, with the exception of
1781
+ # <tt>:conditions</tt> and <tt>:include</tt> options in <tt>:find</tt>, which are merged.
1782
+ #
1783
+ # class Article < ActiveRecord::Base
1784
+ # def self.find_with_scope
1785
+ # with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }, :create => { :blog_id => 1 }) do
1786
+ # with_scope(:find => { :limit => 10 })
1787
+ # find(:all) # => SELECT * from articles WHERE blog_id = 1 LIMIT 10
1788
+ # end
1789
+ # with_scope(:find => { :conditions => "author_id = 3" })
1790
+ # find(:all) # => SELECT * from articles WHERE blog_id = 1 AND author_id = 3 LIMIT 1
1791
+ # end
1792
+ # end
1793
+ # end
1794
+ # end
1795
+ #
1796
+ # You can ignore any previous scopings by using the <tt>with_exclusive_scope</tt> method.
1797
+ #
1798
+ # class Article < ActiveRecord::Base
1799
+ # def self.find_with_exclusive_scope
1800
+ # with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }) do
1801
+ # with_exclusive_scope(:find => { :limit => 10 })
1802
+ # find(:all) # => SELECT * from articles LIMIT 10
1803
+ # end
1804
+ # end
1805
+ # end
1806
+ # end
1807
+ def with_scope(method_scoping = {}, action = :merge, &block)
1808
+ method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping)
1809
+
1810
+ # Dup first and second level of hash (method and params).
1811
+ method_scoping = method_scoping.inject({}) do |hash, (method, params)|
1812
+ hash[method] = (params == true) ? params : params.dup
1813
+ hash
1814
+ end
1815
+
1816
+ method_scoping.assert_valid_keys([ :find, :create ])
1817
+
1818
+ if f = method_scoping[:find]
1819
+ f.assert_valid_keys(VALID_FIND_OPTIONS)
1820
+ set_readonly_option! f
1821
+ end
1822
+
1823
+ # Merge scopings
1824
+ if action == :merge && current_scoped_methods
1825
+ method_scoping = current_scoped_methods.inject(method_scoping) do |hash, (method, params)|
1826
+ case hash[method]
1827
+ when Hash
1828
+ if method == :find
1829
+ (hash[method].keys + params.keys).uniq.each do |key|
1830
+ merge = hash[method][key] && params[key] # merge if both scopes have the same key
1831
+ if key == :conditions && merge
1832
+ hash[method][key] = merge_conditions(params[key], hash[method][key])
1833
+ elsif key == :include && merge
1834
+ hash[method][key] = merge_includes(hash[method][key], params[key]).uniq
1835
+ else
1836
+ hash[method][key] = hash[method][key] || params[key]
1837
+ end
1838
+ end
1839
+ else
1840
+ hash[method] = params.merge(hash[method])
1841
+ end
1842
+ else
1843
+ hash[method] = params
1844
+ end
1845
+ hash
1846
+ end
1847
+ end
1848
+
1849
+ self.scoped_methods << method_scoping
1850
+
1851
+ begin
1852
+ yield
1853
+ ensure
1854
+ self.scoped_methods.pop
1855
+ end
1856
+ end
1857
+
1858
+ # Works like with_scope, but discards any nested properties.
1859
+ def with_exclusive_scope(method_scoping = {}, &block)
1860
+ with_scope(method_scoping, :overwrite, &block)
1861
+ end
1862
+
1863
+ def subclasses #:nodoc:
1864
+ @@subclasses[self] ||= []
1865
+ @@subclasses[self] + extra = @@subclasses[self].inject([]) {|list, subclass| list + subclass.subclasses }
1866
+ end
1867
+
1868
+ # Test whether the given method and optional key are scoped.
1869
+ def scoped?(method, key = nil) #:nodoc:
1870
+ if current_scoped_methods && (scope = current_scoped_methods[method])
1871
+ !key || scope.has_key?(key)
1872
+ end
1873
+ end
1874
+
1875
+ # Retrieve the scope for the given method and optional key.
1876
+ def scope(method, key = nil) #:nodoc:
1877
+ if current_scoped_methods && (scope = current_scoped_methods[method])
1878
+ key ? scope[key] : scope
1879
+ end
1880
+ end
1881
+
1882
+ def thread_safe_scoped_methods #:nodoc:
1883
+ scoped_methods = (Thread.current[:scoped_methods] ||= {})
1884
+ scoped_methods[self] ||= []
1885
+ end
1886
+
1887
+ def single_threaded_scoped_methods #:nodoc:
1888
+ @scoped_methods ||= []
1889
+ end
1890
+
1891
+ # pick up the correct scoped_methods version from @@allow_concurrency
1892
+ if @@allow_concurrency
1893
+ alias_method :scoped_methods, :thread_safe_scoped_methods
1894
+ else
1895
+ alias_method :scoped_methods, :single_threaded_scoped_methods
1896
+ end
1897
+
1898
+ def current_scoped_methods #:nodoc:
1899
+ scoped_methods.last
1900
+ end
1901
+
1902
+ # Returns the class type of the record using the current module as a prefix. So descendents of
1903
+ # MyApp::Business::Account would appear as MyApp::Business::AccountSubclass.
1904
+ def compute_type(type_name)
1905
+ modularized_name = type_name_with_module(type_name)
1906
+ begin
1907
+ class_eval(modularized_name, __FILE__, __LINE__)
1908
+ rescue NameError
1909
+ class_eval(type_name, __FILE__, __LINE__)
1910
+ end
1911
+ end
1912
+
1913
+ # Returns the class descending directly from Active Record in the inheritance hierarchy.
1914
+ def class_of_active_record_descendant(klass)
1915
+ if klass.superclass == Base || klass.superclass.abstract_class?
1916
+ klass
1917
+ elsif klass.superclass.nil?
1918
+ raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord"
1919
+ else
1920
+ class_of_active_record_descendant(klass.superclass)
1921
+ end
1922
+ end
1923
+
1924
+ # Returns the name of the class descending directly from Active Record in the inheritance hierarchy.
1925
+ def class_name_of_active_record_descendant(klass) #:nodoc:
1926
+ klass.base_class.name
1927
+ end
1928
+
1929
+ # Accepts an array, hash, or string of SQL conditions and sanitizes
1930
+ # them into a valid SQL fragment for a WHERE clause.
1931
+ # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
1932
+ # { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'"
1933
+ # "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'"
1934
+ def sanitize_sql_for_conditions(condition)
1935
+ return nil if condition.blank?
1936
+
1937
+ case condition
1938
+ when Array; sanitize_sql_array(condition)
1939
+ when Hash; sanitize_sql_hash_for_conditions(condition)
1940
+ else condition
1941
+ end
1942
+ end
1943
+ alias_method :sanitize_sql, :sanitize_sql_for_conditions
1944
+
1945
+ # Accepts an array, hash, or string of SQL conditions and sanitizes
1946
+ # them into a valid SQL fragment for a SET clause.
1947
+ # { :name => nil, :group_id => 4 } returns "name = NULL , group_id='4'"
1948
+ def sanitize_sql_for_assignment(assignments)
1949
+ case assignments
1950
+ when Array; sanitize_sql_array(assignments)
1951
+ when Hash; sanitize_sql_hash_for_assignment(assignments)
1952
+ else assignments
1953
+ end
1954
+ end
1955
+
1956
+ def aggregate_mapping(reflection)
1957
+ mapping = reflection.options[:mapping] || [reflection.name, reflection.name]
1958
+ mapping.first.is_a?(Array) ? mapping : [mapping]
1959
+ end
1960
+
1961
+ # Accepts a hash of SQL conditions and replaces those attributes
1962
+ # that correspond to a +composed_of+ relationship with their expanded
1963
+ # aggregate attribute values.
1964
+ # Given:
1965
+ # class Person < ActiveRecord::Base
1966
+ # composed_of :address, :class_name => "Address",
1967
+ # :mapping => [%w(address_street street), %w(address_city city)]
1968
+ # end
1969
+ # Then:
1970
+ # { :address => Address.new("813 abc st.", "chicago") }
1971
+ # # => { :address_street => "813 abc st.", :address_city => "chicago" }
1972
+ def expand_hash_conditions_for_aggregates(attrs)
1973
+ expanded_attrs = {}
1974
+ attrs.each do |attr, value|
1975
+ unless (aggregation = reflect_on_aggregation(attr.to_sym)).nil?
1976
+ mapping = aggregate_mapping(aggregation)
1977
+ mapping.each do |field_attr, aggregate_attr|
1978
+ if mapping.size == 1 && !value.respond_to?(aggregate_attr)
1979
+ expanded_attrs[field_attr] = value
1980
+ else
1981
+ expanded_attrs[field_attr] = value.send(aggregate_attr)
1982
+ end
1983
+ end
1984
+ else
1985
+ expanded_attrs[attr] = value
1986
+ end
1987
+ end
1988
+ expanded_attrs
1989
+ end
1990
+
1991
+ # Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause.
1992
+ # { :name => "foo'bar", :group_id => 4 }
1993
+ # # => "name='foo''bar' and group_id= 4"
1994
+ # { :status => nil, :group_id => [1,2,3] }
1995
+ # # => "status IS NULL and group_id IN (1,2,3)"
1996
+ # { :age => 13..18 }
1997
+ # # => "age BETWEEN 13 AND 18"
1998
+ # { 'other_records.id' => 7 }
1999
+ # # => "`other_records`.`id` = 7"
2000
+ # And for value objects on a composed_of relationship:
2001
+ # { :address => Address.new("123 abc st.", "chicago") }
2002
+ # # => "address_street='123 abc st.' and address_city='chicago'"
2003
+ def sanitize_sql_hash_for_conditions(attrs)
2004
+ attrs = expand_hash_conditions_for_aggregates(attrs)
2005
+
2006
+ conditions = attrs.map do |attr, value|
2007
+ attr = attr.to_s
2008
+
2009
+ # Extract table name from qualified attribute names.
2010
+ if attr.include?('.')
2011
+ table_name, attr = attr.split('.', 2)
2012
+ table_name = connection.quote_table_name(table_name)
2013
+ else
2014
+ table_name = quoted_table_name
2015
+ end
2016
+
2017
+ "#{table_name}.#{connection.quote_column_name(attr)} #{attribute_condition(value)}"
2018
+ end.join(' AND ')
2019
+
2020
+ replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
2021
+ end
2022
+ alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions
2023
+
2024
+ # Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause.
2025
+ # { :status => nil, :group_id => 1 }
2026
+ # # => "status = NULL , group_id = 1"
2027
+ def sanitize_sql_hash_for_assignment(attrs)
2028
+ attrs.map do |attr, value|
2029
+ "#{connection.quote_column_name(attr)} = #{quote_bound_value(value)}"
2030
+ end.join(', ')
2031
+ end
2032
+
2033
+ # Accepts an array of conditions. The array has each value
2034
+ # sanitized and interpolated into the SQL statement.
2035
+ # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
2036
+ def sanitize_sql_array(ary)
2037
+ statement, *values = ary
2038
+ if values.first.is_a?(Hash) and statement =~ /:\w+/
2039
+ replace_named_bind_variables(statement, values.first)
2040
+ elsif statement.include?('?')
2041
+ replace_bind_variables(statement, values)
2042
+ else
2043
+ statement % values.collect { |value| connection.quote_string(value.to_s) }
2044
+ end
2045
+ end
2046
+
2047
+ alias_method :sanitize_conditions, :sanitize_sql
2048
+
2049
+ def replace_bind_variables(statement, values) #:nodoc:
2050
+ raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size)
2051
+ bound = values.dup
2052
+ statement.gsub('?') { quote_bound_value(bound.shift) }
2053
+ end
2054
+
2055
+ def replace_named_bind_variables(statement, bind_vars) #:nodoc:
2056
+ statement.gsub(/:([a-zA-Z]\w*)/) do
2057
+ match = $1.to_sym
2058
+ if bind_vars.include?(match)
2059
+ quote_bound_value(bind_vars[match])
2060
+ else
2061
+ raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}"
2062
+ end
2063
+ end
2064
+ end
2065
+
2066
+ def expand_range_bind_variables(bind_vars) #:nodoc:
2067
+ bind_vars.sum do |var|
2068
+ if var.is_a?(Range)
2069
+ [var.first, var.last]
2070
+ else
2071
+ [var]
2072
+ end
2073
+ end
2074
+ end
2075
+
2076
+ def quote_bound_value(value) #:nodoc:
2077
+ if value.respond_to?(:map) && !value.is_a?(String)
2078
+ if value.respond_to?(:empty?) && value.empty?
2079
+ connection.quote(nil)
2080
+ else
2081
+ value.map { |v| connection.quote(v) }.join(',')
2082
+ end
2083
+ else
2084
+ connection.quote(value)
2085
+ end
2086
+ end
2087
+
2088
+ def raise_if_bind_arity_mismatch(statement, expected, provided) #:nodoc:
2089
+ unless expected == provided
2090
+ raise PreparedStatementInvalid, "wrong number of bind variables (#{provided} for #{expected}) in: #{statement}"
2091
+ end
2092
+ end
2093
+
2094
+ VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
2095
+ :order, :select, :readonly, :group, :from, :lock ]
2096
+
2097
+ def validate_find_options(options) #:nodoc:
2098
+ options.assert_valid_keys(VALID_FIND_OPTIONS)
2099
+ end
2100
+
2101
+ def set_readonly_option!(options) #:nodoc:
2102
+ # Inherit :readonly from finder scope if set. Otherwise,
2103
+ # if :joins is not blank then :readonly defaults to true.
2104
+ unless options.has_key?(:readonly)
2105
+ if scoped_readonly = scope(:find, :readonly)
2106
+ options[:readonly] = scoped_readonly
2107
+ elsif !options[:joins].blank? && !options[:select]
2108
+ options[:readonly] = true
2109
+ end
2110
+ end
2111
+ end
2112
+
2113
+ def encode_quoted_value(value) #:nodoc:
2114
+ quoted_value = connection.quote(value)
2115
+ quoted_value = "'#{quoted_value[1..-2].gsub(/\'/, "\\\\'")}'" if quoted_value.include?("\\\'") # (for ruby mode) "
2116
+ quoted_value
2117
+ end
2118
+ end
2119
+
2120
+ public
2121
+ # New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
2122
+ # attributes but not yet saved (pass a hash with key names matching the associated table column names).
2123
+ # In both instances, valid attribute keys are determined by the column names of the associated table --
2124
+ # hence you can't have attributes that aren't part of the table columns.
2125
+ def initialize(attributes = nil)
2126
+ @attributes = attributes_from_column_definition
2127
+ @attributes_cache = {}
2128
+ @new_record = true
2129
+ ensure_proper_type
2130
+ self.attributes = attributes unless attributes.nil?
2131
+ self.class.send(:scope, :create).each { |att,value| self.send("#{att}=", value) } if self.class.send(:scoped?, :create)
2132
+ result = yield self if block_given?
2133
+ callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)
2134
+ result
2135
+ end
2136
+
2137
+ # A model instance's primary key is always available as model.id
2138
+ # whether you name it the default 'id' or set it to something else.
2139
+ def id
2140
+ attr_name = self.class.primary_key
2141
+ column = column_for_attribute(attr_name)
2142
+
2143
+ self.class.send(:define_read_method, :id, attr_name, column)
2144
+ # now that the method exists, call it
2145
+ self.send attr_name.to_sym
2146
+
2147
+ end
2148
+
2149
+ # Enables Active Record objects to be used as URL parameters in Action Pack automatically.
2150
+ def to_param
2151
+ # We can't use alias_method here, because method 'id' optimizes itself on the fly.
2152
+ (id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes
2153
+ end
2154
+
2155
+ # Returns a cache key that can be used to identify this record.
2156
+ #
2157
+ # ==== Examples
2158
+ #
2159
+ # Product.new.cache_key # => "products/new"
2160
+ # Product.find(5).cache_key # => "products/5" (updated_at not available)
2161
+ # Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available)
2162
+ def cache_key
2163
+ case
2164
+ when new_record?
2165
+ "#{self.class.name.tableize}/new"
2166
+ when self[:updated_at]
2167
+ "#{self.class.name.tableize}/#{id}-#{updated_at.to_s(:number)}"
2168
+ else
2169
+ "#{self.class.name.tableize}/#{id}"
2170
+ end
2171
+ end
2172
+
2173
+ def id_before_type_cast #:nodoc:
2174
+ read_attribute_before_type_cast(self.class.primary_key)
2175
+ end
2176
+
2177
+ def quoted_id #:nodoc:
2178
+ quote_value(id, column_for_attribute(self.class.primary_key))
2179
+ end
2180
+
2181
+ # Sets the primary ID.
2182
+ def id=(value)
2183
+ write_attribute(self.class.primary_key, value)
2184
+ end
2185
+
2186
+ # Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet.
2187
+ def new_record?
2188
+ defined?(@new_record) && @new_record
2189
+ end
2190
+
2191
+ # * No record exists: Creates a new record with values matching those of the object attributes.
2192
+ # * A record does exist: Updates the record with values matching those of the object attributes.
2193
+ #
2194
+ # Note: If your model specifies any validations then the method declaration dynamically
2195
+ # changes to:
2196
+ # save(perform_validation=true)
2197
+ # Calling save(false) saves the model without running validations.
2198
+ # See ActiveRecord::Validations for more information.
2199
+ def save
2200
+ create_or_update
2201
+ end
2202
+
2203
+ # Attempts to save the record, but instead of just returning false if it couldn't happen, it raises a
2204
+ # RecordNotSaved exception
2205
+ def save!
2206
+ create_or_update || raise(RecordNotSaved)
2207
+ end
2208
+
2209
+ # Deletes the record in the database and freezes this instance to reflect that no changes should
2210
+ # be made (since they can't be persisted).
2211
+ def destroy
2212
+ unless new_record?
2213
+ connection.delete <<-end_sql, "#{self.class.name} Destroy"
2214
+ DELETE FROM #{self.class.quoted_table_name}
2215
+ WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}
2216
+ end_sql
2217
+ end
2218
+
2219
+ freeze
2220
+ end
2221
+
2222
+ # Returns a clone of the record that hasn't been assigned an id yet and
2223
+ # is treated as a new record. Note that this is a "shallow" clone:
2224
+ # it copies the object's attributes only, not its associations.
2225
+ # The extent of a "deep" clone is application-specific and is therefore
2226
+ # left to the application to implement according to its need.
2227
+ def clone
2228
+ attrs = clone_attributes(:read_attribute_before_type_cast)
2229
+ attrs.delete(self.class.primary_key)
2230
+ record = self.class.new
2231
+ record.send :instance_variable_set, '@attributes', attrs
2232
+ record
2233
+ end
2234
+
2235
+ # Returns an instance of the specified +klass+ with the attributes of the current record. This is mostly useful in relation to
2236
+ # single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record
2237
+ # identification in Action Pack to allow, say, <tt>Client < Company</tt> to do something like render <tt>:partial => @client.becomes(Company)</tt>
2238
+ # to render that instance using the companies/company partial instead of clients/client.
2239
+ #
2240
+ # Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either
2241
+ # instance will affect the other.
2242
+ def becomes(klass)
2243
+ returning klass.new do |became|
2244
+ became.instance_variable_set("@attributes", @attributes)
2245
+ became.instance_variable_set("@attributes_cache", @attributes_cache)
2246
+ became.instance_variable_set("@new_record", new_record?)
2247
+ end
2248
+ end
2249
+
2250
+ # Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records.
2251
+ # Note: This method is overwritten by the Validation module that'll make sure that updates made with this method
2252
+ # aren't subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid.
2253
+ def update_attribute(name, value)
2254
+ send(name.to_s + '=', value)
2255
+ save
2256
+ end
2257
+
2258
+ # Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will
2259
+ # fail and false will be returned.
2260
+ def update_attributes(attributes)
2261
+ self.attributes = attributes
2262
+ save
2263
+ end
2264
+
2265
+ # Updates an object just like Base.update_attributes but calls save! instead of save so an exception is raised if the record is invalid.
2266
+ def update_attributes!(attributes)
2267
+ self.attributes = attributes
2268
+ save!
2269
+ end
2270
+
2271
+ # Initializes +attribute+ to zero if +nil+ and adds the value passed as +by+ (default is 1).
2272
+ # The increment is performed directly on the underlying attribute, no setter is invoked.
2273
+ # Only makes sense for number-based attributes. Returns +self+.
2274
+ def increment(attribute, by = 1)
2275
+ self[attribute] ||= 0
2276
+ self[attribute] += by
2277
+ self
2278
+ end
2279
+
2280
+ # Wrapper around +increment+ that saves the record. This method differs from
2281
+ # its non-bang version in that it passes through the attribute setter.
2282
+ # Saving is not subjected to validation checks. Returns +true+ if the
2283
+ # record could be saved.
2284
+ def increment!(attribute, by = 1)
2285
+ increment(attribute, by).update_attribute(attribute, self[attribute])
2286
+ end
2287
+
2288
+ # Initializes +attribute+ to zero if +nil+ and subtracts the value passed as +by+ (default is 1).
2289
+ # The decrement is performed directly on the underlying attribute, no setter is invoked.
2290
+ # Only makes sense for number-based attributes. Returns +self+.
2291
+ def decrement(attribute, by = 1)
2292
+ self[attribute] ||= 0
2293
+ self[attribute] -= by
2294
+ self
2295
+ end
2296
+
2297
+ # Wrapper around +decrement+ that saves the record. This method differs from
2298
+ # its non-bang version in that it passes through the attribute setter.
2299
+ # Saving is not subjected to validation checks. Returns +true+ if the
2300
+ # record could be saved.
2301
+ def decrement!(attribute, by = 1)
2302
+ decrement(attribute, by).update_attribute(attribute, self[attribute])
2303
+ end
2304
+
2305
+ # Assigns to +attribute+ the boolean opposite of <tt>attribute?</tt>. So
2306
+ # if the predicate returns +true+ the attribute will become +false+. This
2307
+ # method toggles directly the underlying value without calling any setter.
2308
+ # Returns +self+.
2309
+ def toggle(attribute)
2310
+ self[attribute] = !send("#{attribute}?")
2311
+ self
2312
+ end
2313
+
2314
+ # Wrapper around +toggle+ that saves the record. This method differs from
2315
+ # its non-bang version in that it passes through the attribute setter.
2316
+ # Saving is not subjected to validation checks. Returns +true+ if the
2317
+ # record could be saved.
2318
+ def toggle!(attribute)
2319
+ toggle(attribute).update_attribute(attribute, self[attribute])
2320
+ end
2321
+
2322
+ # Reloads the attributes of this object from the database.
2323
+ # The optional options argument is passed to find when reloading so you
2324
+ # may do e.g. record.reload(:lock => true) to reload the same record with
2325
+ # an exclusive row lock.
2326
+ def reload(options = nil)
2327
+ clear_aggregation_cache
2328
+ clear_association_cache
2329
+ @attributes.update(self.class.find(self.id, options).instance_variable_get('@attributes'))
2330
+ @attributes_cache = {}
2331
+ self
2332
+ end
2333
+
2334
+ # Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
2335
+ # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
2336
+ # (Alias for the protected read_attribute method).
2337
+ def [](attr_name)
2338
+ read_attribute(attr_name)
2339
+ end
2340
+
2341
+ # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
2342
+ # (Alias for the protected write_attribute method).
2343
+ def []=(attr_name, value)
2344
+ write_attribute(attr_name, value)
2345
+ end
2346
+
2347
+ # Allows you to set all the attributes at once by passing in a hash with keys
2348
+ # matching the attribute names (which again matches the column names). Sensitive attributes can be protected
2349
+ # from this form of mass-assignment by using the +attr_protected+ macro. Or you can alternatively
2350
+ # specify which attributes *can* be accessed with the +attr_accessible+ macro. Then all the
2351
+ # attributes not included in that won't be allowed to be mass-assigned.
2352
+ def attributes=(new_attributes, guard_protected_attributes = true)
2353
+ return if new_attributes.nil?
2354
+ attributes = new_attributes.dup
2355
+ attributes.stringify_keys!
2356
+
2357
+ multi_parameter_attributes = []
2358
+ attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes
2359
+
2360
+ attributes.each do |k, v|
2361
+ k.include?("(") ? multi_parameter_attributes << [ k, v ] : send(k + "=", v)
2362
+ end
2363
+
2364
+ assign_multiparameter_attributes(multi_parameter_attributes)
2365
+ end
2366
+
2367
+
2368
+ # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
2369
+ def attributes
2370
+ self.attribute_names.inject({}) do |attrs, name|
2371
+ attrs[name] = read_attribute(name)
2372
+ attrs
2373
+ end
2374
+ end
2375
+
2376
+ # Returns a hash of attributes before typecasting and deserialization.
2377
+ def attributes_before_type_cast
2378
+ self.attribute_names.inject({}) do |attrs, name|
2379
+ attrs[name] = read_attribute_before_type_cast(name)
2380
+ attrs
2381
+ end
2382
+ end
2383
+
2384
+ # Format attributes nicely for inspect.
2385
+ def attribute_for_inspect(attr_name)
2386
+ value = read_attribute(attr_name)
2387
+
2388
+ if value.is_a?(String) && value.length > 50
2389
+ "#{value[0..50]}...".inspect
2390
+ elsif value.is_a?(Date) || value.is_a?(Time)
2391
+ %("#{value.to_s(:db)}")
2392
+ else
2393
+ value.inspect
2394
+ end
2395
+ end
2396
+
2397
+ # Returns true if the specified +attribute+ has been set by the user or by a database load and is neither
2398
+ # nil nor empty? (the latter only applies to objects that respond to empty?, most notably Strings).
2399
+ def attribute_present?(attribute)
2400
+ value = read_attribute(attribute)
2401
+ !value.blank?
2402
+ end
2403
+
2404
+ # Returns true if the given attribute is in the attributes hash
2405
+ def has_attribute?(attr_name)
2406
+ @attributes.has_key?(attr_name.to_s)
2407
+ end
2408
+
2409
+ # Returns an array of names for the attributes available on this object sorted alphabetically.
2410
+ def attribute_names
2411
+ @attributes.keys.sort
2412
+ end
2413
+
2414
+ # Returns the column object for the named attribute.
2415
+ def column_for_attribute(name)
2416
+ self.class.columns_hash[name.to_s]
2417
+ end
2418
+
2419
+ # Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id.
2420
+ def ==(comparison_object)
2421
+ comparison_object.equal?(self) ||
2422
+ (comparison_object.instance_of?(self.class) &&
2423
+ comparison_object.id == id &&
2424
+ !comparison_object.new_record?)
2425
+ end
2426
+
2427
+ # Delegates to ==
2428
+ def eql?(comparison_object)
2429
+ self == (comparison_object)
2430
+ end
2431
+
2432
+ # Delegates to id in order to allow two records of the same type and id to work with something like:
2433
+ # [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
2434
+ def hash
2435
+ id.hash
2436
+ end
2437
+
2438
+ # Freeze the attributes hash such that associations are still accessible, even on destroyed records.
2439
+ def freeze
2440
+ @attributes.freeze; self
2441
+ end
2442
+
2443
+ # Returns +true+ if the attributes hash has been frozen.
2444
+ def frozen?
2445
+ @attributes.frozen?
2446
+ end
2447
+
2448
+ # Returns +true+ if the record is read only. Records loaded through joins with piggy-back
2449
+ # attributes will be marked as read only since they cannot be saved.
2450
+ def readonly?
2451
+ defined?(@readonly) && @readonly == true
2452
+ end
2453
+
2454
+ # Marks this record as read only.
2455
+ def readonly!
2456
+ @readonly = true
2457
+ end
2458
+
2459
+ # Returns the contents of the record as a nicely formatted string.
2460
+ def inspect
2461
+ attributes_as_nice_string = self.class.column_names.collect { |name|
2462
+ if has_attribute?(name) || new_record?
2463
+ "#{name}: #{attribute_for_inspect(name)}"
2464
+ end
2465
+ }.compact.join(", ")
2466
+ "#<#{self.class} #{attributes_as_nice_string}>"
2467
+ end
2468
+
2469
+ private
2470
+ def create_or_update
2471
+ raise ReadOnlyRecord if readonly?
2472
+ result = new_record? ? create : update
2473
+ result != false
2474
+ end
2475
+
2476
+ # Updates the associated record with values matching those of the instance attributes.
2477
+ # Returns the number of affected rows.
2478
+ def update(attribute_names = @attributes.keys)
2479
+ quoted_attributes = attributes_with_quotes(false, false, attribute_names)
2480
+ return 0 if quoted_attributes.empty?
2481
+ connection.update(
2482
+ "UPDATE #{self.class.quoted_table_name} " +
2483
+ "SET #{quoted_comma_pair_list(connection, quoted_attributes)} " +
2484
+ "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}",
2485
+ "#{self.class.name} Update"
2486
+ )
2487
+ end
2488
+
2489
+ # Creates a record with values matching those of the instance attributes
2490
+ # and returns its id.
2491
+ def create
2492
+ if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name)
2493
+ self.id = connection.next_sequence_value(self.class.sequence_name)
2494
+ end
2495
+
2496
+ quoted_attributes = attributes_with_quotes
2497
+
2498
+ statement = if quoted_attributes.empty?
2499
+ connection.empty_insert_statement(self.class.table_name)
2500
+ else
2501
+ "INSERT INTO #{self.class.quoted_table_name} " +
2502
+ "(#{quoted_column_names.join(', ')}) " +
2503
+ "VALUES(#{quoted_attributes.values.join(', ')})"
2504
+ end
2505
+
2506
+ self.id = connection.insert(statement, "#{self.class.name} Create",
2507
+ self.class.primary_key, self.id, self.class.sequence_name)
2508
+
2509
+ @new_record = false
2510
+ id
2511
+ end
2512
+
2513
+ # Sets the attribute used for single table inheritance to this class name if this is not the ActiveRecord::Base descendent.
2514
+ # Considering the hierarchy Reply < Message < ActiveRecord::Base, this makes it possible to do Reply.new without having to
2515
+ # set <tt>Reply[Reply.inheritance_column] = "Reply"</tt> yourself. No such attribute would be set for objects of the
2516
+ # Message class in that example.
2517
+ def ensure_proper_type
2518
+ unless self.class.descends_from_active_record?
2519
+ write_attribute(self.class.inheritance_column, self.class.sti_name)
2520
+ end
2521
+ end
2522
+
2523
+ def convert_number_column_value(value)
2524
+ case value
2525
+ when FalseClass; 0
2526
+ when TrueClass; 1
2527
+ when ''; nil
2528
+ else value
2529
+ end
2530
+ end
2531
+
2532
+ def remove_attributes_protected_from_mass_assignment(attributes)
2533
+ safe_attributes =
2534
+ if self.class.accessible_attributes.nil? && self.class.protected_attributes.nil?
2535
+ attributes.reject { |key, value| attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
2536
+ elsif self.class.protected_attributes.nil?
2537
+ attributes.reject { |key, value| !self.class.accessible_attributes.include?(key.gsub(/\(.+/, "")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
2538
+ elsif self.class.accessible_attributes.nil?
2539
+ attributes.reject { |key, value| self.class.protected_attributes.include?(key.gsub(/\(.+/,"")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
2540
+ else
2541
+ raise "Declare either attr_protected or attr_accessible for #{self.class}, but not both."
2542
+ end
2543
+
2544
+ removed_attributes = attributes.keys - safe_attributes.keys
2545
+
2546
+ if removed_attributes.any?
2547
+ logger.debug "WARNING: Can't mass-assign these protected attributes: #{removed_attributes.join(', ')}"
2548
+ end
2549
+
2550
+ safe_attributes
2551
+ end
2552
+
2553
+ # Removes attributes which have been marked as readonly.
2554
+ def remove_readonly_attributes(attributes)
2555
+ unless self.class.readonly_attributes.nil?
2556
+ attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"")) }
2557
+ else
2558
+ attributes
2559
+ end
2560
+ end
2561
+
2562
+ # The primary key and inheritance column can never be set by mass-assignment for security reasons.
2563
+ def attributes_protected_by_default
2564
+ default = [ self.class.primary_key, self.class.inheritance_column ]
2565
+ default << 'id' unless self.class.primary_key.eql? 'id'
2566
+ default
2567
+ end
2568
+
2569
+ # Returns a copy of the attributes hash where all the values have been safely quoted for use in
2570
+ # an SQL statement.
2571
+ def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
2572
+ quoted = {}
2573
+ connection = self.class.connection
2574
+ attribute_names.each do |name|
2575
+ if column = column_for_attribute(name)
2576
+ quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && column.primary
2577
+ end
2578
+ end
2579
+ include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
2580
+ end
2581
+
2582
+ # Quote strings appropriately for SQL statements.
2583
+ def quote_value(value, column = nil)
2584
+ self.class.connection.quote(value, column)
2585
+ end
2586
+
2587
+ # Interpolate custom SQL string in instance context.
2588
+ # Optional record argument is meant for custom insert_sql.
2589
+ def interpolate_sql(sql, record = nil)
2590
+ instance_eval("%@#{sql.gsub('@', '\@')}@")
2591
+ end
2592
+
2593
+ # Initializes the attributes array with keys matching the columns from the linked table and
2594
+ # the values matching the corresponding default value of that column, so
2595
+ # that a new instance, or one populated from a passed-in Hash, still has all the attributes
2596
+ # that instances loaded from the database would.
2597
+ def attributes_from_column_definition
2598
+ self.class.columns.inject({}) do |attributes, column|
2599
+ attributes[column.name] = column.default unless column.name == self.class.primary_key
2600
+ attributes
2601
+ end
2602
+ end
2603
+
2604
+ # Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
2605
+ # by calling new on the column type or aggregation type (through composed_of) object with these parameters.
2606
+ # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
2607
+ # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
2608
+ # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float,
2609
+ # s for String, and a for Array. If all the values for a given attribute are empty, the attribute will be set to nil.
2610
+ def assign_multiparameter_attributes(pairs)
2611
+ execute_callstack_for_multiparameter_attributes(
2612
+ extract_callstack_for_multiparameter_attributes(pairs)
2613
+ )
2614
+ end
2615
+
2616
+ def instantiate_time_object(name, values)
2617
+ if self.class.time_zone_aware_attributes && !self.class.skip_time_zone_conversion_for_attributes.include?(name.to_sym)
2618
+ Time.zone.local(*values)
2619
+ else
2620
+ Time.time_with_datetime_fallback(@@default_timezone, *values)
2621
+ end
2622
+ end
2623
+
2624
+ def execute_callstack_for_multiparameter_attributes(callstack)
2625
+ errors = []
2626
+ callstack.each do |name, values|
2627
+ klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
2628
+ if values.empty?
2629
+ send(name + "=", nil)
2630
+ else
2631
+ begin
2632
+ value = if Time == klass
2633
+ instantiate_time_object(name, values)
2634
+ elsif Date == klass
2635
+ begin
2636
+ Date.new(*values)
2637
+ rescue ArgumentError => ex # if Date.new raises an exception on an invalid date
2638
+ instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
2639
+ end
2640
+ else
2641
+ klass.new(*values)
2642
+ end
2643
+
2644
+ send(name + "=", value)
2645
+ rescue => ex
2646
+ errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
2647
+ end
2648
+ end
2649
+ end
2650
+ unless errors.empty?
2651
+ raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
2652
+ end
2653
+ end
2654
+
2655
+ def extract_callstack_for_multiparameter_attributes(pairs)
2656
+ attributes = { }
2657
+
2658
+ for pair in pairs
2659
+ multiparameter_name, value = pair
2660
+ attribute_name = multiparameter_name.split("(").first
2661
+ attributes[attribute_name] = [] unless attributes.include?(attribute_name)
2662
+
2663
+ unless value.empty?
2664
+ attributes[attribute_name] <<
2665
+ [ find_parameter_position(multiparameter_name), type_cast_attribute_value(multiparameter_name, value) ]
2666
+ end
2667
+ end
2668
+
2669
+ attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } }
2670
+ end
2671
+
2672
+ def type_cast_attribute_value(multiparameter_name, value)
2673
+ multiparameter_name =~ /\([0-9]*([a-z])\)/ ? value.send("to_" + $1) : value
2674
+ end
2675
+
2676
+ def find_parameter_position(multiparameter_name)
2677
+ multiparameter_name.scan(/\(([0-9]*).*\)/).first.first
2678
+ end
2679
+
2680
+ # Returns a comma-separated pair list, like "key1 = val1, key2 = val2".
2681
+ def comma_pair_list(hash)
2682
+ hash.inject([]) { |list, pair| list << "#{pair.first} = #{pair.last}" }.join(", ")
2683
+ end
2684
+
2685
+ def quoted_column_names(attributes = attributes_with_quotes)
2686
+ connection = self.class.connection
2687
+ attributes.keys.collect do |column_name|
2688
+ connection.quote_column_name(column_name)
2689
+ end
2690
+ end
2691
+
2692
+ def self.quoted_table_name
2693
+ self.connection.quote_table_name(self.table_name)
2694
+ end
2695
+
2696
+ def quote_columns(quoter, hash)
2697
+ hash.inject({}) do |quoted, (name, value)|
2698
+ quoted[quoter.quote_column_name(name)] = value
2699
+ quoted
2700
+ end
2701
+ end
2702
+
2703
+ def quoted_comma_pair_list(quoter, hash)
2704
+ comma_pair_list(quote_columns(quoter, hash))
2705
+ end
2706
+
2707
+ def object_from_yaml(string)
2708
+ return string unless string.is_a?(String)
2709
+ YAML::load(string) rescue string
2710
+ end
2711
+
2712
+ def clone_attributes(reader_method = :read_attribute, attributes = {})
2713
+ self.attribute_names.inject(attributes) do |attrs, name|
2714
+ attrs[name] = clone_attribute_value(reader_method, name)
2715
+ attrs
2716
+ end
2717
+ end
2718
+
2719
+ def clone_attribute_value(reader_method, attribute_name)
2720
+ value = send(reader_method, attribute_name)
2721
+ value.duplicable? ? value.clone : value
2722
+ rescue TypeError, NoMethodError
2723
+ value
2724
+ end
2725
+ end
2726
+ end