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,1116 +0,0 @@
1
- h2. The Rails Initialization Process
2
-
3
- This guide explains the internals of the initialization process in Rails as of Rails 3.1. It is an extremely in-depth guide and recommended for advanced Rails developers.
4
-
5
- * Using +rails server+
6
- * Using Passenger
7
-
8
- endprologue.
9
-
10
- This guide goes through every single file, class and method call that is required to boot up the Ruby on Rails stack for a default Rails 3.1 application, explaining each part in detail along the way. For this guide, we will be focusing on how the two most common methods (+rails server+ and Passenger) boot a Rails application.
11
-
12
- NOTE: Paths in this guide are relative to Rails or a Rails application unless otherwise specified.
13
-
14
- h3. Launch!
15
-
16
- As of Rails 3, +script/server+ has become +rails server+. This was done to centralize all rails related commands to one common file.
17
-
18
- h4. +bin/rails+
19
-
20
- The actual +rails+ command is kept in _bin/rails_:
21
-
22
- <ruby>
23
- #!/usr/bin/env ruby
24
-
25
- begin
26
- require "rails/cli"
27
- rescue LoadError
28
- railties_path = File.expand_path('../../railties/lib', __FILE__)
29
- $:.unshift(railties_path)
30
- require "rails/cli"
31
- end
32
- </ruby>
33
-
34
- This file will attempt to load +rails/cli+. If it cannot find it then +railties/lib+ is added to the load path (+$:+) before retrying.
35
-
36
- h4. +railties/lib/rails/cli.rb+
37
-
38
- This file looks like this:
39
-
40
- <ruby>
41
- require 'rbconfig'
42
- require 'rails/script_rails_loader'
43
-
44
- # If we are inside a Rails application this method performs an exec and thus
45
- # the rest of this script is not run.
46
- Rails::ScriptRailsLoader.exec_script_rails!
47
-
48
- require 'rails/ruby_version_check'
49
- Signal.trap("INT") { puts; exit }
50
-
51
- if ARGV.first == 'plugin'
52
- ARGV.shift
53
- require 'rails/commands/plugin_new'
54
- else
55
- require 'rails/commands/application'
56
- end
57
- </ruby>
58
-
59
- The +rbconfig+ file from the Ruby standard library provides us with the +RbConfig+ class which contains detailed information about the Ruby environment, including how Ruby was compiled. We can see this in use in +railties/lib/rails/script_rails_loader+.
60
-
61
- <ruby>
62
- require 'pathname'
63
-
64
- module Rails
65
- module ScriptRailsLoader
66
- RUBY = File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + RbConfig::CONFIG["EXEEXT"]
67
- SCRIPT_RAILS = File.join('script', 'rails')
68
- ...
69
-
70
- end
71
- end
72
- </ruby>
73
-
74
- The +rails/script_rails_loader+ file uses +RbConfig::Config+ to obtain the +bin_dir+ and +ruby_install_name+ values for the configuration which together form the path to the Ruby interpreter. The +RbConfig::CONFIG["EXEEXT"]+ will suffix this path with ".exe" if the script is running on Windows. This constant is used later on in +exec_script_rails!+. As for the +SCRIPT_RAILS+ constant, we'll see that when we get to the +in_rails_application?+ method.
75
-
76
- Back in +rails/cli+, the next line is this:
77
-
78
- <ruby>
79
- Rails::ScriptRailsLoader.exec_script_rails!
80
- </ruby>
81
-
82
- This method is defined in +rails/script_rails_loader+:
83
-
84
- <ruby>
85
- def self.exec_script_rails!
86
- cwd = Dir.pwd
87
- return unless in_rails_application? || in_rails_application_subdirectory?
88
- exec RUBY, SCRIPT_RAILS, *ARGV if in_rails_application?
89
- Dir.chdir("..") do
90
- # Recurse in a chdir block: if the search fails we want to be sure
91
- # the application is generated in the original working directory.
92
- exec_script_rails! unless cwd == Dir.pwd
93
- end
94
- rescue SystemCallError
95
- # could not chdir, no problem just return
96
- end
97
- </ruby>
98
-
99
- This method will first check if the current working directory (+cwd+) is a Rails application or a subdirectory of one. This is determined by the +in_rails_application?+ method:
100
-
101
- <ruby>
102
- def self.in_rails_application?
103
- File.exists?(SCRIPT_RAILS)
104
- end
105
- </ruby>
106
-
107
- The +SCRIPT_RAILS+ constant defined earlier is used here, with +File.exists?+ checking for its presence in the current directory. If this method returns +false+ then +in_rails_application_subdirectory?+ will be used:
108
-
109
- <ruby>
110
- def self.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))
111
- File.exists?(File.join(path, SCRIPT_RAILS)) || !path.root? && in_rails_application_subdirectory?(path.parent)
112
- end
113
- </ruby>
114
-
115
- This climbs the directory tree until it reaches a path which contains a +script/rails+ file. If a directory containing this file is reached then this line will run:
116
-
117
- <ruby>
118
- exec RUBY, SCRIPT_RAILS, *ARGV if in_rails_application?
119
- </ruby>
120
-
121
- This is effectively the same as running +ruby script/rails [arguments]+, where +[arguments]+ at this point in time is simply "server".
122
-
123
- h4. +script/rails+
124
-
125
- This file is as follows:
126
-
127
- <ruby>
128
- APP_PATH = File.expand_path('../../config/application', __FILE__)
129
- require File.expand_path('../../config/boot', __FILE__)
130
- require 'rails/commands'
131
- </ruby>
132
-
133
- The +APP_PATH+ constant will be used later in +rails/commands+. The +config/boot+ file referenced here is the +config/boot.rb+ file in our application which is responsible for loading Bundler and setting it up.
134
-
135
- h4. +config/boot.rb+
136
-
137
- +config/boot.rb+ contains this:
138
-
139
- <ruby>
140
- require 'rubygems'
141
-
142
- # Set up gems listed in the Gemfile.
143
- gemfile = File.expand_path('../../Gemfile', __FILE__)
144
- begin
145
- ENV['BUNDLE_GEMFILE'] = gemfile
146
- require 'bundler'
147
- Bundler.setup
148
- rescue Bundler::GemNotFound => e
149
- STDERR.puts e.message
150
- STDERR.puts "Try running `bundle install`."
151
- exit!
152
- end if File.exist?(gemfile)
153
- </ruby>
154
-
155
- In a standard Rails application, there's a +Gemfile+ which declares all dependencies of the application. +config/boot.rb+ sets +ENV["BUNDLE_GEMFILE"]+ to the location of this file, then requires Bundler and calls +Bundler.setup+ which adds the dependencies of the application (including all the Rails parts) to the load path, making them available for the application to load. The gems that a Rails 3.1 application depends on are as follows:
156
-
157
- * abstract (1.0.0)
158
- * actionmailer (3.1.0.beta)
159
- * actionpack (3.1.0.beta)
160
- * activemodel (3.1.0.beta)
161
- * activerecord (3.1.0.beta)
162
- * activeresource (3.1.0.beta)
163
- * activesupport (3.1.0.beta)
164
- * arel (2.0.7)
165
- * builder (3.0.0)
166
- * bundler (1.0.6)
167
- * erubis (2.6.6)
168
- * i18n (0.5.0)
169
- * mail (2.2.12)
170
- * mime-types (1.16)
171
- * polyglot (0.3.1)
172
- * rack (1.2.1)
173
- * rack-cache (0.5.3)
174
- * rack-mount (0.6.13)
175
- * rack-test (0.5.6)
176
- * rails (3.1.0.beta)
177
- * railties (3.1.0.beta)
178
- * rake (0.8.7)
179
- * sqlite3-ruby (1.3.2)
180
- * thor (0.14.6)
181
- * treetop (1.4.9)
182
- * tzinfo (0.3.23)
183
-
184
- h4. +rails/commands.rb+
185
-
186
- Once +config/boot.rb+ has finished, the next file that is required is +rails/commands+ which will execute a command based on the arguments passed in. In this case, the +ARGV+ array simply contains +server+ which is extracted into the +command+ variable using these lines:
187
-
188
- <ruby>
189
- aliases = {
190
- "g" => "generate",
191
- "c" => "console",
192
- "s" => "server",
193
- "db" => "dbconsole",
194
- "r" => "runner"
195
- }
196
-
197
- command = ARGV.shift
198
- command = aliases[command] || command
199
- </ruby>
200
-
201
- If we used <tt>s</tt> rather than +server+, Rails will use the +aliases+ defined in the file and match them to their respective commands. With the +server+ command, Rails will run this code:
202
-
203
- <ruby>
204
- when 'server'
205
- # Change to the application's path if there is no config.ru file in current dir.
206
- # This allows us to run script/rails server from other directories, but still get
207
- # the main config.ru and properly set the tmp directory.
208
- Dir.chdir(File.expand_path('../../', APP_PATH)) unless File.exists?(File.expand_path("config.ru"))
209
-
210
- require 'rails/commands/server'
211
- Rails::Server.new.tap { |server|
212
- # We need to require application after the server sets environment,
213
- # otherwise the --environment option given to the server won't propagate.
214
- require APP_PATH
215
- Dir.chdir(Rails.application.root)
216
- server.start
217
- }
218
- </ruby>
219
-
220
- This file will change into the root of the directory (a path two directories back from +APP_PATH+ which points at +config/application.rb+), but only if the +config.ru+ file isn't found. This then requires +rails/commands/server+ which requires +action_dispatch+ and sets up the +Rails::Server+ class.
221
-
222
- h4. +actionpack/lib/action_dispatch.rb+
223
-
224
- Action Dispatch is the routing component of the Rails framework. It depends on Active Support, +actionpack/lib/action_pack.rb+ and +Rack+ being available. The first thing required here is +active_support+.
225
-
226
- h4. +activesupport/lib/active_support.rb+
227
-
228
- This file begins with requiring +active_support/lib/active_support/dependencies/autoload.rb+ which redefines Ruby's +autoload+ method to have a little more extra behaviour especially in regards to eager autoloading. Eager autoloading is the loading of all required classes and will happen when the +config.cache_classes+ setting is +true+. The required file also requires another file: +active_support/lazy_load_hooks+
229
-
230
- h4. +activesupport/lib/active_support/lazy_load_hooks.rb+
231
-
232
- This file defines the +ActiveSupport.on_load+ hook which is used to execute code when specific parts are loaded. We'll see this in use a little later on.
233
-
234
- This file begins with requiring +active_support/inflector/methods+.
235
-
236
- h4. +activesupport/lib/active_support/inflector/methods.rb+
237
-
238
- The +methods.rb+ file is responsible for defining methods such as +camelize+, +underscore+ and +dasherize+ as well as a slew of others. The "+ActiveSupport::Inflector+ documentation":http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html covers them all pretty decently.
239
-
240
- In this file there are a lot of lines such as this inside the +ActiveSupport+ module:
241
-
242
- <ruby>
243
- autoload :Inflector
244
- </ruby>
245
-
246
- Due to the overriding of the +autoload+ method, Ruby will know how to look for this file at +activesupport/lib/active_support/inflector.rb+ when the +Inflector+ class is first referenced.
247
-
248
- The +active_support/lib/active_support/version.rb+ that is also required here simply defines an +ActiveSupport::VERSION+ constant which defines a couple of constants inside this module, the main constant of this is +ActiveSupport::VERSION::STRING+ which returns the current version of ActiveSupport.
249
-
250
- The +active_support/lib/active_support.rb+ file simply defines the +ActiveSupport+ module and some autoloads (eager and of the normal variety) for it.
251
-
252
- h4. +actionpack/lib/action_dispatch.rb+ cont'd.
253
-
254
- Now back to +action_pack/lib/action_dispatch.rb+. The next +require+ in this file is one for +action_pack+, which simply calls +action_pack/version.rb+ which defines +ActionPack::VERSION+ and the constants, much like +ActiveSpport+ does.
255
-
256
- After this line, there's a require to +active_model+ which simply defines autoloads for the +ActiveModel+ part of Rails and sets up the +ActiveModel+ module which is used later on.
257
-
258
- The last of the requires is to +rack+, which like the +active_model+ and +active_support+ requires before it, sets up the +Rack+ module as well as the autoloads for constants within it.
259
-
260
- Finally in +action_dispatch.rb+ the +ActionDispatch+ module and *its* autoloads are declared.
261
-
262
- h4. +rails/commands/server.rb+
263
-
264
- The +Rails::Server+ class is defined in this file as inheriting from +Rack::Server+. When +Rails::Server.new+ is called, this calls the +initialize+ method in +rails/commands/server.rb+:
265
-
266
- <ruby>
267
- def initialize(*)
268
- super
269
- set_environment
270
- end
271
- </ruby>
272
-
273
- Firstly, +super+ is called which calls the +initialize+ method on +Rack::Server+.
274
-
275
- h4. Rack: +lib/rack/server.rb+
276
-
277
- +Rack::Server+ is responsible for providing a common server interface for all Rack-based applications, which Rails is now a part of.
278
-
279
- The +initialize+ method in +Rack::Server+ simply sets a couple of variables:
280
-
281
- <ruby>
282
- def initialize(options = nil)
283
- @options = options
284
- @app = options[:app] if options && options[:app]
285
- end
286
- </ruby>
287
-
288
- In this case, +options+ will be +nil+ so nothing happens in this method.
289
-
290
- After +super+ has finished in +Rack::Server+, we jump back to +rails/commands/server.rb+. At this point, +set_environment+ is called within the context of the +Rails::Server+ object and this method doesn't appear to do much at first glance:
291
-
292
- <ruby>
293
- def set_environment
294
- ENV["RAILS_ENV"] ||= options[:environment]
295
- end
296
- </ruby>
297
-
298
- In fact, the +options+ method here does quite a lot. This method is defined in +Rack::Server+ like this:
299
-
300
- <ruby>
301
- def options
302
- @options ||= parse_options(ARGV)
303
- end
304
- </ruby>
305
-
306
- Then +parse_options+ is defined like this:
307
-
308
- <ruby>
309
- def parse_options(args)
310
- options = default_options
311
-
312
- # Don't evaluate CGI ISINDEX parameters.
313
- # http://hoohoo.ncsa.uiuc.edu/cgi/cl.html
314
- args.clear if ENV.include?("REQUEST_METHOD")
315
-
316
- options.merge! opt_parser.parse! args
317
- options[:config] = ::File.expand_path(options[:config])
318
- ENV["RACK_ENV"] = options[:environment]
319
- options
320
- end
321
- </ruby>
322
-
323
- With the +default_options+ set to this:
324
-
325
- <ruby>
326
- def default_options
327
- {
328
- :environment => ENV['RACK_ENV'] || "development",
329
- :pid => nil,
330
- :Port => 9292,
331
- :Host => "0.0.0.0",
332
- :AccessLog => [],
333
- :config => "config.ru"
334
- }
335
- end
336
- </ruby>
337
-
338
- There is no +REQUEST_METHOD+ key in +ENV+ so we can skip over that line. The next line merges in the options from +opt_parser+ which is defined plainly in +Rack::Server+
339
-
340
- <ruby>
341
- def opt_parser
342
- Options.new
343
- end
344
- </ruby>
345
-
346
- The class *is* defined in +Rack::Server+, but is overwritten in +Rails::Server+ to take different arguments. Its +parse!+ method begins like this:
347
-
348
- <ruby>
349
- def parse!(args)
350
- args, options = args.dup, {}
351
-
352
- opt_parser = OptionParser.new do |opts|
353
- opts.banner = "Usage: rails server [mongrel, thin, etc] [options]"
354
- opts.on("-p", "--port=port", Integer,
355
- "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v }
356
- ...
357
- </ruby>
358
-
359
- This method will set up keys for the +options+ which Rails will then be able to use to determine how its server should run. After +initialize+ has finished, then the +start+ method will launch the server.
360
-
361
- h4. +Rails::Server#start+
362
-
363
- This method is defined like this:
364
-
365
- <ruby>
366
- def start
367
- puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
368
- puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}"
369
- puts "=> Call with -d to detach" unless options[:daemonize]
370
- trap(:INT) { exit }
371
- puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
372
-
373
- #Create required tmp directories if not found
374
- %w(cache pids sessions sockets).each do |dir_to_make|
375
- FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make))
376
- end
377
-
378
- super
379
- ensure
380
- # The '-h' option calls exit before @options is set.
381
- # If we call 'options' with it unset, we get double help banners.
382
- puts 'Exiting' unless @options && options[:daemonize]
383
- end
384
- </ruby>
385
-
386
- This is where the first output of the Rails initialization happens. This method creates a trap for +INT+ signals, so if you +CTRL+C+ the server, it will exit the process. As we can see from the code here, it will create the +tmp/cache+, +tmp/pids+, +tmp/sessions+ and +tmp/sockets+ directories if they don't already exist prior to calling +super+. The +super+ method will call +Rack::Server.start+ which begins its definition like this:
387
-
388
- <ruby>
389
- def start
390
- if options[:warn]
391
- $-w = true
392
- end
393
-
394
- if includes = options[:include]
395
- $LOAD_PATH.unshift(*includes)
396
- end
397
-
398
- if library = options[:require]
399
- require library
400
- end
401
-
402
- if options[:debug]
403
- $DEBUG = true
404
- require 'pp'
405
- p options[:server]
406
- pp wrapped_app
407
- pp app
408
- end
409
- end
410
- </ruby>
411
-
412
- In a Rails application, these options are not set at all and therefore aren't used at all. The first line of code that's executed in this method is a call to this method:
413
-
414
- <ruby>
415
- wrapped_app
416
- </ruby>
417
-
418
- This method calls another method:
419
-
420
- <ruby>
421
- @wrapped_app ||= build_app app
422
- </ruby>
423
-
424
- Then the +app+ method here is defined like so:
425
-
426
- <ruby>
427
- def app
428
- @app ||= begin
429
- if !::File.exist? options[:config]
430
- abort "configuration #{options[:config]} not found"
431
- end
432
-
433
- app, options = Rack::Builder.parse_file(self.options[:config], opt_parser)
434
- self.options.merge! options
435
- app
436
- end
437
- end
438
- </ruby>
439
-
440
- The +options[:config]+ value defaults to +config.ru+ which contains this:
441
-
442
- <ruby>
443
- # This file is used by Rack-based servers to start the application.
444
-
445
- require ::File.expand_path('../config/environment', __FILE__)
446
- run YourApp::Application
447
- </ruby>
448
-
449
-
450
- The +Rack::Builder.parse_file+ method here takes the content from this +config.ru+ file and parses it using this code:
451
-
452
- <ruby>
453
- app = eval "Rack::Builder.new {( " <plus> cfgfile <plus> "\n )}.to_app",
454
- TOPLEVEL_BINDING, config
455
- </ruby>
456
-
457
- The +initialize+ method will take the block here and execute it within an instance of +Rack::Builder+. This is where the majority of the initialization process of Rails happens. The chain of events that this simple line sets off will be the focus of a large majority of this guide. The +require+ line for +config/environment.rb+ in +config.ru+ is the first to run:
458
-
459
- <ruby>
460
- require ::File.expand_path('../config/environment', __FILE__)
461
- </ruby>
462
-
463
- h4. +config/environment.rb+
464
-
465
- This file is the common file required by +config.ru+ (+rails server+) and Passenger. This is where these two ways to run the server meet; everything before this point has been Rack and Rails setup.
466
-
467
- This file begins with requiring +config/application.rb+.
468
-
469
- h4. +config/application.rb+
470
-
471
- This file requires +config/boot.rb+, but only if it hasn't been required before, which would be the case in +rails server+ but *wouldn't* be the case with Passenger.
472
-
473
- Then the fun begins!
474
-
475
- h3. Loading Rails
476
-
477
- The next line in +config/application.rb+ is:
478
-
479
- <ruby>
480
- require 'rails/all'
481
- </ruby>
482
-
483
- h4. +railties/lib/rails/all.rb+
484
-
485
- This file is responsible for requiring all the individual parts of Rails like so:
486
-
487
- <ruby>
488
- require "rails"
489
-
490
- %w(
491
- active_record
492
- action_controller
493
- action_mailer
494
- active_resource
495
- rails/test_unit
496
- ).each do |framework|
497
- begin
498
- require "#{framework}/railtie"
499
- rescue LoadError
500
- end
501
- end
502
- </ruby>
503
-
504
- First off the line is the +rails+ require itself.
505
-
506
- h4. +railties/lib/rails.rb+
507
-
508
- This file is responsible for the initial definition of the +Rails+ module and, rather than defining the autoloads like +ActiveSupport+, +ActionDispatch+ and so on, it actually defines other functionality. Such as the +root+, +env+ and +application+ methods which are extremely useful in Rails 3 applications.
509
-
510
- However, before all that takes place the +rails/ruby_version_check+ file is required first.
511
-
512
- h4. +railties/lib/rails/ruby_version_check.rb+
513
-
514
- This file simply checks if the Ruby version is less than 1.8.7 or is 1.9.1 and raises an error if that is the case. Rails 3 simply will not run on earlier versions of Ruby than 1.8.7 or 1.9.1.
515
-
516
- NOTE: You should always endeavor to run the latest version of Ruby with your Rails applications. The benefits are many, including security fixes and the like, and very often there is a speed increase associated with it. The caveat is that you could have code that potentially breaks on the latest version, which should be fixed to work on the latest version rather than kept around as an excuse not to upgrade.
517
-
518
- h4. +active_support/core_ext/kernel/reporting.rb+
519
-
520
- This is the first of the many Active Support core extensions that come with Rails. This one in particular defines methods in the +Kernel+ module which is mixed in to the +Object+ class so the methods are available on +main+ and can therefore be called like this:
521
-
522
- <ruby>
523
- silence_warnings do
524
- # some code
525
- end
526
- </ruby>
527
-
528
- These methods can be used to silence STDERR responses and the +silence_stream+ allows you to also silence other streams. Additionally, this mixin allows you to suppress exceptions and capture streams. For more information see the "Silencing Warnings, Streams, and Exceptions":active_support_core_extensions.html#silencing-warnings-streams-and-exceptions section from the Active Support Core Extensions Guide.
529
-
530
- h4. +active_support/core_ext/logger.rb+
531
-
532
- The next file that is required is another Active Support core extension, this time to the +Logger+ class. This begins by defining the +around_[level]+ helpers for the +Logger+ class as well as other methods such as a +datetime_format+ getter and setter for the +formatter+ object tied to a +Logger+ object.
533
-
534
- For more information see the "Extensions to Logger":active_support_core_extensions.html#extensions-to-logger section from the Active Support Core Extensions Guide.
535
-
536
- h4. +railties/lib/rails/application.rb+
537
-
538
- The next file required by +railties/lib/rails.rb+ is +application.rb+. This file defines the +Rails::Application+ constant which the application's class defined in +config/application.rb+ in a standard Rails application depends on. Before the +Rails::Application+ class is defined however, there's some other files that get required first.
539
-
540
- The first of these is +active_support/core_ext/hash/reverse_merge+ which can be "read about in the Active Support Core Extensions guide":active_support_core_extensions.html#merging under the "Merging" section.
541
-
542
- h4. +active_support/file_update_checker.rb+
543
-
544
- The +ActiveSupport::FileUpdateChecker+ class defined within this file is responsible for checking if a file has been updated since it was last checked. This is used for monitoring the routes file for changes during development environment runs.
545
-
546
- h4. +railties/lib/rails/plugin.rb+
547
-
548
- This file defines +Rails::Plugin+ which inherits from +Rails::Engine+. Unlike +Rails::Engine+ and +Rails::Railtie+ however, this class is not designed to be inherited from. Instead, this is used simply for loading plugins from within an application and an engine.
549
-
550
- This file begins by requiring +rails/engine.rb+
551
-
552
- h4. +railties/lib/rails/engine.rb+
553
-
554
- The +rails/engine.rb+ file defines the +Rails::Engine+ class which inherits from +Rails::Railtie+. The +Rails::Engine+ class defines much of the functionality found within a standard application class such as the +routes+ and +config+ methods.
555
-
556
- The "API documentation":http://api.rubyonrails.org/classes/Rails/Engine.html for +Rails::Engine+ explains the function of this class pretty well.
557
-
558
- This file's first line requires +rails/railtie.rb+.
559
-
560
- h4. +railties/lib/rails/railtie.rb+
561
-
562
- The +rails/railtie.rb+ file is responsible for defining +Rails::Railtie+, the underlying class for all ties to Rails now. Gems that want to have their own initializers or rake tasks and hook into Rails should have a +GemName::Railtie+ class that inherits from +Rails::Railtie+.
563
-
564
- The "API documentation":http://api.rubyonrails.org/classes/Rails/Railtie.html for +Rails::Railtie+, much like +Rails::Engine+, explains this class exceptionally well.
565
-
566
- The first require in this file is +rails/initializable.rb+.
567
-
568
- h4. +railties/lib/rails/initializable.rb+
569
-
570
- Now we reach the end of this particular rabbit hole as +rails/initializable.rb+ doesn't require any more Rails files, only +tsort+ from the Ruby standard library.
571
-
572
- This file defines the +Rails::Initializable+ module which contains the +Initializer+ class, the basis for all initializers in Rails. This module also contains a +ClassMethods+ class which will be included into the +Rails::Railtie+ class when these requires have finished.
573
-
574
- Now that +rails/initializable.rb+ has finished being required from +rails/railtie.rb+, the next require is for +rails/configuration+.
575
-
576
- h4. +railties/lib/rails/configuration.rb+
577
-
578
- This file defines the +Rails::Configuration+ module, containing the +MiddlewareStackProxy+ class as well as the +Generators+ class. The +MiddlewareStackProxy+ class is used for managing the middleware stack for an application, which we'll see later on. The +Generators+ class provides the functionality used for configuring what generators an application uses through the "+config.generators+ option":configuring.html#configuring-generators.
579
-
580
- The first file required in this file is +activesupport/deprecation+.
581
-
582
- h4. +activesupport/lib/active_support/deprecation.rb+
583
-
584
- This file, and the files it requires, define the basic deprecation warning features found in Rails. This file is responsible for setting defaults in the +ActiveSupport::Deprecation+ module for the +deprecation_horizon+, +silenced+ and +debug+ values. The files that are required before this happens are:
585
-
586
- * +active_support/deprecation/behaviors+
587
- * +active_support/deprecation/reporting+
588
- * +active_support/deprecation/method_wrappers+
589
- * +active_support/deprecation/proxy_wrappers+
590
-
591
- h4. +activesupport/lib/active_support/deprecation/behaviors.rb+
592
-
593
- This file defines the behavior of the +ActiveSupport::Deprecation+ module, setting up the +DEFAULT_BEHAVIORS+ hash constant which contains the three defaults to outputting deprecation warnings: +:stderr+, +:log+ and +:notify+. This file begins by requiring +activesupport/notifications+ and +activesupport/core_ext/array/wrap+.
594
-
595
- h4. +activesupport/lib/active_support/notifications.rb+
596
-
597
- This file defines the +ActiveSupport::Notifications+ module. Notifications provides an instrumentation API for Ruby, shipping with a queue implementation that consumes and publish events to log subscribers in a thread.
598
-
599
- The "API documentation":http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html for +ActiveSupport::Notifications+ explains the usage of this module, including the methods that it defines.
600
-
601
- The file required in +active_support/notifications.rb+ is +active_support/core_ext/module/delegation+ which is documented in the "Active Support Core Extensions Guide":active_support_core_extensions.html#method-delegation.
602
-
603
- h4. +activesupport/core_ext/array/wrap+
604
-
605
- As this file comprises of a core extension, it is covered exclusively in "the Active Support Core Extensions guide":active_support_core_extensions.html#wrapping
606
-
607
- h4. +activesupport/lib/active_support/deprecation/reporting.rb+
608
-
609
- This file is responsible for defining the +warn+ and +silence+ methods for +ActiveSupport::Deprecation+ as well as additional private methods for this module.
610
-
611
- h4. +activesupport/lib/active_support/deprecation/method_wrappers.rb+
612
-
613
- This file defines a +deprecate_methods+ which is primarily used by the +module/deprecation+ core extension required by the first line of this file. Other core extensions required by this file are the +module/aliasing+ and +array/extract_options+ files.
614
-
615
- h4. +activesupport/lib/active_support/deprecation/proxy_wrappers.rb+
616
-
617
- +proxy_wrappers.rb+ defines deprecation wrappers for methods, instance variables and constants. Previously, this was used for the +RAILS_ENV+ and +RAILS_ROOT+ constants for 3.0 but since then these constants have been removed. The deprecation message that would be raised from these would be something like:
618
-
619
- <plain>
620
- BadConstant is deprecated! Use GoodConstant instead.
621
- </plain>
622
-
623
- h4. +active_support/ordered_options+
624
-
625
- This file is the next file required from +rails/configuration.rb+ is the file that defines +ActiveSupport::OrderedOptions+ which is used for configuration options such as +config.active_support+ and the like.
626
-
627
- The next file required is +active_support/core_ext/hash/deep_dup+ which is covered in "Active Support Core Extensions guide":active_support_core_extensions.html#deep_dup
628
-
629
- The file that is required next from is +rails/paths+
630
-
631
- h4. +railties/lib/rails/paths.rb+
632
-
633
- This file defines the +Rails::Paths+ module which allows paths to be configured for a Rails application or engine. Later on in this guide when we cover Rails configuration during the initialization process we'll see this used to set up some default paths for Rails and some of them will be configured to be eager loaded.
634
-
635
- h4. +railties/lib/rails/rack.rb+
636
-
637
- The final file to be loaded by +railties/lib/rails/configuration.rb+ is +rails/rack+ which defines some simple autoloads:
638
-
639
- <ruby>
640
- module Rails
641
- module Rack
642
- autoload :Debugger, "rails/rack/debugger"
643
- autoload :Logger, "rails/rack/logger"
644
- autoload :LogTailer, "rails/rack/log_tailer"
645
- autoload :Static, "rails/rack/static"
646
- end
647
- end
648
- </ruby>
649
-
650
- Once this file is finished loading, then the +Rails::Configuration+ class is initialized. This completes the loading of +railties/lib/rails/configuration.rb+ and now we jump back to the loading of +railties/lib/rails/railtie.rb+, where the next file loaded is +active_support/inflector+.
651
-
652
- h4. +activesupport/lib/active_support/inflector.rb+
653
-
654
- +active_support/inflector.rb+ requires a series of file which are responsible for setting up the basics for knowing how to pluralize and singularize words. These files are:
655
-
656
- <ruby>
657
- require 'active_support/inflector/inflections'
658
- require 'active_support/inflector/transliterate'
659
- require 'active_support/inflector/methods'
660
-
661
- require 'active_support/inflections'
662
- require 'active_support/core_ext/string/inflections'
663
- </ruby>
664
-
665
- The +active_support/inflector/methods+ file has already been required by +active_support/autoload+ and so won't be loaded again here. The +activesupport/lib/active_support/inflector/inflections.rb+ is required by +active_support/inflector/methods+.
666
-
667
- h4. +active_support/inflections+
668
-
669
- This file references the +ActiveSupport::Inflector+ constant which isn't loaded by this point. But there were autoloads set up in +activesupport/lib/active_support.rb+ which will load the file which loads this constant and so then it will be defined. Then this file defines pluralization and singularization rules for words in Rails. This is how Rails knows how to pluralize "tomato" to "tomatoes".
670
-
671
- h4. +activesupport/lib/active_support/inflector/transliterate.rb+
672
-
673
- In this file is where the "+transliterate+":http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-transliterate and +parameterize+:http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-parameterize methods are defined. The documentation for both of these methods is very much worth reading.
674
-
675
- h4. Back to +railties/lib/rails/railtie.rb+
676
-
677
- Once the inflector files have been loaded, the +Rails::Railtie+ class is defined. This class includes a module called +Initializable+, which is actually +Rails::Initializable+. This module includes the +initializer+ method which is used later on for setting up initializers, amongst other methods.
678
-
679
- h4. +railties/lib/rails/initializable.rb+
680
-
681
- When the module from this file (+Rails::Initializable+) is included, it extends the class it's included into with the +ClassMethods+ module inside of it. This module defines the +initializer+ method which is used to define initializers throughout all of the railties. This file completes the loading of +railties/lib/rails/railtie.rb+. Now we go back to +rails/engine.rb+.
682
-
683
- h4. +railties/lib/rails/engine.rb+
684
-
685
- The next file required in +rails/engine.rb+ is +active_support/core_ext/module/delegation+ which is documented in the "Active Support Core Extensions Guide":active_support_core_extensions.html#method-delegation.
686
-
687
- The next two files after this are Ruby standard library files: +pathname+ and +rbconfig+. The file after these is +rails/engine/railties+.
688
-
689
- h4. +railties/lib/rails/engine/railties.rb+
690
-
691
- This file defines the +Rails::Engine::Railties+ class which provides the +engines+ and +railties+ methods which are used later on for defining rake tasks and other functionality for engines and railties.
692
-
693
- h4. Back to +railties/lib/rails/engine.rb+
694
-
695
- Once +rails/engine/railties.rb+ has finished loading the +Rails::Engine+ class gets its basic functionality defined, such as the +inherited+ method which will be called when this class is inherited from.
696
-
697
- Once this file has finished loading we jump back to +railties/lib/rails/plugin.rb+
698
-
699
- h4. Back to +railties/lib/rails/plugin.rb+
700
-
701
- The next file required in this is a core extension from Active Support called +array/conversions+ which is covered in "this section":active_support_core_extensions.html#array-conversions of the Active Support Core Extensions Guide.
702
-
703
- Once that file has finished loading, the +Rails::Plugin+ class is defined.
704
-
705
- h4. Back to +railties/lib/rails/application.rb+
706
-
707
- Jumping back to +rails/application.rb+ now. This file defines the +Rails::Application+ class where the application's class inherits from. This class (and its superclasses) define the basic behaviour on the application's constant such as the +config+ method used for configuring the application.
708
-
709
- Once this file's done then we go back to the +railties/lib/rails.rb+ file, which next requires +rails/version+.
710
-
711
- h4. +railties/lib/rails/version.rb+
712
-
713
- Much like +active_support/version+, this file defines the +VERSION+ constant which has a +STRING+ constant on it which returns the current version of Rails.
714
-
715
- Once this file has finished loading we go back to +railties/lib/rails.rb+ which then requires +active_support/railtie.rb+.
716
-
717
- h4. +activesupport/lib/active_support/railtie.rb+
718
-
719
- This file requires +active_support+ and +rails+ which have already been required so these two lines are effectively ignored. The third require in this file is to +active_support/i18n_railtie.rb+.
720
-
721
- h4. +activesupport/lib/active_support/i18n_railtie.rb+
722
-
723
- This file is the first file that sets up configuration with these lines inside the class:
724
-
725
- <ruby>
726
- class Railtie < Rails::Railtie
727
- config.i18n = ActiveSupport::OrderedOptions.new
728
- config.i18n.railties_load_path = []
729
- config.i18n.load_path = []
730
- config.i18n.fallbacks = ActiveSupport::OrderedOptions.new
731
- </ruby>
732
-
733
- By inheriting from +Rails::Railtie+ the +Rails::Railtie#inherited+ method is called:
734
-
735
- <ruby>
736
- def inherited(base)
737
- unless base.abstract_railtie?
738
- base.send(:include, Railtie::Configurable)
739
- subclasses << base
740
- end
741
- end
742
- </ruby>
743
-
744
- This first checks if the Railtie that's inheriting it is a component of Rails itself:
745
-
746
- <ruby>
747
- ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Plugin Rails::Engine Rails::Application)
748
-
749
- ...
750
-
751
- def abstract_railtie?
752
- ABSTRACT_RAILTIES.include?(name)
753
- end
754
- </ruby>
755
-
756
- Because +I18n::Railtie+ isn't in this list, +abstract_railtie?+ returns +false+. Therefore the +Railtie::Configurable+ module is included into this class and the +subclasses+ method is called and +I18n::Railtie+ is added to this new array.
757
-
758
- <ruby>
759
- def subclasses
760
- @subclasses ||= []
761
- end
762
- </ruby>
763
-
764
- The +config+ method used at the top of +I18n::Railtie+ is defined on +Rails::Railtie+ and is defined like this:
765
-
766
- <ruby>
767
- def config
768
- @config ||= Railtie::Configuration.new
769
- end
770
- </ruby>
771
-
772
- At this point, that +Railtie::Configuration+ constant is automatically loaded which causes the +rails/railties/configuration+ file to be loaded. The line for this is this particular line in +railties/lib/rails/railtie.rb+:
773
-
774
- <ruby>
775
- autoload :Configuration, "rails/railtie/configuration"
776
- </ruby>
777
-
778
- h4. +railties/lib/rails/railtie/configuration.rb+
779
-
780
- This file begins with a require out to +rails/configuration+ which has already been required earlier in the process and so isn't required again.
781
-
782
- This file defines the +Rails::Railtie::Configuration+ class which is responsible for providing a way to easily configure railties and it's the +initialize+ method here which is called by the +config+ method back in the +i18n_railtie.rb+ file. The methods on this object don't exist, and so are rescued by the +method_missing+ defined further down in +configuration.rb+:
783
-
784
- <ruby>
785
- def method_missing(name, *args, &blk)
786
- if name.to_s =~ /=$/
787
- @@options[$`.to_sym] = args.first
788
- elsif @@options.key?(name)
789
- @@options[name]
790
- else
791
- super
792
- end
793
- end
794
- </ruby>
795
-
796
- So therefore when an option is referred to it simply stores the value as the key if it's used in a setter context, or retrieves it if used in a getter context. Nothing fancy going on there.
797
-
798
- h4. Back to +activesupport/lib/active_support/i18n_railtie.rb+
799
-
800
- After the configuration method the +reloader+ method is defined, and then the first of of Railties' initializers is defined: +i18n.callbacks+.
801
-
802
- <ruby>
803
- initializer "i18n.callbacks" do
804
- ActionDispatch::Reloader.to_prepare do
805
- I18n::Railtie.reloader.execute_if_updated
806
- end
807
- end
808
- </ruby>
809
-
810
- The +initializer+ method (from the +Rails::Initializable+ module) here doesn't run the block, but rather stores it to be run later on:
811
-
812
- <ruby>
813
- def initializer(name, opts = {}, &blk)
814
- raise ArgumentError, "A block must be passed when defining an initializer" unless blk
815
- opts[:after] ||= initializers.last.name unless initializers.empty? || initializers.find { |i| i.name == opts[:before] }
816
- initializers << Initializer.new(name, nil, opts, &blk)
817
- end
818
- </ruby>
819
-
820
- An initializer can be configured to run before or after another initializer, which we'll see a couple of times throughout this initialization process. Anything that inherits from +Rails::Railtie+ may also make use of the +initializer+ method, something which is covered in the "Configuration guide":configuring.html#rails-railtie-initializer.
821
-
822
- The +Initializer+ class here is defined within the +Rails::Initializable+ module and its +initialize+ method is defined to just set up a couple of variables:
823
-
824
- <ruby>
825
- def initialize(name, context, options, &block)
826
- @name, @context, @options, @block = name, context, options, block
827
- end
828
- </ruby>
829
-
830
- Once this +initialize+ method is finished, the object is added to the object the +initializers+ method returns:
831
-
832
- <ruby>
833
- def initializers
834
- @initializers ||= self.class.initializers_for(self)
835
- end
836
- </ruby>
837
-
838
- If +@initializers+ isn't set (which it won't be at this point), the +intializers_for+ method will be called for this class.
839
-
840
- <ruby>
841
- def initializers_for(binding)
842
- Collection.new(initializers_chain.map { |i| i.bind(binding) })
843
- end
844
- </ruby>
845
-
846
- The +Collection+ class in +railties/lib/rails/initializable.rb+ inherits from +Array+ and includes the +TSort+ module which is used to sort out the order of the initializers based on the order they are placed in.
847
-
848
- The +initializers_chain+ method referenced in the +initializers_for+ method is defined like this:
849
-
850
- <ruby>
851
- def initializers_chain
852
- initializers = Collection.new
853
- ancestors.reverse_each do | klass |
854
- next unless klass.respond_to?(:initializers)
855
- initializers = initializers + klass.initializers
856
- end
857
- initializers
858
- end
859
- </ruby>
860
-
861
- This method collects the initializers from the ancestors of this class and adds them to a new +Collection+ object using the <tt>+</tt> method which is defined like this for the <tt>Collection</tt> class:
862
-
863
- <ruby>
864
- def +(other)
865
- Collection.new(to_a + other.to_a)
866
- end
867
- </ruby>
868
-
869
- So this <tt>+</tt> method is overridden to return a new collection comprising of the existing collection as an array and then using the <tt>Array#+</tt> method combines these two collections, returning a "super" +Collection+ object. In this case, the only initializer that's going to be in this new +Collection+ object is the +i18n.callbacks+ initializer.
870
-
871
- The next method to be called after this +initializer+ method is the +after_initialize+ method on the +config+ object, which is defined like this:
872
-
873
- <ruby>
874
- def after_initialize(&block)
875
- ActiveSupport.on_load(:after_initialize, :yield => true, &block)
876
- end
877
- </ruby>
878
-
879
- The +on_load+ method here is provided by the +active_support/lazy_load_hooks+ file which was required earlier and is defined like this:
880
-
881
- <ruby>
882
- def self.on_load(name, options = {}, &block)
883
- if base = @loaded[name]
884
- execute_hook(base, options, block)
885
- else
886
- @load_hooks[name] << [block, options]
887
- end
888
- end
889
- </ruby>
890
-
891
- The +@loaded+ variable here is a hash containing elements representing the different components of Rails that have been loaded at this stage. Currently, this hash is empty. So the +else+ is executed here, using the +@load_hooks+ variable defined in +active_support/lazy_load_hooks+:
892
-
893
- <ruby>
894
- @load_hooks = Hash.new {|h,k| h[k] = [] }
895
- </ruby>
896
-
897
- This defines a new hash which has keys that default to empty arrays. This saves Rails from having to do something like this instead:
898
-
899
- <ruby>
900
- @load_hooks[name] = []
901
- @load_hooks[name] << [block, options]
902
- </ruby>
903
-
904
- The value added to this array here consists of the block and options passed to +after_initialize+.
905
-
906
- We'll see these +@load_hooks+ used later on in the initialization process.
907
-
908
- This rest of +i18n_railtie.rb+ defines the protected class methods +include_fallback_modules+, +init_fallbacks+ and +validate_fallbacks+.
909
-
910
- h4. Back to +activesupport/lib/active_support/railtie.rb+
911
-
912
- This file defines the +ActiveSupport::Railtie+ constant which like the +I18n::Railtie+ constant just defined, inherits from +Rails::Railtie+ meaning the +inherited+ method would be called again here, including +Rails::Configurable+ into this class. This class makes use of +Rails::Railtie+'s +config+ method again, setting up the configuration options for Active Support.
913
-
914
- Then this Railtie sets up three more initializers:
915
-
916
- * +active_support.initialize_whiny_nils+
917
- * +active_support.deprecation_behavior+
918
- * +active_support.initialize_time_zone+
919
-
920
- We will cover what each of these initializers do when they run.
921
-
922
- Once the +active_support/railtie+ file has finished loading the next file required from +railties/lib/rails.rb+ is the +action_dispatch/railtie+.
923
-
924
- h4. +activesupport/lib/action_dispatch/railtie.rb+
925
-
926
- This file defines the +ActionDispatch::Railtie+ class, but not before requiring +action_dispatch+.
927
-
928
- h4. +activesupport/lib/action_dispatch.rb+
929
-
930
- This file attempts to locate the +active_support+ and +active_model+ libraries by looking a couple of directories back from the current file and then adds the +active_support+ and +active_model+ +lib+ directories to the load path, but only if they aren't already, which they are.
931
-
932
- <ruby>
933
- activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
934
- $:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
935
-
936
- activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
937
- $:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
938
- </ruby>
939
-
940
- In effect, these lines only define the +activesupport_path+ and +activemodel_path+ variables and nothing more.
941
-
942
- The next two requires in this file are already done, so they are not run:
943
-
944
- <ruby>
945
- require 'active_support'
946
- require 'active_support/dependencies/autoload'
947
- </ruby>
948
-
949
- The following require is to +action_pack+ (+activesupport/lib/action_pack.rb+) which has a 22-line copyright notice at the top of it and ends in a simple require to +action_pack/version+. This file, like other +version.rb+ files before it, defines the +ActionPack::VERSION+ constant:
950
-
951
- <ruby>
952
- module ActionPack
953
- module VERSION #:nodoc:
954
- MAJOR = 3
955
- MINOR = 1
956
- TINY = 0
957
- PRE = "beta"
958
-
959
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
960
- end
961
- end
962
- </ruby>
963
-
964
- Once +action_pack+ is finished, then +active_model+ is required.
965
-
966
- h4. +activemodel/lib/active_model.rb+
967
-
968
- This file makes a require to +active_model/version+ which defines the version for Active Model:
969
-
970
- <ruby>
971
- module ActiveModel
972
- module VERSION #:nodoc:
973
- MAJOR = 3
974
- MINOR = 1
975
- TINY = 0
976
- PRE = "beta"
977
-
978
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
979
- end
980
- end
981
- </ruby>
982
-
983
- Once the +version.rb+ file is loaded, the +ActiveModel+ module has its autoloaded constants defined as well as a sub-module called +ActiveModel::Serializers+ which has autoloads of its own. When the +ActiveModel+ module is closed the +active_support/i18n+ file is required.
984
-
985
- h4. +activesupport/lib/active_support/i18n.rb+
986
-
987
- This is where the +i18n+ gem is required and first configured:
988
-
989
- <ruby>
990
- begin
991
- require 'i18n'
992
- require 'active_support/lazy_load_hooks'
993
- rescue LoadError => e
994
- $stderr.puts "You don't have i18n installed in your application. Please add it to your Gemfile and run bundle install"
995
- raise e
996
- end
997
-
998
- I18n.load_path << "#{File.dirname(__FILE__)}/locale/en.yml"
999
- </ruby>
1000
-
1001
- In effect, the +I18n+ module first defined by +i18n_railtie+ is extended by the +i18n+ gem, rather than the other way around. This has no ill effect. They both work on the same way.
1002
-
1003
- This is another spot where +active_support/lazy_load_hooks+ is required, but it has already been required so it's not loaded again.
1004
-
1005
- If +i18n+ cannot be loaded, the user is presented with an error which says that it cannot be loaded and recommends that it's added to the +Gemfile+. However, in a normal Rails application this gem would be loaded.
1006
-
1007
- Once it has finished loading, the +I18n.load_path+ method is used to add the +activesupport/lib/active_support/locale/en.yml+ file to I18n's load path. When the translations are loaded in the initialization process, this is one of the files where they will be sourced from.
1008
-
1009
- The loading of this file finishes the loading of +active_model+ and so we go back to +action_dispatch+.
1010
-
1011
- h4. Back to +activesupport/lib/action_dispatch.rb+
1012
-
1013
- The remainder of this file requires the +rack+ file from the Rack gem which defines the +Rack+ module. After +rack+, there's autoloads defined for the +Rack+, +ActionDispatch+, +ActionDispatch::Http+, +ActionDispatch::Session+. A new method called +autoload_under+ is used here, and this simply prefixes the files where the modules are autoloaded from with the path specified. For example here:
1014
-
1015
- <ruby>
1016
- autoload_under 'testing' do
1017
- autoload :Assertions
1018
- ...
1019
- </ruby>
1020
-
1021
- The +Assertions+ module is in the +action_dispatch/testing+ folder rather than simply +action_dispatch+.
1022
-
1023
- Finally, this file defines a top-level autoload, the +Mime+ constant.
1024
-
1025
- h4. Back to +activesupport/lib/action_dispatch/railtie.rb+
1026
-
1027
- After +action_dispatch+ is required in this file, the +ActionDispatch::Railtie+ class is defined and is yet another class that inherits from +Rails::Railtie+. This class defines some initial configuration option defaults for +config.action_dispatch+ before setting up a single initializer called +action_dispatch.configure+.
1028
-
1029
- With +action_dispatch/railtie+ now complete, we go back to +railties/lib/rails.rb+.
1030
-
1031
- h4. Back to +railties/lib/rails.rb+
1032
-
1033
- With the Active Support and Action Dispatch railties now both loaded, the rest of this file deals with setting up UTF-8 to be the default encoding for Rails and then finally setting up the +Rails+ module. This module defines useful methods such as +Rails.logger+, +Rails.application+, +Rails.env+, and +Rails.root+.
1034
-
1035
- h4. Back to +railties/lib/rails/all.rb+
1036
-
1037
- Now that +rails.rb+ is required, the remaining railties are loaded next, beginning with +active_record/railtie+.
1038
-
1039
- h4. +activerecord/lib/active_record/railtie.rb+
1040
-
1041
- Before this file gets into the swing of defining the +ActiveRecord::Railtie+ class, there are a couple of files that are required first. The first one of these is +active_record+.
1042
-
1043
- h4. +activerecord/lib/active_record.rb+
1044
-
1045
- This file begins by detecting if the +lib+ directories of +active_support+ and +active_model+ are not in the load path and if they aren't then adds them. As we saw back in +action_dispatch.rb+, these directories are already there.
1046
-
1047
- The first three requires have already been done by other files and so aren't loaded here, but the 4th require, the one to +arel+ will require the file provided by the Arel gem, which defines the +Arel+ module.
1048
-
1049
- <ruby>
1050
- require 'active_support'
1051
- require 'active_support/i18n'
1052
- require 'active_model'
1053
- require 'arel'
1054
- </ruby>
1055
-
1056
- The 5th require in this file is one to +active_record/version+ which defines the +ActiveRecord::VERSION+ constant:
1057
-
1058
- <ruby>
1059
- module ActiveRecord
1060
- module VERSION #:nodoc:
1061
- MAJOR = 3
1062
- MINOR = 1
1063
- TINY = 0
1064
- PRE = "beta"
1065
-
1066
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
1067
- end
1068
- end
1069
- </ruby>
1070
-
1071
- Once these requires are finished, the base for the +ActiveRecord+ module is defined along with its autoloads.
1072
-
1073
- Near the end of the file, we see this line:
1074
-
1075
- <ruby>
1076
- ActiveSupport.on_load(:active_record) do
1077
- Arel::Table.engine = self
1078
- end
1079
- </ruby>
1080
-
1081
- This will set the engine for +Arel::Table+ to be +ActiveRecord::Base+.
1082
-
1083
- The file then finishes with this line:
1084
-
1085
- <ruby>
1086
- I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml'
1087
- </ruby>
1088
-
1089
- This will add the translations from +activerecord/lib/active_record/locale/en.yml+ to the load path for +I18n+, with this file being parsed when all the translations are loaded.
1090
-
1091
- h4. Back to +activerecord/lib/active_record/railtie.rb+
1092
-
1093
- The next two <tt>require</tt>s in this file aren't run because their files are already required, with +rails+ being required by +rails/all+ and +active_model/railtie+ being required from +action_dispatch+.
1094
-
1095
- <ruby>
1096
- require "rails"
1097
- require "active_model/railtie"
1098
- </ruby>
1099
-
1100
- The next +require+ in this file is to +action_controller/railtie+.
1101
-
1102
- h4. +actionpack/lib/action_controller/railtie.rb+
1103
-
1104
- This file begins with a couple more requires to files that have already been loaded:
1105
-
1106
- <ruby>
1107
- require "rails"
1108
- require "action_controller"
1109
- require "action_dispatch/railtie"
1110
- </ruby>
1111
-
1112
- However the require after these is to a file that hasn't yet been loaded, +action_view/railtie+, which begins by requiring +action_view+.
1113
-
1114
- h4. +actionpack/lib/action_view.rb+
1115
-
1116
- +action_view.rb+