aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc
diff options
context:
space:
mode:
authorJeff Dean <jeff@zilkey.com>2008-05-30 10:13:29 -0700
committerJeff Dean <jeff@zilkey.com>2008-05-30 10:13:29 -0700
commit60e37868e40ac11f07cbda81f24dcdb0a9c68783 (patch)
treefb87acd340ba39f0ca3310cebc46b438ee0948a5 /railties/doc
parent1b43884c729662e4f0b12f4141dc493ead7da258 (diff)
downloadrails-60e37868e40ac11f07cbda81f24dcdb0a9c68783.tar.gz
rails-60e37868e40ac11f07cbda81f24dcdb0a9c68783.tar.bz2
rails-60e37868e40ac11f07cbda81f24dcdb0a9c68783.zip
added final tree structure, changed String to String.class_eval do
Diffstat (limited to 'railties/doc')
-rw-r--r--railties/doc/guides/creating_plugins/basics.markdown44
1 files changed, 40 insertions, 4 deletions
diff --git a/railties/doc/guides/creating_plugins/basics.markdown b/railties/doc/guides/creating_plugins/basics.markdown
index 9e0092c144..a7b5d53478 100644
--- a/railties/doc/guides/creating_plugins/basics.markdown
+++ b/railties/doc/guides/creating_plugins/basics.markdown
@@ -266,16 +266,15 @@ Great - now you are ready to start development. The first thing we'll do is to
# File: vendor/plugins/yaffle/lib/core_ext.rb
- class String
- # returns the current string, prefixed by "squawk!"
+ String.class_eval do
def to_squawk
"squawk! #{self}".strip
end
end
-To test that your method does what it says it does, run the unit tests. To make sure your code is picked up by
+When monkey-patching existing classes it's often better to use `class_eval` instead of opening the class directly.
-To test this, fire up a console and start squawking:
+To test that your method does what it says it does, run the unit tests. To test this manually, fire up a console and start squawking:
script/console
>> "Hello World".to_squawk
@@ -824,3 +823,40 @@ References
* [http://nubyonrails.com/articles/2006/05/09/the-complete-guide-to-rails-plugins-part-ii](http://nubyonrails.com/articles/2006/05/09/the-complete-guide-to-rails-plugins-part-ii)
* [http://github.com/technoweenie/attachment_fu/tree/master](http://github.com/technoweenie/attachment_fu/tree/master)
* [http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html](http://daddy.platte.name/2007/05/rails-plugins-keep-initrb-thin.html)
+
+Appendices
+------------------------
+
+The final plugin should have a directory structure that looks something like this:
+
+ |-- MIT-LICENSE
+ |-- README
+ |-- Rakefile
+ |-- generators
+ | `-- yaffle
+ | |-- USAGE
+ | |-- templates
+ | | `-- definition.txt
+ | `-- yaffle_generator.rb
+ |-- init.rb
+ |-- install.rb
+ |-- lib
+ | |-- acts_as_yaffle.rb
+ | |-- commands.rb
+ | |-- core_ext.rb
+ | |-- routing.rb
+ | `-- view_helpers.rb
+ |-- tasks
+ | `-- yaffle_tasks.rake
+ |-- test
+ | |-- acts_as_yaffle_test.rb
+ | |-- core_ext_test.rb
+ | |-- database.yml
+ | |-- debug.log
+ | |-- routing_test.rb
+ | |-- schema.rb
+ | |-- test_helper.rb
+ | `-- view_helpers_test.rb
+ |-- uninstall.rb
+ `-- yaffle_plugin.sqlite3.db
+