railties 3.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (334) hide show
  1. data/CHANGELOG +2201 -0
  2. data/README +286 -0
  3. data/bin/rails +11 -0
  4. data/builtin/rails_info/rails/info.rb +147 -0
  5. data/builtin/rails_info/rails/info_controller.rb +15 -0
  6. data/builtin/rails_info/rails/info_helper.rb +2 -0
  7. data/builtin/routes.rb +3 -0
  8. data/guides/files/javascripts/code_highlighter.js +188 -0
  9. data/guides/files/javascripts/guides.js +7 -0
  10. data/guides/files/javascripts/highlighters.js +90 -0
  11. data/guides/files/stylesheets/main.css +441 -0
  12. data/guides/files/stylesheets/print.css +52 -0
  13. data/guides/files/stylesheets/reset.css +43 -0
  14. data/guides/files/stylesheets/style.css +13 -0
  15. data/guides/files/stylesheets/syntax.css +31 -0
  16. data/guides/images/belongs_to.png +0 -0
  17. data/guides/images/book_icon.gif +0 -0
  18. data/guides/images/bullet.gif +0 -0
  19. data/guides/images/chapters_icon.gif +0 -0
  20. data/guides/images/check_bullet.gif +0 -0
  21. data/guides/images/credits_pic_blank.gif +0 -0
  22. data/guides/images/csrf.png +0 -0
  23. data/guides/images/customized_error_messages.png +0 -0
  24. data/guides/images/error_messages.png +0 -0
  25. data/guides/images/feature_tile.gif +0 -0
  26. data/guides/images/footer_tile.gif +0 -0
  27. data/guides/images/fxn.png +0 -0
  28. data/guides/images/grey_bullet.gif +0 -0
  29. data/guides/images/habtm.png +0 -0
  30. data/guides/images/has_many.png +0 -0
  31. data/guides/images/has_many_through.png +0 -0
  32. data/guides/images/has_one.png +0 -0
  33. data/guides/images/has_one_through.png +0 -0
  34. data/guides/images/header_backdrop.png +0 -0
  35. data/guides/images/header_tile.gif +0 -0
  36. data/guides/images/i18n/demo_localized_pirate.png +0 -0
  37. data/guides/images/i18n/demo_translated_en.png +0 -0
  38. data/guides/images/i18n/demo_translated_pirate.png +0 -0
  39. data/guides/images/i18n/demo_translation_missing.png +0 -0
  40. data/guides/images/i18n/demo_untranslated.png +0 -0
  41. data/guides/images/icons/README +5 -0
  42. data/guides/images/icons/callouts/1.png +0 -0
  43. data/guides/images/icons/callouts/10.png +0 -0
  44. data/guides/images/icons/callouts/11.png +0 -0
  45. data/guides/images/icons/callouts/12.png +0 -0
  46. data/guides/images/icons/callouts/13.png +0 -0
  47. data/guides/images/icons/callouts/14.png +0 -0
  48. data/guides/images/icons/callouts/15.png +0 -0
  49. data/guides/images/icons/callouts/2.png +0 -0
  50. data/guides/images/icons/callouts/3.png +0 -0
  51. data/guides/images/icons/callouts/4.png +0 -0
  52. data/guides/images/icons/callouts/5.png +0 -0
  53. data/guides/images/icons/callouts/6.png +0 -0
  54. data/guides/images/icons/callouts/7.png +0 -0
  55. data/guides/images/icons/callouts/8.png +0 -0
  56. data/guides/images/icons/callouts/9.png +0 -0
  57. data/guides/images/icons/caution.png +0 -0
  58. data/guides/images/icons/example.png +0 -0
  59. data/guides/images/icons/home.png +0 -0
  60. data/guides/images/icons/important.png +0 -0
  61. data/guides/images/icons/next.png +0 -0
  62. data/guides/images/icons/note.png +0 -0
  63. data/guides/images/icons/prev.png +0 -0
  64. data/guides/images/icons/tip.png +0 -0
  65. data/guides/images/icons/up.png +0 -0
  66. data/guides/images/icons/warning.png +0 -0
  67. data/guides/images/nav_arrow.gif +0 -0
  68. data/guides/images/polymorphic.png +0 -0
  69. data/guides/images/posts_index.png +0 -0
  70. data/guides/images/rails_guides_logo.gif +0 -0
  71. data/guides/images/rails_logo_remix.gif +0 -0
  72. data/guides/images/rails_welcome.png +0 -0
  73. data/guides/images/session_fixation.png +0 -0
  74. data/guides/images/tab_grey.gif +0 -0
  75. data/guides/images/tab_info.gif +0 -0
  76. data/guides/images/tab_note.gif +0 -0
  77. data/guides/images/tab_red.gif +0 -0
  78. data/guides/images/tab_yellow.gif +0 -0
  79. data/guides/images/tab_yellow.png +0 -0
  80. data/guides/images/validation_error_messages.png +0 -0
  81. data/guides/rails_guides.rb +44 -0
  82. data/guides/rails_guides/generator.rb +178 -0
  83. data/guides/rails_guides/helpers.rb +34 -0
  84. data/guides/rails_guides/indexer.rb +55 -0
  85. data/guides/rails_guides/levenshtein.rb +31 -0
  86. data/guides/rails_guides/textile_extensions.rb +41 -0
  87. data/guides/source/2_2_release_notes.textile +422 -0
  88. data/guides/source/2_3_release_notes.textile +610 -0
  89. data/guides/source/3_0_release_notes.textile +560 -0
  90. data/guides/source/action_controller_overview.textile +783 -0
  91. data/guides/source/action_mailer_basics.textile +437 -0
  92. data/guides/source/action_view_overview.textile +1481 -0
  93. data/guides/source/active_record_basics.textile +204 -0
  94. data/guides/source/active_record_querying.textile +961 -0
  95. data/guides/source/active_support_core_extensions.textile +1835 -0
  96. data/guides/source/activerecord_validations_callbacks.textile +1127 -0
  97. data/guides/source/ajax_on_rails.textile +342 -0
  98. data/guides/source/association_basics.textile +1816 -0
  99. data/guides/source/caching_with_rails.textile +390 -0
  100. data/guides/source/command_line.textile +589 -0
  101. data/guides/source/configuring.textile +290 -0
  102. data/guides/source/contribute.textile +71 -0
  103. data/guides/source/contributing_to_rails.textile +272 -0
  104. data/guides/source/credits.textile.erb +52 -0
  105. data/guides/source/debugging_rails_applications.textile +709 -0
  106. data/guides/source/form_helpers.textile +768 -0
  107. data/guides/source/generators.textile +378 -0
  108. data/guides/source/getting_started.textile +1310 -0
  109. data/guides/source/i18n.textile +879 -0
  110. data/guides/source/index.textile.erb +124 -0
  111. data/guides/source/layout.html.erb +103 -0
  112. data/guides/source/layouts_and_rendering.textile +979 -0
  113. data/guides/source/migrations.textile +591 -0
  114. data/guides/source/nested_model_forms.textile +222 -0
  115. data/guides/source/performance_testing.textile +531 -0
  116. data/guides/source/plugins.textile +1512 -0
  117. data/guides/source/rails_application_templates.textile +238 -0
  118. data/guides/source/rails_on_rack.textile +306 -0
  119. data/guides/source/routing.textile +903 -0
  120. data/guides/source/security.textile +984 -0
  121. data/guides/source/testing.textile +946 -0
  122. data/lib/generators/erb.rb +8 -0
  123. data/lib/generators/erb/controller/controller_generator.rb +21 -0
  124. data/lib/generators/erb/controller/templates/view.html.erb +2 -0
  125. data/lib/generators/erb/mailer/mailer_generator.rb +20 -0
  126. data/lib/generators/erb/mailer/templates/view.text.erb +3 -0
  127. data/lib/generators/erb/scaffold/scaffold_generator.rb +53 -0
  128. data/lib/generators/erb/scaffold/templates/_form.html.erb +13 -0
  129. data/lib/generators/erb/scaffold/templates/edit.html.erb +6 -0
  130. data/lib/generators/erb/scaffold/templates/index.html.erb +27 -0
  131. data/lib/generators/erb/scaffold/templates/layout.html.erb +16 -0
  132. data/lib/generators/erb/scaffold/templates/new.html.erb +5 -0
  133. data/lib/generators/erb/scaffold/templates/show.html.erb +10 -0
  134. data/lib/generators/rails/app/USAGE +9 -0
  135. data/lib/generators/rails/app/app_generator.rb +262 -0
  136. data/lib/generators/rails/app/templates/Gemfile +34 -0
  137. data/lib/generators/rails/app/templates/README +243 -0
  138. data/lib/generators/rails/app/templates/Rakefile +10 -0
  139. data/lib/generators/rails/app/templates/app/controllers/application_controller.rb +3 -0
  140. data/lib/generators/rails/app/templates/app/helpers/application_helper.rb +2 -0
  141. data/lib/generators/rails/app/templates/app/models/.empty_directory +0 -0
  142. data/lib/generators/rails/app/templates/app/views/layouts/.empty_directory +0 -0
  143. data/lib/generators/rails/app/templates/config.ru +4 -0
  144. data/lib/generators/rails/app/templates/config/application.rb +51 -0
  145. data/lib/generators/rails/app/templates/config/boot.rb +17 -0
  146. data/lib/generators/rails/app/templates/config/databases/frontbase.yml +28 -0
  147. data/lib/generators/rails/app/templates/config/databases/ibm_db.yml +71 -0
  148. data/lib/generators/rails/app/templates/config/databases/mysql.yml +60 -0
  149. data/lib/generators/rails/app/templates/config/databases/oracle.yml +39 -0
  150. data/lib/generators/rails/app/templates/config/databases/postgresql.yml +51 -0
  151. data/lib/generators/rails/app/templates/config/databases/sqlite3.yml +22 -0
  152. data/lib/generators/rails/app/templates/config/environment.rb +5 -0
  153. data/lib/generators/rails/app/templates/config/environments/development.rb.tt +19 -0
  154. data/lib/generators/rails/app/templates/config/environments/production.rb.tt +33 -0
  155. data/lib/generators/rails/app/templates/config/environments/test.rb.tt +29 -0
  156. data/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb +7 -0
  157. data/lib/generators/rails/app/templates/config/initializers/cookie_verification_secret.rb.tt +7 -0
  158. data/lib/generators/rails/app/templates/config/initializers/inflections.rb +10 -0
  159. data/lib/generators/rails/app/templates/config/initializers/mime_types.rb +5 -0
  160. data/lib/generators/rails/app/templates/config/initializers/session_store.rb.tt +15 -0
  161. data/lib/generators/rails/app/templates/config/locales/en.yml +5 -0
  162. data/lib/generators/rails/app/templates/config/routes.rb +58 -0
  163. data/lib/generators/rails/app/templates/db/seeds.rb +7 -0
  164. data/lib/generators/rails/app/templates/doc/README_FOR_APP +2 -0
  165. data/lib/generators/rails/app/templates/gitignore +4 -0
  166. data/lib/generators/rails/app/templates/public/404.html +26 -0
  167. data/lib/generators/rails/app/templates/public/422.html +26 -0
  168. data/lib/generators/rails/app/templates/public/500.html +26 -0
  169. data/lib/generators/rails/app/templates/public/favicon.ico +0 -0
  170. data/lib/generators/rails/app/templates/public/images/rails.png +0 -0
  171. data/lib/generators/rails/app/templates/public/index.html +278 -0
  172. data/lib/generators/rails/app/templates/public/javascripts/application.js +2 -0
  173. data/lib/generators/rails/app/templates/public/javascripts/controls.js +963 -0
  174. data/lib/generators/rails/app/templates/public/javascripts/dragdrop.js +973 -0
  175. data/lib/generators/rails/app/templates/public/javascripts/effects.js +1128 -0
  176. data/lib/generators/rails/app/templates/public/javascripts/prototype.js +4320 -0
  177. data/lib/generators/rails/app/templates/public/javascripts/rails.js +110 -0
  178. data/lib/generators/rails/app/templates/public/robots.txt +5 -0
  179. data/lib/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  180. data/lib/generators/rails/app/templates/script/rails +9 -0
  181. data/lib/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  182. data/lib/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  183. data/lib/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  184. data/lib/generators/rails/app/templates/test/performance/browsing_test.rb +9 -0
  185. data/lib/generators/rails/app/templates/test/test_helper.rb +13 -0
  186. data/lib/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  187. data/lib/generators/rails/controller/USAGE +18 -0
  188. data/lib/generators/rails/controller/controller_generator.rb +14 -0
  189. data/lib/generators/rails/controller/templates/controller.rb +7 -0
  190. data/lib/generators/rails/generator/USAGE +11 -0
  191. data/lib/generators/rails/generator/generator_generator.rb +25 -0
  192. data/lib/generators/rails/generator/templates/%file_name%_generator.rb.tt +5 -0
  193. data/lib/generators/rails/generator/templates/USAGE.tt +8 -0
  194. data/lib/generators/rails/generator/templates/templates/.empty_directory +0 -0
  195. data/lib/generators/rails/helper/USAGE +17 -0
  196. data/lib/generators/rails/helper/helper_generator.rb +13 -0
  197. data/lib/generators/rails/helper/templates/helper.rb +2 -0
  198. data/lib/generators/rails/integration_test/USAGE +10 -0
  199. data/lib/generators/rails/integration_test/integration_test_generator.rb +7 -0
  200. data/lib/generators/rails/mailer/USAGE +15 -0
  201. data/lib/generators/rails/mailer/mailer_generator.rb +14 -0
  202. data/lib/generators/rails/mailer/templates/mailer.rb +16 -0
  203. data/lib/generators/rails/metal/USAGE +8 -0
  204. data/lib/generators/rails/metal/metal_generator.rb +11 -0
  205. data/lib/generators/rails/metal/templates/metal.rb +12 -0
  206. data/lib/generators/rails/migration/USAGE +29 -0
  207. data/lib/generators/rails/migration/migration_generator.rb +8 -0
  208. data/lib/generators/rails/model/USAGE +30 -0
  209. data/lib/generators/rails/model/model_generator.rb +8 -0
  210. data/lib/generators/rails/model_subclass/model_subclass_generator.rb +12 -0
  211. data/lib/generators/rails/observer/USAGE +12 -0
  212. data/lib/generators/rails/observer/observer_generator.rb +7 -0
  213. data/lib/generators/rails/performance_test/USAGE +10 -0
  214. data/lib/generators/rails/performance_test/performance_test_generator.rb +7 -0
  215. data/lib/generators/rails/plugin/USAGE +13 -0
  216. data/lib/generators/rails/plugin/plugin_generator.rb +47 -0
  217. data/lib/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
  218. data/lib/generators/rails/plugin/templates/README.tt +13 -0
  219. data/lib/generators/rails/plugin/templates/Rakefile.tt +10 -0
  220. data/lib/generators/rails/plugin/templates/init.rb +1 -0
  221. data/lib/generators/rails/plugin/templates/install.rb +1 -0
  222. data/lib/generators/rails/plugin/templates/lib/%file_name%.rb.tt +1 -0
  223. data/lib/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +4 -0
  224. data/lib/generators/rails/plugin/templates/uninstall.rb +1 -0
  225. data/lib/generators/rails/resource/USAGE +23 -0
  226. data/lib/generators/rails/resource/resource_generator.rb +34 -0
  227. data/lib/generators/rails/scaffold/USAGE +29 -0
  228. data/lib/generators/rails/scaffold/scaffold_generator.rb +13 -0
  229. data/lib/generators/rails/scaffold_controller/USAGE +20 -0
  230. data/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb +27 -0
  231. data/lib/generators/rails/scaffold_controller/templates/controller.rb +85 -0
  232. data/lib/generators/rails/session_migration/USAGE +8 -0
  233. data/lib/generators/rails/session_migration/session_migration_generator.rb +8 -0
  234. data/lib/generators/rails/stylesheets/USAGE +5 -0
  235. data/lib/generators/rails/stylesheets/stylesheets_generator.rb +9 -0
  236. data/lib/generators/rails/stylesheets/templates/scaffold.css +61 -0
  237. data/lib/generators/test_unit.rb +8 -0
  238. data/lib/generators/test_unit/controller/controller_generator.rb +14 -0
  239. data/lib/generators/test_unit/controller/templates/functional_test.rb +8 -0
  240. data/lib/generators/test_unit/helper/helper_generator.rb +13 -0
  241. data/lib/generators/test_unit/helper/templates/helper_test.rb +4 -0
  242. data/lib/generators/test_unit/integration/integration_generator.rb +13 -0
  243. data/lib/generators/test_unit/integration/templates/integration_test.rb +10 -0
  244. data/lib/generators/test_unit/mailer/mailer_generator.rb +21 -0
  245. data/lib/generators/test_unit/mailer/templates/fixture +3 -0
  246. data/lib/generators/test_unit/mailer/templates/functional_test.rb +22 -0
  247. data/lib/generators/test_unit/model/model_generator.rb +24 -0
  248. data/lib/generators/test_unit/model/templates/fixtures.yml +23 -0
  249. data/lib/generators/test_unit/model/templates/unit_test.rb +8 -0
  250. data/lib/generators/test_unit/observer/observer_generator.rb +13 -0
  251. data/lib/generators/test_unit/observer/templates/unit_test.rb +8 -0
  252. data/lib/generators/test_unit/performance/performance_generator.rb +13 -0
  253. data/lib/generators/test_unit/performance/templates/performance_test.rb +9 -0
  254. data/lib/generators/test_unit/plugin/plugin_generator.rb +13 -0
  255. data/lib/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +8 -0
  256. data/lib/generators/test_unit/plugin/templates/test_helper.rb +3 -0
  257. data/lib/generators/test_unit/scaffold/scaffold_generator.rb +18 -0
  258. data/lib/generators/test_unit/scaffold/templates/functional_test.rb +47 -0
  259. data/lib/rails.rb +95 -0
  260. data/lib/rails/all.rb +14 -0
  261. data/lib/rails/application.rb +125 -0
  262. data/lib/rails/application/bootstrap.rb +85 -0
  263. data/lib/rails/application/configurable.rb +19 -0
  264. data/lib/rails/application/configuration.rb +86 -0
  265. data/lib/rails/application/finisher.rb +49 -0
  266. data/lib/rails/application/metal_loader.rb +50 -0
  267. data/lib/rails/application/railties.rb +31 -0
  268. data/lib/rails/application/routes_reloader.rb +46 -0
  269. data/lib/rails/backtrace_cleaner.rb +54 -0
  270. data/lib/rails/code_statistics.rb +107 -0
  271. data/lib/rails/commands.rb +72 -0
  272. data/lib/rails/commands/application.rb +13 -0
  273. data/lib/rails/commands/console.rb +55 -0
  274. data/lib/rails/commands/dbconsole.rb +104 -0
  275. data/lib/rails/commands/destroy.rb +9 -0
  276. data/lib/rails/commands/generate.rb +9 -0
  277. data/lib/rails/commands/performance/benchmarker.rb +23 -0
  278. data/lib/rails/commands/performance/profiler.rb +46 -0
  279. data/lib/rails/commands/plugin.rb +542 -0
  280. data/lib/rails/commands/runner.rb +51 -0
  281. data/lib/rails/commands/server.rb +75 -0
  282. data/lib/rails/commands/update.rb +9 -0
  283. data/lib/rails/configuration.rb +191 -0
  284. data/lib/rails/console/app.rb +33 -0
  285. data/lib/rails/console/helpers.rb +5 -0
  286. data/lib/rails/console/sandbox.rb +6 -0
  287. data/lib/rails/deprecation.rb +62 -0
  288. data/lib/rails/dispatcher.rb +24 -0
  289. data/lib/rails/engine.rb +130 -0
  290. data/lib/rails/engine/configurable.rb +25 -0
  291. data/lib/rails/engine/configuration.rb +49 -0
  292. data/lib/rails/generators.rb +289 -0
  293. data/lib/rails/generators/actions.rb +309 -0
  294. data/lib/rails/generators/active_model.rb +78 -0
  295. data/lib/rails/generators/base.rb +362 -0
  296. data/lib/rails/generators/generated_attribute.rb +48 -0
  297. data/lib/rails/generators/migration.rb +64 -0
  298. data/lib/rails/generators/named_base.rb +95 -0
  299. data/lib/rails/generators/resource_helpers.rb +80 -0
  300. data/lib/rails/generators/test_case.rb +239 -0
  301. data/lib/rails/initializable.rb +97 -0
  302. data/lib/rails/paths.rb +144 -0
  303. data/lib/rails/performance_test_help.rb +3 -0
  304. data/lib/rails/plugin.rb +64 -0
  305. data/lib/rails/rack.rb +8 -0
  306. data/lib/rails/rack/debugger.rb +23 -0
  307. data/lib/rails/rack/log_tailer.rb +33 -0
  308. data/lib/rails/rack/logger.rb +34 -0
  309. data/lib/rails/rack/static.rb +5 -0
  310. data/lib/rails/railtie.rb +74 -0
  311. data/lib/rails/railtie/configurable.rb +23 -0
  312. data/lib/rails/railtie/configuration.rb +9 -0
  313. data/lib/rails/railties_path.rb +1 -0
  314. data/lib/rails/ruby_version_check.rb +10 -0
  315. data/lib/rails/rubyprof_ext.rb +35 -0
  316. data/lib/rails/source_annotation_extractor.rb +102 -0
  317. data/lib/rails/subscriber.rb +108 -0
  318. data/lib/rails/subscriber/test_helper.rb +98 -0
  319. data/lib/rails/tasks.rb +16 -0
  320. data/lib/rails/tasks/annotations.rake +20 -0
  321. data/lib/rails/tasks/documentation.rake +96 -0
  322. data/lib/rails/tasks/framework.rake +69 -0
  323. data/lib/rails/tasks/log.rake +9 -0
  324. data/lib/rails/tasks/middleware.rake +7 -0
  325. data/lib/rails/tasks/misc.rake +71 -0
  326. data/lib/rails/tasks/routes.rake +17 -0
  327. data/lib/rails/tasks/statistics.rake +16 -0
  328. data/lib/rails/tasks/tmp.rake +37 -0
  329. data/lib/rails/test_help.rb +30 -0
  330. data/lib/rails/test_unit/railtie.rb +17 -0
  331. data/lib/rails/test_unit/testing.rake +130 -0
  332. data/lib/rails/version.rb +9 -0
  333. data/lib/rails/webrick_server.rb +156 -0
  334. metadata +427 -0
@@ -0,0 +1,69 @@
1
+ namespace :rails do
2
+ namespace :freeze do
3
+ desc "The rails:freeze:gems is deprecated, please use bundle install instead"
4
+ task :gems do
5
+ puts "The rails:freeze:gems is deprecated, please use bundle install instead"
6
+ end
7
+
8
+ desc 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install'
9
+ task :edge do
10
+ puts 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install'
11
+ end
12
+ end
13
+
14
+ desc 'The unfreeze command has been deprecated, please use bundler commands instead'
15
+ task :unfreeze do
16
+ puts 'The unfreeze command has been deprecated, please use bundler commands instead'
17
+ end
18
+
19
+ desc "Update both configs, scripts and public/javascripts from Rails"
20
+ task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller" ]
21
+
22
+ desc "Applies the template supplied by LOCATION=/path/to/template"
23
+ task :template do
24
+ template = ENV["LOCATION"]
25
+ template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
26
+
27
+ require 'rails/generators'
28
+ require 'generators/rails/app/app_generator'
29
+ generator = Rails::Generators::AppGenerator.new [ Rails.root ], {}, :destination_root => Rails.root
30
+ generator.apply template, :verbose => false
31
+ end
32
+
33
+ namespace :update do
34
+ def invoke_from_app_generator(method)
35
+ require 'rails/generators'
36
+ require 'generators/rails/app/app_generator'
37
+
38
+ generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
39
+ :destination_root => Rails.root
40
+ generator.invoke(method)
41
+ end
42
+
43
+ desc "Update config/boot.rb from your current rails install"
44
+ task :configs do
45
+ invoke_from_app_generator :create_boot_file
46
+ invoke_from_app_generator :create_config_files
47
+ end
48
+
49
+ desc "Update Prototype javascripts from your current rails install"
50
+ task :javascripts do
51
+ invoke_from_app_generator :create_prototype_files
52
+ end
53
+
54
+ desc "Adds new scripts to the application script/ directory"
55
+ task :scripts do
56
+ invoke_from_app_generator :create_script_files
57
+ end
58
+
59
+ desc "Rename application.rb to application_controller.rb"
60
+ task :application_controller do
61
+ old_style = Rails.root + '/app/controllers/application.rb'
62
+ new_style = Rails.root + '/app/controllers/application_controller.rb'
63
+ if File.exists?(old_style) && !File.exists?(new_style)
64
+ FileUtils.mv(old_style, new_style)
65
+ puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,9 @@
1
+ namespace :log do
2
+ desc "Truncates all *.log files in log/ to zero bytes"
3
+ task :clear do
4
+ FileList["log/*.log"].each do |log_file|
5
+ f = File.open(log_file, "w")
6
+ f.close
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ desc 'Prints out your Rack middleware stack'
2
+ task :middleware => :environment do
3
+ Rails.configuration.middleware.active.each do |middleware|
4
+ puts "use #{middleware.inspect}"
5
+ end
6
+ puts "run #{Rails::Application.instance.class.name}.routes"
7
+ end
@@ -0,0 +1,71 @@
1
+ task :default => :test
2
+
3
+ task :rails_env do
4
+ # TODO Do we really need this?
5
+ unless defined? RAILS_ENV
6
+ RAILS_ENV = ENV['RAILS_ENV'] ||= 'development'
7
+ end
8
+ end
9
+
10
+ desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.'
11
+ task :secret do
12
+ require 'active_support/secure_random'
13
+ puts ActiveSupport::SecureRandom.hex(64)
14
+ end
15
+
16
+ desc 'Explain the current environment'
17
+ task :about do
18
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
19
+ require 'rails/info'
20
+ puts Rails::Info
21
+ end
22
+
23
+ namespace :time do
24
+ namespace :zones do
25
+ desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
26
+ task :all do
27
+ build_time_zone_list(:all)
28
+ end
29
+
30
+ desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
31
+ task :us do
32
+ build_time_zone_list(:us_zones)
33
+ end
34
+
35
+ desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
36
+ task :local do
37
+ require 'active_support'
38
+ require 'active_support/time'
39
+ jan_offset = Time.now.beginning_of_year.utc_offset
40
+ jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset
41
+ offset = jan_offset < jul_offset ? jan_offset : jul_offset
42
+ build_time_zone_list(:all, offset)
43
+ end
44
+
45
+ # to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600
46
+ def build_time_zone_list(method, offset = ENV['OFFSET'])
47
+ require 'active_support'
48
+ require 'active_support/time'
49
+ if offset
50
+ offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/)
51
+ sign = $1 == '-' ? -1 : 1
52
+ hours, minutes = $2.to_f, $3.to_f
53
+ ((hours * 3600) + (minutes.to_f * 60)) * sign
54
+ elsif offset.to_f.abs <= 13
55
+ offset.to_f * 3600
56
+ else
57
+ offset.to_f
58
+ end
59
+ end
60
+ previous_offset = nil
61
+ ActiveSupport::TimeZone.__send__(method).each do |zone|
62
+ if offset.nil? || offset == zone.utc_offset
63
+ puts "\n* UTC #{zone.formatted_offset} *" unless zone.utc_offset == previous_offset
64
+ puts zone.name
65
+ previous_offset = zone.utc_offset
66
+ end
67
+ end
68
+ puts "\n"
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
2
+ task :routes => :environment do
3
+ Rails::Application.reload_routes!
4
+ all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes
5
+ routes = all_routes.collect do |route|
6
+ name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
7
+ reqs = route.requirements.empty? ? "" : route.requirements.inspect
8
+ {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
9
+ end
10
+ routes.reject!{ |r| r[:path] == "/rails/info/properties" } # skip the route if it's internal info route
11
+ name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max
12
+ verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max
13
+ path_width = routes.collect {|r| r[:path]}.collect {|s| s.length}.max
14
+ routes.each do |r|
15
+ puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ STATS_DIRECTORIES = [
2
+ %w(Controllers app/controllers),
3
+ %w(Helpers app/helpers),
4
+ %w(Models app/models),
5
+ %w(Libraries lib/),
6
+ %w(APIs app/apis),
7
+ %w(Integration\ tests test/integration),
8
+ %w(Functional\ tests test/functional),
9
+ %w(Unit\ tests test/unit)
10
+ ].collect { |name, dir| [ name, "#{Rails.root}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
11
+
12
+ desc "Report code statistics (KLOCs, etc) from the application"
13
+ task :stats do
14
+ require 'rails/code_statistics'
15
+ CodeStatistics.new(*STATS_DIRECTORIES).to_s
16
+ end
@@ -0,0 +1,37 @@
1
+ namespace :tmp do
2
+ desc "Clear session, cache, and socket files from tmp/"
3
+ task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
4
+
5
+ desc "Creates tmp directories for sessions, cache, sockets, and pids"
6
+ task :create do
7
+ FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids ))
8
+ end
9
+
10
+ namespace :sessions do
11
+ desc "Clears all files in tmp/sessions"
12
+ task :clear do
13
+ FileUtils.rm(Dir['tmp/sessions/[^.]*'])
14
+ end
15
+ end
16
+
17
+ namespace :cache do
18
+ desc "Clears all files and directories in tmp/cache"
19
+ task :clear do
20
+ FileUtils.rm_rf(Dir['tmp/cache/[^.]*'])
21
+ end
22
+ end
23
+
24
+ namespace :sockets do
25
+ desc "Clears all files in tmp/sockets"
26
+ task :clear do
27
+ FileUtils.rm(Dir['tmp/sockets/[^.]*'])
28
+ end
29
+ end
30
+
31
+ namespace :pids do
32
+ desc "Clears all files in tmp/pids"
33
+ task :clear do
34
+ FileUtils.rm(Dir['tmp/pids/[^.]*'])
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ # Make double-sure the RAILS_ENV is set to test,
2
+ # so fixtures are loaded to the right database
3
+ exit("Abort testing: Your Rails environment is not running in test mode!") unless Rails.env.test?
4
+
5
+ require 'test/unit'
6
+ require 'active_support/core_ext/kernel/requires'
7
+
8
+ if defined?(ActiveRecord)
9
+ class ActiveSupport::TestCase
10
+ include ActiveRecord::TestFixtures
11
+ self.fixture_path = "#{Rails.root}/test/fixtures/"
12
+ end
13
+
14
+ ActionController::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
15
+
16
+ def create_fixtures(*table_names, &block)
17
+ Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
18
+ end
19
+ end
20
+
21
+ begin
22
+ require_library_or_gem 'ruby-debug'
23
+ Debugger.start
24
+ if Debugger.respond_to?(:settings)
25
+ Debugger.settings[:autoeval] = true
26
+ Debugger.settings[:autolist] = 1
27
+ end
28
+ rescue LoadError
29
+ # ruby-debug wasn't available so neither can the debugging be
30
+ end
@@ -0,0 +1,17 @@
1
+ module Rails
2
+ class TestUnitRailtie < Rails::Railtie
3
+ railtie_name :test_unit
4
+
5
+ config.generators do |c|
6
+ c.test_framework :test_unit, :fixture => true,
7
+ :fixture_replacement => nil
8
+
9
+ c.integration_tool :test_unit
10
+ c.performance_tool :test_unit
11
+ end
12
+
13
+ rake_tasks do
14
+ load "rails/test_unit/testing.rake"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,130 @@
1
+ TEST_CHANGES_SINCE = Time.now - 600
2
+
3
+ # Look up tests for recently modified sources.
4
+ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
5
+ FileList[source_pattern].map do |path|
6
+ if File.mtime(path) > touched_since
7
+ tests = []
8
+ source_dir = File.dirname(path).split("/")
9
+ source_file = File.basename(path, '.rb')
10
+
11
+ # Support subdirs in app/models and app/controllers
12
+ modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
13
+
14
+ # For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
15
+ test = "#{modified_test_path}/#{source_file}_test.rb"
16
+ tests.push test if File.exist?(test)
17
+
18
+ # For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
19
+ test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
20
+ FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
21
+
22
+ return tests
23
+
24
+ end
25
+ end.flatten.compact
26
+ end
27
+
28
+
29
+ # Recreated here from ActiveSupport because :uncommitted needs it before Rails is available
30
+ module Kernel
31
+ def silence_stderr
32
+ old_stderr = STDERR.dup
33
+ STDERR.reopen(RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'NUL:' : '/dev/null')
34
+ STDERR.sync = true
35
+ yield
36
+ ensure
37
+ STDERR.reopen(old_stderr)
38
+ end
39
+ end
40
+
41
+ desc 'Run all unit, functional and integration tests'
42
+ task :test do
43
+ errors = %w(test:units test:functionals test:integration).collect do |task|
44
+ begin
45
+ Rake::Task[task].invoke
46
+ nil
47
+ rescue => e
48
+ task
49
+ end
50
+ end.compact
51
+ abort "Errors running #{errors * ', '}!" if errors.any?
52
+ end
53
+
54
+ namespace :test do
55
+ Rake::TestTask.new(:recent => "db:test:prepare") do |t|
56
+ since = TEST_CHANGES_SINCE
57
+ touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
58
+ recent_tests('app/models/**/*.rb', 'test/unit', since) +
59
+ recent_tests('app/controllers/**/*.rb', 'test/functional', since)
60
+
61
+ t.libs << 'test'
62
+ t.test_files = touched.uniq
63
+ end
64
+ Rake::Task['test:recent'].comment = "Test recent changes"
65
+
66
+ Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
67
+ def t.file_list
68
+ if File.directory?(".svn")
69
+ changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
70
+ elsif File.directory?(".git")
71
+ changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.map { |path| path.chomp }
72
+ else
73
+ abort "Not a Subversion or Git checkout."
74
+ end
75
+
76
+ models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
77
+ controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
78
+
79
+ unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
80
+ functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
81
+
82
+ unit_tests.uniq + functional_tests.uniq
83
+ end
84
+
85
+ t.libs << 'test'
86
+ end
87
+ Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
88
+
89
+ Rake::TestTask.new(:units => "db:test:prepare") do |t|
90
+ t.libs << "test"
91
+ t.pattern = 'test/unit/**/*_test.rb'
92
+ end
93
+ Rake::Task['test:units'].comment = "Run the unit tests in test/unit"
94
+
95
+ Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
96
+ t.libs << "test"
97
+ t.pattern = 'test/functional/**/*_test.rb'
98
+ end
99
+ Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional"
100
+
101
+ Rake::TestTask.new(:integration => "db:test:prepare") do |t|
102
+ t.libs << "test"
103
+ t.pattern = 'test/integration/**/*_test.rb'
104
+ end
105
+ Rake::Task['test:integration'].comment = "Run the integration tests in test/integration"
106
+
107
+ Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t|
108
+ t.libs << 'test'
109
+ t.pattern = 'test/performance/**/*_test.rb'
110
+ t.options = '-- --benchmark'
111
+ end
112
+ Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests'
113
+
114
+ Rake::TestTask.new(:profile => 'db:test:prepare') do |t|
115
+ t.libs << 'test'
116
+ t.pattern = 'test/performance/**/*_test.rb'
117
+ end
118
+ Rake::Task['test:profile'].comment = 'Profile the performance tests'
119
+
120
+ Rake::TestTask.new(:plugins => :environment) do |t|
121
+ t.libs << "test"
122
+
123
+ if ENV['PLUGIN']
124
+ t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb"
125
+ else
126
+ t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb'
127
+ end
128
+ end
129
+ Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)"
130
+ end
@@ -0,0 +1,9 @@
1
+ module Rails
2
+ module VERSION #:nodoc:
3
+ MAJOR = 3
4
+ MINOR = 0
5
+ TINY = "0.beta"
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -0,0 +1,156 @@
1
+ # Donated by Florian Gross
2
+
3
+ require 'webrick'
4
+ require 'cgi'
5
+ require 'stringio'
6
+ require 'dispatcher'
7
+
8
+ include WEBrick
9
+
10
+ class CGI #:nodoc:
11
+ def stdinput
12
+ @stdin || $stdin
13
+ end
14
+
15
+ def env_table
16
+ @env_table || ENV
17
+ end
18
+
19
+ def initialize(type = "query", table = nil, stdin = nil)
20
+ @env_table, @stdin = table, stdin
21
+
22
+ if defined?(MOD_RUBY) && !ENV.key?("GATEWAY_INTERFACE")
23
+ Apache.request.setup_cgi_env
24
+ end
25
+
26
+ extend QueryExtension
27
+ @multipart = false
28
+ if defined?(CGI_PARAMS)
29
+ warn "do not use CGI_PARAMS and CGI_COOKIES"
30
+ @params = CGI_PARAMS.dup
31
+ @cookies = CGI_COOKIES.dup
32
+ else
33
+ initialize_query() # set @params, @cookies
34
+ end
35
+ @output_cookies = nil
36
+ @output_hidden = nil
37
+ end
38
+ end
39
+
40
+ # A custom dispatch servlet for use with WEBrick. It dispatches requests
41
+ # (using the Rails Dispatcher) to the appropriate controller/action. By default,
42
+ # it restricts WEBrick to a managing a single Rails request at a time, but you
43
+ # can change this behavior by setting ActionController::Base.allow_concurrency
44
+ # to true.
45
+ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
46
+ # Start the WEBrick server with the given options, mounting the
47
+ # DispatchServlet at <tt>/</tt>.
48
+ def self.dispatch(options = {})
49
+ Socket.do_not_reverse_lookup = true # patch for OS X
50
+
51
+ params = { :Port => options[:port].to_i,
52
+ :ServerType => options[:server_type],
53
+ :BindAddress => options[:ip] }
54
+ params[:MimeTypes] = options[:mime_types] if options[:mime_types]
55
+
56
+ server = WEBrick::HTTPServer.new(params)
57
+ server.mount('/', DispatchServlet, options)
58
+
59
+ trap("INT") { server.shutdown }
60
+ server.start
61
+ end
62
+
63
+ def initialize(server, options) #:nodoc:
64
+ @server_options = options
65
+ @file_handler = WEBrick::HTTPServlet::FileHandler.new(server, options[:server_root])
66
+ # Change to the RAILS_ROOT, since Webrick::Daemon.start does a Dir::cwd("/")
67
+ # OPTIONS['working_directory'] is an absolute path of the RAILS_ROOT, set in railties/lib/commands/servers/webrick.rb
68
+ Dir.chdir(OPTIONS['working_directory']) if defined?(OPTIONS) && File.directory?(OPTIONS['working_directory'])
69
+ super
70
+ end
71
+
72
+ def service(req, res) #:nodoc:
73
+ unless handle_file(req, res)
74
+ unless handle_dispatch(req, res)
75
+ raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
76
+ end
77
+ end
78
+ end
79
+
80
+ def handle_file(req, res) #:nodoc:
81
+ begin
82
+ req = req.dup
83
+ path = req.path.dup
84
+
85
+ # Add .html if the last path piece has no . in it
86
+ path << '.html' if path != '/' && (%r{(^|/)[^./]+$} =~ path)
87
+ path.gsub!('+', ' ') # Unescape + since FileHandler doesn't do so.
88
+
89
+ req.instance_variable_set(:@path_info, path) # Set the modified path...
90
+
91
+ @file_handler.send(:service, req, res)
92
+ return true
93
+ rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err
94
+ res.set_error(err)
95
+ return true
96
+ rescue => err
97
+ return false
98
+ end
99
+ end
100
+
101
+ def handle_dispatch(req, res, origin = nil) #:nodoc:
102
+ data = StringIO.new
103
+ Dispatcher.dispatch(
104
+ CGI.new("query", create_env_table(req, origin), StringIO.new(req.body || "")),
105
+ ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS,
106
+ data
107
+ )
108
+
109
+ header, body = extract_header_and_body(data)
110
+
111
+ set_charset(header)
112
+ assign_status(res, header)
113
+ res.cookies.concat(header.delete('set-cookie') || [])
114
+ header.each { |key, val| res[key] = val.join(", ") }
115
+
116
+ res.body = body
117
+ return true
118
+ rescue => err
119
+ p err, err.backtrace
120
+ return false
121
+ end
122
+
123
+ private
124
+ def create_env_table(req, origin)
125
+ env = req.meta_vars.clone
126
+ env.delete "SCRIPT_NAME"
127
+ env["QUERY_STRING"] = req.request_uri.query
128
+ env["REQUEST_URI"] = origin if origin
129
+ return env
130
+ end
131
+
132
+ def extract_header_and_body(data)
133
+ data.rewind
134
+ data = data.read
135
+
136
+ raw_header, body = *data.split(/^[\xd\xa]{2}/on, 2)
137
+ header = WEBrick::HTTPUtils::parse_header(raw_header)
138
+
139
+ return header, body
140
+ end
141
+
142
+ def set_charset(header)
143
+ ct = header["content-type"]
144
+ if ct.any? { |x| x =~ /^text\// } && ! ct.any? { |x| x =~ /charset=/ }
145
+ ch = @server_options[:charset] || "UTF-8"
146
+ ct.find { |x| x =~ /^text\// } << ("; charset=" + ch)
147
+ end
148
+ end
149
+
150
+ def assign_status(res, header)
151
+ if /^(\d+)/ =~ header['status'][0]
152
+ res.status = $1.to_i
153
+ header.delete('status')
154
+ end
155
+ end
156
+ end