Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
commit f2bc404ba82431d32a35b4de15cb21f179bc24c7 2 parents 98b4ef7 + 6ce54d4
@MarkMT MarkMT authored
Showing with 1,186 additions and 9,416 deletions.
  1. +1 −1  .gitignore
  2. +3 −1 .travis.yml
  3. +3 −1 Gemfile
  4. +1 −7 Rakefile
  5. +8 −2 actionmailer/CHANGELOG.md
  6. +28 −0 actionmailer/lib/action_mailer/base.rb
  7. +2 −2 actionmailer/lib/rails/generators/mailer/templates/mailer.rb
  8. +49 −1 actionmailer/test/base_test.rb
  9. +34 −4 actionpack/CHANGELOG.md
  10. +0 −1  actionpack/actionpack.gemspec
  11. +3 −2 actionpack/lib/abstract_controller/base.rb
  12. +14 −6 actionpack/lib/abstract_controller/layouts.rb
  13. +1 −0  actionpack/lib/abstract_controller/rendering.rb
  14. +3 −3 actionpack/lib/action_controller/base.rb
  15. +6 −1 actionpack/lib/action_controller/caching/sweeping.rb
  16. +1 −1  actionpack/lib/action_controller/metal/force_ssl.rb
  17. +1 −0  actionpack/lib/action_controller/metal/helpers.rb
  18. +6 −2 actionpack/lib/action_controller/metal/mime_responds.rb
  19. +1 −1  actionpack/lib/action_controller/metal/redirecting.rb
  20. +18 −2 actionpack/lib/action_controller/metal/request_forgery_protection.rb
  21. +19 −12 actionpack/lib/action_controller/railtie.rb
  22. +22 −0 actionpack/lib/action_controller/railties/helpers.rb
  23. +0 −25 actionpack/lib/action_controller/railties/paths.rb
  24. +2 −2 actionpack/lib/action_controller/record_identifier.rb
  25. +7 −7 actionpack/lib/action_controller/test_case.rb
  26. +7 −2 actionpack/lib/action_dispatch/http/response.rb
  27. +1 −0  actionpack/lib/action_dispatch/middleware/static.rb
  28. +1 −1  actionpack/lib/action_dispatch/routing/mapper.rb
  29. +1 −1  actionpack/lib/action_dispatch/testing/assertions/response.rb
  30. +14 −14 actionpack/lib/action_view/helpers/form_helper.rb
  31. +2 −0  actionpack/lib/action_view/helpers/form_options_helper.rb
  32. +13 −2 actionpack/lib/action_view/helpers/form_tag_helper.rb
  33. +3 −1 actionpack/lib/action_view/helpers/javascript_helper.rb
  34. +2 −3 actionpack/lib/action_view/helpers/tags/base.rb
  35. +8 −2 actionpack/lib/action_view/helpers/tags/check_box.rb
  36. +1 −3 actionpack/lib/action_view/helpers/tags/text_area.rb
  37. +1 −2  actionpack/lib/action_view/helpers/tags/text_field.rb
  38. +1 −1  actionpack/lib/action_view/helpers/url_helper.rb
  39. +4 −4 actionpack/lib/action_view/template/resolver.rb
  40. +0 −105 actionpack/lib/sprockets/assets.rake
  41. +0 −37 actionpack/lib/sprockets/bootstrap.rb
  42. +0 −85 actionpack/lib/sprockets/compressors.rb
  43. +0 −6 actionpack/lib/sprockets/helpers.rb
  44. +0 −13 actionpack/lib/sprockets/helpers/isolated_helper.rb
  45. +0 −167 actionpack/lib/sprockets/helpers/rails_helper.rb
  46. +0 −62 actionpack/lib/sprockets/railtie.rb
  47. +0 −62 actionpack/lib/sprockets/static_compiler.rb
  48. +4 −3 actionpack/test/abstract/abstract_controller_test.rb
  49. +2 −2 actionpack/test/abstract/collector_test.rb
  50. +2 −2 actionpack/test/abstract/helper_test.rb
  51. +33 −0 actionpack/test/abstract/layouts_test.rb
  52. +0 −6 actionpack/test/controller/base_test.rb
  53. +1 −1  actionpack/test/controller/http_digest_authentication_test.rb
  54. +20 −0 actionpack/test/controller/redirect_test.rb
  55. +39 −0 actionpack/test/controller/render_test.rb
  56. +26 −2 actionpack/test/controller/request_forgery_protection_test.rb
  57. +0 −4 actionpack/test/controller/send_file_test.rb
  58. +16 −0 actionpack/test/controller/sweeper_test.rb
  59. +4 −0 actionpack/test/dispatch/static_test.rb
  60. +1 −0  actionpack/test/fixtures/layouts/with_html_partial.html.erb
  61. +0 −1  actionpack/test/fixtures/sprockets/alternate/stylesheets/style.css
  62. 0  actionpack/test/fixtures/sprockets/app/fonts/dir/font.ttf
  63. 0  actionpack/test/fixtures/sprockets/app/fonts/font.ttf
  64. BIN  actionpack/test/fixtures/sprockets/app/images/logo.png
  65. +0 −1  actionpack/test/fixtures/sprockets/app/javascripts/application.js
  66. 0  actionpack/test/fixtures/sprockets/app/javascripts/dir/xmlhr.js
  67. 0  actionpack/test/fixtures/sprockets/app/javascripts/extra.js
  68. 0  actionpack/test/fixtures/sprockets/app/javascripts/xmlhr.js
  69. +0 −1  actionpack/test/fixtures/sprockets/app/stylesheets/application.css
  70. 0  actionpack/test/fixtures/sprockets/app/stylesheets/dir/style.css
  71. 0  actionpack/test/fixtures/sprockets/app/stylesheets/extra.css
  72. 0  actionpack/test/fixtures/sprockets/app/stylesheets/style.css
  73. +1 −0  actionpack/test/fixtures/test/_partial_only_html.html
  74. +1 −0  actionpack/test/fixtures/test/with_html_partial.html.erb
  75. +1 −0  actionpack/test/fixtures/test/with_partial.html.erb
  76. +1 −0  actionpack/test/fixtures/test/with_partial.text.erb
  77. +1 −0  actionpack/test/fixtures/test/with_xml_template.html.erb
  78. +3 −3 actionpack/test/template/active_model_helper_test.rb
  79. +0 −28 actionpack/test/template/compressors_test.rb
  80. +167 −162 actionpack/test/template/form_helper_test.rb
  81. +8 −0 actionpack/test/template/form_options_helper_test.rb
  82. +2 −0  actionpack/test/template/javascript_helper_test.rb
  83. +0 −349 actionpack/test/template/sprockets_helper_test.rb
  84. +0 −57 actionpack/test/template/sprockets_helper_with_routes_test.rb
  85. +6 −0 actionpack/test/template/test_case_test.rb
  86. +13 −0 activemodel/CHANGELOG.md
  87. +1 −1  activemodel/activemodel.gemspec
  88. +2 −2 activemodel/lib/active_model/conversion.rb
  89. +0 −4 activemodel/lib/active_model/locale/en.yml
  90. +5 −7 activemodel/lib/active_model/mass_assignment_security/sanitizer.rb
  91. +1 −0  activemodel/lib/active_model/naming.rb
  92. +0 −13 activemodel/lib/active_model/secure_password.rb
  93. +5 −11 activemodel/lib/active_model/serialization.rb
  94. +1 −1  activemodel/test/cases/conversion_test.rb
  95. +13 −13 activemodel/test/cases/serialization_test.rb
  96. +37 −0 activerecord/CHANGELOG.md
  97. +0 −7 activerecord/RUNNING_UNIT_TESTS
  98. +0 −1  activerecord/lib/active_record.rb
  99. +1 −12 activerecord/lib/active_record/associations/association.rb
  100. +1 −1  activerecord/lib/active_record/associations/collection_association.rb
  101. +50 −23 activerecord/lib/active_record/attribute_methods.rb
  102. +0 −5 activerecord/lib/active_record/attribute_methods/dirty.rb
  103. +1 −7 activerecord/lib/active_record/autosave_association.rb
  104. +3 −0  activerecord/lib/active_record/base.rb
  105. +23 −12 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  106. +19 −20 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  107. +1 −1  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  108. +2 −2 activerecord/lib/active_record/core.rb
  109. +0 −2  activerecord/lib/active_record/counter_cache.rb
  110. +25 −1 activerecord/lib/active_record/dynamic_finder_match.rb
  111. +1 −3 activerecord/lib/active_record/fixtures.rb
  112. +0 −144 activerecord/lib/active_record/identity_map.rb
  113. +3 −20 activerecord/lib/active_record/inheritance.rb
  114. +1 −1  activerecord/lib/active_record/locking/optimistic.rb
  115. +0 −1  activerecord/lib/active_record/model.rb
  116. +2 −1  activerecord/lib/active_record/model_schema.rb
  117. +6 −14 activerecord/lib/active_record/persistence.rb
  118. +0 −5 activerecord/lib/active_record/railtie.rb
  119. +5 −10 activerecord/lib/active_record/relation.rb
  120. +1 −11 activerecord/lib/active_record/relation/finder_methods.rb
  121. +1 −1  activerecord/lib/active_record/relation/query_methods.rb
  122. +0 −10 activerecord/lib/active_record/test_case.rb
  123. +0 −2  activerecord/lib/active_record/transactions.rb
  124. +18 −2 activerecord/lib/active_record/validations/uniqueness.rb
  125. +7 −0 activerecord/test/cases/adapters/postgresql/explain_test.rb
  126. +0 −1  activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb
  127. +10 −10 activerecord/test/cases/associations/eager_test.rb
  128. +7 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  129. +0 −137 activerecord/test/cases/associations/identity_map_test.rb
  130. +2 −6 activerecord/test/cases/autosave_association_test.rb
  131. +12 −2 activerecord/test/cases/base_test.rb
  132. +63 −0 activerecord/test/cases/connection_pool_test.rb
  133. +8 −0 activerecord/test/cases/dynamic_finder_match_test.rb
  134. +10 −0 activerecord/test/cases/finder_respond_to_test.rb
  135. +26 −0 activerecord/test/cases/finder_test.rb
  136. +0 −3  activerecord/test/cases/helper.rb
  137. +0 −74 activerecord/test/cases/identity_map/middleware_test.rb
  138. +0 −439 activerecord/test/cases/identity_map_test.rb
  139. +0 −12 activerecord/test/cases/log_subscriber_test.rb
  140. +7 −1 activerecord/test/cases/multiple_db_test.rb
  141. +1 −1  activerecord/test/cases/query_cache_test.rb
  142. +41 −9 activerecord/test/cases/relations_test.rb
  143. +1 −1  activerecord/test/cases/schema_dumper_test.rb
  144. +12 −0 activerecord/test/cases/validations/uniqueness_validation_test.rb
  145. +1 −1  activerecord/test/support/connection.rb
  146. +0 −385 activeresource/CHANGELOG.md
  147. +0 −20 activeresource/MIT-LICENSE
  148. +0 −189 activeresource/README.rdoc
  149. +0 −66 activeresource/Rakefile
  150. +0 −24 activeresource/activeresource.gemspec
  151. +0 −70 activeresource/examples/performance.rb
  152. +0 −45 activeresource/lib/active_resource.rb
  153. +0 −1,515 activeresource/lib/active_resource/base.rb
  154. +0 −284 activeresource/lib/active_resource/connection.rb
  155. +0 −127 activeresource/lib/active_resource/custom_methods.rb
  156. +0 −82 activeresource/lib/active_resource/exceptions.rb
  157. +0 −22 activeresource/lib/active_resource/formats.rb
  158. +0 −25 activeresource/lib/active_resource/formats/json_format.rb
  159. +0 −25 activeresource/lib/active_resource/formats/xml_format.rb
  160. +0 −332 activeresource/lib/active_resource/http_mock.rb
  161. +0 −15 activeresource/lib/active_resource/log_subscriber.rb
  162. +0 −29 activeresource/lib/active_resource/observing.rb
  163. +0 −14 activeresource/lib/active_resource/railtie.rb
  164. +0 −59 activeresource/lib/active_resource/schema.rb
  165. +0 −172 activeresource/lib/active_resource/validations.rb
  166. +0 −10 activeresource/lib/active_resource/version.rb
  167. +0 −143 activeresource/test/abstract_unit.rb
  168. +0 −251 activeresource/test/cases/authorization_test.rb
  169. +0 −101 activeresource/test/cases/base/custom_methods_test.rb
  170. +0 −52 activeresource/test/cases/base/equality_test.rb
  171. +0 −199 activeresource/test/cases/base/load_test.rb
  172. +0 −411 activeresource/test/cases/base/schema_test.rb
  173. +0 −137 activeresource/test/cases/base_errors_test.rb
  174. +0 −1,177 activeresource/test/cases/base_test.rb
  175. +0 −275 activeresource/test/cases/connection_test.rb
  176. +0 −139 activeresource/test/cases/finder_test.rb
  177. +0 −118 activeresource/test/cases/format_test.rb
  178. +0 −202 activeresource/test/cases/http_mock_test.rb
  179. +0 −32 activeresource/test/cases/log_subscriber_test.rb
  180. +0 −55 activeresource/test/cases/observing_test.rb
  181. +0 −67 activeresource/test/cases/validations_test.rb
  182. +0 −19 activeresource/test/fixtures/address.rb
  183. +0 −14 activeresource/test/fixtures/beast.rb
  184. +0 −3  activeresource/test/fixtures/customer.rb
  185. +0 −3  activeresource/test/fixtures/person.rb
  186. +0 −18 activeresource/test/fixtures/project.rb
  187. +0 −4 activeresource/test/fixtures/proxy.rb
  188. +0 −9 activeresource/test/fixtures/sound.rb
  189. +0 −4 activeresource/test/fixtures/street_address.rb
  190. +0 −5 activeresource/test/fixtures/subscription_plan.rb
  191. +0 −26 activeresource/test/setter_trap.rb
  192. +5 −0 activesupport/CHANGELOG.md
  193. +0 −1  activesupport/lib/active_support/basic_object.rb
  194. +1 −0  activesupport/lib/active_support/cache.rb
  195. +9 −7 activesupport/lib/active_support/core_ext/module/delegation.rb
  196. +12 −17 activesupport/lib/active_support/dependencies.rb
  197. +7 −4 activesupport/lib/active_support/dependencies/autoload.rb
  198. +9 −8 activesupport/lib/active_support/file_update_checker.rb
  199. +4 −4 activesupport/lib/active_support/log_subscriber.rb
  200. +3 −4 activesupport/lib/active_support/notifications/fanout.rb
  201. +0 −2  activesupport/lib/active_support/notifications/instrumenter.rb
  202. +1 −26 activesupport/lib/active_support/railtie.rb
  203. +2 −2 activesupport/lib/active_support/tagged_logging.rb
  204. +9 −4 activesupport/lib/active_support/values/time_zone.rb
  205. +4 −0 activesupport/test/caching_test.rb
  206. +1 −1  activesupport/test/core_ext/hash_ext_test.rb
  207. +15 −0 activesupport/test/file_update_checker_test.rb
  208. +11 −6 activesupport/test/time_zone_test.rb
  209. +1 −9 ci/travis.rb
  210. +11 −0 guides/Rakefile
  211. 0  {railties → }/guides/assets/images/belongs_to.png
  212. 0  {railties → }/guides/assets/images/book_icon.gif
  213. 0  {railties → }/guides/assets/images/bullet.gif
  214. 0  {railties → }/guides/assets/images/challenge.png
  215. 0  {railties → }/guides/assets/images/chapters_icon.gif
  216. 0  {railties → }/guides/assets/images/check_bullet.gif
  217. 0  {railties → }/guides/assets/images/credits_pic_blank.gif
  218. 0  {railties → }/guides/assets/images/csrf.png
  219. 0  {railties → }/guides/assets/images/customized_error_messages.png
  220. 0  {railties → }/guides/assets/images/edge_badge.png
  221. 0  {railties → }/guides/assets/images/error_messages.png
  222. 0  {railties → }/guides/assets/images/feature_tile.gif
  223. 0  {railties → }/guides/assets/images/footer_tile.gif
  224. 0  {railties → }/guides/assets/images/fxn.png
  225. 0  {railties → }/guides/assets/images/grey_bullet.gif
  226. 0  {railties → }/guides/assets/images/habtm.png
  227. 0  {railties → }/guides/assets/images/has_many.png
  228. 0  {railties → }/guides/assets/images/has_many_through.png
  229. 0  {railties → }/guides/assets/images/has_one.png
  230. 0  {railties → }/guides/assets/images/has_one_through.png
  231. 0  {railties → }/guides/assets/images/header_backdrop.png
  232. 0  {railties → }/guides/assets/images/header_tile.gif
  233. 0  {railties → }/guides/assets/images/i18n/demo_html_safe.png
  234. 0  {railties → }/guides/assets/images/i18n/demo_localized_pirate.png
  235. 0  {railties → }/guides/assets/images/i18n/demo_translated_en.png
  236. 0  {railties → }/guides/assets/images/i18n/demo_translated_pirate.png
  237. 0  {railties → }/guides/assets/images/i18n/demo_translation_missing.png
  238. 0  {railties → }/guides/assets/images/i18n/demo_untranslated.png
  239. 0  {railties → }/guides/assets/images/icons/README
  240. 0  {railties → }/guides/assets/images/icons/callouts/1.png
  241. 0  {railties → }/guides/assets/images/icons/callouts/10.png
  242. 0  {railties → }/guides/assets/images/icons/callouts/11.png
  243. 0  {railties → }/guides/assets/images/icons/callouts/12.png
  244. 0  {railties → }/guides/assets/images/icons/callouts/13.png
  245. 0  {railties → }/guides/assets/images/icons/callouts/14.png
  246. 0  {railties → }/guides/assets/images/icons/callouts/15.png
  247. 0  {railties → }/guides/assets/images/icons/callouts/2.png
  248. 0  {railties → }/guides/assets/images/icons/callouts/3.png
  249. 0  {railties → }/guides/assets/images/icons/callouts/4.png
  250. 0  {railties → }/guides/assets/images/icons/callouts/5.png
  251. 0  {railties → }/guides/assets/images/icons/callouts/6.png
  252. 0  {railties → }/guides/assets/images/icons/callouts/7.png
  253. 0  {railties → }/guides/assets/images/icons/callouts/8.png
  254. 0  {railties → }/guides/assets/images/icons/callouts/9.png
  255. 0  {railties → }/guides/assets/images/icons/caution.png
  256. 0  {railties → }/guides/assets/images/icons/example.png
  257. 0  {railties → }/guides/assets/images/icons/home.png
  258. 0  {railties → }/guides/assets/images/icons/important.png
  259. 0  {railties → }/guides/assets/images/icons/next.png
  260. 0  {railties → }/guides/assets/images/icons/note.png
  261. 0  {railties → }/guides/assets/images/icons/prev.png
  262. 0  {railties → }/guides/assets/images/icons/tip.png
  263. 0  {railties → }/guides/assets/images/icons/up.png
  264. 0  {railties → }/guides/assets/images/icons/warning.png
  265. 0  {railties → }/guides/assets/images/jaimeiniesta.jpg
  266. 0  {railties → }/guides/assets/images/nav_arrow.gif
  267. 0  {railties → }/guides/assets/images/polymorphic.png
  268. 0  {railties → }/guides/assets/images/posts_index.png
  269. 0  {railties → }/guides/assets/images/radar.png
  270. 0  {railties → }/guides/assets/images/rails_guides_kindle_cover.jpg
  271. 0  {railties → }/guides/assets/images/rails_guides_logo.gif
  272. 0  {railties → }/guides/assets/images/rails_logo_remix.gif
  273. 0  {railties → }/guides/assets/images/rails_welcome.png
  274. 0  {railties → }/guides/assets/images/session_fixation.png
  275. 0  {railties → }/guides/assets/images/tab_grey.gif
  276. 0  {railties → }/guides/assets/images/tab_info.gif
  277. 0  {railties → }/guides/assets/images/tab_note.gif
  278. 0  {railties → }/guides/assets/images/tab_red.gif
  279. 0  {railties → }/guides/assets/images/tab_yellow.gif
  280. 0  {railties → }/guides/assets/images/tab_yellow.png
  281. 0  {railties → }/guides/assets/images/validation_error_messages.png
  282. 0  {railties → }/guides/assets/images/vijaydev.jpg
  283. 0  {railties → }/guides/assets/javascripts/guides.js
  284. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js
  285. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js
  286. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js
  287. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js
  288. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js
  289. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js
  290. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js
  291. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js
  292. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js
  293. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js
  294. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js
  295. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js
  296. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js
  297. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js
  298. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js
  299. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js
  300. 0  {railties → }/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js
Sorry, we could not display the entire diff because too many files (712) changed.
View
2  .gitignore
@@ -19,6 +19,6 @@ debug.log
/railties/test/fixtures/tmp
/railties/test/initializer/root/log
/railties/doc
-/railties/guides/output
/railties/tmp
+/guides/output
/RDOC_MAIN.rdoc
View
4 .travis.yml
@@ -1,9 +1,11 @@
script: 'ci/travis.rb'
+before_install:
+ - gem install bundler
rvm:
- 1.9.3
env:
- "GEM=railties"
- - "GEM=ap,am,amo,ares,as"
+ - "GEM=ap,am,amo,as"
- "GEM=ar:mysql"
- "GEM=ar:mysql2"
- "GEM=ar:sqlite3"
View
4 Gemfile
@@ -8,7 +8,7 @@ else
gem 'arel'
end
-gem 'rack-test', :git => "https://github.com/brynary/rack-test.git"
+gem 'rack-test', :git => "git://github.com/brynary/rack-test.git"
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'jquery-rails'
@@ -22,6 +22,8 @@ end
# it being automatically loaded by sprockets
gem 'uglifier', '>= 1.0.3', :require => false
+gem 'sprockets-rails', :git => "git://github.com/rails/sprockets-rails.git"
+
gem 'rake', '>= 0.8.7'
gem 'mocha', '>= 0.9.8'
View
8 Rakefile
@@ -13,7 +13,7 @@ task :build => "all:build"
desc "Release all gems to gemcutter and create a tag"
task :release => "all:release"
-PROJECTS = %w(activesupport activemodel actionpack actionmailer activeresource activerecord railties)
+PROJECTS = %w(activesupport activemodel actionpack actionmailer activerecord railties)
desc 'Run all tests by default'
task :default => %w(test test:isolated)
@@ -109,11 +109,6 @@ RDoc::Task.new do |rdoc|
rdoc.rdoc_files.include('activerecord/lib/active_record/**/*.rb')
rdoc.rdoc_files.exclude('activerecord/lib/active_record/vendor/*')
- rdoc.rdoc_files.include('activeresource/README.rdoc')
- rdoc.rdoc_files.include('activeresource/CHANGELOG.md')
- rdoc.rdoc_files.include('activeresource/lib/active_resource.rb')
- rdoc.rdoc_files.include('activeresource/lib/active_resource/*')
-
rdoc.rdoc_files.include('actionpack/README.rdoc')
rdoc.rdoc_files.include('actionpack/CHANGELOG.md')
rdoc.rdoc_files.include('actionpack/lib/abstract_controller/**/*.rb')
@@ -157,7 +152,6 @@ task :update_versions do
"activemodel" => "ActiveModel",
"actionpack" => "ActionPack",
"actionmailer" => "ActionMailer",
- "activeresource" => "ActiveResource",
"activerecord" => "ActiveRecord",
"railties" => "Rails"
}
View
10 actionmailer/CHANGELOG.md
@@ -1,6 +1,11 @@
-## Rails 4.0.0 (unreleased) ##
+## Rails 3.2.3 (unreleased) ##
-* No changes
+* Upgrade mail version to 2.4.3 *ML*
+
+
+## Rails 3.2.2 (March 1, 2012) ##
+
+* No changes.
## Rails 3.2.1 (January 26, 2012) ##
@@ -128,6 +133,7 @@
* Mail does not have "quoted_body", "quoted_subject" etc. All of these are accessed via body.encoded, subject.encoded etc
* Every object in a Mail object returns an object, never a string. So Mail.body returns a Mail::Body class object, need to call #encoded or #decoded to get the string you want.
+
* Mail::Message#set_content_type does not exist, it is simply Mail::Message#content_type
* Every mail message gets a unique message_id unless you specify one, had to change all the tests that check for equality with expected.encoded == actual.encoded to first replace their message_ids with control values
View
28 actionmailer/lib/action_mailer/base.rb
@@ -267,6 +267,33 @@ module ActionMailer #:nodoc:
# set something in the defaults using a proc, and then set the same thing inside of your
# mailer method, it will get over written by the mailer method.
#
+ # = Callbacks
+ #
+ # You can specify callbacks using before_filter and after_filter for configuring your messages.
+ # This may be useful, for example, when you want to add default inline attachments for all
+ # messages sent out by a certain mailer class:
+ #
+ # class Notifier < ActionMailer::Base
+ # before_filter :add_inline_attachment!
+ #
+ # def welcome
+ # mail
+ # end
+ #
+ # private
+ #
+ # def add_inline_attachment!
+ # attachments.inline["footer.jpg"] = File.read('/path/to/filename.jpg')
+ # end
+ # end
+ #
+ # Callbacks in ActionMailer are implemented using AbstractController::Callbacks, so you
+ # can define and configure callbacks in the same manner that you would use callbacks in
+ # classes that inherit from ActionController::Base.
+ #
+ # Note that unless you have a specific reason to do so, you should prefer using before_filter
+ # rather than after_filter in your ActionMailer classes so that headers are parsed properly.
+ #
# = Configuration options
#
# These options are specified on the class level, like
@@ -330,6 +357,7 @@ class Base < AbstractController::Base
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
+ include AbstractController::Callbacks
self.protected_instance_variables = [:@_action_has_layout]
View
4 actionmailer/lib/rails/generators/mailer/templates/mailer.rb
@@ -1,6 +1,6 @@
<% module_namespacing do -%>
class <%= class_name %> < ActionMailer::Base
- default <%= key_value :from, '"from@example.com"' %>
+ default from: "from@example.com"
<% actions.each do |action| -%>
# Subject can be set in your I18n file at config/locales/en.yml
@@ -11,7 +11,7 @@ class <%= class_name %> < ActionMailer::Base
def <%= action %>
@greeting = "Hi"
- mail <%= key_value :to, '"to@example.org"' %>
+ mail to: "to@example.org"
end
<% end -%>
end
View
50 actionmailer/test/base_test.rb
@@ -1,5 +1,7 @@
# encoding: utf-8
require 'abstract_unit'
+require 'set'
+
require 'active_support/time'
require 'mailers/base_mailer'
@@ -550,6 +552,52 @@ def self.delivering_email(mail)
assert_equal("Thanks for signing up this afternoon", mail.subject)
end
+ test "modifying the mail message with a before_filter" do
+ class BeforeFilterMailer < ActionMailer::Base
+ before_filter :add_special_header!
+
+ def welcome ; mail ; end
+
+ private
+ def add_special_header!
+ headers('X-Special-Header' => 'Wow, so special')
+ end
+ end
+
+ assert_equal('Wow, so special', BeforeFilterMailer.welcome['X-Special-Header'].to_s)
+ end
+
+ test "modifying the mail message with an after_filter" do
+ class AfterFilterMailer < ActionMailer::Base
+ after_filter :add_special_header!
+
+ def welcome ; mail ; end
+
+ private
+ def add_special_header!
+ headers('X-Special-Header' => 'Testing')
+ end
+ end
+
+ assert_equal('Testing', AfterFilterMailer.welcome['X-Special-Header'].to_s)
+ end
+
+ test "adding an inline attachment using a before_filter" do
+ class DefaultInlineAttachmentMailer < ActionMailer::Base
+ before_filter :add_inline_attachment!
+
+ def welcome ; mail ; end
+
+ private
+ def add_inline_attachment!
+ attachments.inline["footer.jpg"] = 'hey there'
+ end
+ end
+
+ mail = DefaultInlineAttachmentMailer.welcome
+ assert_equal('image/jpeg; filename=footer.jpg', mail.attachments.inline.first['Content-Type'].to_s)
+ end
+
test "action methods should be refreshed after defining new method" do
class FooMailer < ActionMailer::Base
# this triggers action_methods
@@ -559,7 +607,7 @@ def notify
end
end
- assert_equal ["notify"], FooMailer.action_methods
+ assert_equal Set.new(["notify"]), FooMailer.action_methods
end
protected
View
38 actionpack/CHANGELOG.md
@@ -1,12 +1,18 @@
## Rails 4.0.0 (unreleased) ##
-* Adds support for layouts when rendering a partial with a given collection. *serabe*
+* Add `include_hidden` option to select tag. With `:include_hidden => false` select with `multiple` attribute doesn't generate hidden input with blank value. *Vasiliy Ermolovich*
-* Allows the route helper `root` to take a string argument. For example, `root 'pages#main'`. *bcardarella*
+* Removed default `size` option from the `text_field`, `search_field`, `telephone_field`, `url_field`, `email_field` helpers. *Philip Arndt*
-* Forms of persisted records use always PATCH (via the `_method` hack). *fxn*
+* Removed default `cols` and `rows` options from the `text_area` helper. *Philip Arndt*
-* For resources, both PATCH and PUT are routed to the `update` action. *fxn*
+* Adds support for layouts when rendering a partial with a given collection. *serabe*
+
+* Allows the route helper `root` to take a string argument. For example, `root 'pages#main'`. *bcardarella*
+
+* Forms of persisted records use always PATCH (via the `_method` hack). *fxn*
+
+* For resources, both PATCH and PUT are routed to the `update` action. *fxn*
* Don't ignore `force_ssl` in development. This is a change of behavior - use a `:if` condition to recreate the old behavior.
@@ -83,6 +89,9 @@
* check_box with `:form` html5 attribute will now replicate the `:form`
attribute to the hidden field as well. *Carlos Antonio da Silva*
+* Turn off verbose mode of rack-cache, we still have X-Rack-Cache to
+ check that info. Closes #5245. *Santiago Pastorino*
+
* `label` form helper accepts :for => nil to not generate the attribute. *Carlos Antonio da Silva*
* Add `:format` option to number_to_percentage *Rodrigo Flores*
@@ -115,6 +124,23 @@
HTML5 `mark` element. *Brian Cardarella*
+## Rails 3.2.3 (unreleased) ##
+
+* Do not include the authenticity token in forms where remote: true as ajax forms use the meta-tag value *DHH*
+
+* Upgrade rack-cache to 1.2. *José Valim*
+
+* ActionController::SessionManagement is removed. *Santiago Pastorino*
+
+* Since the router holds references to many parts of the system like engines, controllers and the application itself, inspecting the route set can actually be really slow, therefore we default alias inspect to to_s. *José Valim*
+
+* Add a new line after the textarea opening tag. Closes #393 *Rafael Mendonça França*
+
+* Always pass a respond block from to responder. We should let the responder decide what to do with the given overridden response block, and not short circuit it. *Prem Sichanugrist*
+
+* Fixes layout rendering regression from 3.2.2. *José Valim*
+
+
## Rails 3.2.2 (March 1, 2012) ##
* Format lookup for partials is derived from the format in which the template is being rendered. Closes #5025 part 2 *Santiago Pastorino*
@@ -305,6 +331,7 @@
returned by the class method attribute_names will be wrapped. This fixes
the wrapping of nested attributes by adding them to attr_accessible.
+
## Rails 3.1.4 (March 1, 2012) ##
* Skip assets group in Gemfile and all assets configurations options
@@ -321,6 +348,7 @@
* Assets should use the request protocol by default or default to relative if no request is available *Jonathan del Strother*
+
## Rails 3.1.3 (November 20, 2011) ##
* Downgrade sprockets to ~> 2.0.3. Using 2.1.0 caused regressions.
@@ -330,6 +358,7 @@
*Jon Leighton*
+
## Rails 3.1.2 (November 18, 2011) ##
* Fix XSS security vulnerability in the `translate` helper method. When using interpolation
@@ -371,6 +400,7 @@
* Ensure users upgrading from 3.0.x to 3.1.x will properly upgrade their flash object in session (issues #3298 and #2509)
+
## Rails 3.1.1 (October 07, 2011) ##
* javascript_path and stylesheet_path now refer to /assets if asset pipelining
View
1  actionpack/actionpack.gemspec
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
s.add_dependency('rack', '~> 1.4.1')
s.add_dependency('rack-test', '~> 0.6.1')
s.add_dependency('journey', '~> 1.0.1')
- s.add_dependency('sprockets', '~> 2.2.0')
s.add_dependency('erubis', '~> 2.7.0')
s.add_development_dependency('tzinfo', '~> 0.3.29')
View
5 actionpack/lib/abstract_controller/base.rb
@@ -1,4 +1,5 @@
require 'erubis'
+require 'set'
require 'active_support/configurable'
require 'active_support/descendants_tracker'
require 'active_support/core_ext/module/anonymous'
@@ -59,7 +60,7 @@ def hidden_actions
# itself. Finally, #hidden_actions are removed.
#
# ==== Returns
- # * <tt>array</tt> - A list of all methods that should be considered actions.
+ # * <tt>set</tt> - A set of all methods that should be considered actions.
def action_methods
@action_methods ||= begin
# All public instance methods of this class, including ancestors
@@ -72,7 +73,7 @@ def action_methods
hidden_actions.to_a
# Clear out AS callback method pollution
- methods.reject { |method| method =~ /_one_time_conditions/ }
+ Set.new(methods.reject { |method| method =~ /_one_time_conditions/ })
end
end
View
20 actionpack/lib/abstract_controller/layouts.rb
@@ -89,7 +89,7 @@ module AbstractController
# class TillController < BankController
# layout false
#
- # In these examples, we have three implicit lookup scenrios:
+ # In these examples, we have three implicit lookup scenarios:
# * The BankController uses the "bank" layout.
# * The ExchangeController uses the "exchange" layout.
# * The CurrencyController inherits the layout from BankController.
@@ -120,6 +120,7 @@ module AbstractController
# def writers_and_readers
# logged_in? ? "writer_layout" : "reader_layout"
# end
+ # end
#
# Now when a new request for the index action is processed, the layout will vary depending on whether the person accessing
# is logged in or not.
@@ -127,7 +128,14 @@ module AbstractController
# If you want to use an inline method, such as a proc, do something like this:
#
# class WeblogController < ActionController::Base
- # layout proc{ |controller| controller.logged_in? ? "writer_layout" : "reader_layout" }
+ # layout proc { |controller| controller.logged_in? ? "writer_layout" : "reader_layout" }
+ # end
+ #
+ # If an argument isn't given to the proc, it's evaluated in the context of
+ # the current controller anyway.
+ #
+ # class WeblogController < ActionController::Base
+ # layout proc { logged_in? ? "writer_layout" : "reader_layout" }
# end
#
# Of course, the most common way of specifying a layout is still just as a plain template name:
@@ -298,12 +306,12 @@ def _write_layout_method
end
RUBY
when Proc
- define_method :_layout_from_proc, &_layout
- "_layout_from_proc(self)"
+ define_method :_layout_from_proc, &_layout
+ _layout.arity == 0 ? "_layout_from_proc" : "_layout_from_proc(self)"
when false
nil
when true
- raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
+ raise ArgumentError, "Layouts must be specified as a String, Symbol, Proc, false, or nil"
when nil
name_clause
end
@@ -363,7 +371,7 @@ def _layout_for_option(name)
when false, nil then nil
else
raise ArgumentError,
- "String, true, or false, expected for `layout'; you passed #{name.inspect}"
+ "String, Proc, :default, true, or false, expected for `layout'; you passed #{name.inspect}"
end
end
View
1  actionpack/lib/abstract_controller/rendering.rb
@@ -105,6 +105,7 @@ def render_to_body(options = {})
# Find and renders a template based on the options given.
# :api: private
def _render_template(options) #:nodoc:
+ lookup_context.rendered_format = nil if options[:formats]
view_renderer.render(view_context, options)
end
View
6 actionpack/lib/action_controller/base.rb
@@ -171,11 +171,11 @@ module ActionController
class Base < Metal
abstract!
- # Shortcut helper that returns all the ActionController modules except the ones passed in the argument:
+ # Shortcut helper that returns all the ActionController::Base modules except the ones passed in the argument:
#
# class MetalController
- # ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |module|
- # include module
+ # ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left|
+ # include left
# end
# end
#
View
7 actionpack/lib/action_controller/caching/sweeping.rb
@@ -54,6 +54,11 @@ def cache_sweeper(*sweepers)
class Sweeper < ActiveRecord::Observer #:nodoc:
attr_accessor :controller
+ def initialize(*args)
+ super
+ @controller = nil
+ end
+
def before(controller)
self.controller = controller
callback(:before) if controller.perform_caching
@@ -88,7 +93,7 @@ def callback(timing)
end
def method_missing(method, *arguments, &block)
- return unless @controller
+ super unless @controller
@controller.__send__(method, *arguments, &block)
end
end
View
2  actionpack/lib/action_controller/metal/force_ssl.rb
@@ -44,7 +44,7 @@ def force_ssl(options = {})
redirect_options = {:protocol => 'https://', :status => :moved_permanently}
redirect_options.merge!(:host => host) if host
redirect_options.merge!(:params => request.query_parameters)
- flash.keep
+ flash.keep if respond_to?(:flash)
redirect_to redirect_options
end
end
View
1  actionpack/lib/action_controller/metal/helpers.rb
@@ -52,6 +52,7 @@ module ActionController
module Helpers
extend ActiveSupport::Concern
+ class << self; attr_accessor :helpers_path; end
include AbstractController::Helpers
included do
View
8 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -355,8 +355,12 @@ def collect_mimes_from_class_level #:nodoc:
end
end
- # Collects mimes and return the response for the negotiated format. Returns
- # nil if :not_acceptable was sent to the client.
+ # Returns a Collector object containing the appropriate mime-type response
+ # for the current request, based on the available responses defined by a block.
+ # In typical usage this is the block passed to +respond_with+ or +respond_to+.
+ #
+ # Sends :not_acceptable to the client and returns nil if no suitable format
+ # is available.
#
def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
mimes ||= collect_mimes_from_class_level
View
2  actionpack/lib/action_controller/metal/redirecting.rb
@@ -93,7 +93,7 @@ def _compute_redirect_to_location(options)
_compute_redirect_to_location options.call
else
url_for(options)
- end.gsub(/[\r\n]/, '')
+ end.gsub(/[\0\r\n]/, '')
end
end
end
View
20 actionpack/lib/action_controller/metal/request_forgery_protection.rb
@@ -37,6 +37,10 @@ module RequestForgeryProtection
config_accessor :request_forgery_protection_token
self.request_forgery_protection_token ||= :authenticity_token
+ # Controls how unverified request will be handled
+ config_accessor :request_forgery_protection_method
+ self.request_forgery_protection_method ||= :reset_session
+
# Controls whether request forgery protection is turned on or not. Turned off by default only in test mode.
config_accessor :allow_forgery_protection
self.allow_forgery_protection = true if allow_forgery_protection.nil?
@@ -64,8 +68,10 @@ module ClassMethods
# Valid Options:
#
# * <tt>:only/:except</tt> - Passed to the <tt>before_filter</tt> call. Set which actions are verified.
+ # * <tt>:with</tt> - Set the method to handle unverified request. Valid values: <tt>:exception</tt> and <tt>:reset_session</tt> (default).
def protect_from_forgery(options = {})
self.request_forgery_protection_token ||= :authenticity_token
+ self.request_forgery_protection_method = options.delete(:with) if options.key?(:with)
prepend_before_filter :verify_authenticity_token, options
end
end
@@ -80,9 +86,19 @@ def verify_authenticity_token
end
# This is the method that defines the application behavior when a request is found to be unverified.
- # By default, \Rails resets the session when it finds an unverified request.
+ # By default, \Rails uses <tt>request_forgery_protection_method</tt> when it finds an unverified request:
+ #
+ # * <tt>:reset_session</tt> - Resets the session.
+ # * <tt>:exception</tt>: - Raises ActionController::InvalidAuthenticityToken exception.
def handle_unverified_request
- reset_session
+ case request_forgery_protection_method
+ when :exception
+ raise ActionController::InvalidAuthenticityToken
+ when :reset_session
+ reset_session
+ else
+ raise ArgumentError, 'Invalid request forgery protection method, use :exception or :reset_session'
+ end
end
# Returns true or false if a request is verified. Checks:
View
31 actionpack/lib/action_controller/railtie.rb
@@ -3,33 +3,32 @@
require "action_dispatch/railtie"
require "action_view/railtie"
require "abstract_controller/railties/routes_helpers"
-require "action_controller/railties/paths"
+require "action_controller/railties/helpers"
module ActionController
class Railtie < Rails::Railtie #:nodoc:
config.action_controller = ActiveSupport::OrderedOptions.new
- initializer "action_controller.logger" do
- ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
- end
-
- initializer "action_controller.initialize_framework_caches" do
- ActiveSupport.on_load(:action_controller) { self.cache_store ||= Rails.cache }
- end
-
initializer "action_controller.assets_config", :group => :all do |app|
app.config.action_controller.assets_dir ||= app.config.paths["public"].first
end
+ initializer "action_controller.set_helpers_path" do |app|
+ ActionController::Helpers.helpers_path = app.helpers_paths
+ end
+
initializer "action_controller.set_configs" do |app|
paths = app.config.paths
options = app.config.action_controller
+ options.logger ||= Rails.logger
+ options.cache_store ||= Rails.cache
+
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
options.page_cache_directory ||= paths["public"].first
- # make sure readers methods get compiled
+ # Ensure readers methods get compiled
options.asset_path ||= app.config.asset_path
options.asset_host ||= app.config.asset_host
options.relative_url_root ||= app.config.relative_url_root
@@ -37,8 +36,16 @@ class Railtie < Rails::Railtie #:nodoc:
ActiveSupport.on_load(:action_controller) do
include app.routes.mounted_helpers
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
- extend ::ActionController::Railties::Paths.with(app)
- options.each { |k,v| send("#{k}=", v) }
+ extend ::ActionController::Railties::Helpers
+
+ options.each do |k,v|
+ k = "#{k}="
+ if respond_to?(k)
+ send(k, v)
+ elsif !Base.respond_to?(k)
+ raise "Invalid option key: #{k}"
+ end
+ end
end
end
View
22 actionpack/lib/action_controller/railties/helpers.rb
@@ -0,0 +1,22 @@
+module ActionController
+ module Railties
+ module Helpers
+ def inherited(klass)
+ super
+ return unless klass.respond_to?(:helpers_path=)
+
+ if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) }
+ paths = namespace.railtie_helpers_paths
+ else
+ paths = ActionController::Helpers.helpers_path
+ end
+
+ klass.helpers_path = paths
+
+ if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
+ klass.helper :all
+ end
+ end
+ end
+ end
+end
View
25 actionpack/lib/action_controller/railties/paths.rb
@@ -1,25 +0,0 @@
-module ActionController
- module Railties
- module Paths
- def self.with(app)
- Module.new do
- define_method(:inherited) do |klass|
- super(klass)
-
- if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) }
- paths = namespace.railtie_helpers_paths
- else
- paths = app.helpers_paths
- end
-
- klass.helpers_path = paths
-
- if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
- klass.helper :all
- end
- end
- end
- end
- end
- end
-end
View
4 actionpack/lib/action_controller/record_identifier.rb
@@ -2,8 +2,8 @@
module ActionController
# The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or
- # Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate
- # the view actions to a higher logical level. Example:
+ # pretty much any other model type that has an id. These patterns are then used to try elevate the view actions to
+ # a higher logical level. Example:
#
# # routes
# resources :posts
View
14 actionpack/lib/action_controller/test_case.rb
@@ -56,6 +56,9 @@ def process(*args)
# # assert that the "new" view template was rendered
# assert_template "new"
#
+ # # assert that the exact template "admin/posts/new" was rendered
+ # assert_template %r{\Aadmin/posts/new\Z}
+ #
# # assert that the "_customer" partial was rendered twice
# assert_template :partial => '_customer', :count => 2
#
@@ -74,11 +77,11 @@ def assert_template(options = {}, message = nil)
response.body
case options
- when NilClass, String, Symbol
+ when NilClass, String, Symbol, Regexp
options = options.to_s if Symbol === options
rendered = @templates
msg = message || sprintf("expecting <%s> but rendering with <%s>",
- options, rendered.keys)
+ options.inspect, rendered.keys)
assert_block(msg) do
if options
rendered.any? { |t,num| t.match(options) }
@@ -121,6 +124,8 @@ def assert_template(options = {}, message = nil)
assert @partials.empty?,
"Expected no partials to be rendered"
end
+ else
+ raise ArgumentError, "assert_template only accepts a String, Symbol, Hash, Regexp, or nil"
end
end
end
@@ -500,11 +505,6 @@ def setup_controller_request_and_response
end
end
- # Cause the action to be rescued according to the regular rules for rescue_action when the visitor is not local
- def rescue_action_in_public!
- @request.remote_addr = '208.77.188.166' # example.com
- end
-
included do
include ActionController::TemplateAssertions
include ActionDispatch::Assertions
View
9 actionpack/lib/action_dispatch/http/response.rb
@@ -51,12 +51,13 @@ class Response
# If a character set has been defined for this response (see charset=) then
# the character set information will also be included in the content type
# information.
- attr_accessor :charset, :content_type
+ attr_accessor :charset
+ attr_reader :content_type
CONTENT_TYPE = "Content-Type".freeze
SET_COOKIE = "Set-Cookie".freeze
LOCATION = "Location".freeze
-
+
cattr_accessor(:default_charset) { "utf-8" }
include Rack::Response::Helpers
@@ -83,6 +84,10 @@ def status=(status)
@status = Rack::Utils.status_code(status)
end
+ def content_type=(content_type)
+ @content_type = content_type.to_s
+ end
+
# The response code of the request
def response_code
@status
View
1  actionpack/lib/action_dispatch/middleware/static.rb
@@ -39,6 +39,7 @@ def unescape_path(path)
end
def escape_glob_chars(path)
+ path.force_encoding('binary') if path.respond_to? :force_encoding
path.gsub(/[*?{}\[\]]/, "\\\\\\&")
end
end
View
2  actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1,6 +1,6 @@
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/object/blank'
-require 'active_support/core_ext/object/inclusion'
+require 'active_support/core_ext/enumerable'
require 'active_support/inflector'
require 'action_dispatch/routing/redirection'
View
2  actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -83,7 +83,7 @@ def normalize_argument_to_redirection(fragment)
refer
else
@controller.url_for(fragment)
- end.gsub(/[\r\n]/, '')
+ end.gsub(/[\0\r\n]/, '')
end
end
end
View
28 actionpack/lib/action_view/helpers/form_helper.rb
@@ -56,10 +56,10 @@ module Helpers
# <input name="authenticity_token" type="hidden" value="NrOp5bsjoLRuK8IW5+dQEYjKGUJDe7TQoZVvq95Wteg=" />
# </div>
# <label for="person_first_name">First name</label>:
- # <input id="person_first_name" name="person[first_name]" size="30" type="text" /><br />
+ # <input id="person_first_name" name="person[first_name]" type="text" /><br />
#
# <label for="person_last_name">Last name</label>:
- # <input id="person_last_name" name="person[last_name]" size="30" type="text" /><br />
+ # <input id="person_last_name" name="person[last_name]" type="text" /><br />
#
# <input name="commit" type="submit" value="Create Person" />
# </form>
@@ -87,10 +87,10 @@ module Helpers
# <input name="authenticity_token" type="hidden" value="NrOp5bsjoLRuK8IW5+dQEYjKGUJDe7TQoZVvq95Wteg=" />
# </div>
# <label for="person_first_name">First name</label>:
- # <input id="person_first_name" name="person[first_name]" size="30" type="text" value="John" /><br />
+ # <input id="person_first_name" name="person[first_name]" type="text" value="John" /><br />
#
# <label for="person_last_name">Last name</label>:
- # <input id="person_last_name" name="person[last_name]" size="30" type="text" value="Smith" /><br />
+ # <input id="person_last_name" name="person[last_name]" type="text" value="Smith" /><br />
#
# <input name="commit" type="submit" value="Update Person" />
# </form>
@@ -932,20 +932,20 @@ def radio_button(object_name, method, tag_value, options = {})
# ==== Examples
#
# search_field(:user, :name)
- # # => <input id="user_name" name="user[name]" size="30" type="search" />
+ # # => <input id="user_name" name="user[name]" type="search" />
# search_field(:user, :name, :autosave => false)
- # # => <input autosave="false" id="user_name" name="user[name]" size="30" type="search" />
+ # # => <input autosave="false" id="user_name" name="user[name]" type="search" />
# search_field(:user, :name, :results => 3)
- # # => <input id="user_name" name="user[name]" results="3" size="30" type="search" />
+ # # => <input id="user_name" name="user[name]" results="3" type="search" />
# # Assume request.host returns "www.example.com"
# search_field(:user, :name, :autosave => true)
- # # => <input autosave="com.example.www" id="user_name" name="user[name]" results="10" size="30" type="search" />
+ # # => <input autosave="com.example.www" id="user_name" name="user[name]" results="10" type="search" />
# search_field(:user, :name, :onsearch => true)
- # # => <input id="user_name" incremental="true" name="user[name]" onsearch="true" size="30" type="search" />
+ # # => <input id="user_name" incremental="true" name="user[name]" onsearch="true" type="search" />
# search_field(:user, :name, :autosave => false, :onsearch => true)
- # # => <input autosave="false" id="user_name" incremental="true" name="user[name]" onsearch="true" size="30" type="search" />
+ # # => <input autosave="false" id="user_name" incremental="true" name="user[name]" onsearch="true" type="search" />
# search_field(:user, :name, :autosave => true, :onsearch => true)
- # # => <input autosave="com.example.www" id="user_name" incremental="true" name="user[name]" onsearch="true" results="10" size="30" type="search" />
+ # # => <input autosave="com.example.www" id="user_name" incremental="true" name="user[name]" onsearch="true" results="10" type="search" />
#
def search_field(object_name, method, options = {})
Tags::SearchField.new(object_name, method, self, options).render
@@ -954,7 +954,7 @@ def search_field(object_name, method, options = {})
# Returns a text_field of type "tel".
#
# telephone_field("user", "phone")
- # # => <input id="user_phone" name="user[phone]" size="30" type="tel" />
+ # # => <input id="user_phone" name="user[phone]" type="tel" />
#
def telephone_field(object_name, method, options = {})
Tags::TelField.new(object_name, method, self, options).render
@@ -982,7 +982,7 @@ def date_field(object_name, method, options = {})
# Returns a text_field of type "url".
#
# url_field("user", "homepage")
- # # => <input id="user_homepage" size="30" name="user[homepage]" type="url" />
+ # # => <input id="user_homepage" name="user[homepage]" type="url" />
#
def url_field(object_name, method, options = {})
Tags::UrlField.new(object_name, method, self, options).render
@@ -991,7 +991,7 @@ def url_field(object_name, method, options = {})
# Returns a text_field of type "email".
#
# email_field("user", "address")
- # # => <input id="user_address" size="30" name="user[address]" type="email" />
+ # # => <input id="user_address" name="user[address]" type="email" />
#
def email_field(object_name, method, options = {})
Tags::EmailField.new(object_name, method, self, options).render
View
2  actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -153,6 +153,8 @@ module FormOptionsHelper
# form, and parameters extraction gets the last occurrence of any repeated
# key in the query string, that works for ordinary forms.
#
+ # In case if you don't want the helper to generate this hidden field you can specify <tt>:include_blank => false</tt> option.
+ #
def select(object, method, choices, options = {}, html_options = {})
Tags::Select.new(object, method, self, choices, options, html_options).render
end
View
15 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -27,7 +27,9 @@ module FormTagHelper
# is added to simulate the verb over post.
# * <tt>:authenticity_token</tt> - Authenticity token to use in the form. Use only if you need to
# pass custom authenticity token string, or to not add authenticity_token field at all
- # (by passing <tt>false</tt>).
+ # (by passing <tt>false</tt>). If this is a remote form, the authenticity_token will by default
+ # not be included as the ajax handler will get it from the meta-tag (but you can force it to be
+ # rendered anyway in that case by passing <tt>true</tt>).
# * A list of parameters to feed to the URL the form will be posted to.
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
# submit behavior. By default this behavior is an ajax submit.
@@ -616,8 +618,17 @@ def html_options_for_form(url_for_options, options)
# responsibility of the caller to escape all the values.
html_options["action"] = url_for(url_for_options)
html_options["accept-charset"] = "UTF-8"
+
html_options["data-remote"] = true if html_options.delete("remote")
- html_options["authenticity_token"] = html_options.delete("authenticity_token") if html_options.has_key?("authenticity_token")
+
+ if html_options["data-remote"] && html_options["authenticity_token"] == true
+ # Include the default authenticity_token, which is only generated when its set to nil,
+ # but we needed the true value to override the default of no authenticity_token on data-remote.
+ html_options["authenticity_token"] = nil
+ elsif html_options["data-remote"]
+ # The authenticity token is taken from the meta tag in this case
+ html_options["authenticity_token"] = false
+ end
end
end
View
4 actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -14,6 +14,8 @@ module JavaScriptHelper
}
JS_ESCAPE_MAP["\342\200\250".force_encoding('UTF-8').encode!] = '&#x2028;'
+ JS_ESCAPE_MAP["\342\200\251".force_encoding('UTF-8').encode!] = '&#x2029;'
+
# Escapes carriage returns and single and double quotes for JavaScript segments.
#
@@ -22,7 +24,7 @@ module JavaScriptHelper
# $('some_element').replaceWith('<%=j render 'some/element_template' %>');
def escape_javascript(javascript)
if javascript
- result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] }
+ result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] }
javascript.html_safe? ? result.html_safe : result
else
''
View
5 actionpack/lib/action_view/helpers/tags/base.rb
@@ -5,8 +5,6 @@ class Base #:nodoc:
include Helpers::ActiveModelInstanceTag, Helpers::TagHelper, Helpers::FormTagHelper
include FormOptionsHelper
- DEFAULT_FIELD_OPTIONS = { "size" => 30 }
-
attr_reader :object
def initialize(object_name, method_name, template_object, options = {})
@@ -124,7 +122,8 @@ def select_content_tag(option_tags, options, html_options)
html_options = html_options.stringify_keys
add_default_name_and_id(html_options)
select = content_tag("select", add_options(option_tags, options, value(object)), html_options)
- if html_options["multiple"]
+
+ if html_options["multiple"] && options.fetch(:include_hidden) { true }
tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select
else
select
View
10 actionpack/lib/action_view/helpers/tags/check_box.rb
@@ -25,9 +25,15 @@ def render
add_default_name_and_id(options)
end
- hidden = hidden_field_for_checkbox(options)
+ include_hidden = options.delete("include_hidden") { true }
checkbox = tag("input", options)
- hidden + checkbox
+
+ if include_hidden
+ hidden = hidden_field_for_checkbox(options)
+ hidden + checkbox
+ else
+ checkbox
+ end
end
private
View
4 actionpack/lib/action_view/helpers/tags/text_area.rb
@@ -2,10 +2,8 @@ module ActionView
module Helpers
module Tags
class TextArea < Base #:nodoc:
- DEFAULT_TEXT_AREA_OPTIONS = { "cols" => 40, "rows" => 20 }
-
def render
- options = DEFAULT_TEXT_AREA_OPTIONS.merge(@options.stringify_keys)
+ options = @options.stringify_keys
add_default_name_and_id(options)
if size = options.delete("size")
View
3  actionpack/lib/action_view/helpers/tags/text_field.rb
@@ -4,8 +4,7 @@ module Tags
class TextField < Base #:nodoc:
def render
options = @options.stringify_keys
- options["size"] = options["maxlength"] || DEFAULT_FIELD_OPTIONS["size"] unless options.key?("size")
- options = DEFAULT_FIELD_OPTIONS.merge(options)
+ options["size"] = options["maxlength"] unless options.key?("size")
options["type"] ||= field_type
options["value"] = options.fetch("value"){ value_before_type_cast(object) } unless field_type == "file"
options["value"] &&= ERB::Util.html_escape(options["value"])
View
2  actionpack/lib/action_view/helpers/url_helper.rb
@@ -60,7 +60,7 @@ def optimize_routes_generation? #:nodoc:
#
# ==== Relying on named routes
#
- # Passing a record (like an Active Record or Active Resource) instead of a Hash as the options parameter will
+ # Passing a record (like an Active Record) instead of a Hash as the options parameter will
# trigger the named route for that record. The lookup will happen on the name of the class. So passing a
# Workshop object will attempt to use the +workshop_path+ route. If you have a nested route, such as
# +admin_workshop_path+ you'll have to call that explicitly (it's impossible for +url_for+ to guess that route).
View
8 actionpack/lib/action_view/template/resolver.rb
@@ -176,7 +176,7 @@ def extract_handler_and_format(path, default_formats)
end
end
- # A resolver that loads files from the filesystem. It allows to set your own
+ # A resolver that loads files from the filesystem. It allows setting your own
# resolving pattern. Such pattern can be a glob string supported by some variables.
#
# ==== Examples
@@ -192,7 +192,7 @@ def extract_handler_and_format(path, default_formats)
#
# FileSystemResolver.new("/path/to/views", ":prefix/{:formats/,}:action{.:locale,}{.:formats,}{.:handlers,}")
#
- # If you don't specify pattern then the default will be used.
+ # If you don't specify a pattern then the default will be used.
#
# In order to use any of the customized resolvers above in a Rails application, you just need
# to configure ActionController::Base.view_paths in an initializer, for example:
@@ -204,10 +204,10 @@ def extract_handler_and_format(path, default_formats)
#
# ==== Pattern format and variables
#
- # Pattern have to be a valid glob string, and it allows you to use the
+ # Pattern has to be a valid glob string, and it allows you to use the
# following variables:
#
- # * <tt>:prefix</tt> - usualy the controller path
+ # * <tt>:prefix</tt> - usually the controller path
# * <tt>:action</tt> - name of the action
# * <tt>:locale</tt> - possible locale versions
# * <tt>:formats</tt> - possible request formats (for example html, json, xml...)
View
105 actionpack/lib/sprockets/assets.rake
@@ -1,105 +0,0 @@
-require "fileutils"
-
-namespace :assets do
- def ruby_rake_task(task, fork = true)
- env = ENV['RAILS_ENV'] || 'production'
- groups = ENV['RAILS_GROUPS'] || 'assets'
- args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"]
- args << "--trace" if Rake.application.options.trace
- if $0 =~ /rake\.bat\Z/i
- Kernel.exec $0, *args
- else
- fork ? ruby(*args) : Kernel.exec(FileUtils::RUBY, *args)
- end
- end
-
- # We are currently running with no explicit bundler group
- # and/or no explicit environment - we have to reinvoke rake to
- # execute this task.
- def invoke_or_reboot_rake_task(task)
- if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
- ruby_rake_task task
- else
- Rake::Task[task].invoke
- end
- end
-
- desc "Compile all the assets named in config.assets.precompile"
- task :precompile do
- invoke_or_reboot_rake_task "assets:precompile:all"
- end
-
- namespace :precompile do
- def internal_precompile(digest=nil)
- unless Rails.application.config.assets.enabled
- warn "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
- exit
- end
-
- # Ensure that action view is loaded and the appropriate
- # sprockets hooks get executed
- _ = ActionView::Base
-
- config = Rails.application.config
- config.assets.compile = true
- config.assets.digest = digest unless digest.nil?
- config.assets.digests = {}
-
- env = Rails.application.assets
- target = File.join(Rails.public_path, config.assets.prefix)
- compiler = Sprockets::StaticCompiler.new(env,
- target,
- config.assets.precompile,
- :manifest_path => config.assets.manifest,
- :digest => config.assets.digest,
- :manifest => digest.nil?)
- compiler.compile
- end
-
- task :all do
- Rake::Task["assets:precompile:primary"].invoke
- # We need to reinvoke in order to run the secondary digestless
- # asset compilation run - a fresh Sprockets environment is
- # required in order to compile digestless assets as the
- # environment has already cached the assets on the primary
- # run.
- ruby_rake_task("assets:precompile:nondigest", false) if Rails.application.config.assets.digest
- end
-
- task :primary => ["assets:cache:clean"] do
- internal_precompile
- end
-
- task :nondigest => ["assets:cache:clean"] do
- internal_precompile(false)
- end
- end
-
- desc "Remove compiled assets"
- task :clean do
- invoke_or_reboot_rake_task "assets:clean:all"
- end
-
- namespace :clean do
- task :all => ["assets:cache:clean"] do
- config = Rails.application.config
- public_asset_path = File.join(Rails.public_path, config.assets.prefix)
- rm_rf public_asset_path, :secure => true
- end
- end
-
- namespace :cache do
- task :clean => ["assets:environment"] do
- Rails.application.assets.cache.clear
- end
- end
-
- task :environment do
- if Rails.application.config.assets.initialize_on_precompile
- Rake::Task["environment"].invoke
- else
- Rails.application.initialize!(:assets)
- Sprockets::Bootstrap.new(Rails.application).run
- end
- end
-end
View
37 actionpack/lib/sprockets/bootstrap.rb
@@ -1,37 +0,0 @@
-module Sprockets
- class Bootstrap
- def initialize(app)
- @app = app
- end
-
- # TODO: Get rid of config.assets.enabled
- def run
- app, config = @app, @app.config
- return unless app.assets
-
- config.assets.paths.each { |path| app.assets.append_path(path) }
-
- if config.assets.compress
- # temporarily hardcode default JS compressor to uglify. Soon, it will work
- # the same as SCSS, where a default plugin sets the default.
- unless config.assets.js_compressor == false
- app.assets.js_compressor = LazyCompressor.new { Sprockets::Compressors.registered_js_compressor(config.assets.js_compressor || :uglifier) }
- end
-
- unless config.assets.css_compressor == false
- app.assets.css_compressor = LazyCompressor.new { Sprockets::Compressors.registered_css_compressor(config.assets.css_compressor) }
- end
- end
-
- if config.assets.compile
- app.routes.prepend do
- mount app.assets => config.assets.prefix
- end
- end
-
- if config.assets.digest
- app.assets = app.assets.index
- end
- end
- end
-end
View
85 actionpack/lib/sprockets/compressors.rb
@@ -1,85 +0,0 @@
-module Sprockets
- module Compressors
- extend self
-
- @@css_compressors = {}
- @@js_compressors = {}
- @@default_css_compressor = nil
- @@default_js_compressor = nil
-
- def register_css_compressor(name, klass, options = {})
- @@default_css_compressor = name.to_sym if options[:default] || @@default_css_compressor.nil?
- @@css_compressors[name.to_sym] = { :klass => klass.to_s, :require => options[:require] }
- end
-
- def register_js_compressor(name, klass, options = {})
- @@default_js_compressor = name.to_sym if options[:default] || @@default_js_compressor.nil?
- @@js_compressors[name.to_sym] = { :klass => klass.to_s, :require => options[:require] }
- end
-
- def registered_css_compressor(name)
- find_registered_compressor name, @@css_compressors, @@default_css_compressor
- end
-
- def registered_js_compressor(name)
- find_registered_compressor name, @@js_compressors, @@default_js_compressor
- end
-
- # The default compressors must be registered in default plugins (ex. Sass-Rails)
- register_css_compressor(:scss, 'Sass::Rails::Compressor', :require => 'sass/rails/compressor', :default => true)
- register_js_compressor(:uglifier, 'Uglifier', :require => 'uglifier', :default => true)
-
- # Automaticaly register some compressors
- register_css_compressor(:yui, 'YUI::CssCompressor', :require => 'yui/compressor')
- register_js_compressor(:closure, 'Closure::Compiler', :require => 'closure-compiler')
- register_js_compressor(:yui, 'YUI::JavaScriptCompressor', :require => 'yui/compressor')
-
- private
-
- def find_registered_compressor(name, compressors_hash, default_compressor_name)
- if name.respond_to?(:to_sym)
- compressor = compressors_hash[name.to_sym] || compressors_hash[default_compressor_name]
- require compressor[:require] if compressor[:require]
- compressor[:klass].constantize.new
- else
- name
- end
- end
- end
-
- # 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
-
- # 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 compress(content)
- compressor.compress(content)
- end
-
- private
-
- def compressor
- @compressor ||= (@block.call || NullCompressor.new)
- end
- end
-end
View
6 actionpack/lib/sprockets/helpers.rb
@@ -1,6 +0,0 @@
-module Sprockets
- module Helpers
- autoload :RailsHelper, "sprockets/helpers/rails_helper"
- autoload :IsolatedHelper, "sprockets/helpers/isolated_helper"
- end
-end
View
13 actionpack/lib/sprockets/helpers/isolated_helper.rb
@@ -1,13 +0,0 @@
-module Sprockets
- module Helpers
- module IsolatedHelper
- def controller
- nil
- end
-
- def config
- Rails.application.config.action_controller
- end
- end
- end
-end
View
167 actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -1,167 +0,0 @@
-require "action_view"
-
-module Sprockets
- module Helpers
- module RailsHelper
- extend ActiveSupport::Concern
- include ActionView::Helpers::AssetTagHelper
-
- def asset_paths
- @asset_paths ||= begin
- paths = RailsHelper::AssetPaths.new(config, controller)
- paths.asset_environment = asset_environment
- paths.asset_digests = asset_digests
- paths.compile_assets = compile_assets?
- paths.digest_assets = digest_assets?
- paths
- end
- end
-
- def javascript_include_tag(*sources)
- options = sources.extract_options!
- debug = options.delete(:debug) { debug_assets? }
- body = options.delete(:body) { false }
- digest = options.delete(:digest) { digest_assets? }
-
- sources.collect do |source|
- if debug && asset = asset_paths.asset_for(source, 'js')
- asset.to_a.map { |dep|
- super(dep.pathname.to_s, { :src => path_to_asset(dep, :ext => 'js', :body => true, :digest => digest) }.merge!(options))
- }
- else
- super(source.to_s, { :src => path_to_asset(source, :ext => 'js', :body => body, :digest => digest) }.merge!(options))
- end
- end.join("\n").html_safe
- end
-
- def stylesheet_link_tag(*sources)
- options = sources.extract_options!
- debug = options.delete(:debug) { debug_assets? }
- body = options.delete(:body) { false }
- digest = options.delete(:digest) { digest_assets? }
-
- sources.collect do |source|
- if debug && asset = asset_paths.asset_for(source, 'css')
- asset.to_a.map { |dep|
- super(dep.pathname.to_s, { :href => path_to_asset(dep, :ext => 'css', :body => true, :protocol => :request, :digest => digest) }.merge!(options))
- }
- else
- super(source.to_s, { :href => path_to_asset(source, :ext => 'css', :body => body, :protocol => :request, :digest => digest) }.merge!(options))
- end
- end.join("\n").html_safe
- end
-
- def asset_path(source, options = {})
- source = source.logical_path if source.respond_to?(:logical_path)
- path = asset_paths.compute_public_path(source, asset_prefix, options.merge(:body => true))
- options[:body] ? "#{path}?body=1" : path
- end
- alias_method :path_to_asset, :asset_path # aliased to avoid conflicts with an asset_path named route
-
- def image_path(source)
- path_to_asset(source)
- end
- alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route
-
- def font_path(source)
- path_to_asset(source)
- end
- alias_method :path_to_font, :font_path # aliased to avoid conflicts with an font_path named route
-
- def javascript_path(source)
- path_to_asset(source, :ext => 'js')
- end
- alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with an javascript_path named route
-
- def stylesheet_path(source)
- path_to_asset(source, :ext => 'css')
- end
- alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with an stylesheet_path named route
-
- private
- def debug_assets?
- compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets])
- rescue NoMethodError
- false
- end
-
- # Override to specify an alternative prefix for asset path generation.
- # When combined with a custom +asset_environment+, this can be used to
- # implement themes that can take advantage of the asset pipeline.
- #
- # If you only want to change where the assets are mounted, refer to
- # +config.assets.prefix+ instead.
- def asset_prefix
- Rails.application.config.assets.prefix
- end
-
- def asset_digests
- Rails.application.config.assets.digests
- end
-
- def compile_assets?
- Rails.application.config.assets.compile
- end
-
- def digest_assets?
- Rails.application.config.assets.digest
- end
-
- # Override to specify an alternative asset environment for asset
- # path generation. The environment should already have been mounted
- # at the prefix returned by +asset_prefix+.
- def asset_environment
- Rails.application.assets
- end
-
- class AssetPaths < ::ActionView::AssetPaths #:nodoc:
- attr_accessor :asset_environment, :asset_prefix, :asset_digests, :compile_assets, :digest_assets
-
- class AssetNotPrecompiledError < StandardError; end
-
- def asset_for(source, ext)
- source = source.to_s
- return nil if is_uri?(source)
- source = rewrite_extension(source, nil, ext)
- asset_environment[source]
- rescue Sprockets::FileOutsidePaths
- nil
- end
-
- def digest_for(logical_path)
- if digest_assets && asset_digests && (digest = asset_digests[logical_path])
- return digest
- end
-
- if compile_assets
- if digest_assets && asset = asset_environment[logical_path]
- return asset.digest_path
- end
- return logical_path
- else
- raise AssetNotPrecompiledError.new("#{logical_path} isn't precompiled")
- end
- end
-
- def rewrite_asset_path(source, dir, options = {})
- if source[0] == ?/
- source
- else
- source = digest_for(source) unless options[:digest] == false
- source = File.join(dir, source)
- source = "/#{source}" unless source =~ /^\//
- source
- end
- end
-
- def rewrite_extension(source, dir, ext)
- if ext && File.extname(source) != ".#{ext}"
- "#{source}.#{ext}"
- else
- source
- end
- end
- end
- end
- end
-end
View
62 actionpack/lib/sprockets/railtie.rb
@@ -1,62 +0,0 @@
-require "action_controller/railtie"
-
-module Sprockets
- autoload :Bootstrap, "sprockets/bootstrap"
- autoload :Helpers, "sprockets/helpers"
- autoload :Compressors, "sprockets/compressors"
- autoload :LazyCompressor, "sprockets/compressors"
- autoload :NullCompressor, "sprockets/compressors"
- autoload :StaticCompiler, "sprockets/static_compiler"
-
- # TODO: Get rid of config.assets.enabled
- class Railtie < ::Rails::Railtie
- rake_tasks do
- load "sprockets/assets.rake"
- end
-
- initializer "sprockets.environment", :group => :all do |app|
- config = app.config
- next unless config.assets.enabled
-
- require 'sprockets'
-
- app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
- env.version = ::Rails.env + "-#{config.assets.version}"
-
- if config.assets.logger != false
- env.logger = config.assets.logger || ::Rails.logger
- end
-
- if config.assets.cache_store != false
- env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache
- end
- end
-
- if config.assets.manifest
- path = File.join(config.assets.manifest, "manifest.yml")
- else
- path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")
- end
-
- if File.exist?(path)
- config.assets.digests = YAML.load_file(path)
- end
-
- ActiveSupport.on_load(:action_view) do
- include ::Sprockets::Helpers::RailsHelper
- app.assets.context_class.instance_eval do
- include ::Sprockets::Helpers::IsolatedHelper
- include ::Sprockets::Helpers::RailsHelper
- end
- end
- end
-
- # We need to configure this after initialization to ensure we collect
- # paths from all engines. This hook is invoked exactly before routes
- # are compiled, and so that other Railties have an opportunity to
- # register compressors.
- config.after_initialize do |app|
- Sprockets::Bootstrap.new(app).run
- end
- end
-end
View
62 actionpack/lib/sprockets/static_compiler.rb
@@ -1,62 +0,0 @@
-require 'fileutils'
-
-module Sprockets
- class StaticCompiler
- attr_accessor :env, :target, :paths
-
- def initialize(env, target, paths, options = {})
- @env = env
- @target = target
- @paths = paths
- @digest = options.fetch(:digest, true)
- @manifest = options.fetch(:manifest, true)
- @manifest_path = options.delete(:manifest_path) || target
- @zip_files = options.delete(:zip_files) || /\.(?:css|html|js|svg|txt|xml)$/
- end
-
- def compile
- manifest = {}
- env.each_logical_path do |logical_path|
- next unless compile_path?(logical_path)
- if asset = env.find_asset(logical_path)
- manifest[logical_path] = write_asset(asset)
- end
- end
- write_manifest(manifest) if @manifest
- end
-
- def write_manifest(manifest)
- FileUtils.mkdir_p(@manifest_path)
- File.open("#{@manifest_path}/manifest.yml", 'wb') do |f|
- YAML.dump(manifest, f)
- end
- end
-
- def write_asset(asset)
- path_for(asset).tap do |path|
- filename = File.join(target, path)
- FileUtils.mkdir_p File.dirname(filename)
- asset.write_to(filename)
- asset.write_to("#{filename}.gz") if filename.to_s =~ @zip_files
- end
- end
-
- def compile_path?(logical_path)
- paths.each do |path|
- case path
- when Regexp
- return true if path.match(logical_path)
- when Proc
- return true if path.call(logical_path)
- else
- return true if File.fnmatch(path.to_s, logical_path)
- end
- end
- false
- end
-
- def path_for(asset)
- @digest ? asset.digest_path : asset.logical_path
- end
- end