openskies 0.0.5.2 → 0.0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (491) hide show
  1. data/CHANGELOG.md +0 -87
  2. data/bin/openskies +31 -5
  3. metadata +4 -593
  4. data/guides/assets/images/belongs_to.png +0 -0
  5. data/guides/assets/images/book_icon.gif +0 -0
  6. data/guides/assets/images/bullet.gif +0 -0
  7. data/guides/assets/images/challenge.png +0 -0
  8. data/guides/assets/images/chapters_icon.gif +0 -0
  9. data/guides/assets/images/check_bullet.gif +0 -0
  10. data/guides/assets/images/credits_pic_blank.gif +0 -0
  11. data/guides/assets/images/csrf.png +0 -0
  12. data/guides/assets/images/customized_error_messages.png +0 -0
  13. data/guides/assets/images/edge_badge.png +0 -0
  14. data/guides/assets/images/error_messages.png +0 -0
  15. data/guides/assets/images/feature_tile.gif +0 -0
  16. data/guides/assets/images/footer_tile.gif +0 -0
  17. data/guides/assets/images/fxn.png +0 -0
  18. data/guides/assets/images/grey_bullet.gif +0 -0
  19. data/guides/assets/images/habtm.png +0 -0
  20. data/guides/assets/images/has_many.png +0 -0
  21. data/guides/assets/images/has_many_through.png +0 -0
  22. data/guides/assets/images/has_one.png +0 -0
  23. data/guides/assets/images/has_one_through.png +0 -0
  24. data/guides/assets/images/header_backdrop.png +0 -0
  25. data/guides/assets/images/header_tile.gif +0 -0
  26. data/guides/assets/images/i18n/demo_html_safe.png +0 -0
  27. data/guides/assets/images/i18n/demo_localized_pirate.png +0 -0
  28. data/guides/assets/images/i18n/demo_translated_en.png +0 -0
  29. data/guides/assets/images/i18n/demo_translated_pirate.png +0 -0
  30. data/guides/assets/images/i18n/demo_translation_missing.png +0 -0
  31. data/guides/assets/images/i18n/demo_untranslated.png +0 -0
  32. data/guides/assets/images/icons/README +0 -5
  33. data/guides/assets/images/icons/callouts/1.png +0 -0
  34. data/guides/assets/images/icons/callouts/10.png +0 -0
  35. data/guides/assets/images/icons/callouts/11.png +0 -0
  36. data/guides/assets/images/icons/callouts/12.png +0 -0
  37. data/guides/assets/images/icons/callouts/13.png +0 -0
  38. data/guides/assets/images/icons/callouts/14.png +0 -0
  39. data/guides/assets/images/icons/callouts/15.png +0 -0
  40. data/guides/assets/images/icons/callouts/2.png +0 -0
  41. data/guides/assets/images/icons/callouts/3.png +0 -0
  42. data/guides/assets/images/icons/callouts/4.png +0 -0
  43. data/guides/assets/images/icons/callouts/5.png +0 -0
  44. data/guides/assets/images/icons/callouts/6.png +0 -0
  45. data/guides/assets/images/icons/callouts/7.png +0 -0
  46. data/guides/assets/images/icons/callouts/8.png +0 -0
  47. data/guides/assets/images/icons/callouts/9.png +0 -0
  48. data/guides/assets/images/icons/caution.png +0 -0
  49. data/guides/assets/images/icons/example.png +0 -0
  50. data/guides/assets/images/icons/home.png +0 -0
  51. data/guides/assets/images/icons/important.png +0 -0
  52. data/guides/assets/images/icons/next.png +0 -0
  53. data/guides/assets/images/icons/note.png +0 -0
  54. data/guides/assets/images/icons/prev.png +0 -0
  55. data/guides/assets/images/icons/tip.png +0 -0
  56. data/guides/assets/images/icons/up.png +0 -0
  57. data/guides/assets/images/icons/warning.png +0 -0
  58. data/guides/assets/images/jaimeiniesta.jpg +0 -0
  59. data/guides/assets/images/nav_arrow.gif +0 -0
  60. data/guides/assets/images/polymorphic.png +0 -0
  61. data/guides/assets/images/posts_index.png +0 -0
  62. data/guides/assets/images/radar.png +0 -0
  63. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  64. data/guides/assets/images/rails_guides_logo.gif +0 -0
  65. data/guides/assets/images/rails_logo_remix.gif +0 -0
  66. data/guides/assets/images/rails_welcome.png +0 -0
  67. data/guides/assets/images/session_fixation.png +0 -0
  68. data/guides/assets/images/tab_grey.gif +0 -0
  69. data/guides/assets/images/tab_info.gif +0 -0
  70. data/guides/assets/images/tab_note.gif +0 -0
  71. data/guides/assets/images/tab_red.gif +0 -0
  72. data/guides/assets/images/tab_yellow.gif +0 -0
  73. data/guides/assets/images/tab_yellow.png +0 -0
  74. data/guides/assets/images/validation_error_messages.png +0 -0
  75. data/guides/assets/images/vijaydev.jpg +0 -0
  76. data/guides/assets/javascripts/guides.js +0 -7
  77. data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  78. data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  79. data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  80. data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  81. data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  82. data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  83. data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  84. data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  85. data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  86. data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  87. data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  88. data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  89. data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  90. data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  91. data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  92. data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  93. data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  94. data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  95. data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  96. data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  97. data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  98. data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  99. data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  100. data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  101. data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  102. data/guides/assets/javascripts/syntaxhighlighter/shCore.js +0 -17
  103. data/guides/assets/stylesheets/fixes.css +0 -16
  104. data/guides/assets/stylesheets/kindle.css +0 -11
  105. data/guides/assets/stylesheets/main.css +0 -453
  106. data/guides/assets/stylesheets/print.css +0 -52
  107. data/guides/assets/stylesheets/reset.css +0 -43
  108. data/guides/assets/stylesheets/style.css +0 -13
  109. data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +0 -226
  110. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  111. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  112. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  113. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  114. data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  115. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  116. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  117. data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  118. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  119. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  120. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  121. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  122. data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  123. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  124. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  125. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  126. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  127. data/guides/code/getting_started/Gemfile +0 -38
  128. data/guides/code/getting_started/README.rdoc +0 -261
  129. data/guides/code/getting_started/Rakefile +0 -7
  130. data/guides/code/getting_started/app/assets/images/rails.png +0 -0
  131. data/guides/code/getting_started/app/assets/javascripts/application.js +0 -15
  132. data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +0 -3
  133. data/guides/code/getting_started/app/assets/javascripts/home.js.coffee +0 -3
  134. data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +0 -3
  135. data/guides/code/getting_started/app/assets/stylesheets/application.css +0 -13
  136. data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +0 -3
  137. data/guides/code/getting_started/app/assets/stylesheets/home.css.scss +0 -3
  138. data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +0 -3
  139. data/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss +0 -56
  140. data/guides/code/getting_started/app/controllers/application_controller.rb +0 -3
  141. data/guides/code/getting_started/app/controllers/comments_controller.rb +0 -16
  142. data/guides/code/getting_started/app/controllers/home_controller.rb +0 -5
  143. data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -84
  144. data/guides/code/getting_started/app/helpers/application_helper.rb +0 -2
  145. data/guides/code/getting_started/app/helpers/comments_helper.rb +0 -2
  146. data/guides/code/getting_started/app/helpers/home_helper.rb +0 -2
  147. data/guides/code/getting_started/app/helpers/posts_helper.rb +0 -5
  148. data/guides/code/getting_started/app/models/comment.rb +0 -3
  149. data/guides/code/getting_started/app/models/post.rb +0 -11
  150. data/guides/code/getting_started/app/models/tag.rb +0 -3
  151. data/guides/code/getting_started/app/views/comments/_comment.html.erb +0 -15
  152. data/guides/code/getting_started/app/views/comments/_form.html.erb +0 -13
  153. data/guides/code/getting_started/app/views/home/index.html.erb +0 -2
  154. data/guides/code/getting_started/app/views/layouts/application.html.erb +0 -14
  155. data/guides/code/getting_started/app/views/posts/_form.html.erb +0 -32
  156. data/guides/code/getting_started/app/views/posts/edit.html.erb +0 -6
  157. data/guides/code/getting_started/app/views/posts/index.html.erb +0 -27
  158. data/guides/code/getting_started/app/views/posts/new.html.erb +0 -5
  159. data/guides/code/getting_started/app/views/posts/show.html.erb +0 -31
  160. data/guides/code/getting_started/app/views/tags/_form.html.erb +0 -12
  161. data/guides/code/getting_started/config/application.rb +0 -59
  162. data/guides/code/getting_started/config/boot.rb +0 -6
  163. data/guides/code/getting_started/config/database.yml +0 -25
  164. data/guides/code/getting_started/config/environment.rb +0 -5
  165. data/guides/code/getting_started/config/environments/development.rb +0 -37
  166. data/guides/code/getting_started/config/environments/production.rb +0 -67
  167. data/guides/code/getting_started/config/environments/test.rb +0 -37
  168. data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +0 -7
  169. data/guides/code/getting_started/config/initializers/inflections.rb +0 -15
  170. data/guides/code/getting_started/config/initializers/mime_types.rb +0 -5
  171. data/guides/code/getting_started/config/initializers/secret_token.rb +0 -7
  172. data/guides/code/getting_started/config/initializers/session_store.rb +0 -8
  173. data/guides/code/getting_started/config/initializers/wrap_parameters.rb +0 -14
  174. data/guides/code/getting_started/config/locales/en.yml +0 -5
  175. data/guides/code/getting_started/config/routes.rb +0 -64
  176. data/guides/code/getting_started/config.ru +0 -4
  177. data/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb +0 -11
  178. data/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb +0 -12
  179. data/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb +0 -11
  180. data/guides/code/getting_started/db/schema.rb +0 -43
  181. data/guides/code/getting_started/db/seeds.rb +0 -7
  182. data/guides/code/getting_started/doc/README_FOR_APP +0 -2
  183. data/guides/code/getting_started/public/404.html +0 -26
  184. data/guides/code/getting_started/public/422.html +0 -26
  185. data/guides/code/getting_started/public/500.html +0 -25
  186. data/guides/code/getting_started/public/favicon.ico +0 -0
  187. data/guides/code/getting_started/public/robots.txt +0 -5
  188. data/guides/code/getting_started/script/rails +0 -6
  189. data/guides/code/getting_started/test/fixtures/comments.yml +0 -11
  190. data/guides/code/getting_started/test/fixtures/posts.yml +0 -11
  191. data/guides/code/getting_started/test/fixtures/tags.yml +0 -9
  192. data/guides/code/getting_started/test/functional/comments_controller_test.rb +0 -7
  193. data/guides/code/getting_started/test/functional/home_controller_test.rb +0 -9
  194. data/guides/code/getting_started/test/functional/posts_controller_test.rb +0 -49
  195. data/guides/code/getting_started/test/performance/browsing_test.rb +0 -12
  196. data/guides/code/getting_started/test/test_helper.rb +0 -13
  197. data/guides/code/getting_started/test/unit/comment_test.rb +0 -7
  198. data/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb +0 -4
  199. data/guides/code/getting_started/test/unit/helpers/home_helper_test.rb +0 -4
  200. data/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb +0 -4
  201. data/guides/code/getting_started/test/unit/post_test.rb +0 -7
  202. data/guides/code/getting_started/test/unit/tag_test.rb +0 -7
  203. data/guides/rails_guides/generator.rb +0 -310
  204. data/guides/rails_guides/helpers.rb +0 -45
  205. data/guides/rails_guides/indexer.rb +0 -69
  206. data/guides/rails_guides/levenshtein.rb +0 -31
  207. data/guides/rails_guides/textile_extensions.rb +0 -63
  208. data/guides/rails_guides.rb +0 -50
  209. data/guides/source/2_2_release_notes.textile +0 -422
  210. data/guides/source/2_3_release_notes.textile +0 -610
  211. data/guides/source/3_0_release_notes.textile +0 -595
  212. data/guides/source/3_1_release_notes.textile +0 -553
  213. data/guides/source/3_2_release_notes.textile +0 -540
  214. data/guides/source/_license.html.erb +0 -2
  215. data/guides/source/_welcome.html.erb +0 -19
  216. data/guides/source/action_controller_overview.textile +0 -820
  217. data/guides/source/action_mailer_basics.textile +0 -516
  218. data/guides/source/action_view_overview.textile +0 -1497
  219. data/guides/source/active_model_basics.textile +0 -205
  220. data/guides/source/active_record_basics.textile +0 -218
  221. data/guides/source/active_record_querying.textile +0 -1433
  222. data/guides/source/active_record_validations_callbacks.textile +0 -1283
  223. data/guides/source/active_resource_basics.textile +0 -120
  224. data/guides/source/active_support_core_extensions.textile +0 -3713
  225. data/guides/source/ajax_on_rails.textile +0 -267
  226. data/guides/source/api_documentation_guidelines.textile +0 -185
  227. data/guides/source/asset_pipeline.textile +0 -707
  228. data/guides/source/association_basics.textile +0 -1959
  229. data/guides/source/caching_with_rails.textile +0 -437
  230. data/guides/source/command_line.textile +0 -574
  231. data/guides/source/configuring.textile +0 -641
  232. data/guides/source/contributing_to_ruby_on_rails.textile +0 -448
  233. data/guides/source/credits.html.erb +0 -72
  234. data/guides/source/debugging_rails_applications.textile +0 -714
  235. data/guides/source/documents.yaml +0 -157
  236. data/guides/source/engines.textile +0 -618
  237. data/guides/source/form_helpers.textile +0 -798
  238. data/guides/source/generators.textile +0 -621
  239. data/guides/source/getting_started.textile +0 -1929
  240. data/guides/source/i18n.textile +0 -931
  241. data/guides/source/index.html.erb +0 -30
  242. data/guides/source/initialization.textile +0 -1116
  243. data/guides/source/kindle/KINDLE.md +0 -26
  244. data/guides/source/kindle/copyright.html.erb +0 -1
  245. data/guides/source/kindle/layout.html.erb +0 -27
  246. data/guides/source/kindle/rails_guides.opf.erb +0 -52
  247. data/guides/source/kindle/toc.html.erb +0 -24
  248. data/guides/source/kindle/toc.ncx.erb +0 -64
  249. data/guides/source/kindle/welcome.html.erb +0 -5
  250. data/guides/source/layout.html.erb +0 -124
  251. data/guides/source/layouts_and_rendering.textile +0 -1237
  252. data/guides/source/migrations.textile +0 -900
  253. data/guides/source/nested_model_forms.textile +0 -222
  254. data/guides/source/performance_testing.textile +0 -597
  255. data/guides/source/plugins.textile +0 -464
  256. data/guides/source/rails_application_templates.textile +0 -240
  257. data/guides/source/rails_on_rack.textile +0 -236
  258. data/guides/source/routing.textile +0 -885
  259. data/guides/source/ruby_on_rails_guides_guidelines.textile +0 -79
  260. data/guides/source/security.textile +0 -1004
  261. data/guides/source/testing.textile +0 -947
  262. data/guides/w3c_validator.rb +0 -91
  263. data/lib/rails/all.rb +0 -15
  264. data/lib/rails/application/bootstrap.rb +0 -73
  265. data/lib/rails/application/configuration.rb +0 -151
  266. data/lib/rails/application/finisher.rb +0 -98
  267. data/lib/rails/application/railties.rb +0 -13
  268. data/lib/rails/application/route_inspector.rb +0 -84
  269. data/lib/rails/application/routes_reloader.rb +0 -56
  270. data/lib/rails/application.rb +0 -320
  271. data/lib/rails/backtrace_cleaner.rb +0 -42
  272. data/lib/rails/cli.rb +0 -16
  273. data/lib/rails/code_statistics.rb +0 -118
  274. data/lib/rails/commands/application.rb +0 -36
  275. data/lib/rails/commands/benchmarker.rb +0 -34
  276. data/lib/rails/commands/console.rb +0 -55
  277. data/lib/rails/commands/dbconsole.rb +0 -123
  278. data/lib/rails/commands/destroy.rb +0 -10
  279. data/lib/rails/commands/generate.rb +0 -12
  280. data/lib/rails/commands/plugin.rb +0 -544
  281. data/lib/rails/commands/plugin_new.rb +0 -11
  282. data/lib/rails/commands/profiler.rb +0 -32
  283. data/lib/rails/commands/runner.rb +0 -54
  284. data/lib/rails/commands/server.rb +0 -100
  285. data/lib/rails/commands/update.rb +0 -9
  286. data/lib/rails/commands.rb +0 -104
  287. data/lib/rails/configuration.rb +0 -89
  288. data/lib/rails/console/app.rb +0 -36
  289. data/lib/rails/console/helpers.rb +0 -11
  290. data/lib/rails/engine/commands.rb +0 -43
  291. data/lib/rails/engine/configuration.rb +0 -84
  292. data/lib/rails/engine/railties.rb +0 -33
  293. data/lib/rails/engine.rb +0 -657
  294. data/lib/rails/generators/actions.rb +0 -325
  295. data/lib/rails/generators/active_model.rb +0 -78
  296. data/lib/rails/generators/app_base.rb +0 -266
  297. data/lib/rails/generators/base.rb +0 -390
  298. data/lib/rails/generators/css/assets/assets_generator.rb +0 -13
  299. data/lib/rails/generators/css/assets/templates/stylesheet.css +0 -4
  300. data/lib/rails/generators/css/scaffold/scaffold_generator.rb +0 -16
  301. data/lib/rails/generators/erb/controller/controller_generator.rb +0 -20
  302. data/lib/rails/generators/erb/controller/templates/view.html.erb +0 -2
  303. data/lib/rails/generators/erb/mailer/mailer_generator.rb +0 -13
  304. data/lib/rails/generators/erb/mailer/templates/view.text.erb +0 -3
  305. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +0 -29
  306. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +0 -23
  307. data/lib/rails/generators/erb/scaffold/templates/edit.html.erb +0 -6
  308. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +0 -27
  309. data/lib/rails/generators/erb/scaffold/templates/new.html.erb +0 -5
  310. data/lib/rails/generators/erb/scaffold/templates/show.html.erb +0 -12
  311. data/lib/rails/generators/erb.rb +0 -21
  312. data/lib/rails/generators/generated_attribute.rb +0 -107
  313. data/lib/rails/generators/js/assets/assets_generator.rb +0 -13
  314. data/lib/rails/generators/js/assets/templates/javascript.js +0 -2
  315. data/lib/rails/generators/migration.rb +0 -68
  316. data/lib/rails/generators/named_base.rb +0 -202
  317. data/lib/rails/generators/rails/app/USAGE +0 -15
  318. data/lib/rails/generators/rails/app/app_generator.rb +0 -312
  319. data/lib/rails/generators/rails/app/templates/Gemfile +0 -21
  320. data/lib/rails/generators/rails/app/templates/README +0 -261
  321. data/lib/rails/generators/rails/app/templates/Rakefile +0 -7
  322. data/lib/rails/generators/rails/app/templates/app/assets/images/rails.png +0 -0
  323. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +0 -17
  324. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +0 -13
  325. data/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb +0 -3
  326. data/lib/rails/generators/rails/app/templates/app/helpers/application_helper.rb +0 -2
  327. data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
  328. data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
  329. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +0 -14
  330. data/lib/rails/generators/rails/app/templates/config/application.rb +0 -68
  331. data/lib/rails/generators/rails/app/templates/config/boot.rb +0 -6
  332. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +0 -31
  333. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +0 -86
  334. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
  335. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +0 -33
  336. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +0 -43
  337. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +0 -20
  338. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +0 -54
  339. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +0 -39
  340. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +0 -55
  341. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +0 -25
  342. data/lib/rails/generators/rails/app/templates/config/environment.rb +0 -5
  343. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +0 -41
  344. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +0 -73
  345. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +0 -39
  346. data/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb +0 -7
  347. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb +0 -15
  348. data/lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb +0 -5
  349. data/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt +0 -7
  350. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +0 -8
  351. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +0 -16
  352. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +0 -5
  353. data/lib/rails/generators/rails/app/templates/config/routes.rb +0 -58
  354. data/lib/rails/generators/rails/app/templates/config.ru +0 -4
  355. data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +0 -7
  356. data/lib/rails/generators/rails/app/templates/doc/README_FOR_APP +0 -2
  357. data/lib/rails/generators/rails/app/templates/gitignore +0 -15
  358. data/lib/rails/generators/rails/app/templates/public/404.html +0 -26
  359. data/lib/rails/generators/rails/app/templates/public/422.html +0 -26
  360. data/lib/rails/generators/rails/app/templates/public/500.html +0 -25
  361. data/lib/rails/generators/rails/app/templates/public/robots.txt +0 -5
  362. data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  363. data/lib/rails/generators/rails/app/templates/script/openskies +0 -5
  364. data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  365. data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  366. data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  367. data/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +0 -12
  368. data/lib/rails/generators/rails/app/templates/test/test_helper.rb +0 -15
  369. data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  370. data/lib/rails/generators/rails/assets/USAGE +0 -20
  371. data/lib/rails/generators/rails/assets/assets_generator.rb +0 -25
  372. data/lib/rails/generators/rails/assets/templates/javascript.js +0 -2
  373. data/lib/rails/generators/rails/assets/templates/stylesheet.css +0 -4
  374. data/lib/rails/generators/rails/controller/USAGE +0 -18
  375. data/lib/rails/generators/rails/controller/controller_generator.rb +0 -20
  376. data/lib/rails/generators/rails/controller/templates/controller.rb +0 -13
  377. data/lib/rails/generators/rails/generator/USAGE +0 -12
  378. data/lib/rails/generators/rails/generator/generator_generator.rb +0 -25
  379. data/lib/rails/generators/rails/generator/templates/%file_name%_generator.rb.tt +0 -3
  380. data/lib/rails/generators/rails/generator/templates/USAGE.tt +0 -8
  381. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  382. data/lib/rails/generators/rails/helper/USAGE +0 -17
  383. data/lib/rails/generators/rails/helper/helper_generator.rb +0 -13
  384. data/lib/rails/generators/rails/helper/templates/helper.rb +0 -4
  385. data/lib/rails/generators/rails/integration_test/USAGE +0 -10
  386. data/lib/rails/generators/rails/integration_test/integration_test_generator.rb +0 -7
  387. data/lib/rails/generators/rails/migration/USAGE +0 -29
  388. data/lib/rails/generators/rails/migration/migration_generator.rb +0 -8
  389. data/lib/rails/generators/rails/model/USAGE +0 -45
  390. data/lib/rails/generators/rails/model/model_generator.rb +0 -8
  391. data/lib/rails/generators/rails/observer/USAGE +0 -12
  392. data/lib/rails/generators/rails/observer/observer_generator.rb +0 -7
  393. data/lib/rails/generators/rails/performance_test/USAGE +0 -10
  394. data/lib/rails/generators/rails/performance_test/performance_test_generator.rb +0 -7
  395. data/lib/rails/generators/rails/plugin_new/USAGE +0 -10
  396. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +0 -318
  397. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +0 -29
  398. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +0 -23
  399. data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +0 -20
  400. data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +0 -3
  401. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +0 -31
  402. data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +0 -4
  403. data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +0 -4
  404. data/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory +0 -0
  405. data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
  406. data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt +0 -14
  407. data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +0 -6
  408. data/lib/rails/generators/rails/plugin_new/templates/gitignore +0 -7
  409. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +0 -7
  410. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/version.rb +0 -3
  411. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +0 -6
  412. data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +0 -4
  413. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +0 -18
  414. data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +0 -10
  415. data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +0 -4
  416. data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +0 -7
  417. data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +0 -7
  418. data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +0 -12
  419. data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +0 -15
  420. data/lib/rails/generators/rails/resource/USAGE +0 -23
  421. data/lib/rails/generators/rails/resource/resource_generator.rb +0 -20
  422. data/lib/rails/generators/rails/resource_route/resource_route_generator.rb +0 -50
  423. data/lib/rails/generators/rails/scaffold/USAGE +0 -35
  424. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +0 -23
  425. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +0 -56
  426. data/lib/rails/generators/rails/scaffold_controller/USAGE +0 -19
  427. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +0 -25
  428. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +0 -89
  429. data/lib/rails/generators/rails/session_migration/USAGE +0 -8
  430. data/lib/rails/generators/rails/session_migration/session_migration_generator.rb +0 -8
  431. data/lib/rails/generators/rails/task/USAGE +0 -9
  432. data/lib/rails/generators/rails/task/task_generator.rb +0 -12
  433. data/lib/rails/generators/rails/task/templates/task.rb +0 -8
  434. data/lib/rails/generators/resource_helpers.rb +0 -80
  435. data/lib/rails/generators/test_case.rb +0 -247
  436. data/lib/rails/generators/test_unit/controller/controller_generator.rb +0 -15
  437. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +0 -19
  438. data/lib/rails/generators/test_unit/helper/helper_generator.rb +0 -13
  439. data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +0 -6
  440. data/lib/rails/generators/test_unit/integration/integration_generator.rb +0 -13
  441. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +0 -7
  442. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +0 -14
  443. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +0 -21
  444. data/lib/rails/generators/test_unit/model/model_generator.rb +0 -24
  445. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +0 -23
  446. data/lib/rails/generators/test_unit/model/templates/unit_test.rb +0 -9
  447. data/lib/rails/generators/test_unit/observer/observer_generator.rb +0 -13
  448. data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +0 -9
  449. data/lib/rails/generators/test_unit/performance/performance_generator.rb +0 -13
  450. data/lib/rails/generators/test_unit/performance/templates/performance_test.rb +0 -12
  451. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +0 -13
  452. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +0 -7
  453. data/lib/rails/generators/test_unit/plugin/templates/test_helper.rb +0 -3
  454. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +0 -38
  455. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +0 -51
  456. data/lib/rails/generators/test_unit.rb +0 -8
  457. data/lib/rails/generators.rb +0 -339
  458. data/lib/rails/info.rb +0 -116
  459. data/lib/rails/info_controller.rb +0 -15
  460. data/lib/rails/initializable.rb +0 -89
  461. data/lib/rails/paths.rb +0 -211
  462. data/lib/rails/performance_test_help.rb +0 -3
  463. data/lib/rails/plugin.rb +0 -92
  464. data/lib/rails/rack/debugger.rb +0 -24
  465. data/lib/rails/rack/log_tailer.rb +0 -34
  466. data/lib/rails/rack/logger.rb +0 -60
  467. data/lib/rails/rack.rb +0 -7
  468. data/lib/rails/railtie/configurable.rb +0 -35
  469. data/lib/rails/railtie/configuration.rb +0 -90
  470. data/lib/rails/railtie.rb +0 -202
  471. data/lib/rails/ruby_version_check.rb +0 -23
  472. data/lib/rails/rubyprof_ext.rb +0 -35
  473. data/lib/rails/script_rails_loader.rb +0 -29
  474. data/lib/rails/source_annotation_extractor.rb +0 -104
  475. data/lib/rails/tasks/annotations.rake +0 -20
  476. data/lib/rails/tasks/documentation.rake +0 -155
  477. data/lib/rails/tasks/engine.rake +0 -72
  478. data/lib/rails/tasks/framework.rake +0 -76
  479. data/lib/rails/tasks/log.rake +0 -9
  480. data/lib/rails/tasks/middleware.rake +0 -7
  481. data/lib/rails/tasks/misc.rake +0 -67
  482. data/lib/rails/tasks/routes.rake +0 -9
  483. data/lib/rails/tasks/statistics.rake +0 -16
  484. data/lib/rails/tasks/tmp.rake +0 -37
  485. data/lib/rails/tasks.rb +0 -16
  486. data/lib/rails/test_help.rb +0 -56
  487. data/lib/rails/test_unit/railtie.rb +0 -15
  488. data/lib/rails/test_unit/sub_test_task.rb +0 -8
  489. data/lib/rails/test_unit/testing.rake +0 -146
  490. data/lib/rails.rb +0 -121
  491. data/lib/version.rb +0 -16
@@ -1,621 +0,0 @@
1
- h2. Creating and Customizing Rails Generators & Templates
2
-
3
- Rails generators are an essential tool if you plan to improve your workflow. With this guide you will learn how to create generators and customize existing ones.
4
-
5
- In this guide you will:
6
-
7
- * Learn how to see which generators are available in your application
8
- * Create a generator using templates
9
- * Learn how Rails searches for generators before invoking them
10
- * Customize your scaffold by creating new generators
11
- * Customize your scaffold by changing generator templates
12
- * Learn how to use fallbacks to avoid overwriting a huge set of generators
13
- * Learn how to create an application template
14
-
15
- endprologue.
16
-
17
- NOTE: This guide is about generators in Rails 3, previous versions are not covered.
18
-
19
- h3. First Contact
20
-
21
- When you create an application using the +rails+ command, you are in fact using a Rails generator. After that, you can get a list of all available generators by just invoking +rails generate+:
22
-
23
- <shell>
24
- $ rails new myapp
25
- $ cd myapp
26
- $ rails generate
27
- </shell>
28
-
29
- You will get a list of all generators that comes with Rails. If you need a detailed description of the helper generator, for example, you can simply do:
30
-
31
- <shell>
32
- $ rails generate helper --help
33
- </shell>
34
-
35
- h3. Creating Your First Generator
36
-
37
- Since Rails 3.0, generators are built on top of "Thor":https://github.com/wycats/thor. Thor provides powerful options parsing and a great API for manipulating files. For instance, let's build a generator that creates an initializer file named +initializer.rb+ inside +config/initializers+.
38
-
39
- The first step is to create a file at +lib/generators/initializer_generator.rb+ with the following content:
40
-
41
- <ruby>
42
- class InitializerGenerator < Rails::Generators::Base
43
- def create_initializer_file
44
- create_file "config/initializers/initializer.rb", "# Add initialization content here"
45
- end
46
- end
47
- </ruby>
48
-
49
- NOTE: +create_file+ is a method provided by +Thor::Actions+. Documentation for +create_file+ and other Thor methods can be found in "Thor's documentation":http://rdoc.info/github/wycats/thor/master/Thor/Actions.html
50
-
51
- Our new generator is quite simple: it inherits from +Rails::Generators::Base+ and has one method definition. Each public method in the generator is executed when a generator is invoked. Finally, we invoke the +create_file+ method that will create a file at the given destination with the given content. If you are familiar with the Rails Application Templates API, you'll feel right at home with the new generators API.
52
-
53
- To invoke our new generator, we just need to do:
54
-
55
- <shell>
56
- $ rails generate initializer
57
- </shell>
58
-
59
- Before we go on, let's see our brand new generator description:
60
-
61
- <shell>
62
- $ rails generate initializer --help
63
- </shell>
64
-
65
- Rails is usually able to generate good descriptions if a generator is namespaced, as +ActiveRecord::Generators::ModelGenerator+, but not in this particular case. We can solve this problem in two ways. The first one is calling +desc+ inside our generator:
66
-
67
- <ruby>
68
- class InitializerGenerator < Rails::Generators::Base
69
- desc "This generator creates an initializer file at config/initializers"
70
- def create_initializer_file
71
- create_file "config/initializers/initializer.rb", "# Add initialization content here"
72
- end
73
- end
74
- </ruby>
75
-
76
- Now we can see the new description by invoking +--help+ on the new generator. The second way to add a description is by creating a file named +USAGE+ in the same directory as our generator. We are going to do that in the next step.
77
-
78
- h3. Creating Generators with Generators
79
-
80
- Generators themselves have a generator:
81
-
82
- <shell>
83
- $ rails generate generator initializer
84
- create lib/generators/initializer
85
- create lib/generators/initializer/initializer_generator.rb
86
- create lib/generators/initializer/USAGE
87
- create lib/generators/initializer/templates
88
- </shell>
89
-
90
- This is the generator just created:
91
-
92
- <ruby>
93
- class InitializerGenerator < Rails::Generators::NamedBase
94
- source_root File.expand_path("../templates", __FILE__)
95
- end
96
- </ruby>
97
-
98
- First, notice that we are inheriting from +Rails::Generators::NamedBase+ instead of +Rails::Generators::Base+. This means that our generator expects at least one argument, which will be the name of the initializer, and will be available in our code in the variable +name+.
99
-
100
- We can see that by invoking the description of this new generator (don't forget to delete the old generator file):
101
-
102
- <shell>
103
- $ rails generate initializer --help
104
- Usage:
105
- rails generate initializer NAME [options]
106
- </shell>
107
-
108
- We can also see that our new generator has a class method called +source_root+. This method points to where our generator templates will be placed, if any, and by default it points to the created directory +lib/generators/initializer/templates+.
109
-
110
- In order to understand what a generator template means, let's create the file +lib/generators/initializer/templates/initializer.rb+ with the following content:
111
-
112
- <ruby>
113
- # Add initialization content here
114
- </ruby>
115
-
116
- And now let's change the generator to copy this template when invoked:
117
-
118
- <ruby>
119
- class InitializerGenerator < Rails::Generators::NamedBase
120
- source_root File.expand_path("../templates", __FILE__)
121
-
122
- def copy_initializer_file
123
- copy_file "initializer.rb", "config/initializers/#{file_name}.rb"
124
- end
125
- end
126
- </ruby>
127
-
128
- And let's execute our generator:
129
-
130
- <shell>
131
- $ rails generate initializer core_extensions
132
- </shell>
133
-
134
- We can see that now an initializer named core_extensions was created at +config/initializers/core_extensions.rb+ with the contents of our template. That means that +copy_file+ copied a file in our source root to the destination path we gave. The method +file_name+ is automatically created when we inherit from +Rails::Generators::NamedBase+.
135
-
136
- The methods that are available for generators are covered in the "final section":#generator-methods of this guide.
137
-
138
- h3. Generators Lookup
139
-
140
- When you run +rails generate initializer core_extensions+ Rails requires these files in turn until one is found:
141
-
142
- <shell>
143
- rails/generators/initializer/initializer_generator.rb
144
- generators/initializer/initializer_generator.rb
145
- rails/generators/initializer_generator.rb
146
- generators/initializer_generator.rb
147
- </shell>
148
-
149
- If none is found you get an error message.
150
-
151
- INFO: The examples above put files under the application's +lib+ because said directory belongs to +$LOAD_PATH+.
152
-
153
- h3. Customizing Your Workflow
154
-
155
- Rails own generators are flexible enough to let you customize scaffolding. They can be configured in +config/application.rb+, these are some defaults:
156
-
157
- <ruby>
158
- config.generators do |g|
159
- g.orm :active_record
160
- g.template_engine :erb
161
- g.test_framework :test_unit, :fixture => true
162
- end
163
- </ruby>
164
-
165
- Before we customize our workflow, let's first see what our scaffold looks like:
166
-
167
- <shell>
168
- $ rails generate scaffold User name:string
169
- invoke active_record
170
- create db/migrate/20091120125558_create_users.rb
171
- create app/models/user.rb
172
- invoke test_unit
173
- create test/unit/user_test.rb
174
- create test/fixtures/users.yml
175
- route resources :users
176
- invoke scaffold_controller
177
- create app/controllers/users_controller.rb
178
- invoke erb
179
- create app/views/users
180
- create app/views/users/index.html.erb
181
- create app/views/users/edit.html.erb
182
- create app/views/users/show.html.erb
183
- create app/views/users/new.html.erb
184
- create app/views/users/_form.html.erb
185
- invoke test_unit
186
- create test/functional/users_controller_test.rb
187
- invoke helper
188
- create app/helpers/users_helper.rb
189
- invoke test_unit
190
- create test/unit/helpers/users_helper_test.rb
191
- invoke stylesheets
192
- create app/assets/stylesheets/scaffold.css
193
- </shell>
194
-
195
- Looking at this output, it's easy to understand how generators work in Rails 3.0 and above. The scaffold generator doesn't actually generate anything, it just invokes others to do the work. This allows us to add/replace/remove any of those invocations. For instance, the scaffold generator invokes the scaffold_controller generator, which invokes erb, test_unit and helper generators. Since each generator has a single responsibility, they are easy to reuse, avoiding code duplication.
196
-
197
- Our first customization on the workflow will be to stop generating stylesheets and test fixtures for scaffolds. We can achieve that by changing our configuration to the following:
198
-
199
- <ruby>
200
- config.generators do |g|
201
- g.orm :active_record
202
- g.template_engine :erb
203
- g.test_framework :test_unit, :fixture => false
204
- g.stylesheets false
205
- end
206
- </ruby>
207
-
208
- If we generate another resource with the scaffold generator, we can see that neither stylesheets nor fixtures are created anymore. If you want to customize it further, for example to use DataMapper and RSpec instead of Active Record and TestUnit, it's just a matter of adding their gems to your application and configuring your generators.
209
-
210
- To demonstrate this, we are going to create a new helper generator that simply adds some instance variable readers. First, we create a generator within the rails namespace, as this is where rails searches for generators used as hooks:
211
-
212
- <shell>
213
- $ rails generate generator rails/my_helper
214
- </shell>
215
-
216
- After that, we can delete both the +templates+ directory and the +source_root+ class method from our new generators, because we are not going to need them. So our new generator looks like the following:
217
-
218
- <ruby>
219
- class Rails::MyHelperGenerator < Rails::Generators::NamedBase
220
- def create_helper_file
221
- create_file "app/helpers/#{file_name}_helper.rb", <<-FILE
222
- module #{class_name}Helper
223
- attr_reader :#{plural_name}, :#{plural_name.singularize}
224
- end
225
- FILE
226
- end
227
- end
228
- </ruby>
229
-
230
- We can try out our new generator by creating a helper for users:
231
-
232
- <shell>
233
- $ rails generate my_helper products
234
- </shell>
235
-
236
- And it will generate the following helper file in +app/helpers+:
237
-
238
- <ruby>
239
- module ProductsHelper
240
- attr_reader :products, :product
241
- end
242
- </ruby>
243
-
244
- Which is what we expected. We can now tell scaffold to use our new helper generator by editing +config/application.rb+ once again:
245
-
246
- <ruby>
247
- config.generators do |g|
248
- g.orm :active_record
249
- g.template_engine :erb
250
- g.test_framework :test_unit, :fixture => false
251
- g.stylesheets false
252
- g.helper :my_helper
253
- end
254
- </ruby>
255
-
256
- and see it in action when invoking the generator:
257
-
258
- <shell>
259
- $ rails generate scaffold Post body:text
260
- [...]
261
- invoke my_helper
262
- create app/helpers/posts_helper.rb
263
- </shell>
264
-
265
- We can notice on the output that our new helper was invoked instead of the Rails default. However one thing is missing, which is tests for our new generator and to do that, we are going to reuse old helpers test generators.
266
-
267
- Since Rails 3.0, this is easy to do due to the hooks concept. Our new helper does not need to be focused in one specific test framework, it can simply provide a hook and a test framework just needs to implement this hook in order to be compatible.
268
-
269
- To do that, we can change the generator this way:
270
-
271
- <ruby>
272
- class Rails::MyHelperGenerator < Rails::Generators::NamedBase
273
- def create_helper_file
274
- create_file "app/helpers/#{file_name}_helper.rb", <<-FILE
275
- module #{class_name}Helper
276
- attr_reader :#{plural_name}, :#{plural_name.singularize}
277
- end
278
- FILE
279
- end
280
-
281
- hook_for :test_framework
282
- end
283
- </ruby>
284
-
285
- Now, when the helper generator is invoked and TestUnit is configured as the test framework, it will try to invoke both +Rails::TestUnitGenerator+ and +TestUnit::MyHelperGenerator+. Since none of those are defined, we can tell our generator to invoke +TestUnit::Generators::HelperGenerator+ instead, which is defined since it's a Rails generator. To do that, we just need to add:
286
-
287
- <ruby>
288
- # Search for :helper instead of :my_helper
289
- hook_for :test_framework, :as => :helper
290
- </ruby>
291
-
292
- And now you can re-run scaffold for another resource and see it generating tests as well!
293
-
294
- h3. Customizing Your Workflow by Changing Generators Templates
295
-
296
- In the step above we simply wanted to add a line to the generated helper, without adding any extra functionality. There is a simpler way to do that, and it's by replacing the templates of already existing generators, in that case +Rails::Generators::HelperGenerator+.
297
-
298
- In Rails 3.0 and above, generators don't just look in the source root for templates, they also search for templates in other paths. And one of them is +lib/templates+. Since we want to customize +Rails::Generators::HelperGenerator+, we can do that by simply making a template copy inside +lib/templates/rails/helper+ with the name +helper.rb+. So let's create that file with the following content:
299
-
300
- <erb>
301
- module <%= class_name %>Helper
302
- attr_reader :<%= plural_name %>, <%= plural_name.singularize %>
303
- end
304
- </erb>
305
-
306
- and revert the last change in +config/application.rb+:
307
-
308
- <ruby>
309
- config.generators do |g|
310
- g.orm :active_record
311
- g.template_engine :erb
312
- g.test_framework :test_unit, :fixture => false
313
- g.stylesheets false
314
- end
315
- </ruby>
316
-
317
- If you generate another resource, you can see that we get exactly the same result! This is useful if you want to customize your scaffold templates and/or layout by just creating +edit.html.erb+, +index.html.erb+ and so on inside +lib/templates/erb/scaffold+.
318
-
319
- h3. Adding Generators Fallbacks
320
-
321
- One last feature about generators which is quite useful for plugin generators is fallbacks. For example, imagine that you want to add a feature on top of TestUnit like "shoulda":https://github.com/thoughtbot/shoulda does. Since TestUnit already implements all generators required by Rails and shoulda just wants to overwrite part of it, there is no need for shoulda to reimplement some generators again, it can simply tell Rails to use a +TestUnit+ generator if none was found under the +Shoulda+ namespace.
322
-
323
- We can easily simulate this behavior by changing our +config/application.rb+ once again:
324
-
325
- <ruby>
326
- config.generators do |g|
327
- g.orm :active_record
328
- g.template_engine :erb
329
- g.test_framework :shoulda, :fixture => false
330
- g.stylesheets false
331
-
332
- # Add a fallback!
333
- g.fallbacks[:shoulda] = :test_unit
334
- end
335
- </ruby>
336
-
337
- Now, if you create a Comment scaffold, you will see that the shoulda generators are being invoked, and at the end, they are just falling back to TestUnit generators:
338
-
339
- <shell>
340
- $ rails generate scaffold Comment body:text
341
- invoke active_record
342
- create db/migrate/20091120151323_create_comments.rb
343
- create app/models/comment.rb
344
- invoke shoulda
345
- create test/unit/comment_test.rb
346
- create test/fixtures/comments.yml
347
- route resources :comments
348
- invoke scaffold_controller
349
- create app/controllers/comments_controller.rb
350
- invoke erb
351
- create app/views/comments
352
- create app/views/comments/index.html.erb
353
- create app/views/comments/edit.html.erb
354
- create app/views/comments/show.html.erb
355
- create app/views/comments/new.html.erb
356
- create app/views/comments/_form.html.erb
357
- create app/views/layouts/comments.html.erb
358
- invoke shoulda
359
- create test/functional/comments_controller_test.rb
360
- invoke my_helper
361
- create app/helpers/comments_helper.rb
362
- invoke shoulda
363
- create test/unit/helpers/comments_helper_test.rb
364
- </shell>
365
-
366
- Fallbacks allow your generators to have a single responsibility, increasing code reuse and reducing the amount of duplication.
367
-
368
- h3. Application Templates
369
-
370
- Now that you've seen how generators can be used _inside_ an application, did you know they can also be used to _generate_ applications too? This kind of generator is referred as a "template".
371
-
372
- <ruby>
373
- gem("rspec-rails", :group => "test")
374
- gem("cucumber-rails", :group => "test")
375
-
376
- if yes?("Would you like to install Devise?")
377
- gem("devise")
378
- generate("devise:install")
379
- model_name = ask("What would you like the user model to be called? [user]")
380
- model_name = "user" if model_name.blank?
381
- generate("devise", model_name)
382
- end
383
- </ruby>
384
-
385
- In the above template we specify that the application relies on the +rspec-rails+ and +cucumber-rails+ gem so these two will be added to the +test+ group in the +Gemfile+. Then we pose a question to the user about whether or not they would like to install Devise. If the user replies "y" or "yes" to this question, then the template will add Devise to the +Gemfile+ outside of any group and then runs the +devise:install+ generator. This template then takes the users input and runs the +devise+ generator, with the user's answer from the last question being passed to this generator.
386
-
387
- Imagine that this template was in a file called +template.rb+. We can use it to modify the outcome of the +rails new+ command by using the +-m+ option and passing in the filename:
388
-
389
- <shell>
390
- $ rails new thud -m template.rb
391
- </shell>
392
-
393
- This command will generate the +Thud+ application, and then apply the template to the generated output.
394
-
395
- Templates don't have to be stored on the local system, the +-m+ option also supports online templates:
396
-
397
- <shell>
398
- $ rails new thud -m https://gist.github.com/722911.txt
399
- </shell>
400
-
401
- Whilst the final section of this guide doesn't cover how to generate the most awesome template known to man, it will take you through the methods available at your disposal so that you can develop it yourself. These same methods are also available for generators.
402
-
403
- h3. Generator methods
404
-
405
- The following are methods available for both generators and templates for Rails.
406
-
407
- NOTE: Methods provided by Thor are not covered this guide and can be found in "Thor's documentation":http://rdoc.info/github/wycats/thor/master/Thor/Actions.html
408
-
409
- h4. +plugin+
410
-
411
- +plugin+ will install a plugin into the current application.
412
-
413
- <ruby>
414
- plugin("dynamic-form", :git => "git://github.com/rails/dynamic-form.git")
415
- </ruby>
416
-
417
- Available options are:
418
-
419
- * +:git+ - Takes the path to the git repository where this plugin can be found.
420
- * +:branch+ - The name of the branch of the git repository where the plugin is found.
421
- * +:submodule+ - Set to +true+ for the plugin to be installed as a submodule. Defaults to +false+.
422
- * +:svn+ - Takes the path to the svn repository where this plugin can be found.
423
- * +:revision+ - The revision of the plugin in an SVN repository.
424
-
425
- h4. +gem+
426
-
427
- Specifies a gem dependency of the application.
428
-
429
- <ruby>
430
- gem("rspec", :group => "test", :version => "2.1.0")
431
- gem("devise", "1.1.5")
432
- </ruby>
433
-
434
- Available options are:
435
-
436
- * +:group+ - The group in the +Gemfile+ where this gem should go.
437
- * +:version+ - The version string of the gem you want to use. Can also be specified as the second argument to the method.
438
- * +:git+ - The URL to the git repository for this gem.
439
-
440
- Any additional options passed to this method are put on the end of the line:
441
-
442
- <ruby>
443
- gem("devise", :git => "git://github.com/plataformatec/devise", :branch => "master")
444
- </ruby>
445
-
446
- The above code will put the following line into +Gemfile+:
447
-
448
- <ruby>
449
- gem "devise", :git => "git://github.com/plataformatec/devise", :branch => "master"
450
- </ruby>
451
-
452
- h4. +gem_group+
453
-
454
- Wraps gem entries inside a group:
455
-
456
- <ruby>
457
- gem_group :development, :test do
458
- gem "rspec-rails"
459
- end
460
- </ruby>
461
-
462
- h4. +add_source+
463
-
464
- Adds a specified source to +Gemfile+:
465
-
466
- <ruby>
467
- add_source "http://gems.github.com"
468
- </ruby>
469
-
470
- h4. +application+
471
-
472
- Adds a line to +config/application.rb+ directly after the application class definition.
473
-
474
- <ruby>
475
- application "config.asset_host = 'http://example.com'"
476
- </ruby>
477
-
478
- This method can also take a block:
479
-
480
- <ruby>
481
- application do
482
- "config.asset_host = 'http://example.com'"
483
- end
484
- </ruby>
485
-
486
- Available options are:
487
-
488
- * +:env+ - Specify an environment for this configuration option. If you wish to use this option with the block syntax the recommended syntax is as follows:
489
-
490
- <ruby>
491
- application(nil, :env => "development") do
492
- "config.asset_host = 'http://localhost:3000'"
493
- end
494
- </ruby>
495
-
496
- h4. +git+
497
-
498
- Runs the specified git command:
499
-
500
- <ruby>
501
- git :init
502
- git :add => "."
503
- git :commit => "-m First commit!"
504
- git :add => "onefile.rb", :rm => "badfile.cxx"
505
- </ruby>
506
-
507
- The values of the hash here being the arguments or options passed to the specific git command. As per the final example shown here, multiple git commands can be specified at a time, but the order of their running is not guaranteed to be the same as the order that they were specified in.
508
-
509
- h4. +vendor+
510
-
511
- Places a file into +vendor+ which contains the specified code.
512
-
513
- <ruby>
514
- vendor("sekrit.rb", '#top secret stuff')
515
- </ruby>
516
-
517
- This method also takes a block:
518
-
519
- <ruby>
520
- vendor("seeds.rb") do
521
- "puts 'in ur app, seeding ur database'"
522
- end
523
- </ruby>
524
-
525
- h4. +lib+
526
-
527
- Places a file into +lib+ which contains the specified code.
528
-
529
- <ruby>
530
- lib("special.rb", 'p Rails.root')
531
- </ruby>
532
-
533
- This method also takes a block:
534
-
535
- <ruby>
536
- lib("super_special.rb") do
537
- puts "Super special!"
538
- end
539
- </ruby>
540
-
541
- h4. +rakefile+
542
-
543
- Creates a Rake file in the +lib/tasks+ directory of the application.
544
-
545
- <ruby>
546
- rakefile("test.rake", 'hello there')
547
- </ruby>
548
-
549
- This method also takes a block:
550
-
551
- <ruby>
552
- rakefile("test.rake") do
553
- %Q{
554
- task :rock => :environment do
555
- puts "Rockin'"
556
- end
557
- }
558
- end
559
- </ruby>
560
-
561
- h4. +initializer+
562
-
563
- Creates an initializer in the +config/initializers+ directory of the application:
564
-
565
- <ruby>
566
- initializer("begin.rb", "puts 'this is the beginning'")
567
- </ruby>
568
-
569
- This method also takes a block:
570
-
571
- <ruby>
572
- initializer("begin.rb") do
573
- puts "Almost done!"
574
- end
575
- </ruby>
576
-
577
- h4. +generate+
578
-
579
- Runs the specified generator where the first argument is the generator name and the remaining arguments are passed directly to the generator.
580
-
581
- <ruby>
582
- generate("scaffold", "forums title:string description:text")
583
- </ruby>
584
-
585
-
586
- h4. +rake+
587
-
588
- Runs the specified Rake task.
589
-
590
- <ruby>
591
- rake("db:migrate")
592
- </ruby>
593
-
594
- Available options are:
595
-
596
- * +:env+ - Specifies the environment in which to run this rake task.
597
- * +:sudo+ - Whether or not to run this task using +sudo+. Defaults to +false+.
598
-
599
- h4. +capify!+
600
-
601
- Runs the +capify+ command from Capistrano at the root of the application which generates Capistrano configuration.
602
-
603
- <ruby>
604
- capify!
605
- </ruby>
606
-
607
- h4. +route+
608
-
609
- Adds text to the +config/routes.rb+ file:
610
-
611
- <ruby>
612
- route("resources :people")
613
- </ruby>
614
-
615
- h4. +readme+
616
-
617
- Output the contents of a file in the template's +source_path+, usually a README.
618
-
619
- <ruby>
620
- readme("README")
621
- </ruby>