Skip to content
Browse files

Plugin guide: updated to start working with GemPlugin

  • Loading branch information...
1 parent 88a13fa commit fa9ea057d1252a578f8e056defef41b93853bc8b @zilkey zilkey committed Nov 14, 2008
View
10 railties/doc/guides/html/creating_plugins.html
@@ -447,6 +447,7 @@ <h3 id="_generate_the_plugin_skeleton">1.2. Generate the plugin skeleton</h3>
create vendor/plugins/yaffle/generators/yaffle/yaffle_generator.rb
create vendor/plugins/yaffle/generators/yaffle/USAGE</tt></pre>
</div></div>
+<div class="para"><p>To begin just change one thing - move <em>init.rb</em> to <em>rails/init.rb</em>.</p></div>
<h3 id="_setup_the_plugin_for_testing">1.3. Setup the plugin for testing</h3>
<div class="para"><p>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.</p></div>
<div class="para"><p>To setup your plugin to allow for easy testing you'll need to add 3 files:</p></div>
@@ -553,7 +554,7 @@ <h3 id="_setup_the_plugin_for_testing">1.3. Setup the plugin for testing</h3>
ActiveRecord<span style="color: #990000">::</span>Base<span style="color: #990000">.</span>establish_connection<span style="color: #990000">(</span>config<span style="color: #990000">[</span>db_adapter<span style="color: #990000">])</span>
<span style="font-weight: bold"><span style="color: #0000FF">load</span></span><span style="color: #990000">(</span>File<span style="color: #990000">.</span>dirname<span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">__FILE__</span></span><span style="color: #990000">)</span> <span style="color: #990000">+</span> <span style="color: #FF0000">"/schema.rb"</span><span style="color: #990000">)</span>
- <span style="font-weight: bold"><span style="color: #000080">require</span></span> File<span style="color: #990000">.</span>dirname<span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">__FILE__</span></span><span style="color: #990000">)</span> <span style="color: #990000">+</span> <span style="color: #FF0000">'/../init.rb'</span>
+ <span style="font-weight: bold"><span style="color: #000080">require</span></span> File<span style="color: #990000">.</span>dirname<span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">__FILE__</span></span><span style="color: #990000">)</span> <span style="color: #990000">+</span> <span style="color: #FF0000">'/../rails/init.rb'</span>
<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
</tt></pre></div></div>
<div class="para"><p>Now whenever you write a test that requires the database, you can call <em>load_schema</em>.</p></div>
@@ -668,14 +669,13 @@ <h3 id="_organize_your_files">2.2. Organize your files</h3>
<div class="para"><p>A common pattern in rails plugins is to set up the file structure like this:</p></div>
<div class="listingblock">
<div class="content">
-<pre><tt>|-- init.rb
-|-- lib
+<pre><tt>|-- lib
| |-- yaffle
| | `-- core_ext.rb
| `-- yaffle.rb</tt></pre>
</div></div>
-<div class="para"><p>The first thing we need to to is to require our <em>lib/yaffle.rb</em> file from <em>init.rb</em>:</p></div>
-<div class="para"><p><strong>vendor/plugins/yaffle/init.rb</strong></p></div>
+<div class="para"><p>The first thing we need to to is to require our <em>lib/yaffle.rb</em> file from <em>rails/init.rb</em>:</p></div>
+<div class="para"><p><strong>vendor/plugins/yaffle/rails/init.rb</strong></p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
View
5 railties/doc/guides/source/creating_plugins/core_ext.txt
@@ -45,16 +45,15 @@ Great - now you are ready to start development.
A common pattern in rails plugins is to set up the file structure like this:
--------------------------------------------------------
-|-- init.rb
|-- lib
| |-- yaffle
| | `-- core_ext.rb
| `-- yaffle.rb
--------------------------------------------------------
-The first thing we need to to is to require our 'lib/yaffle.rb' file from 'init.rb':
+The first thing we need to to is to require our 'lib/yaffle.rb' file from 'rails/init.rb':
-*vendor/plugins/yaffle/init.rb*
+*vendor/plugins/yaffle/rails/init.rb*
[source, ruby]
--------------------------------------------------------
View
1 railties/doc/guides/source/creating_plugins/gem.txt
@@ -0,0 +1 @@
+http://www.mbleigh.com/2008/6/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins
View
3 railties/doc/guides/source/creating_plugins/test_setup.txt
@@ -61,6 +61,7 @@ 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'.
=== Setup the plugin for testing ===
@@ -157,7 +158,7 @@ def load_schema
ActiveRecord::Base.establish_connection(config[db_adapter])
load(File.dirname(__FILE__) + "/schema.rb")
- require File.dirname(__FILE__) + '/../init.rb'
+ require File.dirname(__FILE__) + '/../rails/init.rb'
end
----------------------------------------------

0 comments on commit fa9ea05

Please sign in to comment.
Something went wrong with that request. Please try again.