aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/creating_plugins
diff options
context:
space:
mode:
authorJeff Dean <jeff@zilkey.com>2008-11-16 23:09:12 -0500
committerJeff Dean <jeff@zilkey.com>2008-11-16 23:09:12 -0500
commite08af7219795d28fe9e9eb5f0dc2e7488541382e (patch)
treee58587b84665c4d6a0667f5e9bfac972c8c6de9f /railties/doc/guides/source/creating_plugins
parent6b8500ce48f45f18696f6215b8a01f5cf0e328b5 (diff)
downloadrails-e08af7219795d28fe9e9eb5f0dc2e7488541382e.tar.gz
rails-e08af7219795d28fe9e9eb5f0dc2e7488541382e.tar.bz2
rails-e08af7219795d28fe9e9eb5f0dc2e7488541382e.zip
Rails guide: Misc reorganization
Diffstat (limited to 'railties/doc/guides/source/creating_plugins')
-rw-r--r--railties/doc/guides/source/creating_plugins/core_ext.txt27
-rw-r--r--railties/doc/guides/source/creating_plugins/generator_commands.txt1
-rw-r--r--railties/doc/guides/source/creating_plugins/migrations.txt2
-rw-r--r--railties/doc/guides/source/creating_plugins/setup.txt22
-rw-r--r--railties/doc/guides/source/creating_plugins/tests.txt6
5 files changed, 28 insertions, 30 deletions
diff --git a/railties/doc/guides/source/creating_plugins/core_ext.txt b/railties/doc/guides/source/creating_plugins/core_ext.txt
index ca8efc3df1..efef0e1f70 100644
--- a/railties/doc/guides/source/creating_plugins/core_ext.txt
+++ b/railties/doc/guides/source/creating_plugins/core_ext.txt
@@ -1,11 +1,6 @@
== Extending core classes ==
-This section will explain how to add a method to String that will be available anywhere in your rails app by:
-
- * Writing tests for the desired behavior
- * Creating and requiring the correct files
-
-=== Creating the test ===
+This section will explain how to add a method to String that will be available anywhere in your rails app.
In this example you will add a method to String named `to_squawk`. To begin, create a new test file with a few assertions:
@@ -40,26 +35,6 @@ NoMethodError: undefined method `to_squawk' for "Hello World":String
Great - now you are ready to start development.
-=== Organize your files ===
-
-A common pattern in rails plugins is to set up the file structure like this:
-
---------------------------------------------------------
-|-- lib
-| |-- yaffle
-| | `-- core_ext.rb
-| `-- yaffle.rb
---------------------------------------------------------
-
-The first thing we need to to is to require our 'lib/yaffle.rb' file from 'rails/init.rb':
-
-*vendor/plugins/yaffle/rails/init.rb*
-
-[source, ruby]
---------------------------------------------------------
-require 'yaffle'
---------------------------------------------------------
-
Then in 'lib/yaffle.rb' require 'lib/core_ext.rb':
*vendor/plugins/yaffle/lib/yaffle.rb*
diff --git a/railties/doc/guides/source/creating_plugins/generator_commands.txt b/railties/doc/guides/source/creating_plugins/generator_commands.txt
index 5cce81c8bd..3ace3c7318 100644
--- a/railties/doc/guides/source/creating_plugins/generator_commands.txt
+++ b/railties/doc/guides/source/creating_plugins/generator_commands.txt
@@ -137,4 +137,5 @@ To see this work, type:
./script/destroy yaffle_route
-----------------------------------------------------------
+.Editor's note:
NOTE: If you haven't set up the custom route from above, 'script/destroy' will fail and you'll have to remove it manually. \ No newline at end of file
diff --git a/railties/doc/guides/source/creating_plugins/migrations.txt b/railties/doc/guides/source/creating_plugins/migrations.txt
index 4dd932734d..d158004ea3 100644
--- a/railties/doc/guides/source/creating_plugins/migrations.txt
+++ b/railties/doc/guides/source/creating_plugins/migrations.txt
@@ -89,6 +89,7 @@ class CreateBirdhouses < ActiveRecord::Migration
end
----------------------------------------------
+.Editor's note:
NOTE: several plugin frameworks such as Desert and Engines provide more advanced plugin functionality.
=== Generate migrations ===
@@ -146,6 +147,7 @@ class MigrationGeneratorTest < Test::Unit::TestCase
end
------------------------------------------------------------------
+.Editor's note:
NOTE: the migration generator checks to see if a migation already exists, and it's hard-coded to check the 'db/migrate' directory. As a result, if your test tries to generate a migration that already exists in the app, it will fail. The easy workaround is to make sure that the name you generate in your test is very unlikely to actually appear in the app.
After running the test with 'rake' you can make it pass with:
diff --git a/railties/doc/guides/source/creating_plugins/setup.txt b/railties/doc/guides/source/creating_plugins/setup.txt
index fcf5b459e6..cd4b6ecb04 100644
--- a/railties/doc/guides/source/creating_plugins/setup.txt
+++ b/railties/doc/guides/source/creating_plugins/setup.txt
@@ -61,4 +61,24 @@ create vendor/plugins/yaffle/generators/yaffle/yaffle_generator.rb
create vendor/plugins/yaffle/generators/yaffle/USAGE
----------------------------------------------
-To begin just change one thing - move 'init.rb' to 'rails/init.rb'.
+=== Organize your files ===
+
+To make it easy to organize your files and to make the plugin more compatible with GemPlugins, start out by altering your file system to look like this:
+
+--------------------------------------------------------
+|-- lib
+| |-- yaffle
+| `-- yaffle.rb
+`-- rails
+ |
+ `-- init.rb
+--------------------------------------------------------
+
+*vendor/plugins/yaffle/rails/init.rb*
+
+[source, ruby]
+--------------------------------------------------------
+require 'yaffle'
+--------------------------------------------------------
+
+Now you can add any 'require' statements to 'lib/yaffle.rb' and keep 'init.rb' clean. \ No newline at end of file
diff --git a/railties/doc/guides/source/creating_plugins/tests.txt b/railties/doc/guides/source/creating_plugins/tests.txt
index ef6dab2f9f..47611542cb 100644
--- a/railties/doc/guides/source/creating_plugins/tests.txt
+++ b/railties/doc/guides/source/creating_plugins/tests.txt
@@ -1,13 +1,13 @@
== Tests ==
-If your plugin interacts with a database, you'll need to setup a database connection. In this guide you will learn how to test your plugin against multiple different database adapters using Active Record. This guide will not cover how to use fixtures in plugin tests.
-
-To setup your plugin to allow for easy testing you'll need to add 3 files:
+In this guide you will learn how to test your plugin against multiple different database adapters using Active Record. To setup your plugin to allow for easy testing you'll need to add 3 files:
* A 'database.yml' file with all of your connection strings
* A 'schema.rb' file with your table definitions
* A test helper method that sets up the database
+=== Test Setup ===
+
*vendor/plugins/yaffle/test/database.yml:*
----------------------------------------------