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,51 @@
1
+ require 'optparse'
2
+
3
+ options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
4
+ code_or_file = nil
5
+
6
+ ARGV.clone.options do |opts|
7
+ script_name = File.basename($0)
8
+ opts.banner = "Usage: runner [options] ('Some.ruby(code)' or a filename)"
9
+
10
+ opts.separator ""
11
+
12
+ opts.on("-e", "--environment=name", String,
13
+ "Specifies the environment for the runner to operate under (test/development/production).",
14
+ "Default: development") { |v| options[:environment] = v }
15
+
16
+ opts.separator ""
17
+
18
+ opts.on("-h", "--help",
19
+ "Show this help message.") { $stderr.puts opts; exit }
20
+
21
+ if RUBY_PLATFORM !~ /mswin/
22
+ opts.separator ""
23
+ opts.separator "You can also use runner as a shebang line for your scripts like this:"
24
+ opts.separator "-------------------------------------------------------------"
25
+ opts.separator "#!/usr/bin/env #{File.expand_path($0)}"
26
+ opts.separator ""
27
+ opts.separator "Product.find(:all).each { |p| p.price *= 2 ; p.save! }"
28
+ opts.separator "-------------------------------------------------------------"
29
+ end
30
+
31
+ opts.order! { |o| code_or_file ||= o } rescue retry
32
+ end
33
+
34
+ ARGV.delete(code_or_file)
35
+
36
+ ENV["RAILS_ENV"] = options[:environment]
37
+
38
+ begin
39
+ if code_or_file.nil?
40
+ $stderr.puts "Run '#{$0} -h' for help."
41
+ exit 1
42
+ elsif File.exist?(code_or_file)
43
+ eval(File.read(code_or_file), nil, code_or_file)
44
+ else
45
+ eval(code_or_file)
46
+ end
47
+ ensure
48
+ if defined? Rails
49
+ Rails.logger.flush if Rails.logger.respond_to?(:flush)
50
+ end
51
+ end
@@ -0,0 +1,75 @@
1
+ require 'fileutils'
2
+ require 'optparse'
3
+ require 'action_dispatch'
4
+
5
+ module Rails
6
+ class Server < ::Rack::Server
7
+ class Options
8
+ def parse!(args)
9
+ options = {}
10
+ args = args.dup
11
+ opt_parser = OptionParser.new do |opts|
12
+ opts.on("-p", "--port=port", Integer,
13
+ "Runs Rails on the specified port.", "Default: #{options[:Port]}") { |v| options[:Port] = v }
14
+ opts.on("-b", "--binding=ip", String,
15
+ "Binds Rails to the specified ip.", "Default: #{options[:Host]}") { |v| options[:Host] = v }
16
+ opts.on("-c", "--config=file", String,
17
+ "Use custom rackup configuration file") { |v| options[:config] = v }
18
+ opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true }
19
+ opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true }
20
+ opts.on("-e", "--environment=name", String,
21
+ "Specifies the environment to run this server under (test/development/production).",
22
+ "Default: #{options[:environment]}") { |v| options[:environment] = v }
23
+
24
+ opts.separator ""
25
+
26
+ opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
27
+ end
28
+
29
+ opt_parser.parse! args
30
+
31
+ options[:server] = args.shift
32
+ options
33
+ end
34
+ end
35
+
36
+ def opt_parser
37
+ Options.new
38
+ end
39
+
40
+ def start
41
+ ENV["RAILS_ENV"] = options[:environment]
42
+
43
+ puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
44
+ puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}"
45
+ puts "=> Call with -d to detach" unless options[:daemonize]
46
+ trap(:INT) { exit }
47
+ puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
48
+
49
+ super
50
+ ensure
51
+ puts 'Exiting' unless options[:daemonize]
52
+ end
53
+
54
+ def middleware
55
+ middlewares = []
56
+ middlewares << [Rails::Rack::LogTailer, log_path] unless options[:daemonize]
57
+ middlewares << [Rails::Rack::Debugger] if options[:debugger]
58
+ Hash.new(middlewares)
59
+ end
60
+
61
+ def log_path
62
+ "log/#{options[:environment]}.log"
63
+ end
64
+
65
+ def default_options
66
+ super.merge({
67
+ :Port => 3000,
68
+ :environment => (ENV['RAILS_ENV'] || "development").dup,
69
+ :daemonize => false,
70
+ :debugger => false,
71
+ :pid => "tmp/pids/server.pid"
72
+ })
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators'))
2
+
3
+ if ARGV.size == 0
4
+ Rails::Generators.help
5
+ exit
6
+ end
7
+
8
+ name = ARGV.shift
9
+ Rails::Generators.invoke name, ARGV, :behavior => :skip
@@ -0,0 +1,191 @@
1
+ require 'active_support/ordered_options'
2
+ require 'rails/paths'
3
+ require 'rails/rack'
4
+
5
+ module Rails
6
+ module Configuration
7
+ module Shared
8
+ def middleware
9
+ @@default_middleware_stack ||= ActionDispatch::MiddlewareStack.new.tap do |middleware|
10
+ middleware.use('::ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { Rails.application.config.serve_static_assets })
11
+ middleware.use('::Rack::Lock', :if => lambda { !Rails.application.config.allow_concurrency })
12
+ middleware.use('::Rack::Runtime')
13
+ middleware.use('::Rails::Rack::Logger')
14
+ middleware.use('::ActionDispatch::ShowExceptions', lambda { Rails.application.config.consider_all_requests_local })
15
+ middleware.use('::ActionDispatch::Callbacks', lambda { !Rails.application.config.cache_classes })
16
+ middleware.use('::ActionDispatch::Cookies')
17
+ middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options })
18
+ middleware.use('::ActionDispatch::Flash', :if => lambda { ActionController::Base.session_store })
19
+ middleware.use(lambda { Rails.application.metal_loader.build_middleware(Rails.application.config.metals) }, :if => lambda { Rails.application.metal_loader.metals.any? })
20
+ middleware.use('ActionDispatch::ParamsParser')
21
+ middleware.use('::Rack::MethodOverride')
22
+ middleware.use('::ActionDispatch::Head')
23
+ end
24
+ end
25
+
26
+ # Holds generators configuration:
27
+ #
28
+ # config.generators do |g|
29
+ # g.orm :datamapper, :migration => true
30
+ # g.template_engine :haml
31
+ # g.test_framework :rspec
32
+ # end
33
+ #
34
+ # If you want to disable color in console, do:
35
+ #
36
+ # config.generators.colorize_logging = false
37
+ #
38
+ def generators
39
+ @@generators ||= Rails::Configuration::Generators.new
40
+ if block_given?
41
+ yield @@generators
42
+ else
43
+ @@generators
44
+ end
45
+ end
46
+
47
+ def after_initialize_blocks
48
+ @@after_initialize_blocks ||= []
49
+ end
50
+
51
+ def after_initialize(&blk)
52
+ after_initialize_blocks << blk if blk
53
+ end
54
+
55
+ def to_prepare_blocks
56
+ @@to_prepare_blocks ||= []
57
+ end
58
+
59
+ def to_prepare(&blk)
60
+ to_prepare_blocks << blk if blk
61
+ end
62
+
63
+ def respond_to?(name)
64
+ super || name.to_s =~ config_key_regexp
65
+ end
66
+
67
+ private
68
+
69
+ def method_missing(name, *args, &blk)
70
+ if name.to_s =~ config_key_regexp
71
+ return $2 == '=' ? options[$1] = args.first : options[$1]
72
+ end
73
+ super
74
+ end
75
+
76
+ def config_key_regexp
77
+ bits = config_keys.map { |n| Regexp.escape(n.to_s) }.join('|')
78
+ /^(#{bits})(?:=)?$/
79
+ end
80
+
81
+ def config_keys
82
+ (Railtie.railtie_names + Engine.engine_names).map { |n| n.to_s }.uniq
83
+ end
84
+
85
+ def options
86
+ @@options ||= Hash.new { |h,k| h[k] = ActiveSupport::OrderedOptions.new }
87
+ end
88
+ end
89
+
90
+ class Generators #:nodoc:
91
+ attr_accessor :aliases, :options, :fallbacks, :colorize_logging
92
+
93
+ def initialize
94
+ @aliases = Hash.new { |h,k| h[k] = {} }
95
+ @options = Hash.new { |h,k| h[k] = {} }
96
+ @fallbacks = {}
97
+ @colorize_logging = true
98
+ end
99
+
100
+ def method_missing(method, *args)
101
+ method = method.to_s.sub(/=$/, '').to_sym
102
+
103
+ return @options[method] if args.empty?
104
+
105
+ if method == :rails
106
+ namespace, configuration = :rails, args.shift
107
+ elsif args.first.is_a?(Hash)
108
+ namespace, configuration = method, args.shift
109
+ else
110
+ namespace, configuration = args.shift, args.shift
111
+ @options[:rails][method] = namespace
112
+ end
113
+
114
+ if configuration
115
+ aliases = configuration.delete(:aliases)
116
+ @aliases[namespace].merge!(aliases) if aliases
117
+ @options[namespace].merge!(configuration)
118
+ end
119
+ end
120
+ end
121
+
122
+ module Deprecated
123
+ def frameworks(*args)
124
+ raise "config.frameworks in no longer supported. See the generated " \
125
+ "config/boot.rb for steps on how to limit the frameworks that " \
126
+ "will be loaded"
127
+ end
128
+ alias :frameworks= :frameworks
129
+
130
+ def view_path=(value)
131
+ ActiveSupport::Deprecation.warn "config.view_path= is deprecated, " <<
132
+ "please do paths.app.views= instead", caller
133
+ paths.app.views = value
134
+ end
135
+
136
+ def view_path
137
+ ActiveSupport::Deprecation.warn "config.view_path is deprecated, " <<
138
+ "please do paths.app.views instead", caller
139
+ paths.app.views.to_a.first
140
+ end
141
+
142
+ def routes_configuration_file=(value)
143
+ ActiveSupport::Deprecation.warn "config.routes_configuration_file= is deprecated, " <<
144
+ "please do paths.config.routes= instead", caller
145
+ paths.config.routes = value
146
+ end
147
+
148
+ def routes_configuration_file
149
+ ActiveSupport::Deprecation.warn "config.routes_configuration_file is deprecated, " <<
150
+ "please do paths.config.routes instead", caller
151
+ paths.config.routes.to_a.first
152
+ end
153
+
154
+ def database_configuration_file=(value)
155
+ ActiveSupport::Deprecation.warn "config.database_configuration_file= is deprecated, " <<
156
+ "please do paths.config.database= instead", caller
157
+ paths.config.database = value
158
+ end
159
+
160
+ def database_configuration_file
161
+ ActiveSupport::Deprecation.warn "config.database_configuration_file is deprecated, " <<
162
+ "please do paths.config.database instead", caller
163
+ paths.config.database.to_a.first
164
+ end
165
+
166
+ def log_path=(value)
167
+ ActiveSupport::Deprecation.warn "config.log_path= is deprecated, " <<
168
+ "please do paths.log= instead", caller
169
+ paths.config.log = value
170
+ end
171
+
172
+ def log_path
173
+ ActiveSupport::Deprecation.warn "config.log_path is deprecated, " <<
174
+ "please do paths.log instead", caller
175
+ paths.config.log.to_a.first
176
+ end
177
+
178
+ def controller_paths=(value)
179
+ ActiveSupport::Deprecation.warn "config.controller_paths= is deprecated, " <<
180
+ "please do paths.app.controllers= instead", caller
181
+ paths.app.controllers = value
182
+ end
183
+
184
+ def controller_paths
185
+ ActiveSupport::Deprecation.warn "config.controller_paths is deprecated, " <<
186
+ "please do paths.app.controllers instead", caller
187
+ paths.app.controllers.to_a.uniq
188
+ end
189
+ end
190
+ end
191
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_support/all'
2
+ require 'active_support/test_case'
3
+ require 'action_controller'
4
+
5
+ # work around the at_exit hook in test/unit, which kills IRB
6
+ Test::Unit.run = true if Test::Unit.respond_to?(:run=)
7
+
8
+ # reference the global "app" instance, created on demand. To recreate the
9
+ # instance, pass a non-false value as the parameter.
10
+ def app(create=false)
11
+ @app_integration_instance = nil if create
12
+ @app_integration_instance ||= new_session do |sess|
13
+ sess.host! "www.example.com"
14
+ end
15
+ end
16
+
17
+ # create a new session. If a block is given, the new session will be yielded
18
+ # to the block before being returned.
19
+ def new_session
20
+ app = ActionController::Dispatcher.new
21
+ session = ActionController::Integration::Session.new(app)
22
+ yield session if block_given?
23
+ session
24
+ end
25
+
26
+ # reloads the environment
27
+ def reload!(print=true)
28
+ puts "Reloading..." if print
29
+ ActionDispatch::Callbacks.new(lambda {}, false)
30
+ true
31
+ end
32
+
33
+ reload!(false)
@@ -0,0 +1,5 @@
1
+ def helper
2
+ @helper ||= ApplicationController.helpers
3
+ end
4
+
5
+ @controller = ApplicationController.new
@@ -0,0 +1,6 @@
1
+ ActiveRecord::Base.connection.increment_open_transactions
2
+ ActiveRecord::Base.connection.begin_db_transaction
3
+ at_exit do
4
+ ActiveRecord::Base.connection.rollback_db_transaction
5
+ ActiveRecord::Base.connection.decrement_open_transactions
6
+ end
@@ -0,0 +1,62 @@
1
+ require "active_support/string_inquirer"
2
+ require "active_support/deprecation"
3
+
4
+ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
5
+ cattr_accessor :warned
6
+ self.warned = false
7
+
8
+ def target
9
+ Rails.root
10
+ end
11
+
12
+ def replace(*args)
13
+ warn(caller, :replace, *args)
14
+ end
15
+
16
+ def warn(callstack, called, args)
17
+ unless warned
18
+ ActiveSupport::Deprecation.warn("RAILS_ROOT is deprecated! Use Rails.root instead", callstack)
19
+ self.warned = true
20
+ end
21
+ end
22
+ end).new
23
+
24
+ RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
25
+ cattr_accessor :warned
26
+ self.warned = false
27
+
28
+ def target
29
+ Rails.env
30
+ end
31
+
32
+ def replace(*args)
33
+ warn(caller, :replace, *args)
34
+ end
35
+
36
+ def warn(callstack, called, args)
37
+ unless warned
38
+ ActiveSupport::Deprecation.warn("RAILS_ENV is deprecated! Use Rails.env instead", callstack)
39
+ self.warned = true
40
+ end
41
+ end
42
+ end).new
43
+
44
+ RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
45
+ cattr_accessor :warned
46
+ self.warned = false
47
+
48
+ def target
49
+ Rails.logger
50
+ end
51
+
52
+ def replace(*args)
53
+ warn(caller, :replace, *args)
54
+ end
55
+
56
+ def warn(callstack, called, args)
57
+ unless warned
58
+ ActiveSupport::Deprecation.warn("RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead", callstack)
59
+ self.warned = true
60
+ end
61
+ end
62
+ end).new
@@ -0,0 +1,24 @@
1
+ #--
2
+ # Copyright (c) 2004-2010 David Heinemeier Hansson
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ require 'action_controller/deprecated/dispatcher'
24
+ Dispatcher = ActionController::Dispatcher