From ec8d8652f36bc4bf2ea19b8f7dd264187efc99ae Mon Sep 17 00:00:00 2001 From: schneems Date: Mon, 1 Jul 2013 00:02:19 +0300 Subject: [PATCH] s/plugin_new/plugin There are historical reasons that the `plugin` command was `plugin_new`, now those are no longer applicable, we should remove the naming edge case from the project. This PR is based off of comments from #11176 ATP Railties --- railties/CHANGELOG.md | 4 ++++ railties/lib/rails/cli.rb | 2 +- railties/lib/rails/commands.rb | 2 +- railties/lib/rails/commands/plugin.rb | 9 +++++++++ railties/lib/rails/commands/plugin_new.rb | 9 --------- railties/lib/rails/generators.rb | 2 +- .../rails/generators/rails/{plugin_new => plugin}/USAGE | 0 .../plugin_generator.rb} | 2 +- .../{plugin_new => plugin}/templates/%name%.gemspec | 0 .../rails/{plugin_new => plugin}/templates/Gemfile | 0 .../rails/{plugin_new => plugin}/templates/MIT-LICENSE | 0 .../rails/{plugin_new => plugin}/templates/README.rdoc | 0 .../rails/{plugin_new => plugin}/templates/Rakefile | 0 .../app/controllers/%name%/application_controller.rb.tt | 0 .../app/helpers/%name%/application_helper.rb.tt | 0 .../templates/app/mailers/.empty_directory | 0 .../templates/app/models/.empty_directory | 0 .../app/views/layouts/%name%/application.html.erb.tt | 0 .../rails/{plugin_new => plugin}/templates/bin/rails.tt | 0 .../{plugin_new => plugin}/templates/config/routes.rb | 0 .../rails/{plugin_new => plugin}/templates/gitignore | 0 .../rails/{plugin_new => plugin}/templates/lib/%name%.rb | 0 .../templates/lib/%name%/engine.rb | 0 .../templates/lib/%name%/version.rb | 0 .../templates/lib/tasks/%name%_tasks.rake | 0 .../templates/rails/application.rb | 0 .../rails/{plugin_new => plugin}/templates/rails/boot.rb | 0 .../templates/rails/javascripts.js | 0 .../{plugin_new => plugin}/templates/rails/routes.rb | 0 .../templates/rails/stylesheets.css | 0 .../{plugin_new => plugin}/templates/test/%name%_test.rb | 0 .../templates/test/integration/navigation_test.rb | 0 .../{plugin_new => plugin}/templates/test/test_helper.rb | 0 ...in_new_generator_test.rb => plugin_generator_test.rb} | 4 ++-- railties/test/generators_test.rb | 2 +- 35 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 railties/lib/rails/commands/plugin.rb delete mode 100644 railties/lib/rails/commands/plugin_new.rb rename railties/lib/rails/generators/rails/{plugin_new => plugin}/USAGE (100%) rename railties/lib/rails/generators/rails/{plugin_new/plugin_new_generator.rb => plugin/plugin_generator.rb} (99%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/%name%.gemspec (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/Gemfile (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/MIT-LICENSE (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/README.rdoc (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/Rakefile (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/app/controllers/%name%/application_controller.rb.tt (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/app/helpers/%name%/application_helper.rb.tt (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/app/mailers/.empty_directory (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/app/models/.empty_directory (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/app/views/layouts/%name%/application.html.erb.tt (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/bin/rails.tt (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/config/routes.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/gitignore (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/lib/%name%.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/lib/%name%/engine.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/lib/%name%/version.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/lib/tasks/%name%_tasks.rake (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/rails/application.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/rails/boot.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/rails/javascripts.js (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/rails/routes.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/rails/stylesheets.css (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/test/%name%_test.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/test/integration/navigation_test.rb (100%) rename railties/lib/rails/generators/rails/{plugin_new => plugin}/templates/test/test_helper.rb (100%) rename railties/test/generators/{plugin_new_generator_test.rb => plugin_generator_test.rb} (99%) diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 639dd70152..a7132d0a9a 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Rename `commands/plugin_new.rb` to `commands/plugin.rb` and fix references + + *Richard Schneeman* + * Fix `rails plugin --help` command. *Richard Schneeman* diff --git a/railties/lib/rails/cli.rb b/railties/lib/rails/cli.rb index e5341ac436..20313a2608 100644 --- a/railties/lib/rails/cli.rb +++ b/railties/lib/rails/cli.rb @@ -10,7 +10,7 @@ Signal.trap("INT") { puts; exit(1) } if ARGV.first == 'plugin' ARGV.shift - require 'rails/commands/plugin_new' + require 'rails/commands/plugin' else require 'rails/commands/application' end diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index c2ce2b4d2a..3e8163490f 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -36,7 +36,7 @@ command = aliases[command] || command case command when 'plugin' - require "rails/commands/plugin_new" + require "rails/commands/plugin" when 'generate', 'destroy' require 'rails/generators' diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb new file mode 100644 index 0000000000..837fe0ec10 --- /dev/null +++ b/railties/lib/rails/commands/plugin.rb @@ -0,0 +1,9 @@ +if ARGV.first != "new" + ARGV[0] = "--help" +else + ARGV.shift +end + +require 'rails/generators' +require 'rails/generators/rails/plugin/plugin_generator' +Rails::Generators::PluginGenerator.start diff --git a/railties/lib/rails/commands/plugin_new.rb b/railties/lib/rails/commands/plugin_new.rb deleted file mode 100644 index 4d7bf3c9f3..0000000000 --- a/railties/lib/rails/commands/plugin_new.rb +++ /dev/null @@ -1,9 +0,0 @@ -if ARGV.first != "new" - ARGV[0] = "--help" -else - ARGV.shift -end - -require 'rails/generators' -require 'rails/generators/rails/plugin_new/plugin_new_generator' -Rails::Generators::PluginNewGenerator.start \ No newline at end of file diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 4b767ea0c6..6b34db3e3f 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -225,7 +225,7 @@ module Rails rails = groups.delete("rails") rails.map! { |n| n.sub(/^rails:/, '') } rails.delete("app") - rails.delete("plugin_new") + rails.delete("plugin") print_list("rails", rails) hidden_namespaces.each { |n| groups.delete(n.to_s) } diff --git a/railties/lib/rails/generators/rails/plugin_new/USAGE b/railties/lib/rails/generators/rails/plugin/USAGE similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/USAGE rename to railties/lib/rails/generators/rails/plugin/USAGE diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb similarity index 99% rename from railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb rename to railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 850c9d5c0d..13f5472ede 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -154,7 +154,7 @@ task default: :test end module Generators - class PluginNewGenerator < AppBase # :nodoc: + class PluginGenerator < AppBase # :nodoc: add_shared_options_for "plugin" alias_method :plugin_path, :app_path diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec rename to railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Gemfile b/railties/lib/rails/generators/rails/plugin/templates/Gemfile similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/Gemfile rename to railties/lib/rails/generators/rails/plugin/templates/Gemfile diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE rename to railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/README.rdoc b/railties/lib/rails/generators/rails/plugin/templates/README.rdoc similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/README.rdoc rename to railties/lib/rails/generators/rails/plugin/templates/README.rdoc diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin/templates/Rakefile similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/Rakefile rename to railties/lib/rails/generators/rails/plugin/templates/Rakefile diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt rename to railties/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt rename to railties/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory b/railties/lib/rails/generators/rails/plugin/templates/app/mailers/.empty_directory similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory rename to railties/lib/rails/generators/rails/plugin/templates/app/mailers/.empty_directory diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory b/railties/lib/rails/generators/rails/plugin/templates/app/models/.empty_directory similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory rename to railties/lib/rails/generators/rails/plugin/templates/app/models/.empty_directory diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt rename to railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/bin/rails.tt rename to railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/config/routes.rb b/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/config/routes.rb rename to railties/lib/rails/generators/rails/plugin/templates/config/routes.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/gitignore b/railties/lib/rails/generators/rails/plugin/templates/gitignore similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/gitignore rename to railties/lib/rails/generators/rails/plugin/templates/gitignore diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb rename to railties/lib/rails/generators/rails/plugin/templates/lib/%name%.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb rename to railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%/version.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/lib/%name%/version.rb rename to railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake b/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%name%_tasks.rake similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake rename to railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%name%_tasks.rake diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb b/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb rename to railties/lib/rails/generators/rails/plugin/templates/rails/application.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb b/railties/lib/rails/generators/rails/plugin/templates/rails/boot.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb rename to railties/lib/rails/generators/rails/plugin/templates/rails/boot.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js rename to railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb b/railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb rename to railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css b/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css rename to railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb b/railties/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb rename to railties/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb b/railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb rename to railties/lib/rails/generators/rails/plugin/templates/test/integration/navigation_test.rb diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb similarity index 100% rename from railties/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb rename to railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_generator_test.rb similarity index 99% rename from railties/test/generators/plugin_new_generator_test.rb rename to railties/test/generators/plugin_generator_test.rb index 32c7612a8f..068eb66bc6 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -1,5 +1,5 @@ require 'generators/generators_test_helper' -require 'rails/generators/rails/plugin_new/plugin_new_generator' +require 'rails/generators/rails/plugin/plugin_generator' require 'generators/shared_generator_tests' DEFAULT_PLUGIN_FILES = %w( @@ -18,7 +18,7 @@ DEFAULT_PLUGIN_FILES = %w( test/dummy ) -class PluginNewGeneratorTest < Rails::Generators::TestCase +class PluginGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper destination File.join(Rails.root, "tmp/bukkits") arguments [destination_root] diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 361784f509..5130b285a9 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -106,7 +106,7 @@ class GeneratorsTest < Rails::Generators::TestCase def test_rails_generators_help_does_not_include_app_nor_plugin_new output = capture(:stdout){ Rails::Generators.help } assert_no_match(/app/, output) - assert_no_match(/plugin_new/, output) + assert_no_match(/[^:]plugin/, output) end def test_rails_generators_with_others_information