rails 2.2.2 → 3.0.0

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

Potentially problematic release.


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

Files changed (336) hide show
  1. data/bin/rails +8 -18
  2. metadata +118 -452
  3. data/CHANGELOG +0 -2071
  4. data/MIT-LICENSE +0 -20
  5. data/README +0 -256
  6. data/Rakefile +0 -411
  7. data/bin/about +0 -4
  8. data/bin/console +0 -3
  9. data/bin/dbconsole +0 -3
  10. data/bin/destroy +0 -3
  11. data/bin/generate +0 -3
  12. data/bin/performance/benchmarker +0 -3
  13. data/bin/performance/profiler +0 -3
  14. data/bin/performance/request +0 -3
  15. data/bin/plugin +0 -3
  16. data/bin/process/inspector +0 -3
  17. data/bin/process/reaper +0 -3
  18. data/bin/process/spawner +0 -3
  19. data/bin/runner +0 -3
  20. data/bin/server +0 -3
  21. data/builtin/rails_info/rails/info.rb +0 -125
  22. data/builtin/rails_info/rails/info_controller.rb +0 -9
  23. data/builtin/rails_info/rails/info_helper.rb +0 -2
  24. data/builtin/rails_info/rails_info_controller.rb +0 -2
  25. data/config.ru +0 -17
  26. data/configs/apache.conf +0 -40
  27. data/configs/databases/frontbase.yml +0 -28
  28. data/configs/databases/ibm_db.yml +0 -62
  29. data/configs/databases/mysql.yml +0 -57
  30. data/configs/databases/oracle.yml +0 -39
  31. data/configs/databases/postgresql.yml +0 -51
  32. data/configs/databases/sqlite2.yml +0 -19
  33. data/configs/databases/sqlite3.yml +0 -22
  34. data/configs/empty.log +0 -0
  35. data/configs/initializers/inflections.rb +0 -10
  36. data/configs/initializers/mime_types.rb +0 -5
  37. data/configs/initializers/new_rails_defaults.rb +0 -17
  38. data/configs/lighttpd.conf +0 -54
  39. data/configs/locales/en.yml +0 -5
  40. data/configs/routes.rb +0 -43
  41. data/dispatches/dispatch.fcgi +0 -24
  42. data/dispatches/dispatch.rb +0 -10
  43. data/dispatches/gateway.cgi +0 -97
  44. data/doc/README_FOR_APP +0 -5
  45. data/doc/guides/html/2_2_release_notes.html +0 -1185
  46. data/doc/guides/html/actioncontroller_basics.html +0 -1270
  47. data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
  48. data/doc/guides/html/association_basics.html +0 -2585
  49. data/doc/guides/html/authors.html +0 -240
  50. data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
  51. data/doc/guides/html/caching_with_rails.html +0 -583
  52. data/doc/guides/html/command_line.html +0 -434
  53. data/doc/guides/html/configuring.html +0 -438
  54. data/doc/guides/html/creating_plugins.html +0 -1594
  55. data/doc/guides/html/debugging_rails_applications.html +0 -1175
  56. data/doc/guides/html/finders.html +0 -1090
  57. data/doc/guides/html/form_helpers.html +0 -638
  58. data/doc/guides/html/getting_started_with_rails.html +0 -2066
  59. data/doc/guides/html/index.html +0 -349
  60. data/doc/guides/html/layouts_and_rendering.html +0 -1406
  61. data/doc/guides/html/migrations.html +0 -921
  62. data/doc/guides/html/routing_outside_in.html +0 -2213
  63. data/doc/guides/html/security.html +0 -1346
  64. data/doc/guides/html/testing_rails_applications.html +0 -1859
  65. data/doc/guides/source/2_2_release_notes.txt +0 -435
  66. data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
  67. data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
  68. data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
  69. data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
  70. data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
  71. data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
  72. data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
  73. data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
  74. data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
  75. data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
  76. data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
  77. data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
  78. data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
  79. data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
  80. data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
  81. data/doc/guides/source/active_record_basics.txt +0 -181
  82. data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
  83. data/doc/guides/source/association_basics.txt +0 -1840
  84. data/doc/guides/source/authors.txt +0 -39
  85. data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
  86. data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
  87. data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
  88. data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
  89. data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
  90. data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
  91. data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
  92. data/doc/guides/source/caching_with_rails.txt +0 -367
  93. data/doc/guides/source/command_line.txt +0 -147
  94. data/doc/guides/source/configuring.txt +0 -225
  95. data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
  96. data/doc/guides/source/creating_plugins/appendix.txt +0 -46
  97. data/doc/guides/source/creating_plugins/controllers.txt +0 -59
  98. data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
  99. data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
  100. data/doc/guides/source/creating_plugins/gem.txt +0 -1
  101. data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
  102. data/doc/guides/source/creating_plugins/helpers.txt +0 -51
  103. data/doc/guides/source/creating_plugins/index.txt +0 -52
  104. data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
  105. data/doc/guides/source/creating_plugins/models.txt +0 -76
  106. data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
  107. data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
  108. data/doc/guides/source/debugging_rails_applications.txt +0 -733
  109. data/doc/guides/source/finders.txt +0 -668
  110. data/doc/guides/source/form_helpers.txt +0 -345
  111. data/doc/guides/source/getting_started_with_rails.txt +0 -1256
  112. data/doc/guides/source/images/belongs_to.png +0 -0
  113. data/doc/guides/source/images/bullet.gif +0 -0
  114. data/doc/guides/source/images/csrf.png +0 -0
  115. data/doc/guides/source/images/habtm.png +0 -0
  116. data/doc/guides/source/images/has_many.png +0 -0
  117. data/doc/guides/source/images/has_many_through.png +0 -0
  118. data/doc/guides/source/images/has_one.png +0 -0
  119. data/doc/guides/source/images/has_one_through.png +0 -0
  120. data/doc/guides/source/images/header_backdrop.png +0 -0
  121. data/doc/guides/source/images/icons/README +0 -5
  122. data/doc/guides/source/images/icons/callouts/1.png +0 -0
  123. data/doc/guides/source/images/icons/callouts/10.png +0 -0
  124. data/doc/guides/source/images/icons/callouts/11.png +0 -0
  125. data/doc/guides/source/images/icons/callouts/12.png +0 -0
  126. data/doc/guides/source/images/icons/callouts/13.png +0 -0
  127. data/doc/guides/source/images/icons/callouts/14.png +0 -0
  128. data/doc/guides/source/images/icons/callouts/15.png +0 -0
  129. data/doc/guides/source/images/icons/callouts/2.png +0 -0
  130. data/doc/guides/source/images/icons/callouts/3.png +0 -0
  131. data/doc/guides/source/images/icons/callouts/4.png +0 -0
  132. data/doc/guides/source/images/icons/callouts/5.png +0 -0
  133. data/doc/guides/source/images/icons/callouts/6.png +0 -0
  134. data/doc/guides/source/images/icons/callouts/7.png +0 -0
  135. data/doc/guides/source/images/icons/callouts/8.png +0 -0
  136. data/doc/guides/source/images/icons/callouts/9.png +0 -0
  137. data/doc/guides/source/images/icons/caution.png +0 -0
  138. data/doc/guides/source/images/icons/example.png +0 -0
  139. data/doc/guides/source/images/icons/home.png +0 -0
  140. data/doc/guides/source/images/icons/important.png +0 -0
  141. data/doc/guides/source/images/icons/next.png +0 -0
  142. data/doc/guides/source/images/icons/note.png +0 -0
  143. data/doc/guides/source/images/icons/prev.png +0 -0
  144. data/doc/guides/source/images/icons/tip.png +0 -0
  145. data/doc/guides/source/images/icons/up.png +0 -0
  146. data/doc/guides/source/images/icons/warning.png +0 -0
  147. data/doc/guides/source/images/polymorphic.png +0 -0
  148. data/doc/guides/source/images/rails_logo_remix.gif +0 -0
  149. data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
  150. data/doc/guides/source/images/session_fixation.png +0 -0
  151. data/doc/guides/source/index.txt +0 -118
  152. data/doc/guides/source/layouts_and_rendering.txt +0 -982
  153. data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
  154. data/doc/guides/source/migrations/changelog.txt +0 -5
  155. data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
  156. data/doc/guides/source/migrations/foreign_keys.txt +0 -8
  157. data/doc/guides/source/migrations/index.txt +0 -22
  158. data/doc/guides/source/migrations/rakeing_around.txt +0 -111
  159. data/doc/guides/source/migrations/scheming.txt +0 -47
  160. data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
  161. data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
  162. data/doc/guides/source/routing_outside_in.txt +0 -986
  163. data/doc/guides/source/security.txt +0 -984
  164. data/doc/guides/source/stylesheets/base.css +0 -358
  165. data/doc/guides/source/stylesheets/forms.css +0 -35
  166. data/doc/guides/source/stylesheets/more.css +0 -82
  167. data/doc/guides/source/templates/guides.html.erb +0 -97
  168. data/doc/guides/source/templates/inline.css +0 -165
  169. data/doc/guides/source/testing_rails_applications.txt +0 -995
  170. data/environments/boot.rb +0 -109
  171. data/environments/development.rb +0 -17
  172. data/environments/environment.rb +0 -75
  173. data/environments/production.rb +0 -24
  174. data/environments/test.rb +0 -22
  175. data/fresh_rakefile +0 -10
  176. data/helpers/application.rb +0 -15
  177. data/helpers/application_helper.rb +0 -3
  178. data/helpers/performance_test.rb +0 -9
  179. data/helpers/test_helper.rb +0 -38
  180. data/html/404.html +0 -30
  181. data/html/422.html +0 -30
  182. data/html/500.html +0 -33
  183. data/html/favicon.ico +0 -0
  184. data/html/images/rails.png +0 -0
  185. data/html/index.html +0 -274
  186. data/html/javascripts/application.js +0 -2
  187. data/html/javascripts/controls.js +0 -963
  188. data/html/javascripts/dragdrop.js +0 -973
  189. data/html/javascripts/effects.js +0 -1128
  190. data/html/javascripts/prototype.js +0 -4320
  191. data/html/robots.txt +0 -5
  192. data/lib/code_statistics.rb +0 -107
  193. data/lib/commands.rb +0 -17
  194. data/lib/commands/about.rb +0 -3
  195. data/lib/commands/console.rb +0 -45
  196. data/lib/commands/dbconsole.rb +0 -67
  197. data/lib/commands/destroy.rb +0 -6
  198. data/lib/commands/generate.rb +0 -6
  199. data/lib/commands/ncgi/listener +0 -86
  200. data/lib/commands/ncgi/tracker +0 -69
  201. data/lib/commands/performance/benchmarker.rb +0 -24
  202. data/lib/commands/performance/profiler.rb +0 -50
  203. data/lib/commands/performance/request.rb +0 -6
  204. data/lib/commands/plugin.rb +0 -967
  205. data/lib/commands/process/inspector.rb +0 -68
  206. data/lib/commands/process/reaper.rb +0 -149
  207. data/lib/commands/process/spawner.rb +0 -219
  208. data/lib/commands/process/spinner.rb +0 -57
  209. data/lib/commands/runner.rb +0 -48
  210. data/lib/commands/server.rb +0 -49
  211. data/lib/commands/servers/base.rb +0 -31
  212. data/lib/commands/servers/lighttpd.rb +0 -94
  213. data/lib/commands/servers/mongrel.rb +0 -69
  214. data/lib/commands/servers/new_mongrel.rb +0 -16
  215. data/lib/commands/servers/thin.rb +0 -25
  216. data/lib/commands/servers/webrick.rb +0 -66
  217. data/lib/commands/update.rb +0 -4
  218. data/lib/console_app.rb +0 -30
  219. data/lib/console_sandbox.rb +0 -6
  220. data/lib/console_with_helpers.rb +0 -26
  221. data/lib/dispatcher.rb +0 -24
  222. data/lib/fcgi_handler.rb +0 -237
  223. data/lib/initializer.rb +0 -1038
  224. data/lib/performance_test_help.rb +0 -5
  225. data/lib/rails/gem_builder.rb +0 -21
  226. data/lib/rails/gem_dependency.rb +0 -251
  227. data/lib/rails/mongrel_server/commands.rb +0 -342
  228. data/lib/rails/mongrel_server/handler.rb +0 -55
  229. data/lib/rails/plugin.rb +0 -124
  230. data/lib/rails/plugin/loader.rb +0 -152
  231. data/lib/rails/plugin/locator.rb +0 -100
  232. data/lib/rails/rack.rb +0 -6
  233. data/lib/rails/rack/logger.rb +0 -28
  234. data/lib/rails/rack/static.rb +0 -35
  235. data/lib/rails/vendor_gem_source_index.rb +0 -140
  236. data/lib/rails/version.rb +0 -9
  237. data/lib/rails_generator.rb +0 -43
  238. data/lib/rails_generator/base.rb +0 -263
  239. data/lib/rails_generator/commands.rb +0 -616
  240. data/lib/rails_generator/generated_attribute.rb +0 -46
  241. data/lib/rails_generator/generators/applications/app/USAGE +0 -9
  242. data/lib/rails_generator/generators/applications/app/app_generator.rb +0 -184
  243. data/lib/rails_generator/generators/components/controller/USAGE +0 -29
  244. data/lib/rails_generator/generators/components/controller/controller_generator.rb +0 -37
  245. data/lib/rails_generator/generators/components/controller/templates/controller.rb +0 -7
  246. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +0 -8
  247. data/lib/rails_generator/generators/components/controller/templates/helper.rb +0 -2
  248. data/lib/rails_generator/generators/components/controller/templates/view.html.erb +0 -2
  249. data/lib/rails_generator/generators/components/integration_test/USAGE +0 -8
  250. data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +0 -16
  251. data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +0 -10
  252. data/lib/rails_generator/generators/components/mailer/USAGE +0 -16
  253. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +0 -30
  254. data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +0 -3
  255. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
  256. data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +0 -15
  257. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +0 -20
  258. data/lib/rails_generator/generators/components/mailer/templates/view.erb +0 -3
  259. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
  260. data/lib/rails_generator/generators/components/migration/USAGE +0 -29
  261. data/lib/rails_generator/generators/components/migration/migration_generator.rb +0 -20
  262. data/lib/rails_generator/generators/components/migration/templates/migration.rb +0 -11
  263. data/lib/rails_generator/generators/components/model/USAGE +0 -27
  264. data/lib/rails_generator/generators/components/model/model_generator.rb +0 -45
  265. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +0 -19
  266. data/lib/rails_generator/generators/components/model/templates/migration.rb +0 -16
  267. data/lib/rails_generator/generators/components/model/templates/model.rb +0 -5
  268. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +0 -8
  269. data/lib/rails_generator/generators/components/observer/USAGE +0 -13
  270. data/lib/rails_generator/generators/components/observer/observer_generator.rb +0 -16
  271. data/lib/rails_generator/generators/components/observer/templates/observer.rb +0 -2
  272. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +0 -8
  273. data/lib/rails_generator/generators/components/performance_test/USAGE +0 -8
  274. data/lib/rails_generator/generators/components/performance_test/performance_test_generator.rb +0 -16
  275. data/lib/rails_generator/generators/components/performance_test/templates/performance_test.rb +0 -9
  276. data/lib/rails_generator/generators/components/plugin/USAGE +0 -25
  277. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +0 -39
  278. data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +0 -20
  279. data/lib/rails_generator/generators/components/plugin/templates/README +0 -13
  280. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +0 -23
  281. data/lib/rails_generator/generators/components/plugin/templates/USAGE +0 -8
  282. data/lib/rails_generator/generators/components/plugin/templates/generator.rb +0 -8
  283. data/lib/rails_generator/generators/components/plugin/templates/init.rb +0 -1
  284. data/lib/rails_generator/generators/components/plugin/templates/install.rb +0 -1
  285. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +0 -1
  286. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +0 -4
  287. data/lib/rails_generator/generators/components/plugin/templates/test_helper.rb +0 -3
  288. data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +0 -1
  289. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +0 -8
  290. data/lib/rails_generator/generators/components/resource/USAGE +0 -23
  291. data/lib/rails_generator/generators/components/resource/resource_generator.rb +0 -74
  292. data/lib/rails_generator/generators/components/resource/templates/controller.rb +0 -2
  293. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +0 -8
  294. data/lib/rails_generator/generators/components/resource/templates/helper.rb +0 -2
  295. data/lib/rails_generator/generators/components/scaffold/USAGE +0 -29
  296. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -100
  297. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +0 -85
  298. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +0 -45
  299. data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +0 -2
  300. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +0 -17
  301. data/lib/rails_generator/generators/components/scaffold/templates/style.css +0 -54
  302. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +0 -18
  303. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +0 -24
  304. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +0 -17
  305. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +0 -10
  306. data/lib/rails_generator/generators/components/session_migration/USAGE +0 -10
  307. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +0 -18
  308. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +0 -16
  309. data/lib/rails_generator/lookup.rb +0 -249
  310. data/lib/rails_generator/manifest.rb +0 -53
  311. data/lib/rails_generator/options.rb +0 -150
  312. data/lib/rails_generator/scripts.rb +0 -89
  313. data/lib/rails_generator/scripts/destroy.rb +0 -29
  314. data/lib/rails_generator/scripts/generate.rb +0 -7
  315. data/lib/rails_generator/scripts/update.rb +0 -12
  316. data/lib/rails_generator/secret_key_generator.rb +0 -22
  317. data/lib/rails_generator/simple_logger.rb +0 -46
  318. data/lib/rails_generator/spec.rb +0 -44
  319. data/lib/railties_path.rb +0 -1
  320. data/lib/ruby_version_check.rb +0 -17
  321. data/lib/rubyprof_ext.rb +0 -35
  322. data/lib/source_annotation_extractor.rb +0 -102
  323. data/lib/tasks/annotations.rake +0 -20
  324. data/lib/tasks/databases.rake +0 -416
  325. data/lib/tasks/documentation.rake +0 -95
  326. data/lib/tasks/framework.rake +0 -118
  327. data/lib/tasks/gems.rake +0 -80
  328. data/lib/tasks/log.rake +0 -9
  329. data/lib/tasks/misc.rake +0 -56
  330. data/lib/tasks/rails.rb +0 -8
  331. data/lib/tasks/routes.rake +0 -17
  332. data/lib/tasks/statistics.rake +0 -18
  333. data/lib/tasks/testing.rake +0 -139
  334. data/lib/tasks/tmp.rake +0 -37
  335. data/lib/test_help.rb +0 -27
  336. data/lib/webrick_server.rb +0 -156
@@ -1,102 +0,0 @@
1
- # Implements the logic behind the rake tasks for annotations like
2
- #
3
- # rake notes
4
- # rake notes:optimize
5
- #
6
- # and friends. See <tt>rake -T notes</tt> and <tt>railties/lib/tasks/annotations.rake</tt>.
7
- #
8
- # Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
9
- # represent the line where the annotation lives, its tag, and its text. Note
10
- # the filename is not stored.
11
- #
12
- # Annotations are looked for in comments and modulus whitespace they have to
13
- # start with the tag optionally followed by a colon. Everything up to the end
14
- # of the line (or closing ERb comment tag) is considered to be their text.
15
- class SourceAnnotationExtractor
16
- class Annotation < Struct.new(:line, :tag, :text)
17
-
18
- # Returns a representation of the annotation that looks like this:
19
- #
20
- # [126] [TODO] This algorithm is simple and clearly correct, make it faster.
21
- #
22
- # If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
23
- # Otherwise the string contains just line and text.
24
- def to_s(options={})
25
- s = "[%3d] " % line
26
- s << "[#{tag}] " if options[:tag]
27
- s << text
28
- end
29
- end
30
-
31
- # Prints all annotations with tag +tag+ under the root directories +app+, +lib+,
32
- # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+,
33
- # +.rxml+, +.rjs+, +.rhtml+, or +.erb+ are taken into account. The +options+
34
- # hash is passed to each annotation's +to_s+.
35
- #
36
- # This class method is the single entry point for the rake tasks.
37
- def self.enumerate(tag, options={})
38
- extractor = new(tag)
39
- extractor.display(extractor.find, options)
40
- end
41
-
42
- attr_reader :tag
43
-
44
- def initialize(tag)
45
- @tag = tag
46
- end
47
-
48
- # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
49
- # with their annotations. Only files with annotations are included, and only
50
- # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
51
- # are taken into account.
52
- def find(dirs=%w(app lib test))
53
- dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
54
- end
55
-
56
- # Returns a hash that maps filenames under +dir+ (recursively) to arrays
57
- # with their annotations. Only files with annotations are included, and only
58
- # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
59
- # are taken into account.
60
- def find_in(dir)
61
- results = {}
62
-
63
- Dir.glob("#{dir}/*") do |item|
64
- next if File.basename(item)[0] == ?.
65
-
66
- if File.directory?(item)
67
- results.update(find_in(item))
68
- elsif item =~ /\.(builder|(r(?:b|xml|js)))$/
69
- results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
70
- elsif item =~ /\.(rhtml|erb)$/
71
- results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
72
- end
73
- end
74
-
75
- results
76
- end
77
-
78
- # If +file+ is the filename of a file that contains annotations this method returns
79
- # a hash with a single entry that maps +file+ to an array of its annotations.
80
- # Otherwise it returns an empty hash.
81
- def extract_annotations_from(file, pattern)
82
- lineno = 0
83
- result = File.readlines(file).inject([]) do |list, line|
84
- lineno += 1
85
- next list unless line =~ pattern
86
- list << Annotation.new(lineno, $1, $2)
87
- end
88
- result.empty? ? {} : { file => result }
89
- end
90
-
91
- # Prints the mapping from filenames to annotations in +results+ ordered by filename.
92
- # The +options+ hash is passed to each annotation's +to_s+.
93
- def display(results, options={})
94
- results.keys.sort.each do |file|
95
- puts "#{file}:"
96
- results[file].each do |note|
97
- puts " * #{note.to_s(options)}"
98
- end
99
- puts
100
- end
101
- end
102
- end
@@ -1,20 +0,0 @@
1
- require 'source_annotation_extractor'
2
-
3
- desc "Enumerate all annotations"
4
- task :notes do
5
- SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
6
- end
7
-
8
- namespace :notes do
9
- ["OPTIMIZE", "FIXME", "TODO"].each do |annotation|
10
- desc "Enumerate all #{annotation} annotations"
11
- task annotation.downcase.intern do
12
- SourceAnnotationExtractor.enumerate annotation
13
- end
14
- end
15
-
16
- desc "Enumerate a custom annotation, specify with ANNOTATION=WTFHAX"
17
- task :custom do
18
- SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
19
- end
20
- end
@@ -1,416 +0,0 @@
1
- namespace :db do
2
- namespace :create do
3
- desc 'Create all the local databases defined in config/database.yml'
4
- task :all => :environment do
5
- ActiveRecord::Base.configurations.each_value do |config|
6
- # Skip entries that don't have a database key, such as the first entry here:
7
- #
8
- # defaults: &defaults
9
- # adapter: mysql
10
- # username: root
11
- # password:
12
- # host: localhost
13
- #
14
- # development:
15
- # database: blog_development
16
- # <<: *defaults
17
- next unless config['database']
18
- # Only connect to local databases
19
- local_database?(config) { create_database(config) }
20
- end
21
- end
22
- end
23
-
24
- desc 'Create the database defined in config/database.yml for the current RAILS_ENV'
25
- task :create => :environment do
26
- create_database(ActiveRecord::Base.configurations[RAILS_ENV])
27
- end
28
-
29
- def create_database(config)
30
- begin
31
- if config['adapter'] =~ /sqlite/
32
- if File.exist?(config['database'])
33
- $stderr.puts "#{config['database']} already exists"
34
- else
35
- begin
36
- # Create the SQLite database
37
- ActiveRecord::Base.establish_connection(config)
38
- ActiveRecord::Base.connection
39
- rescue
40
- $stderr.puts $!, *($!.backtrace)
41
- $stderr.puts "Couldn't create database for #{config.inspect}"
42
- end
43
- end
44
- return # Skip the else clause of begin/rescue
45
- else
46
- ActiveRecord::Base.establish_connection(config)
47
- ActiveRecord::Base.connection
48
- end
49
- rescue
50
- case config['adapter']
51
- when 'mysql'
52
- @charset = ENV['CHARSET'] || 'utf8'
53
- @collation = ENV['COLLATION'] || 'utf8_general_ci'
54
- begin
55
- ActiveRecord::Base.establish_connection(config.merge('database' => nil))
56
- ActiveRecord::Base.connection.create_database(config['database'], :charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation))
57
- ActiveRecord::Base.establish_connection(config)
58
- rescue
59
- $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)"
60
- end
61
- when 'postgresql'
62
- @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
63
- begin
64
- ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
65
- ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
66
- ActiveRecord::Base.establish_connection(config)
67
- rescue
68
- $stderr.puts $!, *($!.backtrace)
69
- $stderr.puts "Couldn't create database for #{config.inspect}"
70
- end
71
- end
72
- else
73
- $stderr.puts "#{config['database']} already exists"
74
- end
75
- end
76
-
77
- namespace :drop do
78
- desc 'Drops all the local databases defined in config/database.yml'
79
- task :all => :environment do
80
- ActiveRecord::Base.configurations.each_value do |config|
81
- # Skip entries that don't have a database key
82
- next unless config['database']
83
- # Only connect to local databases
84
- local_database?(config) { drop_database(config) }
85
- end
86
- end
87
- end
88
-
89
- desc 'Drops the database for the current RAILS_ENV'
90
- task :drop => :environment do
91
- config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
92
- begin
93
- drop_database(config)
94
- rescue Exception => e
95
- puts "Couldn't drop #{config['database']} : #{e.inspect}"
96
- end
97
- end
98
-
99
- def local_database?(config, &block)
100
- if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank?
101
- yield
102
- else
103
- puts "This task only modifies local databases. #{config['database']} is on a remote host."
104
- end
105
- end
106
-
107
-
108
- desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
109
- task :migrate => :environment do
110
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
111
- ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
112
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
113
- end
114
-
115
- namespace :migrate do
116
- desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
117
- task :redo => :environment do
118
- if ENV["VERSION"]
119
- Rake::Task["db:migrate:down"].invoke
120
- Rake::Task["db:migrate:up"].invoke
121
- else
122
- Rake::Task["db:rollback"].invoke
123
- Rake::Task["db:migrate"].invoke
124
- end
125
- end
126
-
127
- desc 'Resets your database using your migrations for the current environment'
128
- task :reset => ["db:drop", "db:create", "db:migrate"]
129
-
130
- desc 'Runs the "up" for a given migration VERSION.'
131
- task :up => :environment do
132
- version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
133
- raise "VERSION is required" unless version
134
- ActiveRecord::Migrator.run(:up, "db/migrate/", version)
135
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
136
- end
137
-
138
- desc 'Runs the "down" for a given migration VERSION.'
139
- task :down => :environment do
140
- version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
141
- raise "VERSION is required" unless version
142
- ActiveRecord::Migrator.run(:down, "db/migrate/", version)
143
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
144
- end
145
- end
146
-
147
- desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
148
- task :rollback => :environment do
149
- step = ENV['STEP'] ? ENV['STEP'].to_i : 1
150
- ActiveRecord::Migrator.rollback('db/migrate/', step)
151
- Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
152
- end
153
-
154
- desc 'Drops and recreates the database from db/schema.rb for the current environment.'
155
- task :reset => ['db:drop', 'db:create', 'db:schema:load']
156
-
157
- desc "Retrieves the charset for the current environment's database"
158
- task :charset => :environment do
159
- config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
160
- case config['adapter']
161
- when 'mysql'
162
- ActiveRecord::Base.establish_connection(config)
163
- puts ActiveRecord::Base.connection.charset
164
- when 'postgresql'
165
- ActiveRecord::Base.establish_connection(config)
166
- puts ActiveRecord::Base.connection.encoding
167
- else
168
- puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
169
- end
170
- end
171
-
172
- desc "Retrieves the collation for the current environment's database"
173
- task :collation => :environment do
174
- config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
175
- case config['adapter']
176
- when 'mysql'
177
- ActiveRecord::Base.establish_connection(config)
178
- puts ActiveRecord::Base.connection.collation
179
- else
180
- puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
181
- end
182
- end
183
-
184
- desc "Retrieves the current schema version number"
185
- task :version => :environment do
186
- puts "Current version: #{ActiveRecord::Migrator.current_version}"
187
- end
188
-
189
- desc "Raises an error if there are pending migrations"
190
- task :abort_if_pending_migrations => :environment do
191
- if defined? ActiveRecord
192
- pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
193
-
194
- if pending_migrations.any?
195
- puts "You have #{pending_migrations.size} pending migrations:"
196
- pending_migrations.each do |pending_migration|
197
- puts ' %4d %s' % [pending_migration.version, pending_migration.name]
198
- end
199
- abort %{Run "rake db:migrate" to update your database then try again.}
200
- end
201
- end
202
- end
203
-
204
- namespace :fixtures do
205
- desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
206
- task :load => :environment do
207
- require 'active_record/fixtures'
208
- ActiveRecord::Base.establish_connection(Rails.env)
209
- base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
210
- fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
211
-
212
- (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
213
- Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
214
- end
215
- end
216
-
217
- desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
218
- task :identify => :environment do
219
- require "active_record/fixtures"
220
-
221
- label, id = ENV["LABEL"], ENV["ID"]
222
- raise "LABEL or ID required" if label.blank? && id.blank?
223
-
224
- puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
225
-
226
- base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
227
- Dir["#{base_dir}/**/*.yml"].each do |file|
228
- if data = YAML::load(ERB.new(IO.read(file)).result)
229
- data.keys.each do |key|
230
- key_id = Fixtures.identify(key)
231
-
232
- if key == label || key_id == id.to_i
233
- puts "#{file}: #{key} (#{key_id})"
234
- end
235
- end
236
- end
237
- end
238
- end
239
- end
240
-
241
- namespace :schema do
242
- desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
243
- task :dump => :environment do
244
- require 'active_record/schema_dumper'
245
- File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file|
246
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
247
- end
248
- end
249
-
250
- desc "Load a schema.rb file into the database"
251
- task :load => :environment do
252
- file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
253
- load(file)
254
- end
255
- end
256
-
257
- namespace :structure do
258
- desc "Dump the database structure to a SQL file"
259
- task :dump => :environment do
260
- abcs = ActiveRecord::Base.configurations
261
- case abcs[RAILS_ENV]["adapter"]
262
- when "mysql", "oci", "oracle"
263
- ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
264
- File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
265
- when "postgresql"
266
- ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
267
- ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
268
- ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"]
269
- search_path = abcs[RAILS_ENV]["schema_search_path"]
270
- search_path = "--schema=#{search_path}" if search_path
271
- `pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}`
272
- raise "Error dumping database" if $?.exitstatus == 1
273
- when "sqlite", "sqlite3"
274
- dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"]
275
- `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql`
276
- when "sqlserver"
277
- `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
278
- `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
279
- when "firebird"
280
- set_firebird_env(abcs[RAILS_ENV])
281
- db_string = firebird_db_string(abcs[RAILS_ENV])
282
- sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql"
283
- else
284
- raise "Task not supported by '#{abcs["test"]["adapter"]}'"
285
- end
286
-
287
- if ActiveRecord::Base.connection.supports_migrations?
288
- File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
289
- end
290
- end
291
- end
292
-
293
- namespace :test do
294
- desc "Recreate the test database from the current schema.rb"
295
- task :load => 'db:test:purge' do
296
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
297
- ActiveRecord::Schema.verbose = false
298
- Rake::Task["db:schema:load"].invoke
299
- end
300
-
301
- desc "Recreate the test database from the current environment's database schema"
302
- task :clone => %w(db:schema:dump db:test:load)
303
-
304
- desc "Recreate the test databases from the development structure"
305
- task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
306
- abcs = ActiveRecord::Base.configurations
307
- case abcs["test"]["adapter"]
308
- when "mysql"
309
- ActiveRecord::Base.establish_connection(:test)
310
- ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
311
- IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
312
- ActiveRecord::Base.connection.execute(table)
313
- end
314
- when "postgresql"
315
- ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
316
- ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
317
- ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
318
- `psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
319
- when "sqlite", "sqlite3"
320
- dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
321
- `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql`
322
- when "sqlserver"
323
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
324
- when "oci", "oracle"
325
- ActiveRecord::Base.establish_connection(:test)
326
- IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
327
- ActiveRecord::Base.connection.execute(ddl)
328
- end
329
- when "firebird"
330
- set_firebird_env(abcs["test"])
331
- db_string = firebird_db_string(abcs["test"])
332
- sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}"
333
- else
334
- raise "Task not supported by '#{abcs["test"]["adapter"]}'"
335
- end
336
- end
337
-
338
- desc "Empty the test database"
339
- task :purge => :environment do
340
- abcs = ActiveRecord::Base.configurations
341
- case abcs["test"]["adapter"]
342
- when "mysql"
343
- ActiveRecord::Base.establish_connection(:test)
344
- ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
345
- when "postgresql"
346
- ActiveRecord::Base.clear_active_connections!
347
- drop_database(abcs['test'])
348
- create_database(abcs['test'])
349
- when "sqlite","sqlite3"
350
- dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
351
- File.delete(dbfile) if File.exist?(dbfile)
352
- when "sqlserver"
353
- dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
354
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
355
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
356
- when "oci", "oracle"
357
- ActiveRecord::Base.establish_connection(:test)
358
- ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
359
- ActiveRecord::Base.connection.execute(ddl)
360
- end
361
- when "firebird"
362
- ActiveRecord::Base.establish_connection(:test)
363
- ActiveRecord::Base.connection.recreate_database!
364
- else
365
- raise "Task not supported by '#{abcs["test"]["adapter"]}'"
366
- end
367
- end
368
-
369
- desc 'Check for pending migrations and load the test schema'
370
- task :prepare => 'db:abort_if_pending_migrations' do
371
- if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
372
- Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke
373
- end
374
- end
375
- end
376
-
377
- namespace :sessions do
378
- desc "Creates a sessions migration for use with CGI::Session::ActiveRecordStore"
379
- task :create => :environment do
380
- raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
381
- require 'rails_generator'
382
- require 'rails_generator/scripts/generate'
383
- Rails::Generator::Scripts::Generate.new.run(["session_migration", ENV["MIGRATION"] || "CreateSessions"])
384
- end
385
-
386
- desc "Clear the sessions table"
387
- task :clear => :environment do
388
- ActiveRecord::Base.connection.execute "DELETE FROM #{session_table_name}"
389
- end
390
- end
391
- end
392
-
393
- def drop_database(config)
394
- case config['adapter']
395
- when 'mysql'
396
- ActiveRecord::Base.connection.drop_database config['database']
397
- when /^sqlite/
398
- FileUtils.rm(File.join(RAILS_ROOT, config['database']))
399
- when 'postgresql'
400
- ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
401
- ActiveRecord::Base.connection.drop_database config['database']
402
- end
403
- end
404
-
405
- def session_table_name
406
- ActiveRecord::Base.pluralize_table_names ? :sessions : :session
407
- end
408
-
409
- def set_firebird_env(config)
410
- ENV["ISC_USER"] = config["username"].to_s if config["username"]
411
- ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"]
412
- end
413
-
414
- def firebird_db_string(config)
415
- FireRuby::Database.db_string_for(config.symbolize_keys)
416
- end