From 3fbd9acc5c6418cffe8b2676f9e9e69ee1a84847 Mon Sep 17 00:00:00 2001 From: Jeff Dean Date: Mon, 17 Nov 2008 00:45:20 -0500 Subject: Plugin guide: Edits --- railties/doc/guides/html/creating_plugins.html | 35 ++++++---------------- .../guides/source/creating_plugins/appendix.txt | 3 +- .../guides/source/creating_plugins/generators.txt | 9 +----- .../doc/guides/source/creating_plugins/routes.txt | 4 ++- 4 files changed, 15 insertions(+), 36 deletions(-) diff --git a/railties/doc/guides/html/creating_plugins.html b/railties/doc/guides/html/creating_plugins.html index 0fa9822c0c..850822c8ed 100644 --- a/railties/doc/guides/html/creating_plugins.html +++ b/railties/doc/guides/html/creating_plugins.html @@ -1120,7 +1120,8 @@ http://www.gnu.org/software/src-highlite -->

8. Routes

-

Testing routes in plugins can be complex, especially if the controllers are also in the plugin itself. Jamis Buck showed a great example of this in http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2.

+

In a standard routes.rb file you use routes like map.connect or map.resources. You can add your own custom routes from a plugin. This section will describe how to add a custom method called that can be called with map.yaffles.

+

Testing routes from plugins is slightly different from testing routes in a standard rails app. To begin, add a test like this:

vendor/plugins/yaffle/test/routing_test.rb

9. Generators

Many plugins ship with generators. When you created the plugin above, you specified the —with-generator option, so you already have the generator stubs in vendor/plugins/yaffle/generators/yaffle.

-

Building generators is a complex topic unto itself and this section will cover one small aspect of generators: creating a generator that adds a time-stamped migration.

-

To add a generator to a plugin:

-
    -
  • -

    -Write a test -

    -
  • -
  • -

    -Add your instructions to the manifest method of the generator -

    -
  • -
  • -

    -Add any necessary template files to the templates directory -

    -
  • -
  • -

    -Update the USAGE file to add helpful documentation for your generator -

    -
  • -
+

Building generators is a complex topic unto itself and this section will cover one small aspect of generators: generating a simple text file.

9.1. Testing generators

Many rails plugin authors do not test their generators, however testing generators is quite simple. A typical generator test does the following:

    @@ -1804,7 +1782,7 @@ Warning, gotchas or tips that might help save users time

15. Appendix

-

If you prefer to use RSpec instead of tets, you may be interested in the RSpec Plugin Generator.

+

If you prefer to use RSpec instead of Test::Unit, you may be interested in the RSpec Plugin Generator.

15.1. References

15.2. Contents of lib/yaffle.rb

vendor/plugins/yaffle/lib/yaffle.rb:

diff --git a/railties/doc/guides/source/creating_plugins/appendix.txt b/railties/doc/guides/source/creating_plugins/appendix.txt index 5c3bd20a1b..340c03dd4e 100644 --- a/railties/doc/guides/source/creating_plugins/appendix.txt +++ b/railties/doc/guides/source/creating_plugins/appendix.txt @@ -1,6 +1,6 @@ == Appendix == -If you prefer to use RSpec instead of tets, you may be interested in the http://github.com/pat-maddox/rspec-plugin-generator/tree/master[RSpec Plugin Generator]. +If you prefer to use RSpec instead of Test::Unit, you may be interested in the http://github.com/pat-maddox/rspec-plugin-generator/tree/master[RSpec Plugin Generator]. === References === @@ -9,6 +9,7 @@ If you prefer to use RSpec instead of tets, you may be interested in the http:// * http://github.com/technoweenie/attachment_fu/tree/master * http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html * http://www.mbleigh.com/2008/6/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins + * http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2. === Contents of 'lib/yaffle.rb' === diff --git a/railties/doc/guides/source/creating_plugins/generators.txt b/railties/doc/guides/source/creating_plugins/generators.txt index 8ef46561d1..f856bec7a2 100644 --- a/railties/doc/guides/source/creating_plugins/generators.txt +++ b/railties/doc/guides/source/creating_plugins/generators.txt @@ -2,14 +2,7 @@ Many plugins ship with generators. When you created the plugin above, you specified the --with-generator option, so you already have the generator stubs in 'vendor/plugins/yaffle/generators/yaffle'. -Building generators is a complex topic unto itself and this section will cover one small aspect of generators: creating a generator that adds a time-stamped migration. - -To add a generator to a plugin: - - * Write a test - * Add your instructions to the 'manifest' method of the generator - * Add any necessary template files to the templates directory - * Update the USAGE file to add helpful documentation for your generator +Building generators is a complex topic unto itself and this section will cover one small aspect of generators: generating a simple text file. === Testing generators === diff --git a/railties/doc/guides/source/creating_plugins/routes.txt b/railties/doc/guides/source/creating_plugins/routes.txt index 249176729c..dc1bf09fd1 100644 --- a/railties/doc/guides/source/creating_plugins/routes.txt +++ b/railties/doc/guides/source/creating_plugins/routes.txt @@ -1,6 +1,8 @@ == Routes == -Testing routes in plugins can be complex, especially if the controllers are also in the plugin itself. Jamis Buck showed a great example of this in http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2. +In a standard 'routes.rb' file you use routes like 'map.connect' or 'map.resources'. You can add your own custom routes from a plugin. This section will describe how to add a custom method called that can be called with 'map.yaffles'. + +Testing routes from plugins is slightly different from testing routes in a standard rails app. To begin, add a test like this: *vendor/plugins/yaffle/test/routing_test.rb* -- cgit v1.2.3