Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/rails/rails

  • Loading branch information...
commit 667d21814b67c615d3317488d0678cb992d3bdb1 2 parents f690367 + 2bf33bd
@icco icco authored
Showing with 5,496 additions and 2,844 deletions.
  1. +1 −0  .gitignore
  2. +13 −5 Gemfile
  3. +5 −4 README.rdoc
  4. +8 −1 Rakefile
  5. +1 −1  actionmailer/CHANGELOG
  6. +45 −1 actionpack/CHANGELOG
  7. +4 −4 actionpack/actionpack.gemspec
  8. +1 −1  actionpack/lib/action_controller/caching/sweeping.rb
  9. +6 −3 actionpack/lib/action_controller/metal/helpers.rb
  10. +1 −1  actionpack/lib/action_controller/metal/http_authentication.rb
  11. +8 −8 actionpack/lib/action_controller/metal/params_wrapper.rb
  12. +1 −1  actionpack/lib/action_controller/metal/redirecting.rb
  13. +1 −1  actionpack/lib/action_controller/metal/request_forgery_protection.rb
  14. +1 −1  actionpack/lib/action_controller/metal/url_for.rb
  15. +1 −1  actionpack/lib/action_controller/record_identifier.rb
  16. +7 −9 actionpack/lib/action_controller/test_case.rb
  17. +3 −14 actionpack/lib/action_dispatch/http/upload.rb
  18. +1 −1  actionpack/lib/action_dispatch/http/url.rb
  19. +5 −0 actionpack/lib/action_dispatch/middleware/cookies.rb
  20. +4 −1 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  21. +0 −1  actionpack/lib/action_dispatch/railtie.rb
  22. +16 −14 actionpack/lib/action_dispatch/routing/mapper.rb
  23. +0 −60 actionpack/lib/action_dispatch/routing/route.rb
  24. +71 −33 actionpack/lib/action_dispatch/routing/route_set.rb
  25. +8 −4 actionpack/lib/action_dispatch/routing/url_for.rb
  26. +2 −2 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  27. +12 −10 actionpack/lib/action_view/asset_paths.rb
  28. +1 −1  actionpack/lib/action_view/base.rb
  29. +2 −2 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb
  30. +1 −1  actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
  31. +1 −1  actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
  32. +2 −2 actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
  33. +3 −3 actionpack/lib/action_view/helpers/capture_helper.rb
  34. +7 −4 actionpack/lib/action_view/helpers/form_tag_helper.rb
  35. +12 −3 actionpack/lib/action_view/helpers/javascript_helper.rb
  36. +51 −5 actionpack/lib/action_view/helpers/record_tag_helper.rb
  37. +11 −3 actionpack/lib/action_view/helpers/url_helper.rb
  38. +111 −100 actionpack/lib/action_view/lookup_context.rb
  39. +13 −5 actionpack/lib/sprockets/assets.rake
  40. +23 −7 actionpack/lib/sprockets/compressors.rb
  41. +47 −39 actionpack/lib/sprockets/helpers/rails_helper.rb
  42. +16 −3 actionpack/lib/sprockets/railtie.rb
  43. +53 −0 actionpack/lib/sprockets/static_compiler.rb
  44. +19 −0 actionpack/test/controller/assert_select_test.rb
  45. +8 −0 actionpack/test/controller/http_basic_authentication_test.rb
  46. +1 −1  actionpack/test/controller/render_test.rb
  47. +16 −0 actionpack/test/controller/request_forgery_protection_test.rb
  48. +1 −10 actionpack/test/controller/resources_test.rb
  49. +23 −0 actionpack/test/controller/test_test.rb
  50. +16 −0 actionpack/test/dispatch/cookies_test.rb
  51. +1 −0  actionpack/test/dispatch/mapper_test.rb
  52. 0  actionpack/test/fixtures/test/{hello_w*rld.erb → hello,world.erb}
  53. +2 −9 actionpack/test/lib/controller/fake_models.rb
  54. +36 −0 actionpack/test/template/capture_helper_test.rb
  55. +1 −2  actionpack/test/template/form_helper_test.rb
  56. +6 −0 actionpack/test/template/form_tag_helper_test.rb
  57. +6 −0 actionpack/test/template/javascript_helper_test.rb
  58. +39 −2 actionpack/test/template/record_tag_helper_test.rb
  59. +47 −29 actionpack/test/template/sprockets_helper_test.rb
  60. +8 −2 actionpack/test/template/url_helper_test.rb
  61. +3 −1 activemodel/CHANGELOG
  62. +0 −1  activemodel/activemodel.gemspec
  63. +52 −42 activemodel/lib/active_model/attribute_methods.rb
  64. +1 −1  activemodel/lib/active_model/dirty.rb
  65. +25 −15 activemodel/lib/active_model/errors.rb
  66. +9 −2 activemodel/lib/active_model/secure_password.rb
  67. +2 −0  activemodel/lib/active_model/serialization.rb
  68. +15 −31 activemodel/lib/active_model/serializers/xml.rb
  69. +2 −0  activemodel/lib/active_model/validations/acceptance.rb
  70. +2 −0  activemodel/lib/active_model/validations/confirmation.rb
  71. +2 −0  activemodel/lib/active_model/validations/exclusion.rb
  72. +2 −0  activemodel/lib/active_model/validations/format.rb
  73. +2 −0  activemodel/lib/active_model/validations/inclusion.rb
  74. +2 −0  activemodel/lib/active_model/validations/length.rb
  75. +2 −0  activemodel/lib/active_model/validations/numericality.rb
  76. +2 −0  activemodel/lib/active_model/validations/presence.rb
  77. +15 −3 activemodel/lib/active_model/validations/validates.rb
  78. +4 −2 activemodel/lib/active_model/validations/with.rb
  79. +102 −6 activemodel/test/cases/attribute_methods_test.rb
  80. +35 −2 activemodel/test/cases/errors_test.rb
  81. +14 −1 activemodel/test/cases/serialization_test.rb
  82. +17 −0 activemodel/test/cases/serializers/xml_serialization_test.rb
  83. +33 −0 activemodel/test/cases/validations_test.rb
  84. +16 −2 activerecord/CHANGELOG
  85. +0 −7 activerecord/lib/active_record.rb
  86. +1 −1  activerecord/lib/active_record/associations.rb
  87. +12 −6 activerecord/lib/active_record/associations/alias_tracker.rb
  88. +4 −0 activerecord/lib/active_record/associations/belongs_to_association.rb
  89. +1 −1  activerecord/lib/active_record/associations/through_association.rb
  90. +56 −28 activerecord/lib/active_record/attribute_methods.rb
  91. +0 −2  activerecord/lib/active_record/attribute_methods/read.rb
  92. +11 −3 activerecord/lib/active_record/attribute_methods/write.rb
  93. +4 −1 activerecord/lib/active_record/autosave_association.rb
  94. +5 −10 activerecord/lib/active_record/base.rb
  95. +1 −1  activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  96. +1 −1  activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
  97. +7 −4 activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
  98. +1 −0  activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  99. +611 −0 activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
  100. +54 −538 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
  101. +110 −601 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  102. +54 −12 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  103. +57 −8 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  104. +40 −0 activerecord/lib/active_record/connection_adapters/statement_pool.rb
  105. +361 −368 activerecord/lib/active_record/fixtures.rb
  106. +11 −1 activerecord/lib/active_record/fixtures/file.rb
  107. +1 −1  activerecord/lib/active_record/migration/command_recorder.rb
  108. +1 −1  activerecord/lib/active_record/persistence.rb
  109. +6 −0 activerecord/lib/active_record/query_cache.rb
  110. +8 −6 activerecord/lib/active_record/railties/databases.rake
  111. +1 −1  activerecord/lib/active_record/reflection.rb
  112. +42 −0 activerecord/lib/active_record/relation.rb
  113. +1 −1  activerecord/lib/active_record/relation/batches.rb
  114. +9 −3 activerecord/lib/active_record/relation/finder_methods.rb
  115. +67 −7 activerecord/lib/active_record/relation/query_methods.rb
  116. +1 −1  activerecord/lib/active_record/serializers/xml_serializer.rb
  117. +15 −2 activerecord/lib/active_record/timestamp.rb
  118. +4 −4 activerecord/test/cases/adapters/mysql/active_schema_test.rb
  119. +23 −0 activerecord/test/cases/adapters/mysql/statement_pool_test.rb
  120. +6 −15 activerecord/test/cases/adapters/postgresql/schema_test.rb
  121. +23 −0 activerecord/test/cases/adapters/postgresql/statement_pool_test.rb
  122. +18 −0 activerecord/test/cases/adapters/postgresql/utils_test.rb
  123. +16 −0 activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
  124. +24 −0 activerecord/test/cases/adapters/sqlite3/statement_pool_test.rb
  125. +6 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  126. +10 −0 activerecord/test/cases/associations/extension_test.rb
  127. +10 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  128. +4 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  129. +11 −0 activerecord/test/cases/associations/nested_through_associations_test.rb
  130. +1 −0  activerecord/test/cases/attribute_methods/read_test.rb
  131. +34 −27 activerecord/test/cases/attribute_methods_test.rb
  132. +51 −1 activerecord/test/cases/base_test.rb
  133. +20 −0 activerecord/test/cases/batches_test.rb
  134. +16 −16 activerecord/test/cases/column_definition_test.rb
  135. +20 −1 activerecord/test/cases/connection_adapters/connection_handler_test.rb
  136. +35 −0 activerecord/test/cases/finder_test.rb
  137. +16 −0 activerecord/test/cases/fixtures_test.rb
  138. +2 −2 activerecord/test/cases/migration/command_recorder_test.rb
  139. +1 −1  activerecord/test/cases/named_scope_test.rb
  140. +11 −6 activerecord/test/cases/persistence_test.rb
  141. +32 −3 activerecord/test/cases/query_cache_test.rb
  142. +123 −1 activerecord/test/cases/relations_test.rb
  143. +7 −6 activerecord/test/cases/serialization_test.rb
  144. +2 −0  activerecord/test/cases/session_store/session_test.rb
  145. +1 −1  activerecord/test/fixtures/tasks.yml
  146. +1 −1  activerecord/test/models/car.rb
  147. +7 −6 activerecord/test/models/contact.rb
  148. +10 −0 activerecord/test/models/post.rb
  149. +5 −4 activerecord/test/models/topic.rb
  150. +2 −0  activerecord/test/models/toy.rb
  151. +7 −1 activerecord/test/schema/schema.rb
  152. +1 −1  activeresource/CHANGELOG
  153. +10 −2 activeresource/lib/active_resource/base.rb
  154. +19 −0 activeresource/test/cases/base/load_test.rb
  155. +27 −3 activeresource/test/cases/base_test.rb
  156. +15 −3 activesupport/CHANGELOG
  157. +5 −2 activesupport/lib/active_support/core_ext/big_decimal/conversions.rb
  158. +2 −2 activesupport/lib/active_support/core_ext/enumerable.rb
  159. +1 −1  activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
  160. +2 −6 activesupport/lib/active_support/core_ext/module/delegation.rb
  161. +0 −1  activesupport/lib/active_support/core_ext/object.rb
  162. +0 −25 activesupport/lib/active_support/core_ext/object/public_send.rb
  163. +1 −1  activesupport/lib/active_support/core_ext/object/to_query.rb
  164. +4 −4 activesupport/lib/active_support/core_ext/string/output_safety.rb
  165. +22 −0 activesupport/lib/active_support/core_ext/time/conversions.rb
  166. +8 −3 activesupport/lib/active_support/dependencies.rb
  167. +1 −1  activesupport/lib/active_support/hash_with_indifferent_access.rb
  168. +2 −1  activesupport/lib/active_support/i18n_railtie.rb
  169. +2 −2 activesupport/lib/active_support/log_subscriber/test_helper.rb
  170. +10 −4 activesupport/lib/active_support/message_encryptor.rb
  171. +15 −4 activesupport/lib/active_support/message_verifier.rb
  172. +5 −0 activesupport/lib/active_support/ordered_hash.rb
  173. +0 −1  activesupport/lib/active_support/railtie.rb
  174. +1 −1  activesupport/lib/active_support/time_with_zone.rb
  175. +1 −1  activesupport/lib/active_support/values/time_zone.rb
  176. +2 −2 activesupport/test/core_ext/array_ext_test.rb
  177. +8 −8 activesupport/test/core_ext/hash_ext_test.rb
  178. +7 −23 activesupport/test/core_ext/module_test.rb
  179. +0 −117 activesupport/test/core_ext/object/public_send_test.rb
  180. +9 −0 activesupport/test/core_ext/object/to_query_test.rb
  181. +18 −0 activesupport/test/dependencies_test.rb
  182. +25 −2 activesupport/test/message_encryptor_test.rb
  183. +25 −1 activesupport/test/message_verifier_test.rb
  184. +5 −0 activesupport/test/ordered_hash_test.rb
  185. +0 −7 bin/rails
  186. +1 −1  rails.gemspec
  187. +18 −1 railties/CHANGELOG
  188. +4 −4 railties/README.rdoc
  189. +7 −2 railties/Rakefile
  190. +6 −1 railties/bin/rails
  191. BIN  railties/guides/assets/images/i18n/demo_html_safe.png
  192. +32 −0 railties/guides/code/getting_started/Gemfile
  193. +261 −0 railties/guides/code/getting_started/README
  194. +7 −0 railties/guides/code/getting_started/Rakefile
  195. BIN  railties/guides/code/getting_started/app/assets/images/rails.png
  196. +9 −0 railties/guides/code/getting_started/app/assets/javascripts/application.js
  197. +3 −0  railties/guides/code/getting_started/app/assets/javascripts/comments.js.coffee
  198. +3 −0  railties/guides/code/getting_started/app/assets/javascripts/home.js.coffee
  199. +3 −0  railties/guides/code/getting_started/app/assets/javascripts/posts.js.coffee
  200. +7 −0 railties/guides/code/getting_started/app/assets/stylesheets/application.css
  201. +3 −0  railties/guides/code/getting_started/app/assets/stylesheets/comments.css.scss
  202. +3 −0  railties/guides/code/getting_started/app/assets/stylesheets/home.css.scss
  203. +3 −0  railties/guides/code/getting_started/app/assets/stylesheets/posts.css.scss
  204. +56 −0 railties/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss
  205. +3 −0  railties/guides/code/getting_started/app/controllers/application_controller.rb
  206. +16 −0 railties/guides/code/getting_started/app/controllers/comments_controller.rb
  207. +5 −0 railties/guides/code/getting_started/app/controllers/home_controller.rb
  208. +84 −0 railties/guides/code/getting_started/app/controllers/posts_controller.rb
  209. +2 −0  railties/guides/code/getting_started/app/helpers/application_helper.rb
  210. +2 −0  railties/guides/code/getting_started/app/helpers/comments_helper.rb
  211. +2 −0  railties/guides/code/getting_started/app/helpers/home_helper.rb
  212. +5 −0 railties/guides/code/getting_started/app/helpers/posts_helper.rb
  213. 0  railties/guides/code/getting_started/app/mailers/.gitkeep
  214. 0  railties/guides/code/getting_started/app/models/.gitkeep
  215. +3 −0  railties/guides/code/getting_started/app/models/comment.rb
  216. +11 −0 railties/guides/code/getting_started/app/models/post.rb
  217. +3 −0  railties/guides/code/getting_started/app/models/tag.rb
  218. +15 −0 railties/guides/code/getting_started/app/views/comments/_comment.html.erb
  219. +13 −0 railties/guides/code/getting_started/app/views/comments/_form.html.erb
  220. +2 −0  railties/guides/code/getting_started/app/views/home/index.html.erb
  221. +14 −0 railties/guides/code/getting_started/app/views/layouts/application.html.erb
  222. +32 −0 railties/guides/code/getting_started/app/views/posts/_form.html.erb
  223. +6 −0 railties/guides/code/getting_started/app/views/posts/edit.html.erb
  224. +27 −0 railties/guides/code/getting_started/app/views/posts/index.html.erb
  225. +5 −0 railties/guides/code/getting_started/app/views/posts/new.html.erb
  226. +31 −0 railties/guides/code/getting_started/app/views/posts/show.html.erb
  227. +12 −0 railties/guides/code/getting_started/app/views/tags/_form.html.erb
  228. +4 −0 railties/guides/code/getting_started/config.ru
  229. +48 −0 railties/guides/code/getting_started/config/application.rb
  230. +6 −0 railties/guides/code/getting_started/config/boot.rb
  231. +25 −0 railties/guides/code/getting_started/config/database.yml
  232. +5 −0 railties/guides/code/getting_started/config/environment.rb
  233. +30 −0 railties/guides/code/getting_started/config/environments/development.rb
  234. +60 −0 railties/guides/code/getting_started/config/environments/production.rb
  235. +42 −0 railties/guides/code/getting_started/config/environments/test.rb
  236. +7 −0 railties/guides/code/getting_started/config/initializers/backtrace_silencers.rb
  237. +10 −0 railties/guides/code/getting_started/config/initializers/inflections.rb
  238. +5 −0 railties/guides/code/getting_started/config/initializers/mime_types.rb
  239. +7 −0 railties/guides/code/getting_started/config/initializers/secret_token.rb
  240. +8 −0 railties/guides/code/getting_started/config/initializers/session_store.rb
  241. +14 −0 railties/guides/code/getting_started/config/initializers/wrap_parameters.rb
  242. +5 −0 railties/guides/code/getting_started/config/locales/en.yml
  243. +64 −0 railties/guides/code/getting_started/config/routes.rb
  244. +11 −0 railties/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb
  245. +12 −0 railties/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb
  246. +11 −0 railties/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb
  247. +43 −0 railties/guides/code/getting_started/db/schema.rb
  248. +7 −0 railties/guides/code/getting_started/db/seeds.rb
  249. +2 −0  railties/guides/code/getting_started/doc/README_FOR_APP
  250. 0  railties/guides/code/getting_started/lib/assets/.gitkeep
  251. 0  railties/guides/code/getting_started/lib/tasks/.gitkeep
  252. +26 −0 railties/guides/code/getting_started/public/404.html
  253. +26 −0 railties/guides/code/getting_started/public/422.html
  254. +26 −0 railties/guides/code/getting_started/public/500.html
  255. 0  railties/guides/code/getting_started/public/favicon.ico
  256. +5 −0 railties/guides/code/getting_started/public/robots.txt
  257. +6 −0 railties/guides/code/getting_started/script/rails
  258. 0  railties/guides/code/getting_started/test/fixtures/.gitkeep
  259. +11 −0 railties/guides/code/getting_started/test/fixtures/comments.yml
  260. +11 −0 railties/guides/code/getting_started/test/fixtures/posts.yml
  261. +9 −0 railties/guides/code/getting_started/test/fixtures/tags.yml
  262. 0  railties/guides/code/getting_started/test/functional/.gitkeep
  263. +7 −0 railties/guides/code/getting_started/test/functional/comments_controller_test.rb
  264. +9 −0 railties/guides/code/getting_started/test/functional/home_controller_test.rb
  265. +49 −0 railties/guides/code/getting_started/test/functional/posts_controller_test.rb
  266. 0  railties/guides/code/getting_started/test/integration/.gitkeep
  267. +12 −0 railties/guides/code/getting_started/test/performance/browsing_test.rb
  268. +13 −0 railties/guides/code/getting_started/test/test_helper.rb
  269. 0  railties/guides/code/getting_started/test/unit/.gitkeep
  270. +7 −0 railties/guides/code/getting_started/test/unit/comment_test.rb
  271. +4 −0 railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb
  272. +4 −0 railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb
  273. +4 −0 railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb
  274. +7 −0 railties/guides/code/getting_started/test/unit/post_test.rb
  275. +7 −0 railties/guides/code/getting_started/test/unit/tag_test.rb
  276. 0  railties/guides/code/getting_started/vendor/assets/stylesheets/.gitkeep
  277. 0  railties/guides/code/getting_started/vendor/plugins/.gitkeep
  278. +6 −4 railties/guides/source/3_1_release_notes.textile
  279. +3 −7 railties/guides/source/action_controller_overview.textile
  280. +4 −8 railties/guides/source/action_mailer_basics.textile
  281. +78 −8 railties/guides/source/action_view_overview.textile
  282. +7 −6 railties/guides/source/active_model_basics.textile
  283. +72 −18 railties/guides/source/active_record_querying.textile
  284. +2 −13 railties/guides/source/active_record_validations_callbacks.textile
  285. +0 −4 railties/guides/source/active_resource_basics.textile
  286. +10 −39 railties/guides/source/active_support_core_extensions.textile
  287. +3 −1 railties/guides/source/ajax_on_rails.textile
  288. +1 −5 railties/guides/source/api_documentation_guidelines.textile
  289. +295 −70 railties/guides/source/asset_pipeline.textile
  290. +4 −13 railties/guides/source/association_basics.textile
  291. +0 −11 railties/guides/source/caching_with_rails.textile
  292. +2 −0  railties/guides/source/command_line.textile
  293. +13 −9 railties/guides/source/configuring.textile
  294. +0 −70 railties/guides/source/contribute.textile
  295. +10 −18 railties/guides/source/contributing_to_ruby_on_rails.textile
  296. +0 −7 railties/guides/source/debugging_rails_applications.textile
  297. +0 −10 railties/guides/source/form_helpers.textile
  298. +9 −11 railties/guides/source/generators.textile
  299. +17 −35 railties/guides/source/getting_started.textile
  300. +37 −2 railties/guides/source/i18n.textile
Sorry, we could not display the entire diff because too many files (349) changed.
View
1  .gitignore
@@ -21,4 +21,5 @@ railties/doc
railties/guides/output
railties/tmp
.rvmrc
+.rbenv-version
RDOC_MAIN.rdoc
View
18 Gemfile
@@ -6,10 +6,18 @@ if ENV['AREL']
gem "arel", :path => ENV['AREL']
end
+gem "bcrypt-ruby", "~> 3.0.0"
gem "jquery-rails"
+
+if ENV['JOURNEY']
+ gem "journey", :path => ENV['JOURNEY']
+else
+ gem "journey", :git => "git://github.com/rails/journey"
+end
+
# This needs to be with require false to avoid
# it being automatically loaded by sprockets
-gem "uglifier", ">= 1.0.0", :require => false
+gem "uglifier", ">= 1.0.3", :require => false
# Temp fix until rake 0.9.3 is out
if RUBY_VERSION >= "1.9.3"
@@ -21,7 +29,7 @@ gem "mocha", ">= 0.9.8"
group :doc do
gem "rdoc", "~> 3.4"
- gem "horo", "= 1.0.3"
+ gem "sdoc", "~> 0.3"
gem "RedCloth", "~> 4.2" if RUBY_VERSION < "1.9.3"
gem "w3c_validators"
end
@@ -67,7 +75,7 @@ end
platforms :jruby do
gem "ruby-debug", ">= 0.10.3"
gem "json"
- gem "activerecord-jdbcsqlite3-adapter"
+ gem "activerecord-jdbcsqlite3-adapter", ">= 1.2.0"
# This is needed by now to let tests work on JRuby
# TODO: When the JRuby guys merge jruby-openssl in
@@ -75,8 +83,8 @@ platforms :jruby do
gem "jruby-openssl"
group :db do
- gem "activerecord-jdbcmysql-adapter"
- gem "activerecord-jdbcpostgresql-adapter"
+ gem "activerecord-jdbcmysql-adapter", ">= 1.2.0"
+ gem "activerecord-jdbcpostgresql-adapter", ">= 1.2.0"
end
end
View
9 README.rdoc
@@ -8,12 +8,12 @@ into three layers, each with a specific responsibility.
The View layer is composed of "templates" that are responsible for providing
appropriate representations of your application's resources. Templates
-can come in a variety of formats, but most view templates are HTML with embedded Ruby
+can come in a variety of formats, but most view templates are \HTML with embedded Ruby
code (.erb files).
The Model layer represents your domain model (such as Account, Product, Person, Post)
and encapsulates the business logic that is specific to your application. In Rails,
-database-backed model classes are derived from ActiveRecord::Base. ActiveRecord allows
+database-backed model classes are derived from ActiveRecord::Base. Active Record allows
you to present the data from database rows as objects and embellish these data objects
with business logic methods. Although most Rails models are backed by a database, models
can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as
@@ -21,7 +21,7 @@ provided by the ActiveModel module. You can read more about Active Record in its
{README}[link:/rails/rails/blob/master/activerecord/README.rdoc].
The Controller layer is responsible for handling incoming HTTP requests and providing a
-suitable response. Usually this means returning HTML, but Rails controllers can also
+suitable response. Usually this means returning \HTML, but Rails controllers can also
generate XML, JSON, PDFs, mobile-specific views, and more. Controllers manipulate models
and render view templates in order to generate the appropriate HTTP response.
@@ -61,13 +61,14 @@ can read more about Action Pack in its {README}[link:/rails/rails/blob/master/ac
* The {Ruby on Rails Guides}[http://guides.rubyonrails.org].
* The {API Documentation}[http://api.rubyonrails.org].
-
== Contributing
We encourage you to contribute to Ruby on Rails! Please check out the {Contributing to Rails
guide}[http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html] for guidelines about how
to proceed. {Join us}[http://contributors.rubyonrails.org]!
+== Travis Build Status {<img src="https://secure.travis-ci.org/rails/rails.png"/>}[http://travis-ci.org/rails/rails]
+
== License
Ruby on Rails is released under the MIT license.
View
9 Rakefile
@@ -1,6 +1,7 @@
#!/usr/bin/env rake
require 'rdoc/task'
+require 'sdoc'
require 'net/http'
$:.unshift File.expand_path('..', __FILE__)
@@ -76,6 +77,10 @@ RDoc::Task.new do |rdoc|
rdoc_main.gsub!(/^(?=\S).*?\b(?=Rails)\b/) { "#$&\\" }
rdoc_main.gsub!(%r{link:/rails/rails/blob/master/(\w+)/README\.rdoc}, "link:files/\\1/README_rdoc.html")
+ # Remove Travis build status image from API pages. Only GitHub README page gets this image
+ # https build image is used to avoid GitHub caching: http://about.travis-ci.org/docs/user/status-images
+ rdoc_main.gsub!(%r{^== Travis.*}, '')
+
File.open(RDOC_MAIN, 'w') do |f|
f.write(rdoc_main)
end
@@ -86,8 +91,10 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_dir = 'doc/rdoc'
rdoc.title = "Ruby on Rails Documentation"
- rdoc.options << '-f' << 'horo'
+ rdoc.options << '-f' << 'sdoc'
+ rdoc.options << '-T' << 'rails'
rdoc.options << '-c' << 'utf-8'
+ rdoc.options << '-g' # SDoc flag, link methods to GitHub
rdoc.options << '-m' << RDOC_MAIN
rdoc.rdoc_files.include('railties/CHANGELOG')
View
2  actionmailer/CHANGELOG
@@ -1,4 +1,4 @@
-*Rails 3.1.0 (unreleased)*
+*Rails 3.1.0 (August 30, 2011)*
* No changes
View
46 actionpack/CHANGELOG
@@ -1,5 +1,23 @@
*Rails 3.2.0 (unreleased)*
+* Changed log level of warning for missing CSRF token from :debug to :warn. [Mike Dillon]
+
+* content_tag_for and div_for can now take the collection of records. It will also yield the record as the first argument if you set a receiving argument in your block [Prem Sichanugrist]
+
+ So instead of having to do this:
+
+ @items.each do |item|
+ content_tag_for(:li, item) do
+ Title: <%= item.title %>
+ end
+ end
+
+ You can now do this:
+
+ content_tag_for(:li, @items) do |item|
+ Title: <%= item.title %>
+ end
+
* send_file now guess the mime type [Esad Hajdarevic]
* Mime type entries for PDF, ZIP and other formats were added [Esad Hajdarevic]
@@ -28,7 +46,33 @@
for your test you need to do it before the cookie jar is created.
-*Rails 3.1.0 (unreleased)*
+*Rails 3.1.1 (unreleased)*
+
+* Allow asset tag helper methods to accept :digest => false option in order to completely avoid the digest generation.
+Useful for linking assets from static html files or from emails when the user
+could probably look at an older html email with an older asset. [Santiago Pastorino]
+
+* Don't mount Sprockets server at config.assets.prefix if config.assets.compile is false. [Mark J. Titorenko]
+
+* Set relative url root in assets when controller isn't available for Sprockets (eg. Sass files using asset_path). Fixes #2435 [Guillermo Iguaran]
+
+* Fix basic auth credential generation to not make newlines. GH #2882
+
+* Fixed the behavior of asset pipeline when config.assets.digest and config.assets.compile are false and requested asset isn't precompiled.
+ Before the requested asset were compiled anyway ignoring that the config.assets.compile flag is false. [Guillermo Iguaran]
+
+* CookieJar is now Enumerable. Fixes #2795
+
+* Fixed AssetNotPrecompiled error raised when rake assets:precompile is compiling certain .erb files. See GH #2763 #2765 #2805 [Guillermo Iguaran]
+
+* Manifest is correctly placed in assets path when default assets prefix is changed. Fixes #2776 [Guillermo Iguaran]
+
+* Fixed stylesheet_link_tag and javascript_include_tag to respect additional options passed by the users when debug is on. [Guillermo Iguaran]
+
+
+*Rails 3.1.0 (August 30, 2011)*
+
+* Param values are `paramified` in controller tests. [David Chelimsky]
* x_sendfile_header now defaults to nil and config/environments/production.rb doesn't set a particular value for it. This allows servers to set it through X-Sendfile-Type. [Santiago Pastorino]
View
8 actionpack/actionpack.gemspec
@@ -18,13 +18,13 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', version)
s.add_dependency('activemodel', version)
- s.add_dependency('rack-cache', '~> 1.0.2')
+ s.add_dependency('rack-cache', '~> 1.0.3')
s.add_dependency('builder', '~> 3.0.0')
s.add_dependency('i18n', '~> 0.6')
s.add_dependency('rack', '~> 1.3.2')
- s.add_dependency('rack-test', '~> 0.6.0')
- s.add_dependency('rack-mount', '~> 0.8.1')
- s.add_dependency('sprockets', '~> 2.0.0.beta.14')
+ s.add_dependency('rack-test', '~> 0.6.1')
+ s.add_dependency('journey', '~> 1.0.0')
+ s.add_dependency('sprockets', '~> 2.0.0')
s.add_dependency('erubis', '~> 2.7.0')
s.add_development_dependency('tzinfo', '~> 0.3.29')
View
2  actionpack/lib/action_controller/caching/sweeping.rb
@@ -88,7 +88,7 @@ def callback(timing)
end
def method_missing(method, *arguments, &block)
- return if @controller.nil?
+ return unless @controller
@controller.__send__(method, *arguments, &block)
end
end
View
9 actionpack/lib/action_controller/metal/helpers.rb
@@ -7,9 +7,12 @@ module ActionController
# by default.
#
# In addition to using the standard template helpers provided, creating custom helpers to
- # extract complicated logic or reusable functionality is strongly encouraged. By default, the controller will
- # include a helper whose name matches that of the controller, e.g., <tt>MyController</tt> will automatically
- # include <tt>MyHelper</tt>.
+ # extract complicated logic or reusable functionality is strongly encouraged. By default, each controller
+ # will include all helpers.
+ #
+ # In previous versions of \Rails the controller will include a helper whose
+ # name matches that of the controller, e.g., <tt>MyController</tt> will automatically
+ # include <tt>MyHelper</tt>. To return old behavior set +config.action_controller.include_all_helpers+ to +false+.
#
# Additional helpers can be specified using the +helper+ class method in ActionController::Base or any
# controller which inherits from it.
View
2  actionpack/lib/action_controller/metal/http_authentication.rb
@@ -145,7 +145,7 @@ def decode_credentials(request)
end
def encode_credentials(user_name, password)
- "Basic #{ActiveSupport::Base64.encode64("#{user_name}:#{password}")}"
+ "Basic #{ActiveSupport::Base64.encode64s("#{user_name}:#{password}")}"
end
def authentication_request(controller, realm)
View
16 actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -6,30 +6,30 @@
require 'action_dispatch/http/mime_types'
module ActionController
- # Wraps parameters hash into nested hash. This will allow client to submit
- # POST request without having to specify a root element in it.
+ # Wraps the parameters hash into a nested hash. This will allow clients to submit
+ # POST requests without having to specify any root elements.
#
# This functionality is enabled in +config/initializers/wrap_parameters.rb+
- # and can be customized. If you are upgrading to Rails 3.1, this file will
+ # and can be customized. If you are upgrading to \Rails 3.1, this file will
# need to be created for the functionality to be enabled.
#
# You could also turn it on per controller by setting the format array to
- # non-empty array:
+ # a non-empty array:
#
# class UsersController < ApplicationController
# wrap_parameters :format => [:json, :xml]
# end
#
- # If you enable +ParamsWrapper+ for +:json+ format. Instead of having to
+ # If you enable +ParamsWrapper+ for +:json+ format, instead of having to
# send JSON parameters like this:
#
# {"user": {"name": "Konata"}}
#
- # You can now just send a parameters like this:
+ # You can send parameters like this:
#
# {"name": "Konata"}
#
- # And it will be wrapped into a nested hash with the key name matching
+ # And it will be wrapped into a nested hash with the key name matching the
# controller's name. For example, if you're posting to +UsersController+,
# your new +params+ hash will look like this:
#
@@ -81,7 +81,7 @@ module ClassMethods
#
# ==== Examples
# wrap_parameters :format => :xml
- # # enables the parmeter wrapper for XML format
+ # # enables the parameter wrapper for XML format
#
# wrap_parameters :person
# # wraps parameters into +params[:person]+ hash
View
2  actionpack/lib/action_controller/metal/redirecting.rb
@@ -57,7 +57,7 @@ module Redirecting
# When using <tt>redirect_to :back</tt>, if there is no referrer, RedirectBackError will be raised. You may specify some fallback
# behavior for this case by rescuing RedirectBackError.
def redirect_to(options = {}, response_status = {}) #:doc:
- raise ActionControllerError.new("Cannot redirect to nil!") if options.nil?
+ raise ActionControllerError.new("Cannot redirect to nil!") unless options
raise AbstractController::DoubleRenderError if response_body
self.status = _extract_redirect_to_status(options, response_status)
View
2  actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -74,7 +74,7 @@ def protect_from_forgery(options = {})
# The actual before_filter that is used. Modify this to change how you handle unverified requests.
def verify_authenticity_token
unless verified_request?
- logger.debug "WARNING: Can't verify CSRF token authenticity" if logger
+ logger.warn "WARNING: Can't verify CSRF token authenticity" if logger
handle_unverified_request
end
end
View
2  actionpack/lib/action_controller/metal/url_for.rb
@@ -18,7 +18,7 @@
# @url = root_path # named route from the application.
# end
# end
-# =>
+#
module ActionController
module UrlFor
extend ActiveSupport::Concern
View
2  actionpack/lib/action_controller/record_identifier.rb
@@ -67,7 +67,7 @@ def dom_id(record, prefix = nil)
# This can be overwritten to customize the default generated string representation if desired.
# If you need to read back a key from a dom_id in order to query for the underlying database record,
# you should write a helper like 'person_record_from_dom_id' that will extract the key either based
- # on the default implementation (which just joins all key attributes with '-') or on your own
+ # on the default implementation (which just joins all key attributes with '_') or on your own
# overwritten version of the method. By default, this implementation passes the key string through a
# method that replaces all characters that are invalid inside DOM ids, with valid ones. You need to
# make sure yourself that your dom ids are valid, in case you overwrite this method.
View
16 actionpack/lib/action_controller/test_case.rb
@@ -79,10 +79,10 @@ def assert_template(options = {}, message = nil)
"expecting <?> but rendering with <?>",
options, rendered.keys.join(', '))
assert_block(msg) do
- if options.nil?
- @templates.blank?
- else
+ if options
rendered.any? { |t,num| t.match(options) }
+ else
+ @templates.blank?
end
end
when Hash
@@ -180,7 +180,7 @@ def recycle!
@env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
@symbolized_path_params = nil
@method = @request_method = nil
- @fullpath = @ip = @remote_ip = nil
+ @fullpath = @ip = @remote_ip = @protocol = nil
@env['action_dispatch.request.query_parameters'] = {}
@set_cookies ||= {}
@set_cookies.update(Hash[cookie_jar.instance_variable_get("@set_cookies").map{ |k,o| [k,o[:value]] }])
@@ -401,9 +401,7 @@ def xml_http_request(request_method, action, parameters = nil, session = nil, fl
def paramify_values(hash_or_array_or_value)
case hash_or_array_or_value
when Hash
- hash_or_array_or_value.each do |key, value|
- hash_or_array_or_value[key] = paramify_values(value)
- end
+ Hash[hash_or_array_or_value.map{|key, value| [key, paramify_values(value)] }]
when Array
hash_or_array_or_value.map {|i| paramify_values(i)}
when Rack::Test::UploadedFile
@@ -416,7 +414,7 @@ def paramify_values(hash_or_array_or_value)
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
# Ensure that numbers and symbols passed as params are converted to
# proper params, as is the case when engaging rack.
- paramify_values(parameters)
+ parameters = paramify_values(parameters)
# Sanity check for required instance variables so we can give an
# understandable error message.
@@ -450,7 +448,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
@controller.params.merge!(parameters)
build_request_uri(action, parameters)
@controller.class.class_eval { include Testing }
- @controller.recycle!
+ @controller.recycle!
@controller.process_with_new_base_test(@request, @response)
@assigns = @controller.respond_to?(:view_assigns) ? @controller.view_assigns : {}
@request.session.delete('flash') if @request.session['flash'].blank?
View
17 actionpack/lib/action_dispatch/http/upload.rb
@@ -11,24 +11,13 @@ def initialize(hash)
raise(ArgumentError, ':tempfile is required') unless @tempfile
end
- def open
- @tempfile.open
- end
-
- def path
- @tempfile.path
- end
-
def read(*args)
@tempfile.read(*args)
end
- def rewind
- @tempfile.rewind
- end
-
- def size
- @tempfile.size
+ # Delegate these methods to the tempfile.
+ [:open, :path, :rewind, :size].each do |method|
+ class_eval "def #{method}; @tempfile.#{method}; end"
end
private
View
2  actionpack/lib/action_dispatch/http/url.rb
@@ -45,7 +45,7 @@ def url_for(options = {})
rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
rewritten_url << "?#{params.to_query}" unless params.empty?
- rewritten_url << "##{Rack::Mount::Utils.escape_uri(options[:anchor].to_param.to_s)}" if options[:anchor]
+ rewritten_url << "##{Journey::Router::Utils.escape_uri(options[:anchor].to_param.to_s)}" if options[:anchor]
rewritten_url
end
View
5 actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -85,6 +85,7 @@ class Cookies
class CookieOverflow < StandardError; end
class CookieJar #:nodoc:
+ include Enumerable
# This regular expression is used to split the levels of a domain.
# The top level domain can be any string without a period or
@@ -124,6 +125,10 @@ def initialize(secret = nil, host = nil, secure = false)
alias :closed? :closed
def close!; @closed = true end
+ def each(&block)
+ @cookies.each(&block)
+ end
+
# Returns the value of the cookie by +name+, or +nil+ if no such cookie exists.
def [](name)
@cookies[name.to_s]
View
5 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -59,7 +59,10 @@ def stale_session_check!
# Note that the regexp does not allow $1 to end with a ':'
$1.constantize
rescue LoadError, NameError => const_error
- raise ActionDispatch::Session::SessionRestoreError, "Session contains objects whose class definition isn't available.\nRemember to require the classes for all objects kept in the session.\n(Original exception: #{const_error.message} [#{const_error.class}])\n"
+ raise ActionDispatch::Session::SessionRestoreError,
+ "Session contains objects whose class definition isn't available.\n" +
+ "Remember to require the classes for all objects kept in the session.\n" +
+ "(Original exception: #{const_error.message} [#{const_error.class}])\n"
end
retry
else
View
1  actionpack/lib/action_dispatch/railtie.rb
@@ -1,5 +1,4 @@
require "action_dispatch"
-require "rails"
module ActionDispatch
class Railtie < Rails::Railtie
View
30 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -213,8 +213,8 @@ def request_method_condition
end
def segment_keys
- @segment_keys ||= Rack::Mount::RegexpWithNamedGroups.new(
- Rack::Mount::Strexp.compile(@path, requirements, SEPARATORS)
+ @segment_keys ||= Journey::Path::Pattern.new(
+ Journey::Router::Strexp.compile(@path, requirements, SEPARATORS)
).names
end
@@ -235,7 +235,7 @@ def default_action
# (:locale) becomes (/:locale) instead of /(:locale). Except
# for root cases, where the latter is the correct one.
def self.normalize_path(path)
- path = Rack::Mount::Utils.normalize_path(path)
+ path = Journey::Router::Utils.normalize_path(path)
path.gsub!(%r{/(\(+)/?}, '\1/') unless path =~ %r{^/\(+[^/]+\)$}
path
end
@@ -452,7 +452,9 @@ def define_generate_prefix(app, name)
prefix_options = options.slice(*_route.segment_keys)
# we must actually delete prefix segment keys to avoid passing them to next url_for
_route.segment_keys.each { |k| options.delete(k) }
- _routes.url_helpers.send("#{name}_path", prefix_options)
+ prefix = _routes.url_helpers.send("#{name}_path", prefix_options)
+ prefix = '' if prefix == '/'
+ prefix
end
end
end
@@ -1036,12 +1038,12 @@ def resource(*resources, &block)
#
# This generates the following comments routes:
#
- # GET /photos/:id/comments/new
- # POST /photos/:id/comments
- # GET /photos/:id/comments/:id
- # GET /photos/:id/comments/:id/edit
- # PUT /photos/:id/comments/:id
- # DELETE /photos/:id/comments/:id
+ # GET /photos/:photo_id/comments/new
+ # POST /photos/:photo_id/comments
+ # GET /photos/:photo_id/comments/:id
+ # GET /photos/:photo_id/comments/:id/edit
+ # PUT /photos/:photo_id/comments/:id
+ # DELETE /photos/:photo_id/comments/:id
#
# === Options
# Takes same options as <tt>Base#match</tt> as well as:
@@ -1436,7 +1438,7 @@ def name_for_action(as, action) #:nodoc:
name_prefix = @scope[:as]
if parent_resource
- return nil if as.nil? && action.nil?
+ return nil unless as || action
collection_name = parent_resource.collection_name
member_name = parent_resource.member_name
@@ -1463,9 +1465,9 @@ def name_for_action(as, action) #:nodoc:
end
module Shorthand #:nodoc:
- def match(*args)
- if args.size == 1 && args.last.is_a?(Hash)
- options = args.pop
+ def match(path, *rest)
+ if rest.empty? && Hash === path
+ options = path
path, to = options.find { |name, value| name.is_a?(String) }
options.merge!(:to => to).delete(path)
super(path, options)
View
60 actionpack/lib/action_dispatch/routing/route.rb
@@ -1,60 +0,0 @@
-module ActionDispatch
- module Routing
- class Route #:nodoc:
- attr_reader :app, :conditions, :defaults, :name
- attr_reader :path, :requirements, :set
-
- def initialize(set, app, conditions, requirements, defaults, name, anchor)
- @set = set
- @app = app
- @defaults = defaults
- @name = name
-
- # FIXME: we should not be doing this much work in a constructor.
-
- @requirements = requirements.merge(defaults)
- @requirements.delete(:controller) if @requirements[:controller].is_a?(Regexp)
- @requirements.delete_if { |k, v|
- v == Regexp.compile("[^#{SEPARATORS.join}]+")
- }
-
- if path = conditions[:path_info]
- @path = path
- conditions[:path_info] = ::Rack::Mount::Strexp.compile(path, requirements, SEPARATORS, anchor)
- end
-
- @verbs = conditions[:request_method] || []
-
- @conditions = conditions.dup
-
- # Rack-Mount requires that :request_method be a regular expression.
- # :request_method represents the HTTP verb that matches this route.
- #
- # Here we munge values before they get sent on to rack-mount.
- @conditions[:request_method] = %r[^#{verb}$] unless @verbs.empty?
- @conditions[:path_info] = Rack::Mount::RegexpWithNamedGroups.new(@conditions[:path_info]) if @conditions[:path_info]
- @conditions.delete_if{ |k,v| k != :path_info && !valid_condition?(k) }
- @requirements.delete_if{ |k,v| !valid_condition?(k) }
- end
-
- def verb
- @verbs.join '|'
- end
-
- def segment_keys
- @segment_keys ||= conditions[:path_info].names.compact.map { |key| key.to_sym }
- end
-
- def to_s
- @to_s ||= begin
- "%-6s %-40s %s" % [(verb || :any).to_s.upcase, path, requirements.inspect]
- end
- end
-
- private
- def valid_condition?(method)
- segment_keys.include?(method) || set.valid_conditions.include?(method)
- end
- end
- end
-end
View
104 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -1,4 +1,4 @@
-require 'rack/mount'
+require 'journey/router'
require 'forwardable'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/to_query'
@@ -205,29 +205,42 @@ def #{selector}(*args)
end
end
- attr_accessor :set, :routes, :named_routes, :default_scope
+ attr_accessor :formatter, :set, :named_routes, :default_scope, :router
attr_accessor :disable_clear_and_finalize, :resources_path_names
attr_accessor :default_url_options, :request_class, :valid_conditions
+ alias :routes :set
+
def self.default_resources_path_names
{ :new => 'new', :edit => 'edit' }
end
def initialize(request_class = ActionDispatch::Request)
- self.routes = []
self.named_routes = NamedRouteCollection.new
self.resources_path_names = self.class.default_resources_path_names.dup
self.default_url_options = {}
self.request_class = request_class
- self.valid_conditions = request_class.public_instance_methods.map { |m| m.to_sym }
+ @valid_conditions = {}
+
+ request_class.public_instance_methods.each { |m|
+ @valid_conditions[m.to_sym] = true
+ }
+ @valid_conditions[:controller] = true
+ @valid_conditions[:action] = true
+
self.valid_conditions.delete(:id)
- self.valid_conditions.push(:controller, :action)
- @append = []
- @prepend = []
+ @append = []
+ @prepend = []
@disable_clear_and_finalize = false
- clear!
+ @finalized = false
+
+ @set = Journey::Routes.new
+ @router = Journey::Router.new(@set, {
+ :parameters_key => PARAMETERS_KEY,
+ :request_class => request_class})
+ @formatter = Journey::Formatter.new @set
end
def draw(&block)
@@ -263,17 +276,13 @@ def finalize!
return if @finalized
@append.each { |blk| eval_block(blk) }
@finalized = true
- @set.freeze
end
def clear!
@finalized = false
- routes.clear
named_routes.clear
- @set = ::Rack::Mount::RouteSet.new(
- :parameters_key => PARAMETERS_KEY,
- :request_class => request_class
- )
+ set.clear
+ formatter.clear
@prepend.each { |blk| eval_block(blk) }
end
@@ -341,26 +350,55 @@ def empty?
def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
- route = Route.new(self, app, conditions, requirements, defaults, name, anchor)
- @set.add_route(route.app, route.conditions, route.defaults, route.name)
+
+ path = build_path(conditions.delete(:path_info), requirements, SEPARATORS, anchor)
+ conditions = build_conditions(conditions, valid_conditions, path.names.map { |x| x.to_sym })
+
+ route = @set.add_route(app, path, conditions, defaults, name)
named_routes[name] = route if name
- routes << route
route
end
+ def build_path(path, requirements, separators, anchor)
+ strexp = Journey::Router::Strexp.new(
+ path,
+ requirements,
+ SEPARATORS,
+ anchor)
+
+ Journey::Path::Pattern.new(strexp)
+ end
+ private :build_path
+
+ def build_conditions(current_conditions, req_predicates, path_values)
+ conditions = current_conditions.dup
+
+ verbs = conditions[:request_method] || []
+
+ # Rack-Mount requires that :request_method be a regular expression.
+ # :request_method represents the HTTP verb that matches this route.
+ #
+ # Here we munge values before they get sent on to rack-mount.
+ unless verbs.empty?
+ conditions[:request_method] = %r[^#{verbs.join('|')}$]
+ end
+ conditions.delete_if { |k,v| !(req_predicates.include?(k) || path_values.include?(k)) }
+
+ conditions
+ end
+ private :build_conditions
+
class Generator #:nodoc:
- PARAMETERIZE = {
- :parameterize => lambda do |name, value|
- if name == :controller
- value
- elsif value.is_a?(Array)
- value.map { |v| Rack::Mount::Utils.escape_uri(v.to_param) }.join('/')
- else
- return nil unless param = value.to_param
- param.split('/').map { |v| Rack::Mount::Utils.escape_uri(v) }.join("/")
- end
+ PARAMETERIZE = lambda do |name, value|
+ if name == :controller
+ value
+ elsif value.is_a?(Array)
+ value.map { |v| Journey::Router::Utils.escape_uri(v.to_param) }.join('/')
+ else
+ return nil unless param = value.to_param
+ param.split('/').map { |v| Journey::Router::Utils.escape_uri(v) }.join("/")
end
- }
+ end
attr_reader :options, :recall, :set, :named_route
@@ -450,14 +488,14 @@ def handle_nil_action!
end
def generate
- path, params = @set.set.generate(:path_info, named_route, options, recall, PARAMETERIZE)
+ path, params = @set.formatter.generate(:path_info, named_route, options, recall, PARAMETERIZE)
raise_routing_error unless path
return [path, params.keys] if @extras
[path, params]
- rescue Rack::Mount::RoutingError
+ rescue Journey::Router::RoutingError
raise_routing_error
end
@@ -529,12 +567,12 @@ def url_for(options)
def call(env)
finalize!
- @set.call(env)
+ @router.call(env)
end
def recognize_path(path, environment = {})
method = (environment[:method] || "GET").to_s.upcase
- path = Rack::Mount::Utils.normalize_path(path) unless path =~ %r{://}
+ path = Journey::Router::Utils.normalize_path(path) unless path =~ %r{://}
begin
env = Rack::MockRequest.env_for(path, {:method => method})
@@ -543,7 +581,7 @@ def recognize_path(path, environment = {})
end
req = @request_class.new(env)
- @set.recognize(req) do |route, matches, params|
+ @router.recognize(req) do |route, matches, params|
params.each do |key, value|
if value.is_a?(String)
value = value.dup.force_encoding(Encoding::BINARY) if value.encoding_aware?
View
12 actionpack/lib/action_dispatch/routing/url_for.rb
@@ -131,10 +131,14 @@ def url_options
#
# Examples:
#
- # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :port => '8080' # => 'http://somehost.org:8080/tasks/testing'
- # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :anchor => 'ok', :only_path => true # => '/tasks/testing#ok'
- # url_for :controller => 'tasks', :action => 'testing', :trailing_slash => true # => 'http://somehost.org/tasks/testing/'
- # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :number => '33' # => 'http://somehost.org/tasks/testing?number=33'
+ # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :port => '8080'
+ # # => 'http://somehost.org:8080/tasks/testing'
+ # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :anchor => 'ok', :only_path => true
+ # # => '/tasks/testing#ok'
+ # url_for :controller => 'tasks', :action => 'testing', :trailing_slash => true
+ # # => 'http://somehost.org/tasks/testing/'
+ # url_for :controller => 'tasks', :action => 'testing', :host => 'somehost.org', :number => '33'
+ # # => 'http://somehost.org/tasks/testing?number=33'
def url_for(options = nil)
case options
when String
View
4 actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -415,9 +415,9 @@ def assert_select_email(&block)
assert !deliveries.empty?, "No e-mail in delivery list"
for delivery in deliveries
- for part in delivery.parts
+ for part in (delivery.parts.empty? ? [delivery] : delivery.parts)
if part["Content-Type"].to_s =~ /^text\/html\W/
- root = HTML::Document.new(part.body).root
+ root = HTML::Document.new(part.body.to_s).root
assert_select root, ":root", &block
end
end
View
22 actionpack/lib/action_view/asset_paths.rb
@@ -21,14 +21,15 @@ def initialize(config, controller = nil)
# When :relative (default), the protocol will be determined by the client using current protocol
# When :request, the protocol will be the request protocol
# Otherwise, the protocol is used (E.g. :http, :https, etc)
- def compute_public_path(source, dir, ext = nil, include_host = true, protocol = nil)
+ def compute_public_path(source, dir, options = {})
source = source.to_s
return source if is_uri?(source)
- source = rewrite_extension(source, dir, ext) if ext
- source = rewrite_asset_path(source, dir)
- source = rewrite_relative_url_root(source, relative_url_root) if has_request?
- source = rewrite_host_and_protocol(source, protocol) if include_host
+ options[:include_host] ||= true
+ source = rewrite_extension(source, dir, options[:ext]) if options[:ext]
+ source = rewrite_asset_path(source, dir, options)
+ source = rewrite_relative_url_root(source, relative_url_root)
+ source = rewrite_host_and_protocol(source, options[:protocol]) if options[:include_host]
source
end
@@ -69,7 +70,7 @@ def rewrite_host_and_protocol(source, protocol = nil)
host = "#{compute_protocol(protocol)}#{host}"
end
end
- host.nil? ? source : "#{host}#{source}"
+ host ? "#{host}#{source}" : source
end
def compute_protocol(protocol)
@@ -119,10 +120,11 @@ def compute_asset_host(source)
end
def relative_url_root
- config = controller.config if controller.respond_to?(:config)
- config ||= config.action_controller if config.action_controller.present?
- config ||= config
- config.relative_url_root
+ if config.action_controller.present?
+ config.action_controller.relative_url_root
+ else
+ config.relative_url_root
+ end
end
def asset_host_config
View
2  actionpack/lib/action_view/base.rb
@@ -116,7 +116,7 @@ module ActionView #:nodoc:
# xml.language "en-us"
# xml.ttl "40"
#
- # for item in @recent_items
+ # @recent_items.each do |item|
# xml.item do
# xml.title(item_title(item))
# xml.description(item_description(item)) if item_description(item)
View
4 actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb
@@ -60,8 +60,8 @@ def include_tag(*sources)
private
- def path_to_asset(source, include_host = true, protocol = nil)
- asset_paths.compute_public_path(source, asset_name.to_s.pluralize, extension, include_host, protocol)
+ def path_to_asset(source, options = {})
+ asset_paths.compute_public_path(source, asset_name.to_s.pluralize, options.merge(:ext => extension))
end
def path_to_asset_source(source)
View
2  actionpack/lib/action_view/helpers/asset_tag_helpers/asset_paths.rb
@@ -41,7 +41,7 @@ def rewrite_extension(source, dir, ext)
# Break out the asset path rewrite in case plugins wish to put the asset id
# someplace other than the query string.
- def rewrite_asset_path(source, dir)
+ def rewrite_asset_path(source, dir, options = nil)
source = "/#{dir}/#{source}" unless source[0] == ?/
path = config.asset_path
View
2  actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
@@ -83,7 +83,7 @@ def register_javascript_expansion(expansions)
# javascript_path "http://www.example.com/js/xmlhr" # => http://www.example.com/js/xmlhr
# javascript_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js
def javascript_path(source)
- asset_paths.compute_public_path(source, 'javascripts', 'js')
+ asset_paths.compute_public_path(source, 'javascripts', :ext => 'js')
end
alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route
View
4 actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
@@ -17,7 +17,7 @@ def extension
def asset_tag(source, options)
# We force the :request protocol here to avoid a double-download bug in IE7 and IE8
- tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => ERB::Util.html_escape(path_to_asset(source, true, :request)) }.merge(options), false, false)
+ tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => ERB::Util.html_escape(path_to_asset(source, :protocol => :request)) }.merge(options), false, false)
end
def custom_dir
@@ -61,7 +61,7 @@ def register_stylesheet_expansion(expansions)
# stylesheet_path "http://www.example.com/css/style" # => http://www.example.com/css/style
# stylesheet_path "http://www.example.com/css/style.css" # => http://www.example.com/css/style.css
def stylesheet_path(source)
- asset_paths.compute_public_path(source, 'stylesheets', 'css', true, :request)
+ asset_paths.compute_public_path(source, 'stylesheets', :ext => 'css', :protocol => :request)
end
alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route
View
6 actionpack/lib/action_view/helpers/capture_helper.rb
@@ -134,9 +134,9 @@ def capture(*args)
# WARNING: content_for is ignored in caches. So you shouldn't use it
# for elements that will be fragment cached.
def content_for(name, content = nil, &block)
- content = capture(&block) if block_given?
- if content
- @view_flow.append(name, content)
+ if content || block_given?
+ content = capture(&block) if block_given?
+ @view_flow.append(name, content) if content
nil
else
@view_flow.get(name)
View
11 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -177,9 +177,12 @@ def text_field_tag(name, value = nil, options = {})
# label_tag 'name', nil, :class => 'small_label'
# # => <label for="name" class="small_label">Name</label>
def label_tag(name = nil, content_or_options = nil, options = nil, &block)
- options = content_or_options if block_given? && content_or_options.is_a?(Hash)
- options ||= {}
- options.stringify_keys!
+ if block_given? && content_or_options.is_a?(Hash)
+ options = content_or_options = content_or_options.stringify_keys
+ else
+ options ||= {}
+ options = options.stringify_keys
+ end
options["for"] = sanitize_to_id(name) unless name.blank? || options.has_key?("for")
content_tag :label, content_or_options || name.to_s.humanize, options, &block
end
@@ -653,7 +656,7 @@ def token_tag(token)
if token == false || !protect_against_forgery?
''
else
- token = form_authenticity_token if token.nil?
+ token ||= form_authenticity_token
tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => token)
end
end
View
15 actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -1,4 +1,5 @@
require 'action_view/helpers/tag_helper'
+require 'active_support/core_ext/string/encoding'
module ActionView
module Helpers
@@ -10,15 +11,23 @@ module JavaScriptHelper
"\n" => '\n',
"\r" => '\n',
'"' => '\\"',
- "'" => "\\'" }
+ "'" => "\\'"
+ }
- # Escape carrier returns and single and double quotes for JavaScript segments.
+ if "ruby".encoding_aware?
+ JS_ESCAPE_MAP["\342\200\250".force_encoding('UTF-8').encode!] = '&#x2028;'
+ else
+ JS_ESCAPE_MAP["\342\200\250"] = '&#x2028;'
+ end
+
+ # Escapes carriage returns and single and double quotes for JavaScript segments.
+ #
# Also available through the alias j(). This is particularly helpful in JavaScript responses, like:
#
# $('some_element').replaceWith('<%=j render 'some/element_template' %>');
def escape_javascript(javascript)
if javascript
- result = javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) {|match| JS_ESCAPE_MAP[match] }
+ result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] }
javascript.html_safe? ? result.html_safe : result
else
''
View
56 actionpack/lib/action_view/helpers/record_tag_helper.rb
@@ -17,6 +17,19 @@ module RecordTagHelper
#
# <div id="person_123" class="person foo"> Joe Bloggs </div>
#
+ # You can also pass an array of Active Record objects, which will then
+ # get iterated over and yield each record as an argument for the block.
+ # For example:
+ #
+ # <%= div_for(@people, :class => "foo") do |person| %>
+ # <%= person.name %>
+ # <% end %>
+ #
+ # produces:
+ #
+ # <div id="person_123" class="person foo"> Joe Bloggs </div>
+ # <div id="person_124" class="person foo"> Jane Bloggs </div>
+ #
def div_for(record, *args, &block)
content_tag_for(:div, record, *args, &block)
end
@@ -42,6 +55,21 @@ def div_for(record, *args, &block)
#
# <tr id="foo_person_123" class="person">...
#
+ # You can also pass an array of objects which this method will loop through
+ # and yield the current object to the supplied block, reducing the need for
+ # having to iterate through the object (using <tt>each</tt>) beforehand.
+ # For example (assuming @people is an array of Person objects):
+ #
+ # <%= content_tag_for(:tr, @people) do |person| %>
+ # <td><%= person.first_name %></td>
+ # <td><%= person.last_name %></td>
+ # <% end %>
+ #
+ # produces:
+ #
+ # <tr id="person_123" class="person">...</tr>
+ # <tr id="person_124" class="person">...</tr>
+ #
# content_tag_for also accepts a hash of options, which will be converted to
# additional HTML attributes. If you specify a <tt>:class</tt> value, it will be combined
# with the default class name for your object. For example:
@@ -52,12 +80,30 @@ def div_for(record, *args, &block)
#
# <li id="person_123" class="person bar">...
#
- def content_tag_for(tag_name, record, prefix = nil, options = nil, &block)
- options, prefix = prefix, nil if prefix.is_a?(Hash)
- options ||= {}
- options.merge!({ :class => "#{dom_class(record, prefix)} #{options[:class]}".strip, :id => dom_id(record, prefix) })
- content_tag(tag_name, options, &block)
+ def content_tag_for(tag_name, single_or_multiple_records, prefix = nil, options = nil, &block)
+ if single_or_multiple_records.respond_to?(:to_ary)
+ single_or_multiple_records.to_ary.map do |single_record|
+ capture { content_tag_for_single_record(tag_name, single_record, prefix, options, &block) }
+ end.join("\n").html_safe
+ else
+ content_tag_for_single_record(tag_name, single_or_multiple_records, prefix, options, &block)
+ end
end
+
+ private
+
+ # Called by <tt>content_tag_for</tt> internally to render a content tag
+ # for each record.
+ def content_tag_for_single_record(tag_name, record, prefix, options, &block)
+ options, prefix = prefix, nil if prefix.is_a?(Hash)
+ options ||= {}
+ options.merge!({ :class => "#{dom_class(record, prefix)} #{options[:class]}".strip, :id => dom_id(record, prefix) })
+ if block.arity == 0
+ content_tag(tag_name, capture(&block), options)
+ else
+ content_tag(tag_name, capture(record, &block), options)
+ end
+ end
end
end
end
View
14 actionpack/lib/action_view/helpers/url_helper.rb
@@ -569,6 +569,12 @@ def mail_to(email_address, name = nil, html_options = {})
#
# current_page?(:controller => 'library', :action => 'checkout')
# # => false
+ #
+ # Let's say we're in the <tt>/products</tt> action with method POST in case of invalid product.
+ #
+ # current_page?(:controller => 'product', :action => 'index')
+ # # => false
+ #
def current_page?(options)
unless request
raise "You cannot use helpers that need to determine the current " \
@@ -576,6 +582,8 @@ def current_page?(options)
"in a #request method"
end
+ return false unless request.get?
+
url_string = url_for(options)
# We ignore any extra parameters in the request_uri if the
@@ -596,9 +604,7 @@ def current_page?(options)
private
def convert_options_to_data_attributes(options, html_options)
- if html_options.nil?
- link_to_remote_options?(options) ? {'data-remote' => 'true'} : {}
- else
+ if html_options
html_options = html_options.stringify_keys
html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options)
@@ -611,6 +617,8 @@ def convert_options_to_data_attributes(options, html_options)
add_method_to_attributes!(html_options, method) if method
html_options
+ else
+ link_to_remote_options?(options) ? {'data-remote' => 'true'} : {}
end
end
View
211 actionpack/lib/action_view/lookup_context.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
+require 'active_support/core_ext/module/remove_method'
module ActionView
# = Action View Lookup Context
@@ -17,12 +18,11 @@ class LookupContext #:nodoc:
mattr_accessor :registered_details
self.registered_details = []
- mattr_accessor :registered_detail_setters
- self.registered_detail_setters = []
-
def self.register_detail(name, options = {}, &block)
self.registered_details << name
- self.registered_detail_setters << [name, "#{name}="]
+
+ initialize = registered_details.map { |n| "self.#{n} = details[:#{n}]" }
+ update = registered_details.map { |n| "self.#{n} = details[:#{n}] if details.key?(:#{n})" }
Accessors.send :define_method, :"_#{name}_defaults", &block
Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
@@ -34,6 +34,16 @@ def #{name}=(value)
value = Array.wrap(value.presence || _#{name}_defaults)
_set_detail(:#{name}, value) if value != @details[:#{name}]
end
+
+ remove_possible_method :initialize_details
+ def initialize_details(details)
+ #{initialize.join("\n")}
+ end
+
+ remove_possible_method :update_details
+ def update_details(details)
+ #{update.join("\n")}
+ end
METHOD
end
@@ -60,18 +70,53 @@ def initialize
end
end
- def initialize(view_paths, details = {}, prefixes = [])
- @details, @details_key = { :handlers => default_handlers }, nil
- @frozen_formats, @skip_default_locale = false, false
- @cache = true
- @prefixes = prefixes
+ # Add caching behavior on top of Details.
+ module DetailsCache
+ attr_accessor :cache
- self.view_paths = view_paths
- self.registered_detail_setters.each do |key, setter|
- send(setter, details[key])
+ # Calculate the details key. Remove the handlers from calculation to improve performance
+ # since the user cannot modify it explicitly.
+ def details_key #:nodoc:
+ @details_key ||= DetailsKey.get(@details) if @cache
+ end
+
+ # Temporary skip passing the details_key forward.
+ def disable_cache
+ old_value, @cache = @cache, false
+ yield
+ ensure
+ @cache = old_value
+ end
+
+ # Update the details keys by merging the given hash into the current
+ # details hash. If a block is given, the details are modified just during
+ # the execution of the block and reverted to the previous value after.
+ def update_details(new_details)
+ if block_given?
+ old_details = @details.dup
+ super
+
+ begin
+ yield
+ ensure
+ @details_key = nil
+ @details = old_details
+ end
+ else
+ super
+ end
+ end
+
+ protected
+
+ def _set_detail(key, value)
+ @details_key = nil
+ @details = @details.dup if @details.frozen?
+ @details[key] = value.freeze
end
end
+ # Helpers related to template lookup using the lookup context information.
module ViewPaths
attr_reader :view_paths
@@ -141,111 +186,77 @@ def handlers_regexp #:nodoc:
end
end
- module Details
- attr_accessor :cache
-
- # Calculate the details key. Remove the handlers from calculation to improve performance
- # since the user cannot modify it explicitly.
- def details_key #:nodoc:
- @details_key ||= DetailsKey.get(@details) if @cache
- end
-
- # Temporary skip passing the details_key forward.
- def disable_cache
- old_value, @cache = @cache, false
- yield
- ensure
- @cache = old_value
- end
+ include Accessors
+ include DetailsCache
+ include ViewPaths
- # Freeze the current formats in the lookup context. By freezing them, you are guaranteeing
- # that next template lookups are not going to modify the formats. The controller can also
- # use this, to ensure that formats won't be further modified (as it does in respond_to blocks).
- def freeze_formats(formats, unless_frozen=false) #:nodoc:
- return if unless_frozen && @frozen_formats
- self.formats = formats
- @frozen_formats = true
- end
+ def initialize(view_paths, details = {}, prefixes = [])
+ @details, @details_key = { :handlers => default_handlers }, nil
+ @frozen_formats, @skip_default_locale = false, false
+ @cache = true
+ @prefixes = prefixes
- # Overload formats= to expand ["*/*"] values and automatically
- # add :html as fallback to :js.
- def formats=(values)
- if values
- values.concat(_formats_defaults) if values.delete "*/*"
- values << :html if values == [:js]
- end
- super(values)
- end
+ self.view_paths = view_paths
+ initialize_details(details)
+ end
- # Do not use the default locale on template lookup.
- def skip_default_locale!
- @skip_default_locale = true
- self.locale = nil
- end
+ # Freeze the current formats in the lookup context. By freezing them, you
+ # that next template lookups are not going to modify the formats. The con
+ # use this, to ensure that formats won't be further modified (as it does
+ def freeze_formats(formats, unless_frozen=false) #:nodoc:
+ return if unless_frozen && @frozen_formats
+ self.formats = formats
+ @frozen_formats = true
+ end
- # Overload locale to return a symbol instead of array.
- def locale
- @details[:locale].first
+ # Override formats= to expand ["*/*"] values and automatically
+ # add :html as fallback to :js.
+ def formats=(values)
+ if values
+ values.concat(_formats_defaults) if values.delete "*/*"
+ values << :html if values == [:js]
end
+ super(values)
+ end
- # Overload locale= to also set the I18n.locale. If the current I18n.config object responds
- # to original_config, it means that it's has a copy of the original I18n configuration and it's
- # acting as proxy, which we need to skip.
- def locale=(value)
- if value
- config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
- config.locale = value
- end
-
- super(@skip_default_locale ? I18n.locale : _locale_defaults)
- end
+ # Do not use the default locale on template lookup.
+ def skip_default_locale!
+ @skip_default_locale = true
+ self.locale = nil
+ end
- # A method which only uses the first format in the formats array for layout lookup.
- # This method plays straight with instance variables for performance reasons.
- def with_layout_format
- if formats.size == 1
- yield
- else
- old_formats = formats
- _set_detail(:formats, formats[0,1])
+ # Override locale to return a symbol instead of array.
+ def locale
+ @details[:locale].first
+ end
- begin
- yield
- ensure
- _set_detail(:formats, old_formats)
- end
- end
+ # Overload locale= to also set the I18n.locale. If the current I18n.config object responds
+ # to original_config, it means that it's has a copy of the original I18n configuration and it's
+ # acting as proxy, which we need to skip.
+ def locale=(value)
+ if value
+ config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
+ config.locale = value
end
- # Update the details keys by merging the given hash into the current
- # details hash. If a block is given, the details are modified just during
- # the execution of the block and reverted to the previous value after.
- def update_details(new_details)
- old_details = @details.dup
+ super(@skip_default_locale ? I18n.locale : _locale_defaults)
+ end
- registered_detail_setters.each do |key, setter|
- send(setter, new_details[key]) if new_details.key?(key)
- end
+ # A method which only uses the first format in the formats array for layout lookup.
+ # This method plays straight with instance variables for performance reasons.
+ def with_layout_format
+ if formats.size == 1
+ yield
+ else
+ old_formats = formats
+ _set_detail(:formats, formats[0,1])
begin
yield
ensure
- @details_key = nil
- @details = old_details
+ _set_detail(:formats, old_formats)
end
end
-
- protected
-
- def _set_detail(key, value)
- @details_key = nil
- @details = @details.dup if @details.frozen?
- @details[key] = value.freeze
- end
end
-
- include Accessors
- include Details
- include ViewPaths
end
end
View
18 actionpack/lib/sprockets/assets.rake
@@ -9,17 +9,25 @@ namespace :assets do
Kernel.exec $0, *ARGV
else
Rake::Task["environment"].invoke
+ Rake::Task["tmp:cache:clear"].invoke
# Ensure that action view is loaded and the appropriate sprockets hooks get executed
ActionView::Base
- # Always perform caching so that asset_path appends the timestamps to file references.
- Rails.application.config.action_controller.perform_caching = true
+ # Always compile files
+ Rails.application.config.assets.compile = true
config = Rails.application.config
- assets = config.assets.precompile.dup
- assets << {:to => File.join(Rails.public_path, config.assets.prefix)}
- Rails.application.assets.precompile(*assets)
+ env = Rails.application.assets
+ target = Pathname.new(File.join(Rails.public_path, config.assets.prefix))
+ manifest_path = config.assets.manifest || target
+
+ static_compiler = Sprockets::StaticCompiler.new(env, target, :digest => config.assets.digest)
+ manifest = static_compiler.precompile(config.assets.precompile)
+
+ File.open("#{manifest_path}/manifest.yml", 'wb') do |f|
+ YAML.dump(manifest, f)
+ end
end
end
View
30 actionpack/lib/sprockets/compressors.rb
@@ -1,21 +1,37 @@
module Sprockets
- class NullCompressor
+ # An asset compressor which does nothing.
+ #
+ # This compressor simply returns the asset as-is, without any compression
+ # whatsoever. It is useful in development mode, when compression isn't
+ # needed but using the same asset pipeline as production is desired.
+ class NullCompressor #:nodoc:
def compress(content)
content
end
end
- class LazyCompressor
+ # An asset compressor which only initializes the underlying compression
+ # engine when needed.
+ #
+ # This postpones the initialization of the compressor until
+ # <code>#compress</code> is called the first time.
+ class LazyCompressor #:nodoc:
+ # Initializes a new LazyCompressor.
+ #
+ # The block should return a compressor when called, i.e. an object
+ # which responds to <code>#compress</code>.
def initialize(&block)
@block = block
end
- def compressor
- @compressor ||= @block.call || NullCompressor.new
- end
-
def compress(content)
compressor.compress(content)
end
+
+ private
+
+ def compressor
+ @compressor ||= (@block.call || NullCompressor.new)
+ end
end
-end
+end