radiant 0.8.0 → 0.8.1

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

Potentially problematic release.


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

Files changed (513) hide show
  1. data/CHANGELOG +33 -1
  2. data/CONTRIBUTORS +15 -2
  3. data/INSTALL +9 -7
  4. data/README +11 -7
  5. data/app/controllers/admin/layouts_controller.rb +5 -2
  6. data/app/controllers/admin/pages_controller.rb +8 -5
  7. data/app/controllers/admin/snippets_controller.rb +5 -2
  8. data/app/controllers/application_controller.rb +7 -0
  9. data/app/helpers/admin/node_helper.rb +2 -2
  10. data/app/helpers/application_helper.rb +2 -2
  11. data/app/models/radiant/config.rb +36 -4
  12. data/app/models/standard_tags.rb +1 -1
  13. data/app/views/admin/layouts/index.html.haml +15 -12
  14. data/app/views/admin/page_parts/_page_part.html.haml +2 -2
  15. data/app/views/admin/pages/index.html.haml +1 -1
  16. data/app/views/admin/snippets/_form.html.haml +1 -1
  17. data/app/views/admin/snippets/index.html.haml +14 -10
  18. data/config/database.db2.yml +20 -0
  19. data/config/environment.rb +4 -4
  20. data/config/environments/test.rb +1 -2
  21. data/features/support/env.rb +2 -1
  22. data/lib/generators/extension/extension_generator.rb +5 -0
  23. data/lib/generators/extension/templates/RSpecRakefile +11 -8
  24. data/lib/generators/extension/templates/cucumber.yml +1 -0
  25. data/lib/generators/extension/templates/cucumber_env.rb +16 -0
  26. data/lib/generators/extension/templates/cucumber_paths.rb +14 -0
  27. data/lib/generators/extension/templates/extension.rb +1 -1
  28. data/lib/generators/instance/instance_generator.rb +1 -1
  29. data/lib/generators/instance/templates/databases/db2.yml +40 -0
  30. data/lib/generators/instance/templates/instance_environment.rb +6 -6
  31. data/lib/local_time.rb +3 -9
  32. data/lib/radiant.rb +1 -1
  33. data/lib/radiant/cache.rb +10 -8
  34. data/lib/radiant/extension.rb +36 -0
  35. data/lib/radiant/extension/script.rb +1 -1
  36. data/lib/radiant/extension_loader.rb +5 -1
  37. data/lib/radiant/initializer.rb +52 -4
  38. data/lib/task_support.rb +33 -0
  39. data/lib/tasks/cucumber.rake +5 -1
  40. data/lib/tasks/radiant_config.rake +18 -0
  41. data/lib/tasks/release.rake +1 -0
  42. data/public/javascripts/admin/admin.js +1 -1
  43. data/spec/controllers/admin/layouts_controller_spec.rb +18 -12
  44. data/spec/controllers/admin/pages_controller_spec.rb +35 -29
  45. data/spec/controllers/admin/snippets_controller_spec.rb +11 -5
  46. data/spec/controllers/admin/welcome_controller_spec.rb +1 -1
  47. data/spec/controllers/application_controller_spec.rb +18 -0
  48. data/spec/fixtures/radiant_config.yml +10 -0
  49. data/spec/generators/extension_generator_spec.rb +12 -0
  50. data/spec/helpers/admin/node_helper_spec.rb +6 -0
  51. data/spec/helpers/application_helper_spec.rb +1 -1
  52. data/spec/lib/radiant/extension_loader_spec.rb +17 -0
  53. data/spec/lib/radiant/extension_spec.rb +28 -0
  54. data/spec/lib/radiant/initializer_spec.rb +34 -0
  55. data/spec/lib/task_support_spec.rb +42 -0
  56. data/spec/models/page_spec.rb +6 -2
  57. data/spec/models/radiant/config_spec.rb +42 -1
  58. data/spec/models/standard_tags_spec.rb +2 -2
  59. data/test/fixtures/extensions/01_basic/app/metal/basic_metal.rb +9 -0
  60. data/test/fixtures/extensions/02_overriding/app/metal/basic_metal.rb +9 -0
  61. data/vendor/extensions/textile_filter/textile.html +2 -2
  62. data/vendor/plugins/dataset/CHANGELOG +2 -1
  63. data/vendor/plugins/dataset/Rakefile +3 -0
  64. data/vendor/plugins/dataset/VERSION.yml +2 -2
  65. data/vendor/plugins/dataset/dataset.gemspec +9 -3
  66. data/vendor/plugins/dataset/lib/dataset.rb +3 -0
  67. data/vendor/radius/lib/radius.rb +5 -0
  68. data/vendor/radius/test/radius_test.rb +6 -0
  69. data/vendor/rails/actionmailer/CHANGELOG +8 -0
  70. data/vendor/rails/actionmailer/Rakefile +3 -2
  71. data/vendor/rails/actionmailer/lib/action_mailer/base.rb +2 -1
  72. data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
  73. data/vendor/rails/actionmailer/test/abstract_unit.rb +0 -3
  74. data/vendor/rails/actionmailer/test/mail_service_test.rb +3 -2
  75. data/vendor/rails/actionpack/CHANGELOG +16 -0
  76. data/vendor/rails/actionpack/Rakefile +5 -3
  77. data/vendor/rails/actionpack/lib/action_controller.rb +2 -7
  78. data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +13 -3
  79. data/vendor/rails/actionpack/lib/action_controller/base.rb +12 -3
  80. data/vendor/rails/actionpack/lib/action_controller/caching.rb +1 -1
  81. data/vendor/rails/actionpack/lib/action_controller/caching/actions.rb +9 -1
  82. data/vendor/rails/actionpack/lib/action_controller/caching/sweeper.rb +45 -0
  83. data/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb +0 -42
  84. data/vendor/rails/actionpack/lib/action_controller/cookies.rb +1 -1
  85. data/vendor/rails/actionpack/lib/action_controller/dispatcher.rb +21 -6
  86. data/vendor/rails/actionpack/lib/action_controller/failsafe.rb +40 -6
  87. data/vendor/rails/actionpack/lib/action_controller/flash.rb +11 -3
  88. data/vendor/rails/actionpack/lib/action_controller/http_authentication.rb +7 -3
  89. data/vendor/rails/actionpack/lib/action_controller/integration.rb +5 -12
  90. data/vendor/rails/actionpack/lib/action_controller/middlewares.rb +0 -1
  91. data/vendor/rails/actionpack/lib/action_controller/params_parser.rb +6 -0
  92. data/vendor/rails/actionpack/lib/action_controller/reloader.rb +47 -7
  93. data/vendor/rails/actionpack/lib/action_controller/request.rb +6 -2
  94. data/vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb +2 -1
  95. data/vendor/rails/actionpack/lib/action_controller/resources.rb +17 -13
  96. data/vendor/rails/actionpack/lib/action_controller/response.rb +8 -2
  97. data/vendor/rails/actionpack/lib/action_controller/routing.rb +3 -0
  98. data/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb +20 -6
  99. data/vendor/rails/actionpack/lib/action_controller/streaming.rb +4 -2
  100. data/vendor/rails/actionpack/lib/action_controller/test_process.rb +9 -1
  101. data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +1 -1
  102. data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
  103. data/vendor/rails/actionpack/lib/action_view/helpers.rb +1 -1
  104. data/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +21 -9
  105. data/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +1 -1
  106. data/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +2 -2
  107. data/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +26 -12
  108. data/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +71 -1
  109. data/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +10 -4
  110. data/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +1 -1
  111. data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +7 -7
  112. data/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +5 -5
  113. data/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +1 -1
  114. data/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +23 -14
  115. data/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +2 -2
  116. data/vendor/rails/actionpack/lib/action_view/locale/en.yml +4 -0
  117. data/vendor/rails/actionpack/lib/action_view/paths.rb +1 -1
  118. data/vendor/rails/actionpack/lib/action_view/template.rb +22 -33
  119. data/vendor/rails/actionpack/test/abstract_unit.rb +17 -1
  120. data/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +3 -3
  121. data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +27 -0
  122. data/vendor/rails/actionpack/test/controller/caching_test.rb +40 -1
  123. data/vendor/rails/actionpack/test/controller/cookie_test.rb +16 -0
  124. data/vendor/rails/actionpack/test/controller/dispatcher_test.rb +59 -18
  125. data/vendor/rails/actionpack/test/controller/failsafe_test.rb +60 -0
  126. data/vendor/rails/actionpack/test/controller/filter_params_test.rb +3 -1
  127. data/vendor/rails/actionpack/test/controller/flash_test.rb +6 -1
  128. data/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +25 -0
  129. data/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +63 -9
  130. data/vendor/rails/actionpack/test/controller/integration_test.rb +31 -3
  131. data/vendor/rails/actionpack/test/controller/rack_test.rb +18 -1
  132. data/vendor/rails/actionpack/test/controller/redirect_test.rb +4 -1
  133. data/vendor/rails/actionpack/test/controller/reloader_test.rb +124 -0
  134. data/vendor/rails/actionpack/test/controller/render_test.rb +19 -9
  135. data/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb +24 -4
  136. data/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb +1 -62
  137. data/vendor/rails/actionpack/test/controller/request/test_request_test.rb +35 -0
  138. data/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +0 -38
  139. data/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb +15 -0
  140. data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +6 -5
  141. data/vendor/rails/actionpack/test/controller/request_test.rb +218 -230
  142. data/vendor/rails/actionpack/test/controller/resources_test.rb +52 -0
  143. data/vendor/rails/actionpack/test/controller/routing_test.rb +28 -2
  144. data/vendor/rails/actionpack/test/controller/send_file_test.rb +12 -2
  145. data/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +9 -32
  146. data/vendor/rails/actionpack/test/controller/test_test.rb +8 -0
  147. data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +29 -3
  148. data/vendor/rails/actionpack/test/fixtures/failsafe/500.html +1 -0
  149. data/vendor/rails/actionpack/test/fixtures/public/absolute/test.css +23 -0
  150. data/vendor/rails/actionpack/test/fixtures/public/absolute/test.js +63 -0
  151. data/vendor/rails/actionpack/test/template/active_record_helper_test.rb +1 -1
  152. data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +46 -0
  153. data/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +29 -0
  154. data/vendor/rails/actionpack/test/template/form_helper_test.rb +143 -6
  155. data/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb +27 -0
  156. data/vendor/rails/actionpack/test/template/form_options_helper_test.rb +56 -0
  157. data/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +23 -6
  158. data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +11 -11
  159. data/vendor/rails/actionpack/test/template/template_test.rb +32 -0
  160. data/vendor/rails/actionpack/test/template/text_helper_test.rb +23 -0
  161. data/vendor/rails/actionpack/test/template/url_helper_test.rb +8 -0
  162. data/vendor/rails/activerecord/CHANGELOG +18 -0
  163. data/vendor/rails/activerecord/Rakefile +26 -9
  164. data/vendor/rails/activerecord/examples/performance.rb +162 -0
  165. data/vendor/rails/activerecord/lib/active_record/associations.rb +104 -35
  166. data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +10 -5
  167. data/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +2 -2
  168. data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +22 -4
  169. data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -1
  170. data/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +16 -0
  171. data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +1 -0
  172. data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +13 -3
  173. data/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +15 -9
  174. data/vendor/rails/activerecord/lib/active_record/autosave_association.rb +15 -9
  175. data/vendor/rails/activerecord/lib/active_record/base.rb +34 -31
  176. data/vendor/rails/activerecord/lib/active_record/batches.rb +23 -15
  177. data/vendor/rails/activerecord/lib/active_record/calculations.rb +7 -13
  178. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +16 -2
  179. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +2 -2
  180. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +7 -0
  181. data/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +17 -8
  182. data/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +98 -35
  183. data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -0
  184. data/vendor/rails/activerecord/lib/active_record/dirty.rb +1 -1
  185. data/vendor/rails/activerecord/lib/active_record/fixtures.rb +14 -11
  186. data/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb +1 -1
  187. data/vendor/rails/activerecord/lib/active_record/locale/en.yml +4 -0
  188. data/vendor/rails/activerecord/lib/active_record/named_scope.rb +3 -8
  189. data/vendor/rails/activerecord/lib/active_record/reflection.rb +1 -1
  190. data/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +6 -3
  191. data/vendor/rails/activerecord/lib/active_record/serialization.rb +3 -2
  192. data/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +10 -18
  193. data/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +6 -2
  194. data/vendor/rails/activerecord/lib/active_record/session_store.rb +9 -1
  195. data/vendor/rails/activerecord/lib/active_record/timestamp.rb +39 -9
  196. data/vendor/rails/activerecord/lib/active_record/validations.rb +149 -80
  197. data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
  198. data/vendor/rails/activerecord/test/cases/adapter_test.rb +12 -0
  199. data/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +102 -22
  200. data/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +5 -5
  201. data/vendor/rails/activerecord/test/cases/associations/eager_test.rb +12 -0
  202. data/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb +56 -0
  203. data/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +62 -2
  204. data/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +46 -1
  205. data/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +18 -1
  206. data/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +5 -0
  207. data/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +4 -4
  208. data/vendor/rails/activerecord/test/cases/autosave_association_test.rb +22 -0
  209. data/vendor/rails/activerecord/test/cases/base_test.rb +51 -6
  210. data/vendor/rails/activerecord/test/cases/calculations_test.rb +14 -14
  211. data/vendor/rails/activerecord/test/cases/column_definition_test.rb +34 -0
  212. data/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +5 -5
  213. data/vendor/rails/activerecord/test/cases/dirty_test.rb +10 -0
  214. data/vendor/rails/activerecord/test/cases/finder_test.rb +21 -50
  215. data/vendor/rails/activerecord/test/cases/fixtures_test.rb +6 -1
  216. data/vendor/rails/activerecord/test/cases/helper.rb +1 -2
  217. data/vendor/rails/activerecord/test/cases/i18n_test.rb +5 -0
  218. data/vendor/rails/activerecord/test/cases/json_serialization_test.rb +57 -57
  219. data/vendor/rails/activerecord/test/cases/method_scoping_test.rb +14 -4
  220. data/vendor/rails/activerecord/test/cases/migration_test.rb +39 -11
  221. data/vendor/rails/activerecord/test/cases/modules_test.rb +42 -0
  222. data/vendor/rails/activerecord/test/cases/named_scope_test.rb +6 -4
  223. data/vendor/rails/activerecord/test/cases/pk_test.rb +18 -0
  224. data/vendor/rails/activerecord/test/cases/reflection_test.rb +7 -7
  225. data/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +35 -7
  226. data/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +76 -0
  227. data/vendor/rails/activerecord/test/cases/timestamp_test.rb +75 -0
  228. data/vendor/rails/activerecord/test/cases/validations_i18n_test.rb +656 -624
  229. data/vendor/rails/activerecord/test/cases/validations_test.rb +12 -2
  230. data/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +20 -0
  231. data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite +0 -0
  232. data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 +0 -0
  233. data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite +0 -0
  234. data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 +0 -0
  235. data/vendor/rails/activerecord/test/fixtures/posts.yml +3 -0
  236. data/vendor/rails/activerecord/test/models/author.rb +5 -0
  237. data/vendor/rails/activerecord/test/models/comment.rb +5 -1
  238. data/vendor/rails/activerecord/test/models/company.rb +9 -7
  239. data/vendor/rails/activerecord/test/models/company_in_module.rb +1 -1
  240. data/vendor/rails/activerecord/test/models/contract.rb +5 -0
  241. data/vendor/rails/activerecord/test/models/developer.rb +10 -0
  242. data/vendor/rails/activerecord/test/models/essay.rb +3 -0
  243. data/vendor/rails/activerecord/test/models/organization.rb +2 -0
  244. data/vendor/rails/activerecord/test/models/pet.rb +1 -1
  245. data/vendor/rails/activerecord/test/models/project.rb +1 -1
  246. data/vendor/rails/activerecord/test/models/reply.rb +2 -1
  247. data/vendor/rails/activerecord/test/models/topic.rb +1 -2
  248. data/vendor/rails/activerecord/test/models/toy.rb +2 -0
  249. data/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +13 -2
  250. data/vendor/rails/activerecord/test/schema/schema.rb +19 -0
  251. data/vendor/rails/activeresource/CHANGELOG +16 -0
  252. data/vendor/rails/activeresource/Rakefile +3 -2
  253. data/vendor/rails/activeresource/lib/active_resource/base.rb +89 -9
  254. data/vendor/rails/activeresource/lib/active_resource/connection.rb +73 -8
  255. data/vendor/rails/activeresource/lib/active_resource/exceptions.rb +66 -0
  256. data/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +2 -2
  257. data/vendor/rails/activeresource/lib/active_resource/validations.rb +20 -4
  258. data/vendor/rails/activeresource/lib/active_resource/version.rb +1 -1
  259. data/vendor/rails/activeresource/test/abstract_unit.rb +1 -3
  260. data/vendor/rails/activeresource/test/base/load_test.rb +16 -1
  261. data/vendor/rails/activeresource/test/base_errors_test.rb +56 -19
  262. data/vendor/rails/activeresource/test/base_test.rb +147 -0
  263. data/vendor/rails/activeresource/test/connection_test.rb +42 -0
  264. data/vendor/rails/activeresource/test/debug.log +7974 -0
  265. data/vendor/rails/activeresource/test/fixtures/proxy.rb +4 -0
  266. data/vendor/rails/activesupport/CHANGELOG +13 -0
  267. data/vendor/rails/activesupport/lib/active_support/all.rb +8 -0
  268. data/vendor/rails/activesupport/lib/active_support/cache.rb +14 -1
  269. data/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +16 -10
  270. data/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb +1 -1
  271. data/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +1 -0
  272. data/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +2 -1
  273. data/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +2 -4
  274. data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +14 -4
  275. data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +4 -2
  276. data/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +2 -0
  277. data/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +19 -5
  278. data/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb +8 -6
  279. data/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +15 -9
  280. data/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +1 -0
  281. data/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +29 -5
  282. data/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb +5 -0
  283. data/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +7 -7
  284. data/vendor/rails/activesupport/lib/active_support/deprecation.rb +9 -9
  285. data/vendor/rails/activesupport/lib/active_support/duration.rb +4 -2
  286. data/vendor/rails/activesupport/lib/active_support/json.rb +1 -22
  287. data/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb +38 -0
  288. data/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb +88 -0
  289. data/vendor/rails/activesupport/lib/active_support/json/decoding.rb +23 -72
  290. data/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +9 -8
  291. data/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +9 -8
  292. data/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +14 -9
  293. data/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +4 -2
  294. data/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +21 -11
  295. data/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +4 -2
  296. data/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +16 -0
  297. data/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +6 -2
  298. data/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +4 -0
  299. data/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +5 -32
  300. data/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +2 -2
  301. data/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +9 -8
  302. data/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +4 -2
  303. data/vendor/rails/activesupport/lib/active_support/json/encoding.rb +80 -9
  304. data/vendor/rails/activesupport/lib/active_support/memoizable.rb +1 -1
  305. data/vendor/rails/activesupport/lib/active_support/message_verifier.rb +16 -3
  306. data/vendor/rails/activesupport/lib/active_support/multibyte.rb +30 -6
  307. data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +23 -17
  308. data/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb +61 -0
  309. data/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +28 -0
  310. data/vendor/rails/activesupport/lib/active_support/test_case.rb +9 -8
  311. data/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb +2 -0
  312. data/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +9 -8
  313. data/vendor/rails/activesupport/lib/active_support/vendor.rb +6 -7
  314. data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -1
  315. data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -1
  316. data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -1
  317. data/vendor/rails/activesupport/lib/active_support/vendor/{memcache-client-1.6.5 → memcache-client-1.7.4}/memcache.rb +242 -70
  318. data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
  319. data/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb +162 -0
  320. data/vendor/rails/railties/CHANGELOG +10 -0
  321. data/vendor/rails/railties/Rakefile +13 -9
  322. data/vendor/rails/railties/bin/about +2 -2
  323. data/vendor/rails/railties/bin/console +1 -1
  324. data/vendor/rails/railties/bin/dbconsole +1 -1
  325. data/vendor/rails/railties/bin/destroy +1 -1
  326. data/vendor/rails/railties/bin/generate +1 -1
  327. data/vendor/rails/railties/bin/performance/benchmarker +1 -1
  328. data/vendor/rails/railties/bin/performance/profiler +1 -1
  329. data/vendor/rails/railties/bin/plugin +1 -1
  330. data/vendor/rails/railties/bin/runner +1 -1
  331. data/vendor/rails/railties/bin/server +1 -1
  332. data/vendor/rails/railties/builtin/rails_info/rails/info.rb +4 -2
  333. data/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +2 -0
  334. data/vendor/rails/railties/configs/routes.rb +1 -1
  335. data/vendor/rails/railties/configs/seeds.rb +7 -0
  336. data/vendor/rails/railties/environments/boot.rb +1 -1
  337. data/vendor/rails/railties/guides/files/javascripts/code_highlighter.js +188 -0
  338. data/vendor/rails/railties/guides/files/javascripts/guides.js +8 -0
  339. data/vendor/rails/railties/guides/files/javascripts/highlighters.js +90 -0
  340. data/vendor/rails/railties/guides/files/stylesheets/main.css +441 -0
  341. data/vendor/rails/railties/guides/files/stylesheets/print.css +52 -0
  342. data/vendor/rails/railties/guides/files/stylesheets/reset.css +43 -0
  343. data/vendor/rails/railties/guides/files/stylesheets/style.css +13 -0
  344. data/vendor/rails/railties/guides/files/stylesheets/syntax.css +31 -0
  345. data/vendor/rails/railties/guides/images/belongs_to.png +0 -0
  346. data/vendor/rails/railties/guides/images/book_icon.gif +0 -0
  347. data/vendor/rails/railties/guides/images/bullet.gif +0 -0
  348. data/vendor/rails/railties/guides/images/chapters_icon.gif +0 -0
  349. data/vendor/rails/railties/guides/images/check_bullet.gif +0 -0
  350. data/vendor/rails/railties/guides/images/credits_pic_blank.gif +0 -0
  351. data/vendor/rails/railties/guides/images/csrf.png +0 -0
  352. data/vendor/rails/railties/guides/images/customized_error_messages.png +0 -0
  353. data/vendor/rails/railties/guides/images/error_messages.png +0 -0
  354. data/vendor/rails/railties/guides/images/feature_tile.gif +0 -0
  355. data/vendor/rails/railties/guides/images/footer_tile.gif +0 -0
  356. data/vendor/rails/railties/guides/images/fxn.jpg +0 -0
  357. data/vendor/rails/railties/guides/images/grey_bullet.gif +0 -0
  358. data/vendor/rails/railties/guides/images/habtm.png +0 -0
  359. data/vendor/rails/railties/guides/images/has_many.png +0 -0
  360. data/vendor/rails/railties/guides/images/has_many_through.png +0 -0
  361. data/vendor/rails/railties/guides/images/has_one.png +0 -0
  362. data/vendor/rails/railties/guides/images/has_one_through.png +0 -0
  363. data/vendor/rails/railties/guides/images/header_backdrop.png +0 -0
  364. data/vendor/rails/railties/guides/images/header_tile.gif +0 -0
  365. data/vendor/rails/railties/guides/images/i18n/demo_localized_pirate.png +0 -0
  366. data/vendor/rails/railties/guides/images/i18n/demo_translated_en.png +0 -0
  367. data/vendor/rails/railties/guides/images/i18n/demo_translated_pirate.png +0 -0
  368. data/vendor/rails/railties/guides/images/i18n/demo_translation_missing.png +0 -0
  369. data/vendor/rails/railties/guides/images/i18n/demo_untranslated.png +0 -0
  370. data/vendor/rails/railties/guides/images/icons/README +5 -0
  371. data/vendor/rails/railties/guides/images/icons/callouts/1.png +0 -0
  372. data/vendor/rails/railties/guides/images/icons/callouts/10.png +0 -0
  373. data/vendor/rails/railties/guides/images/icons/callouts/11.png +0 -0
  374. data/vendor/rails/railties/guides/images/icons/callouts/12.png +0 -0
  375. data/vendor/rails/railties/guides/images/icons/callouts/13.png +0 -0
  376. data/vendor/rails/railties/guides/images/icons/callouts/14.png +0 -0
  377. data/vendor/rails/railties/guides/images/icons/callouts/15.png +0 -0
  378. data/vendor/rails/railties/guides/images/icons/callouts/2.png +0 -0
  379. data/vendor/rails/railties/guides/images/icons/callouts/3.png +0 -0
  380. data/vendor/rails/railties/guides/images/icons/callouts/4.png +0 -0
  381. data/vendor/rails/railties/guides/images/icons/callouts/5.png +0 -0
  382. data/vendor/rails/railties/guides/images/icons/callouts/6.png +0 -0
  383. data/vendor/rails/railties/guides/images/icons/callouts/7.png +0 -0
  384. data/vendor/rails/railties/guides/images/icons/callouts/8.png +0 -0
  385. data/vendor/rails/railties/guides/images/icons/callouts/9.png +0 -0
  386. data/vendor/rails/railties/guides/images/icons/caution.png +0 -0
  387. data/vendor/rails/railties/guides/images/icons/example.png +0 -0
  388. data/vendor/rails/railties/guides/images/icons/home.png +0 -0
  389. data/vendor/rails/railties/guides/images/icons/important.png +0 -0
  390. data/vendor/rails/railties/guides/images/icons/next.png +0 -0
  391. data/vendor/rails/railties/guides/images/icons/note.png +0 -0
  392. data/vendor/rails/railties/guides/images/icons/prev.png +0 -0
  393. data/vendor/rails/railties/guides/images/icons/tip.png +0 -0
  394. data/vendor/rails/railties/guides/images/icons/up.png +0 -0
  395. data/vendor/rails/railties/guides/images/icons/warning.png +0 -0
  396. data/vendor/rails/railties/guides/images/nav_arrow.gif +0 -0
  397. data/vendor/rails/railties/guides/images/polymorphic.png +0 -0
  398. data/vendor/rails/railties/guides/images/posts_index.png +0 -0
  399. data/vendor/rails/railties/guides/images/rails_guides_logo.gif +0 -0
  400. data/vendor/rails/railties/guides/images/rails_logo_remix.gif +0 -0
  401. data/vendor/rails/railties/guides/images/rails_welcome.png +0 -0
  402. data/vendor/rails/railties/guides/images/session_fixation.png +0 -0
  403. data/vendor/rails/railties/guides/images/tab_grey.gif +0 -0
  404. data/vendor/rails/railties/guides/images/tab_info.gif +0 -0
  405. data/vendor/rails/railties/guides/images/tab_note.gif +0 -0
  406. data/vendor/rails/railties/guides/images/tab_red.gif +0 -0
  407. data/vendor/rails/railties/guides/images/tab_yellow.gif +0 -0
  408. data/vendor/rails/railties/guides/images/tab_yellow.png +0 -0
  409. data/vendor/rails/railties/guides/images/validation_error_messages.png +0 -0
  410. data/vendor/rails/railties/guides/rails_guides.rb +42 -0
  411. data/vendor/rails/railties/guides/rails_guides/generator.rb +138 -0
  412. data/vendor/rails/railties/guides/rails_guides/helpers.rb +34 -0
  413. data/vendor/rails/railties/guides/rails_guides/indexer.rb +55 -0
  414. data/vendor/rails/railties/guides/rails_guides/textile_extensions.rb +41 -0
  415. data/vendor/rails/railties/guides/source/2_2_release_notes.textile +422 -0
  416. data/vendor/rails/railties/guides/source/2_3_release_notes.textile +610 -0
  417. data/vendor/rails/railties/guides/source/action_controller_overview.textile +776 -0
  418. data/vendor/rails/railties/guides/source/action_mailer_basics.textile +424 -0
  419. data/vendor/rails/railties/guides/source/active_record_basics.textile +135 -0
  420. data/vendor/rails/railties/guides/source/active_record_querying.textile +969 -0
  421. data/vendor/rails/railties/guides/source/activerecord_validations_callbacks.textile +1086 -0
  422. data/vendor/rails/railties/guides/source/association_basics.textile +1781 -0
  423. data/vendor/rails/railties/guides/source/caching_with_rails.textile +524 -0
  424. data/vendor/rails/railties/guides/source/command_line.textile +589 -0
  425. data/vendor/rails/railties/guides/source/configuring.textile +234 -0
  426. data/vendor/rails/railties/guides/source/contribute.textile +71 -0
  427. data/vendor/rails/railties/guides/source/contributing_to_rails.textile +239 -0
  428. data/vendor/rails/railties/guides/source/credits.erb.textile +52 -0
  429. data/vendor/rails/railties/guides/source/debugging_rails_applications.textile +709 -0
  430. data/vendor/rails/railties/guides/source/form_helpers.textile +766 -0
  431. data/vendor/rails/railties/guides/source/getting_started.textile +1297 -0
  432. data/vendor/rails/railties/guides/source/i18n.textile +912 -0
  433. data/vendor/rails/railties/guides/source/index.erb.textile +124 -0
  434. data/vendor/rails/railties/guides/source/layout.html.erb +103 -0
  435. data/vendor/rails/railties/guides/source/layouts_and_rendering.textile +979 -0
  436. data/vendor/rails/railties/guides/source/migrations.textile +591 -0
  437. data/vendor/rails/railties/guides/source/nested_model_forms.textile +222 -0
  438. data/vendor/rails/railties/guides/source/performance_testing.textile +531 -0
  439. data/vendor/rails/railties/guides/source/plugins.textile +1512 -0
  440. data/vendor/rails/railties/guides/source/rails_on_rack.textile +309 -0
  441. data/vendor/rails/railties/guides/source/routing.textile +903 -0
  442. data/vendor/rails/railties/guides/source/security.textile +986 -0
  443. data/vendor/rails/railties/guides/source/testing.textile +951 -0
  444. data/vendor/rails/railties/lib/commands/dbconsole.rb +8 -4
  445. data/vendor/rails/railties/lib/commands/performance/profiler.rb +1 -1
  446. data/vendor/rails/railties/lib/initializer.rb +27 -4
  447. data/vendor/rails/railties/lib/rails/gem_dependency.rb +35 -6
  448. data/vendor/rails/railties/lib/rails/plugin.rb +12 -0
  449. data/vendor/rails/railties/lib/rails/plugin/loader.rb +7 -0
  450. data/vendor/rails/railties/lib/rails/rack/metal.rb +1 -1
  451. data/vendor/rails/railties/lib/rails/version.rb +1 -1
  452. data/vendor/rails/railties/lib/rails_generator/base.rb +1 -1
  453. data/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +5 -0
  454. data/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb +1 -1
  455. data/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +9 -2
  456. data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -0
  457. data/vendor/rails/railties/lib/tasks/databases.rake +17 -4
  458. data/vendor/rails/railties/lib/tasks/gems.rake +19 -6
  459. data/vendor/rails/railties/lib/tasks/routes.rake +4 -3
  460. data/vendor/rails/railties/lib/test_help.rb +4 -1
  461. metadata +158 -58
  462. data/spec/lib/local_time_spec.rb +0 -40
  463. data/vendor/rails/actionpack/lib/action_controller/rewindable_input.rb +0 -28
  464. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack.rb +0 -89
  465. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +0 -22
  466. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +0 -37
  467. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +0 -37
  468. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +0 -58
  469. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +0 -124
  470. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +0 -51
  471. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +0 -55
  472. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +0 -40
  473. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +0 -480
  474. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/builder.rb +0 -63
  475. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +0 -36
  476. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +0 -49
  477. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +0 -61
  478. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +0 -45
  479. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +0 -29
  480. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +0 -23
  481. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +0 -85
  482. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/directory.rb +0 -153
  483. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/file.rb +0 -88
  484. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler.rb +0 -48
  485. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +0 -61
  486. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +0 -8
  487. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +0 -89
  488. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +0 -55
  489. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +0 -84
  490. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +0 -59
  491. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +0 -8
  492. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +0 -18
  493. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +0 -67
  494. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/head.rb +0 -19
  495. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb +0 -462
  496. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +0 -65
  497. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lock.rb +0 -16
  498. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +0 -27
  499. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mime.rb +0 -204
  500. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb +0 -160
  501. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +0 -57
  502. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +0 -64
  503. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb +0 -241
  504. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/response.rb +0 -179
  505. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +0 -142
  506. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +0 -91
  507. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +0 -109
  508. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +0 -100
  509. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +0 -349
  510. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +0 -106
  511. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb +0 -38
  512. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +0 -55
  513. data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb +0 -392
@@ -4,10 +4,12 @@ module ActiveRecord
4
4
  base.extend(ClassMethods)
5
5
  end
6
6
 
7
- # When processing large numbers of records, it's often a good idea to do so in batches to prevent memory ballooning.
7
+ # When processing large numbers of records, it's often a good idea to do
8
+ # so in batches to prevent memory ballooning.
8
9
  module ClassMethods
9
- # Yields each record that was found by the find +options+. The find is performed by find_in_batches
10
- # with a batch size of 1000 (or as specified by the +batch_size+ option).
10
+ # Yields each record that was found by the find +options+. The find is
11
+ # performed by find_in_batches with a batch size of 1000 (or as
12
+ # specified by the <tt>:batch_size</tt> option).
11
13
  #
12
14
  # Example:
13
15
  #
@@ -15,9 +17,10 @@ module ActiveRecord
15
17
  # person.party_all_night!
16
18
  # end
17
19
  #
18
- # Note: This method is only intended to use for batch processing of large amounts of records that wouldn't fit in
19
- # memory all at once. If you just need to loop over less than 1000 records, it's probably better just to use the
20
- # regular find methods.
20
+ # Note: This method is only intended to use for batch processing of
21
+ # large amounts of records that wouldn't fit in memory all at once. If
22
+ # you just need to loop over less than 1000 records, it's probably
23
+ # better just to use the regular find methods.
21
24
  def find_each(options = {})
22
25
  find_in_batches(options) do |records|
23
26
  records.each { |record| yield record }
@@ -26,17 +29,22 @@ module ActiveRecord
26
29
  self
27
30
  end
28
31
 
29
- # Yields each batch of records that was found by the find +options+ as an array. The size of each batch is
30
- # set by the +batch_size+ option; the default is 1000.
32
+ # Yields each batch of records that was found by the find +options+ as
33
+ # an array. The size of each batch is set by the <tt>:batch_size</tt>
34
+ # option; the default is 1000.
31
35
  #
32
- # You can control the starting point for the batch processing by supplying the +start+ option. This is especially
33
- # useful if you want multiple workers dealing with the same processing queue. You can make worker 1 handle all the
34
- # records between id 0 and 10,000 and worker 2 handle from 10,000 and beyond (by setting the +start+ option on that
35
- # worker).
36
+ # You can control the starting point for the batch processing by
37
+ # supplying the <tt>:start</tt> option. This is especially useful if you
38
+ # want multiple workers dealing with the same processing queue. You can
39
+ # make worker 1 handle all the records between id 0 and 10,000 and
40
+ # worker 2 handle from 10,000 and beyond (by setting the <tt>:start</tt>
41
+ # option on that worker).
36
42
  #
37
- # It's not possible to set the order. That is automatically set to ascending on the primary key ("id ASC")
38
- # to make the batch ordering work. This also mean that this method only works with integer-based primary keys.
39
- # You can't set the limit either, that's used to control the the batch sizes.
43
+ # It's not possible to set the order. That is automatically set to
44
+ # ascending on the primary key ("id ASC") to make the batch ordering
45
+ # work. This also mean that this method only works with integer-based
46
+ # primary keys. You can't set the limit either, that's used to control
47
+ # the the batch sizes.
40
48
  #
41
49
  # Example:
42
50
  #
@@ -141,30 +141,22 @@ module ActiveRecord
141
141
  def construct_count_options_from_args(*args)
142
142
  options = {}
143
143
  column_name = :all
144
-
144
+
145
145
  # We need to handle
146
146
  # count()
147
147
  # count(:column_name=:all)
148
148
  # count(options={})
149
149
  # count(column_name=:all, options={})
150
- # selects specified by scopes
151
150
  case args.size
152
- when 0
153
- column_name = scope(:find)[:select] if scope(:find)
154
151
  when 1
155
- if args[0].is_a?(Hash)
156
- column_name = scope(:find)[:select] if scope(:find)
157
- options = args[0]
158
- else
159
- column_name = args[0]
160
- end
152
+ args[0].is_a?(Hash) ? options = args[0] : column_name = args[0]
161
153
  when 2
162
154
  column_name, options = args
163
155
  else
164
156
  raise ArgumentError, "Unexpected parameters passed to count(): #{args.inspect}"
165
- end
166
-
167
- [column_name || :all, options]
157
+ end if args.size > 0
158
+
159
+ [column_name, options]
168
160
  end
169
161
 
170
162
  def construct_calculation_sql(operation, column_name, options) #:nodoc:
@@ -198,6 +190,8 @@ module ActiveRecord
198
190
  sql << ", #{options[:group_field]} AS #{options[:group_alias]}" if options[:group]
199
191
  if options[:from]
200
192
  sql << " FROM #{options[:from]} "
193
+ elsif scope && scope[:from] && !use_workaround
194
+ sql << " FROM #{scope[:from]} "
201
195
  else
202
196
  sql << " FROM (SELECT #{distinct}#{column_name}" if use_workaround
203
197
  sql << " FROM #{connection.quote_table_name(table_name)} "
@@ -277,7 +277,6 @@ module ActiveRecord
277
277
  add_column_options!(column_sql, column_options) unless type.to_sym == :primary_key
278
278
  column_sql
279
279
  end
280
- alias to_s :to_sql
281
280
 
282
281
  private
283
282
 
@@ -316,6 +315,20 @@ module ActiveRecord
316
315
  @base = base
317
316
  end
318
317
 
318
+ #Handles non supported datatypes - e.g. XML
319
+ def method_missing(symbol, *args)
320
+ if symbol.to_s == 'xml'
321
+ xml_column_fallback(args)
322
+ end
323
+ end
324
+
325
+ def xml_column_fallback(*args)
326
+ case @base.adapter_name.downcase
327
+ when 'sqlite', 'mysql'
328
+ options = args.extract_options!
329
+ column(args[0], :text, options)
330
+ end
331
+ end
319
332
  # Appends a primary key definition to the table definition.
320
333
  # Can be called multiple times, but this is probably not a good idea.
321
334
  def primary_key(name)
@@ -508,7 +521,7 @@ module ActiveRecord
508
521
  # concatenated together. This string can then be prepended and appended to
509
522
  # to generate the final SQL to create the table.
510
523
  def to_sql
511
- @columns * ', '
524
+ @columns.map(&:to_sql) * ', '
512
525
  end
513
526
 
514
527
  private
@@ -706,3 +719,4 @@ module ActiveRecord
706
719
 
707
720
  end
708
721
  end
722
+
@@ -99,7 +99,7 @@ module ActiveRecord
99
99
  # See also TableDefinition#column for details on how to create columns.
100
100
  def create_table(table_name, options = {})
101
101
  table_definition = TableDefinition.new(self)
102
- table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false
102
+ table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name.to_s.singularize)) unless options[:id] == false
103
103
 
104
104
  yield table_definition
105
105
 
@@ -321,7 +321,7 @@ module ActiveRecord
321
321
  schema_migrations_table.column :version, :string, :null => false
322
322
  end
323
323
  add_index sm_table, :version, :unique => true,
324
- :name => 'unique_schema_migrations'
324
+ :name => "#{Base.table_name_prefix}unique_schema_migrations#{Base.table_name_suffix}"
325
325
 
326
326
  # Backwards-compatibility: if we find schema_info, assume we've
327
327
  # migrated up to that point:
@@ -54,6 +54,13 @@ module ActiveRecord
54
54
  false
55
55
  end
56
56
 
57
+ # Can this adapter determine the primary key for tables not attached
58
+ # to an ActiveRecord class, such as join tables? Backend specific, as
59
+ # the abstract adapter always returns +false+.
60
+ def supports_primary_key?
61
+ false
62
+ end
63
+
57
64
  # Does this adapter support using DISTINCT within COUNT? This is +true+
58
65
  # for all adapters except sqlite.
59
66
  def supports_count_distinct?
@@ -52,12 +52,7 @@ module ActiveRecord
52
52
  socket = config[:socket]
53
53
  username = config[:username] ? config[:username].to_s : 'root'
54
54
  password = config[:password].to_s
55
-
56
- if config.has_key?(:database)
57
- database = config[:database]
58
- else
59
- raise ArgumentError, "No database specified. Missing argument: database."
60
- end
55
+ database = config[:database]
61
56
 
62
57
  # Require the MySQL driver and define Mysql::Result.all_hashes
63
58
  unless defined? Mysql
@@ -80,7 +75,7 @@ module ActiveRecord
80
75
  module ConnectionAdapters
81
76
  class MysqlColumn < Column #:nodoc:
82
77
  def extract_default(default)
83
- if type == :binary || type == :text
78
+ if sql_type =~ /blob/i || type == :text
84
79
  if default.blank?
85
80
  return null ? nil : ''
86
81
  else
@@ -94,7 +89,7 @@ module ActiveRecord
94
89
  end
95
90
 
96
91
  def has_default?
97
- return false if type == :binary || type == :text #mysql forbids defaults on blob and text columns
92
+ return false if sql_type =~ /blob/i || type == :text #mysql forbids defaults on blob and text columns
98
93
  super
99
94
  end
100
95
 
@@ -212,6 +207,10 @@ module ActiveRecord
212
207
  true
213
208
  end
214
209
 
210
+ def supports_primary_key? #:nodoc:
211
+ true
212
+ end
213
+
215
214
  def supports_savepoints? #:nodoc:
216
215
  true
217
216
  end
@@ -554,6 +553,12 @@ module ActiveRecord
554
553
  keys.length == 1 ? [keys.first, nil] : nil
555
554
  end
556
555
 
556
+ # Returns just a table's primary key
557
+ def primary_key(table)
558
+ pk_and_sequence = pk_and_sequence_for(table)
559
+ pk_and_sequence && pk_and_sequence.first
560
+ end
561
+
557
562
  def case_sensitive_equality_operator
558
563
  "= BINARY"
559
564
  end
@@ -573,6 +578,10 @@ module ActiveRecord
573
578
  @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher])
574
579
  end
575
580
 
581
+ @connection.options(Mysql::OPT_CONNECT_TIMEOUT, @config[:connect_timeout]) if @config[:connect_timeout]
582
+ @connection.options(Mysql::OPT_READ_TIMEOUT, @config[:read_timeout]) if @config[:read_timeout]
583
+ @connection.options(Mysql::OPT_WRITE_TIMEOUT, @config[:write_timeout]) if @config[:write_timeout]
584
+
576
585
  @connection.real_connect(*@connection_options)
577
586
 
578
587
  # reconnect must be set after real_connect is called, because real_connect sets it to false internally
@@ -39,6 +39,12 @@ module ActiveRecord
39
39
  end
40
40
 
41
41
  module ConnectionAdapters
42
+ class TableDefinition
43
+ def xml(*args)
44
+ options = args.extract_options!
45
+ column(args[0], 'xml', options)
46
+ end
47
+ end
42
48
  # PostgreSQL-specific extensions to column definitions in a table.
43
49
  class PostgreSQLColumn < Column #:nodoc:
44
50
  # Instantiates a new PostgreSQL column definition in a table.
@@ -67,7 +73,7 @@ module ActiveRecord
67
73
  # depending on the server specifics
68
74
  super
69
75
  end
70
-
76
+
71
77
  # Maps PostgreSQL-specific data types to logical Rails types.
72
78
  def simplified_type(field_type)
73
79
  case field_type
@@ -99,10 +105,10 @@ module ActiveRecord
99
105
  :string
100
106
  # XML type
101
107
  when /^xml$/
102
- :string
108
+ :xml
103
109
  # Arrays
104
110
  when /^\D+\[\]$/
105
- :string
111
+ :string
106
112
  # Object identifier types
107
113
  when /^oid$/
108
114
  :integer
@@ -111,7 +117,7 @@ module ActiveRecord
111
117
  super
112
118
  end
113
119
  end
114
-
120
+
115
121
  # Extracts the value from a PostgreSQL column default definition.
116
122
  def self.extract_value_from_default(default)
117
123
  case default
@@ -194,7 +200,8 @@ module ActiveRecord
194
200
  :time => { :name => "time" },
195
201
  :date => { :name => "date" },
196
202
  :binary => { :name => "bytea" },
197
- :boolean => { :name => "boolean" }
203
+ :boolean => { :name => "boolean" },
204
+ :xml => { :name => "xml" }
198
205
  }
199
206
 
200
207
  # Returns 'PostgreSQL' as adapter name for identification purposes.
@@ -249,6 +256,11 @@ module ActiveRecord
249
256
  true
250
257
  end
251
258
 
259
+ # Does PostgreSQL support finding primary key on non-ActiveRecord tables?
260
+ def supports_primary_key? #:nodoc:
261
+ true
262
+ end
263
+
252
264
  # Does PostgreSQL support standard conforming strings?
253
265
  def supports_standard_conforming_strings?
254
266
  # Temporarily set the client message level above error to prevent unintentional
@@ -272,7 +284,7 @@ module ActiveRecord
272
284
  def supports_ddl_transactions?
273
285
  true
274
286
  end
275
-
287
+
276
288
  def supports_savepoints?
277
289
  true
278
290
  end
@@ -287,7 +299,13 @@ module ActiveRecord
287
299
 
288
300
  # Escapes binary strings for bytea input to the database.
289
301
  def escape_bytea(value)
290
- if PGconn.respond_to?(:escape_bytea)
302
+ if @connection.respond_to?(:escape_bytea)
303
+ self.class.instance_eval do
304
+ define_method(:escape_bytea) do |value|
305
+ @connection.escape_bytea(value) if value
306
+ end
307
+ end
308
+ elsif PGconn.respond_to?(:escape_bytea)
291
309
  self.class.instance_eval do
292
310
  define_method(:escape_bytea) do |value|
293
311
  PGconn.escape_bytea(value) if value
@@ -358,7 +376,7 @@ module ActiveRecord
358
376
  if value.kind_of?(String) && column && column.type == :binary
359
377
  "#{quoted_string_prefix}'#{escape_bytea(value)}'"
360
378
  elsif value.kind_of?(String) && column && column.sql_type =~ /^xml$/
361
- "xml '#{quote_string(value)}'"
379
+ "xml E'#{quote_string(value)}'"
362
380
  elsif value.kind_of?(Numeric) && column && column.sql_type =~ /^money$/
363
381
  # Not truly string input, so doesn't require (or allow) escape string syntax.
364
382
  "'#{value.to_s}'"
@@ -376,7 +394,13 @@ module ActiveRecord
376
394
 
377
395
  # Quotes strings for use in SQL input in the postgres driver for better performance.
378
396
  def quote_string(s) #:nodoc:
379
- if PGconn.respond_to?(:escape)
397
+ if @connection.respond_to?(:escape)
398
+ self.class.instance_eval do
399
+ define_method(:quote_string) do |s|
400
+ @connection.escape(s)
401
+ end
402
+ end
403
+ elsif PGconn.respond_to?(:escape)
380
404
  self.class.instance_eval do
381
405
  define_method(:quote_string) do |s|
382
406
  PGconn.escape(s)
@@ -392,9 +416,28 @@ module ActiveRecord
392
416
  quote_string(s)
393
417
  end
394
418
 
419
+ # Checks the following cases:
420
+ #
421
+ # - table_name
422
+ # - "table.name"
423
+ # - schema_name.table_name
424
+ # - schema_name."table.name"
425
+ # - "schema.name".table_name
426
+ # - "schema.name"."table.name"
427
+ def quote_table_name(name)
428
+ schema, name_part = extract_pg_identifier_from_name(name.to_s)
429
+
430
+ unless name_part
431
+ quote_column_name(schema)
432
+ else
433
+ table_name, name_part = extract_pg_identifier_from_name(name_part)
434
+ "#{quote_column_name(schema)}.#{quote_column_name(table_name)}"
435
+ end
436
+ end
437
+
395
438
  # Quotes column names for use in SQL queries.
396
439
  def quote_column_name(name) #:nodoc:
397
- %("#{name}")
440
+ PGconn.quote_ident(name.to_s)
398
441
  end
399
442
 
400
443
  # Quote date/time values for use in SQL input. Includes microseconds
@@ -532,7 +575,7 @@ module ActiveRecord
532
575
  def rollback_db_transaction
533
576
  execute "ROLLBACK"
534
577
  end
535
-
578
+
536
579
  if defined?(PGconn::PQTRANS_IDLE)
537
580
  # The ruby-pg driver supports inspecting the transaction status,
538
581
  # while the ruby-postgres driver does not.
@@ -621,33 +664,36 @@ module ActiveRecord
621
664
  def indexes(table_name, name = nil)
622
665
  schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
623
666
  result = query(<<-SQL, name)
624
- SELECT distinct i.relname, d.indisunique, a.attname
625
- FROM pg_class t, pg_class i, pg_index d, pg_attribute a
667
+ SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
668
+ FROM pg_class t, pg_class i, pg_index d
626
669
  WHERE i.relkind = 'i'
627
670
  AND d.indexrelid = i.oid
628
671
  AND d.indisprimary = 'f'
629
672
  AND t.oid = d.indrelid
630
673
  AND t.relname = '#{table_name}'
631
674
  AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (#{schemas}) )
632
- AND a.attrelid = t.oid
633
- AND ( d.indkey[0]=a.attnum OR d.indkey[1]=a.attnum
634
- OR d.indkey[2]=a.attnum OR d.indkey[3]=a.attnum
635
- OR d.indkey[4]=a.attnum OR d.indkey[5]=a.attnum
636
- OR d.indkey[6]=a.attnum OR d.indkey[7]=a.attnum
637
- OR d.indkey[8]=a.attnum OR d.indkey[9]=a.attnum )
638
675
  ORDER BY i.relname
639
676
  SQL
640
677
 
641
- current_index = nil
678
+
642
679
  indexes = []
643
680
 
644
- result.each do |row|
645
- if current_index != row[0]
646
- indexes << IndexDefinition.new(table_name, row[0], row[1] == "t", [])
647
- current_index = row[0]
648
- end
681
+ indexes = result.map do |row|
682
+ index_name = row[0]
683
+ unique = row[1] == 't'
684
+ indkey = row[2].split(" ")
685
+ oid = row[3]
686
+
687
+ columns = query(<<-SQL, "Columns for index #{row[0]} on #{table_name}").inject({}) {|attlist, r| attlist[r[1]] = r[0]; attlist}
688
+ SELECT a.attname, a.attnum
689
+ FROM pg_attribute a
690
+ WHERE a.attrelid = #{oid}
691
+ AND a.attnum IN (#{indkey.join(",")})
692
+ SQL
693
+
694
+ column_names = indkey.map {|attnum| columns[attnum] }
695
+ IndexDefinition.new(table_name, index_name, unique, column_names)
649
696
 
650
- indexes.last.columns << row[2]
651
697
  end
652
698
 
653
699
  indexes
@@ -745,7 +791,7 @@ module ActiveRecord
745
791
  AND attr.attrelid = cons.conrelid
746
792
  AND attr.attnum = cons.conkey[1]
747
793
  AND cons.contype = 'p'
748
- AND dep.refobjid = '#{table}'::regclass
794
+ AND dep.refobjid = '#{quote_table_name(table)}'::regclass
749
795
  end_sql
750
796
 
751
797
  if result.nil? or result.empty?
@@ -764,7 +810,7 @@ module ActiveRecord
764
810
  JOIN pg_attribute attr ON (t.oid = attrelid)
765
811
  JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)
766
812
  JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
767
- WHERE t.oid = '#{table}'::regclass
813
+ WHERE t.oid = '#{quote_table_name(table)}'::regclass
768
814
  AND cons.contype = 'p'
769
815
  AND def.adsrc ~* 'nextval'
770
816
  end_sql
@@ -776,6 +822,12 @@ module ActiveRecord
776
822
  nil
777
823
  end
778
824
 
825
+ # Returns just a table's primary key
826
+ def primary_key(table)
827
+ pk_and_sequence = pk_and_sequence_for(table)
828
+ pk_and_sequence && pk_and_sequence.first
829
+ end
830
+
779
831
  # Renames a table.
780
832
  def rename_table(name, new_name)
781
833
  execute "ALTER TABLE #{quote_table_name(name)} RENAME TO #{quote_table_name(new_name)}"
@@ -839,7 +891,7 @@ module ActiveRecord
839
891
 
840
892
  # Drops an index from a table.
841
893
  def remove_index(table_name, options = {})
842
- execute "DROP INDEX #{index_name(table_name, options)}"
894
+ execute "DROP INDEX #{quote_table_name(index_name(table_name, options))}"
843
895
  end
844
896
 
845
897
  # Maps logical Rails types to PostgreSQL-specific data types.
@@ -874,18 +926,18 @@ module ActiveRecord
874
926
  sql = "DISTINCT ON (#{columns}) #{columns}, "
875
927
  sql << order_columns * ', '
876
928
  end
877
-
929
+
878
930
  # Returns an ORDER BY clause for the passed order option.
879
- #
931
+ #
880
932
  # PostgreSQL does not allow arbitrary ordering when using DISTINCT ON, so we work around this
881
933
  # by wrapping the +sql+ string as a sub-select and ordering in that query.
882
934
  def add_order_by_for_association_limiting!(sql, options) #:nodoc:
883
935
  return sql if options[:order].blank?
884
-
936
+
885
937
  order = options[:order].split(',').collect { |s| s.strip }.reject(&:blank?)
886
938
  order.map! { |s| 'DESC' if s =~ /\bdesc$/i }
887
939
  order = order.zip((0...order.size).to_a).map { |s,i| "id_list.alias_#{i} #{s}" }.join(', ')
888
-
940
+
889
941
  sql.replace "SELECT * FROM (#{sql}) AS id_list ORDER BY #{order}"
890
942
  end
891
943
 
@@ -998,7 +1050,7 @@ module ActiveRecord
998
1050
  if res.ftype(cell_index) == MONEY_COLUMN_TYPE_OID
999
1051
  # Because money output is formatted according to the locale, there are two
1000
1052
  # cases to consider (note the decimal separators):
1001
- # (1) $12,345,678.12
1053
+ # (1) $12,345,678.12
1002
1054
  # (2) $12.345.678,12
1003
1055
  case column = row[cell_index]
1004
1056
  when /^-?\D+[\d,]+\.\d{2}$/ # (1)
@@ -1040,11 +1092,22 @@ module ActiveRecord
1040
1092
  SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
1041
1093
  FROM pg_attribute a LEFT JOIN pg_attrdef d
1042
1094
  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
1043
- WHERE a.attrelid = '#{table_name}'::regclass
1095
+ WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass
1044
1096
  AND a.attnum > 0 AND NOT a.attisdropped
1045
1097
  ORDER BY a.attnum
1046
1098
  end_sql
1047
1099
  end
1100
+
1101
+ def extract_pg_identifier_from_name(name)
1102
+ match_data = name[0,1] == '"' ? name.match(/\"([^\"]+)\"/) : name.match(/([^\.]+)/)
1103
+
1104
+ if match_data
1105
+ rest = name[match_data[0].length..-1]
1106
+ rest = rest[1..-1] if rest[0,1] == "."
1107
+ [match_data[1], (rest.length > 0 ? rest : nil)]
1108
+ end
1109
+ end
1048
1110
  end
1049
1111
  end
1050
1112
  end
1113
+