railties 3.1.12 → 3.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/CHANGELOG.md +2292 -41
  2. data/README.rdoc +14 -5
  3. data/bin/rails +7 -0
  4. data/guides/code/getting_started/Gemfile +27 -0
  5. data/guides/code/getting_started/README.rdoc +261 -0
  6. data/guides/code/getting_started/Rakefile +7 -0
  7. data/guides/code/getting_started/app/assets/images/rails.png +0 -0
  8. data/guides/code/getting_started/app/assets/javascripts/application.js +9 -0
  9. data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +3 -0
  10. data/guides/code/getting_started/app/assets/javascripts/home.js.coffee +3 -0
  11. data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +3 -0
  12. data/guides/code/getting_started/app/assets/stylesheets/application.css +7 -0
  13. data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +3 -0
  14. data/guides/code/getting_started/app/assets/stylesheets/home.css.scss +3 -0
  15. data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +3 -0
  16. data/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss +56 -0
  17. data/guides/code/getting_started/app/controllers/application_controller.rb +3 -0
  18. data/guides/code/getting_started/app/controllers/comments_controller.rb +16 -0
  19. data/guides/code/getting_started/app/controllers/home_controller.rb +5 -0
  20. data/guides/code/getting_started/app/controllers/posts_controller.rb +84 -0
  21. data/guides/code/getting_started/app/helpers/application_helper.rb +2 -0
  22. data/guides/code/getting_started/app/helpers/comments_helper.rb +2 -0
  23. data/guides/code/getting_started/app/helpers/home_helper.rb +2 -0
  24. data/guides/code/getting_started/app/helpers/posts_helper.rb +5 -0
  25. data/guides/code/getting_started/app/models/comment.rb +3 -0
  26. data/guides/code/getting_started/app/models/post.rb +11 -0
  27. data/guides/code/getting_started/app/models/tag.rb +3 -0
  28. data/guides/code/getting_started/app/views/comments/_comment.html.erb +15 -0
  29. data/guides/code/getting_started/app/views/comments/_form.html.erb +13 -0
  30. data/guides/code/getting_started/app/views/home/index.html.erb +2 -0
  31. data/guides/code/getting_started/app/views/layouts/application.html.erb +14 -0
  32. data/guides/code/getting_started/app/views/posts/_form.html.erb +32 -0
  33. data/guides/code/getting_started/app/views/posts/edit.html.erb +6 -0
  34. data/guides/code/getting_started/app/views/posts/index.html.erb +27 -0
  35. data/guides/code/getting_started/app/views/posts/new.html.erb +5 -0
  36. data/guides/code/getting_started/app/views/posts/show.html.erb +31 -0
  37. data/guides/code/getting_started/app/views/tags/_form.html.erb +12 -0
  38. data/guides/code/getting_started/config.ru +4 -0
  39. data/guides/code/getting_started/config/application.rb +53 -0
  40. data/guides/code/getting_started/config/boot.rb +6 -0
  41. data/guides/code/getting_started/config/database.yml +25 -0
  42. data/guides/code/getting_started/config/environment.rb +5 -0
  43. data/guides/code/getting_started/config/environments/development.rb +37 -0
  44. data/guides/code/getting_started/config/environments/production.rb +67 -0
  45. data/guides/code/getting_started/config/environments/test.rb +37 -0
  46. data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +7 -0
  47. data/guides/code/getting_started/config/initializers/inflections.rb +10 -0
  48. data/guides/code/getting_started/config/initializers/mime_types.rb +5 -0
  49. data/guides/code/getting_started/config/initializers/secret_token.rb +7 -0
  50. data/guides/code/getting_started/config/initializers/session_store.rb +8 -0
  51. data/guides/code/getting_started/config/initializers/wrap_parameters.rb +14 -0
  52. data/guides/code/getting_started/config/locales/en.yml +5 -0
  53. data/guides/code/getting_started/config/routes.rb +64 -0
  54. data/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb +11 -0
  55. data/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb +12 -0
  56. data/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb +11 -0
  57. data/guides/code/getting_started/db/schema.rb +43 -0
  58. data/guides/code/getting_started/db/seeds.rb +7 -0
  59. data/guides/code/getting_started/doc/README_FOR_APP +2 -0
  60. data/guides/code/getting_started/public/404.html +26 -0
  61. data/guides/code/getting_started/public/422.html +26 -0
  62. data/guides/code/getting_started/public/500.html +26 -0
  63. data/guides/code/getting_started/public/favicon.ico +0 -0
  64. data/guides/code/getting_started/public/robots.txt +5 -0
  65. data/guides/code/getting_started/script/rails +6 -0
  66. data/guides/code/getting_started/test/fixtures/comments.yml +11 -0
  67. data/guides/code/getting_started/test/fixtures/posts.yml +11 -0
  68. data/guides/code/getting_started/test/fixtures/tags.yml +9 -0
  69. data/guides/code/getting_started/test/functional/comments_controller_test.rb +7 -0
  70. data/guides/code/getting_started/test/functional/home_controller_test.rb +9 -0
  71. data/guides/code/getting_started/test/functional/posts_controller_test.rb +49 -0
  72. data/guides/code/getting_started/test/performance/browsing_test.rb +12 -0
  73. data/guides/code/getting_started/test/test_helper.rb +13 -0
  74. data/guides/code/getting_started/test/unit/comment_test.rb +7 -0
  75. data/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb +4 -0
  76. data/guides/code/getting_started/test/unit/helpers/home_helper_test.rb +4 -0
  77. data/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb +4 -0
  78. data/guides/code/getting_started/test/unit/post_test.rb +7 -0
  79. data/guides/code/getting_started/test/unit/tag_test.rb +7 -0
  80. data/guides/rails_guides/generator.rb +2 -1
  81. data/guides/source/3_0_release_notes.textile +2 -2
  82. data/guides/source/3_1_release_notes.textile +3 -110
  83. data/guides/source/action_controller_overview.textile +11 -13
  84. data/guides/source/action_mailer_basics.textile +7 -18
  85. data/guides/source/action_view_overview.textile +78 -9
  86. data/guides/source/active_model_basics.textile +205 -0
  87. data/guides/source/active_record_basics.textile +31 -31
  88. data/guides/source/active_record_querying.textile +288 -67
  89. data/guides/source/active_record_validations_callbacks.textile +69 -75
  90. data/guides/source/active_resource_basics.textile +48 -2
  91. data/guides/source/active_support_core_extensions.textile +145 -24
  92. data/guides/source/ajax_on_rails.textile +65 -7
  93. data/guides/source/api_documentation_guidelines.textile +0 -6
  94. data/guides/source/asset_pipeline.textile +2 -2
  95. data/guides/source/association_basics.textile +25 -34
  96. data/guides/source/caching_with_rails.textile +12 -17
  97. data/guides/source/command_line.textile +29 -19
  98. data/guides/source/configuring.textile +40 -18
  99. data/guides/source/contributing_to_ruby_on_rails.textile +11 -18
  100. data/guides/source/debugging_rails_applications.textile +10 -21
  101. data/guides/source/engines.textile +618 -0
  102. data/guides/source/form_helpers.textile +1 -12
  103. data/guides/source/generators.textile +9 -11
  104. data/guides/source/getting_started.textile +152 -152
  105. data/guides/source/i18n.textile +4 -5
  106. data/guides/source/index.html.erb +0 -1
  107. data/guides/source/initialization.textile +26 -26
  108. data/guides/source/layouts_and_rendering.textile +97 -61
  109. data/guides/source/migrations.textile +380 -161
  110. data/guides/source/performance_testing.textile +4 -10
  111. data/guides/source/plugins.textile +11 -19
  112. data/guides/source/rails_application_templates.textile +12 -4
  113. data/guides/source/rails_on_rack.textile +25 -19
  114. data/guides/source/routing.textile +6 -13
  115. data/guides/source/ruby_on_rails_guides_guidelines.textile +0 -5
  116. data/guides/source/security.textile +11 -15
  117. data/guides/source/testing.textile +1 -9
  118. data/lib/rails/application.rb +107 -42
  119. data/lib/rails/application/bootstrap.rb +12 -11
  120. data/lib/rails/application/configuration.rb +27 -21
  121. data/lib/rails/application/finisher.rb +40 -17
  122. data/lib/rails/application/route_inspector.rb +75 -0
  123. data/lib/rails/application/routes_reloader.rb +15 -4
  124. data/lib/rails/code_statistics.rb +16 -5
  125. data/lib/rails/commands.rb +6 -5
  126. data/lib/rails/commands/application.rb +8 -1
  127. data/lib/rails/commands/console.rb +2 -0
  128. data/lib/rails/commands/dbconsole.rb +2 -2
  129. data/lib/rails/commands/destroy.rb +0 -2
  130. data/lib/rails/commands/generate.rb +3 -3
  131. data/lib/rails/commands/plugin.rb +161 -159
  132. data/lib/rails/commands/plugin_new.rb +3 -2
  133. data/lib/rails/commands/runner.rb +4 -0
  134. data/lib/rails/console/app.rb +26 -22
  135. data/lib/rails/console/helpers.rb +9 -5
  136. data/lib/rails/engine.rb +70 -34
  137. data/lib/rails/engine/commands.rb +39 -0
  138. data/lib/rails/engine/configuration.rb +1 -1
  139. data/lib/rails/generators.rb +3 -14
  140. data/lib/rails/generators/actions.rb +36 -9
  141. data/lib/rails/generators/app_base.rb +34 -38
  142. data/lib/rails/generators/base.rb +4 -4
  143. data/lib/rails/generators/generated_attribute.rb +1 -1
  144. data/lib/rails/generators/named_base.rb +1 -3
  145. data/lib/rails/generators/rails/app/USAGE +6 -0
  146. data/lib/rails/generators/rails/app/app_generator.rb +6 -2
  147. data/lib/rails/generators/rails/app/templates/Gemfile +4 -3
  148. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +9 -3
  149. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +11 -5
  150. data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
  151. data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
  152. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -1
  153. data/lib/rails/generators/rails/app/templates/config/application.rb +11 -0
  154. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +1 -1
  155. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +1 -1
  156. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +10 -1
  157. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +10 -1
  158. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -6
  159. data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb +5 -0
  160. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  161. data/lib/rails/generators/rails/app/templates/public/500.html +0 -1
  162. data/lib/rails/generators/rails/app/templates/public/index.html +1 -1
  163. data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  164. data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  165. data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  166. data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  167. data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  168. data/lib/rails/generators/rails/controller/templates/controller.rb +1 -1
  169. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  170. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +17 -5
  171. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +1 -0
  172. data/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory +0 -0
  173. data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
  174. data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt +1 -1
  175. data/lib/rails/generators/rails/plugin_new/templates/gitignore +4 -3
  176. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +1 -1
  177. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +1 -1
  178. data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -3
  179. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +2 -2
  180. data/lib/rails/generators/rails/task/USAGE +9 -0
  181. data/lib/rails/generators/rails/task/task_generator.rb +12 -0
  182. data/lib/rails/generators/rails/task/templates/task.rb +8 -0
  183. data/lib/rails/generators/resource_helpers.rb +3 -3
  184. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +0 -2
  185. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +4 -4
  186. data/lib/rails/paths.rb +11 -38
  187. data/lib/rails/rack/debugger.rb +3 -4
  188. data/lib/rails/rack/logger.rb +26 -12
  189. data/lib/rails/railtie.rb +6 -1
  190. data/lib/rails/railtie/configuration.rb +12 -5
  191. data/lib/rails/source_annotation_extractor.rb +12 -10
  192. data/lib/rails/tasks/documentation.rake +3 -1
  193. data/lib/rails/tasks/engine.rake +1 -0
  194. data/lib/rails/tasks/misc.rake +1 -1
  195. data/lib/rails/tasks/routes.rake +3 -23
  196. data/lib/rails/test_help.rb +1 -2
  197. data/lib/rails/test_unit/testing.rake +8 -4
  198. data/lib/rails/version.rb +3 -3
  199. metadata +131 -61
  200. checksums.yaml +0 -7
  201. data/lib/rails/generators/rails/plugin/USAGE +0 -13
  202. data/lib/rails/generators/rails/plugin/plugin_generator.rb +0 -54
  203. data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +0 -20
  204. data/lib/rails/generators/rails/plugin/templates/README.tt +0 -13
  205. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +0 -23
  206. data/lib/rails/generators/rails/plugin/templates/init.rb +0 -1
  207. data/lib/rails/generators/rails/plugin/templates/install.rb +0 -1
  208. data/lib/rails/generators/rails/plugin/templates/lib/%file_name%.rb.tt +0 -1
  209. data/lib/rails/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +0 -4
  210. data/lib/rails/generators/rails/plugin/templates/uninstall.rb +0 -1
@@ -1,12 +1,12 @@
1
1
  require 'rails/generators'
2
2
  require 'active_support/core_ext/object/inclusion'
3
3
 
4
- Rails::Generators.configure!
5
-
6
4
  if ARGV.first.in?([nil, "-h", "--help"])
7
5
  Rails::Generators.help 'generate'
8
6
  exit
9
7
  end
10
8
 
11
9
  name = ARGV.shift
12
- Rails::Generators.invoke name, ARGV, :behavior => :invoke, :destination_root => Rails.root
10
+
11
+ root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root
12
+ Rails::Generators.invoke name, ARGV, :behavior => :invoke, :destination_root => root
@@ -274,198 +274,200 @@ end
274
274
 
275
275
  # load default environment and parse arguments
276
276
  require 'optparse'
277
- module Commands
278
- class Plugin
279
- attr_reader :environment, :script_name
280
- def initialize
281
- @environment = RailsEnvironment.default
282
- @rails_root = RailsEnvironment.default.root
283
- @script_name = File.basename($0)
284
- end
277
+ module Rails
278
+ module Commands
279
+ class Plugin
280
+ attr_reader :environment, :script_name
281
+ def initialize
282
+ @environment = RailsEnvironment.default
283
+ @rails_root = RailsEnvironment.default.root
284
+ @script_name = File.basename($0)
285
+ end
285
286
 
286
- def environment=(value)
287
- @environment = value
288
- RailsEnvironment.default = value
289
- end
287
+ def environment=(value)
288
+ @environment = value
289
+ RailsEnvironment.default = value
290
+ end
290
291
 
291
- def options
292
- OptionParser.new do |o|
293
- o.set_summary_indent(' ')
294
- o.banner = "Usage: plugin [OPTIONS] command"
295
- o.define_head "Rails plugin manager."
292
+ def options
293
+ OptionParser.new do |o|
294
+ o.set_summary_indent(' ')
295
+ o.banner = "Usage: plugin [OPTIONS] command"
296
+ o.define_head "Rails plugin manager."
296
297
 
297
- o.separator ""
298
- o.separator "GENERAL OPTIONS"
298
+ o.separator ""
299
+ o.separator "GENERAL OPTIONS"
299
300
 
300
- o.on("-r", "--root=DIR", String,
301
- "Set an explicit rails app directory.",
302
- "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
301
+ o.on("-r", "--root=DIR", String,
302
+ "Set an explicit rails app directory.",
303
+ "Default: #{@rails_root}") { |rails_root| @rails_root = rails_root; self.environment = RailsEnvironment.new(@rails_root) }
303
304
 
304
- o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
305
- o.on("-h", "--help", "Show this help message.") { puts o; exit }
305
+ o.on("-v", "--verbose", "Turn on verbose output.") { |verbose| $verbose = verbose }
306
+ o.on("-h", "--help", "Show this help message.") { puts o; exit }
306
307
 
307
- o.separator ""
308
- o.separator "COMMANDS"
308
+ o.separator ""
309
+ o.separator "COMMANDS"
309
310
 
310
- o.separator " install Install plugin(s) from known repositories or URLs."
311
- o.separator " remove Uninstall plugins."
311
+ o.separator " install Install plugin(s) from known repositories or URLs."
312
+ o.separator " remove Uninstall plugins."
312
313
 
313
- o.separator ""
314
- o.separator "EXAMPLES"
315
- o.separator " Install a plugin from a subversion URL:"
316
- o.separator " #{@script_name} plugin install http://dev.rubyonrails.com/svn/rails/plugins/continuous_builder\n"
317
- o.separator " Install a plugin from a git URL:"
318
- o.separator " #{@script_name} plugin install git://github.com/SomeGuy/my_awesome_plugin.git\n"
319
- o.separator " Install a plugin and add a svn:externals entry to vendor/plugins"
320
- o.separator " #{@script_name} plugin install -x continuous_builder\n"
314
+ o.separator ""
315
+ o.separator "EXAMPLES"
316
+ o.separator " Install a plugin from a subversion URL:"
317
+ o.separator " #{@script_name} plugin install http://example.com/my_svn_plugin\n"
318
+ o.separator " Install a plugin from a git URL:"
319
+ o.separator " #{@script_name} plugin install git://github.com/SomeGuy/my_awesome_plugin.git\n"
320
+ o.separator " Install a plugin and add a svn:externals entry to vendor/plugins"
321
+ o.separator " #{@script_name} plugin install -x my_svn_plugin\n"
322
+ end
321
323
  end
322
- end
323
324
 
324
- def parse!(args=ARGV)
325
- general, sub = split_args(args)
326
- options.parse!(general)
325
+ def parse!(args=ARGV)
326
+ general, sub = split_args(args)
327
+ options.parse!(general)
327
328
 
328
- command = general.shift
329
- if command =~ /^(install|remove)$/
330
- command = Commands.const_get(command.capitalize).new(self)
331
- command.parse!(sub)
332
- else
333
- puts "Unknown command: #{command}" unless command.blank?
334
- puts options
335
- exit 1
329
+ command = general.shift
330
+ if command =~ /^(install|remove)$/
331
+ command = Commands.const_get(command.capitalize).new(self)
332
+ command.parse!(sub)
333
+ else
334
+ puts "Unknown command: #{command}" unless command.blank?
335
+ puts options
336
+ exit 1
337
+ end
336
338
  end
337
- end
338
339
 
339
- def split_args(args)
340
- left = []
341
- left << args.shift while args[0] and args[0] =~ /^-/
342
- left << args.shift if args[0]
343
- [left, args]
344
- end
345
-
346
- def self.parse!(args=ARGV)
347
- Plugin.new.parse!(args)
348
- end
349
- end
340
+ def split_args(args)
341
+ left = []
342
+ left << args.shift while args[0] and args[0] =~ /^-/
343
+ left << args.shift if args[0]
344
+ [left, args]
345
+ end
350
346
 
351
- class Install
352
- def initialize(base_command)
353
- @base_command = base_command
354
- @method = :http
355
- @options = { :quiet => false, :revision => nil, :force => false }
347
+ def self.parse!(args=ARGV)
348
+ Plugin.new.parse!(args)
349
+ end
356
350
  end
357
351
 
358
- def options
359
- OptionParser.new do |o|
360
- o.set_summary_indent(' ')
361
- o.banner = "Usage: #{@base_command.script_name} install PLUGIN [PLUGIN [PLUGIN] ...]"
362
- o.define_head "Install one or more plugins."
363
- o.separator ""
364
- o.separator "Options:"
365
- o.on( "-x", "--externals",
366
- "Use svn:externals to grab the plugin.",
367
- "Enables plugin updates and plugin versioning.") { |v| @method = :externals }
368
- o.on( "-o", "--checkout",
369
- "Use svn checkout to grab the plugin.",
370
- "Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout }
371
- o.on( "-e", "--export",
372
- "Use svn export to grab the plugin.",
373
- "Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry.") { |v| @method = :export }
374
- o.on( "-q", "--quiet",
375
- "Suppresses the output from installation.",
376
- "Ignored if -v is passed (rails plugin -v install ...)") { |v| @options[:quiet] = true }
377
- o.on( "-r REVISION", "--revision REVISION",
378
- "Checks out the given revision from subversion or git.",
379
- "Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
380
- o.on( "-f", "--force",
381
- "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
382
- o.separator ""
383
- o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to "
384
- o.separator "a plugin repository."
352
+ class Install
353
+ def initialize(base_command)
354
+ @base_command = base_command
355
+ @method = :http
356
+ @options = { :quiet => false, :revision => nil, :force => false }
385
357
  end
386
- end
387
358
 
388
- def determine_install_method
389
- best = @base_command.environment.best_install_method
390
- @method = :http if best == :http and @method == :export
391
- case
392
- when (best == :http and @method != :http)
393
- msg = "Cannot install using subversion because `svn' cannot be found in your PATH"
394
- when (best == :export and (@method != :export and @method != :http))
395
- msg = "Cannot install using #{@method} because this project is not under subversion."
396
- when (best != :externals and @method == :externals)
397
- msg = "Cannot install using externals because vendor/plugins is not under subversion."
359
+ def options
360
+ OptionParser.new do |o|
361
+ o.set_summary_indent(' ')
362
+ o.banner = "Usage: #{@base_command.script_name} install PLUGIN [PLUGIN [PLUGIN] ...]"
363
+ o.define_head "Install one or more plugins."
364
+ o.separator ""
365
+ o.separator "Options:"
366
+ o.on( "-x", "--externals",
367
+ "Use svn:externals to grab the plugin.",
368
+ "Enables plugin updates and plugin versioning.") { |v| @method = :externals }
369
+ o.on( "-o", "--checkout",
370
+ "Use svn checkout to grab the plugin.",
371
+ "Enables updating but does not add a svn:externals entry.") { |v| @method = :checkout }
372
+ o.on( "-e", "--export",
373
+ "Use svn export to grab the plugin.",
374
+ "Exports the plugin, allowing you to check it into your local repository. Does not enable updates or add an svn:externals entry.") { |v| @method = :export }
375
+ o.on( "-q", "--quiet",
376
+ "Suppresses the output from installation.",
377
+ "Ignored if -v is passed (rails plugin -v install ...)") { |v| @options[:quiet] = true }
378
+ o.on( "-r REVISION", "--revision REVISION",
379
+ "Checks out the given revision from subversion or git.",
380
+ "Ignored if subversion/git is not used.") { |v| @options[:revision] = v }
381
+ o.on( "-f", "--force",
382
+ "Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
383
+ o.separator ""
384
+ o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to "
385
+ o.separator "a plugin repository."
386
+ end
398
387
  end
399
- if msg
400
- puts msg
401
- exit 1
388
+
389
+ def determine_install_method
390
+ best = @base_command.environment.best_install_method
391
+ @method = :http if best == :http and @method == :export
392
+ case
393
+ when (best == :http and @method != :http)
394
+ msg = "Cannot install using subversion because `svn' cannot be found in your PATH"
395
+ when (best == :export and (@method != :export and @method != :http))
396
+ msg = "Cannot install using #{@method} because this project is not under subversion."
397
+ when (best != :externals and @method == :externals)
398
+ msg = "Cannot install using externals because vendor/plugins is not under subversion."
399
+ end
400
+ if msg
401
+ puts msg
402
+ exit 1
403
+ end
404
+ @method
402
405
  end
403
- @method
404
- end
405
406
 
406
- def parse!(args)
407
- options.parse!(args)
408
- if args.blank?
409
- puts options
407
+ def parse!(args)
408
+ options.parse!(args)
409
+ if args.blank?
410
+ puts options
411
+ exit 1
412
+ end
413
+ environment = @base_command.environment
414
+ install_method = determine_install_method
415
+ puts "Plugins will be installed using #{install_method}" if $verbose
416
+ args.each do |name|
417
+ ::Plugin.find(name).install(install_method, @options)
418
+ end
419
+ rescue StandardError => e
420
+ puts "Plugin not found: #{args.inspect}"
421
+ puts e.inspect if $verbose
410
422
  exit 1
411
423
  end
412
- environment = @base_command.environment
413
- install_method = determine_install_method
414
- puts "Plugins will be installed using #{install_method}" if $verbose
415
- args.each do |name|
416
- ::Plugin.find(name).install(install_method, @options)
417
- end
418
- rescue StandardError => e
419
- puts "Plugin not found: #{args.inspect}"
420
- puts e.inspect if $verbose
421
- exit 1
422
- end
423
- end
424
-
425
- class Remove
426
- def initialize(base_command)
427
- @base_command = base_command
428
424
  end
429
425
 
430
- def options
431
- OptionParser.new do |o|
432
- o.set_summary_indent(' ')
433
- o.banner = "Usage: #{@base_command.script_name} remove name [name]..."
434
- o.define_head "Remove plugins."
426
+ class Remove
427
+ def initialize(base_command)
428
+ @base_command = base_command
435
429
  end
436
- end
437
430
 
438
- def parse!(args)
439
- options.parse!(args)
440
- if args.blank?
441
- puts options
442
- exit 1
431
+ def options
432
+ OptionParser.new do |o|
433
+ o.set_summary_indent(' ')
434
+ o.banner = "Usage: #{@base_command.script_name} remove name [name]..."
435
+ o.define_head "Remove plugins."
436
+ end
443
437
  end
444
- root = @base_command.environment.root
445
- args.each do |name|
446
- ::Plugin.new(name).uninstall
438
+
439
+ def parse!(args)
440
+ options.parse!(args)
441
+ if args.blank?
442
+ puts options
443
+ exit 1
444
+ end
445
+ root = @base_command.environment.root
446
+ args.each do |name|
447
+ ::Plugin.new(name).uninstall
448
+ end
447
449
  end
448
450
  end
449
- end
450
451
 
451
- class Info
452
- def initialize(base_command)
453
- @base_command = base_command
454
- end
452
+ class Info
453
+ def initialize(base_command)
454
+ @base_command = base_command
455
+ end
455
456
 
456
- def options
457
- OptionParser.new do |o|
458
- o.set_summary_indent(' ')
459
- o.banner = "Usage: #{@base_command.script_name} info name [name]..."
460
- o.define_head "Shows plugin info at {url}/about.yml."
457
+ def options
458
+ OptionParser.new do |o|
459
+ o.set_summary_indent(' ')
460
+ o.banner = "Usage: #{@base_command.script_name} info name [name]..."
461
+ o.define_head "Shows plugin info at {url}/about.yml."
462
+ end
461
463
  end
462
- end
463
464
 
464
- def parse!(args)
465
- options.parse!(args)
466
- args.each do |name|
467
- puts ::Plugin.find(name).info
468
- puts
465
+ def parse!(args)
466
+ options.parse!(args)
467
+ args.each do |name|
468
+ puts ::Plugin.find(name).info
469
+ puts
470
+ end
469
471
  end
470
472
  end
471
473
  end
@@ -539,4 +541,4 @@ class RecursiveHTTPFetcher
539
541
  end
540
542
  end
541
543
 
542
- Commands::Plugin.parse!
544
+ Rails::Commands::Plugin.parse!
@@ -1,3 +1,5 @@
1
+ require 'rubygems' if ARGV.include?("--dev")
2
+
1
3
  if ARGV.first != "new"
2
4
  ARGV[0] = "--help"
3
5
  else
@@ -6,5 +8,4 @@ end
6
8
 
7
9
  require 'rails/generators'
8
10
  require 'rails/generators/rails/plugin_new/plugin_new_generator'
9
-
10
- Rails::Generators::PluginNewGenerator.start
11
+ Rails::Generators::PluginNewGenerator.start
@@ -4,6 +4,10 @@ require 'rbconfig'
4
4
  options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
5
5
  code_or_file = nil
6
6
 
7
+ if ARGV.first.nil?
8
+ ARGV.push "-h"
9
+ end
10
+
7
11
  ARGV.clone.options do |opts|
8
12
  script_name = File.basename($0)
9
13
  opts.banner = "Usage: runner [options] ('Some.ruby(code)' or a filename)"
@@ -5,28 +5,32 @@ require 'action_controller'
5
5
  # work around the at_exit hook in test/unit, which kills IRB
6
6
  Test::Unit.run = true if Test::Unit.respond_to?(:run=)
7
7
 
8
- # reference the global "app" instance, created on demand. To recreate the
9
- # instance, pass a non-false value as the parameter.
10
- def app(create=false)
11
- @app_integration_instance = nil if create
12
- @app_integration_instance ||= new_session do |sess|
13
- sess.host! "www.example.com"
14
- end
15
- end
8
+ module Rails
9
+ module ConsoleMethods
10
+ # reference the global "app" instance, created on demand. To recreate the
11
+ # instance, pass a non-false value as the parameter.
12
+ def app(create=false)
13
+ @app_integration_instance = nil if create
14
+ @app_integration_instance ||= new_session do |sess|
15
+ sess.host! "www.example.com"
16
+ end
17
+ end
16
18
 
17
- # create a new session. If a block is given, the new session will be yielded
18
- # to the block before being returned.
19
- def new_session
20
- app = Rails.application
21
- session = ActionDispatch::Integration::Session.new(app)
22
- yield session if block_given?
23
- session
24
- end
19
+ # create a new session. If a block is given, the new session will be yielded
20
+ # to the block before being returned.
21
+ def new_session
22
+ app = Rails.application
23
+ session = ActionDispatch::Integration::Session.new(app)
24
+ yield session if block_given?
25
+ session
26
+ end
25
27
 
26
- # reloads the environment
27
- def reload!(print=true)
28
- puts "Reloading..." if print
29
- ActionDispatch::Reloader.cleanup!
30
- ActionDispatch::Reloader.prepare!
31
- true
28
+ # reloads the environment
29
+ def reload!(print=true)
30
+ puts "Reloading..." if print
31
+ ActionDispatch::Reloader.cleanup!
32
+ ActionDispatch::Reloader.prepare!
33
+ true
34
+ end
35
+ end
32
36
  end