GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Desert is a component framework for Rails that allows your plugins have a Rails app like directory structure, routes, migrations, and dependencies.
Homepage: http://desert.rubyforge.org
Clone URL: git://github.com/pivotal/desert.git
BT - Removed some fluff in the first sentence. Removed "Desert plugins" 
distinction where appropriate. Rephrased to "Desert enables your plugins" 
where appropriate.

git-svn-id: svn+ssh://rubyforge.org/var/svn/pivotalrb/desert/trunk@998 
af276e61-6b34-4dac-905b-574b5f35ef33
btakita (author)
Sat Nov 17 14:37:24 -0800 2007
commit  a30c0dbd84e7f6ea1951339721f46478d44b39d8
tree    f938056567097199c45700f916202bc2ecc56bba
parent  2ec2b64e9f14f28953b407e6f7f1bfdc75f6546e
...
1
2
 
 
3
4
5
...
15
16
17
18
 
 
19
20
21
...
55
56
57
58
 
 
59
60
 
 
61
62
 
63
 
 
 
64
65
66
...
68
69
70
71
 
 
72
73
74
75
76
77
78
 
79
80
81
 
82
83
84
...
114
115
116
117
 
 
 
118
119
120
...
139
140
141
142
 
 
143
144
145
...
155
156
157
158
 
 
 
159
160
161
...
171
172
173
174
 
 
175
176
177
...
182
183
184
185
186
187
188
189
190
 
 
 
 
 
191
...
1
 
2
3
4
5
6
...
16
17
18
 
19
20
21
22
23
...
57
58
59
 
60
61
62
 
63
64
65
 
66
67
68
69
70
71
72
73
...
75
76
77
 
78
79
80
81
82
83
84
85
 
86
87
88
 
89
90
91
92
...
122
123
124
 
125
126
127
128
129
130
...
149
150
151
 
152
153
154
155
156
...
166
167
168
 
169
170
171
172
173
174
...
184
185
186
 
187
188
189
190
191
...
196
197
198
 
 
 
 
 
199
200
201
202
203
204
205
0
@@ -1,5 +1,6 @@
0
 #Desert -- It doesn't get any DRYer than this
0
-Desert takes Rails plugins to the extreme, making it easy to share models, views, controllers, helpers, routes, and migrations across your applications. With Desert, reusability doesn't come at the cost of extensibility: it's trivial to extend the functionality of a Desert plugin--both in your application _and_ in other Desert plugins.
0
+Desert is a Rails plugin framework that makes it easy to share models, views, controllers, helpers, routes, and migrations across your applications.
0
+With Desert, reusability doesn't come at the cost of extensibility: it's trivial to extend the functionality of a plugin--both in your application _and_ in other plugins.
0
 
0
 
0
 "I tried generators, but all I got was a bunch of code duplication. With Desert, I've been able to re-use all of my social networking functionality without a single duplicated character! Thanks Desert!"
0
@@ -15,7 +16,8 @@ Desert takes Rails plugins to the extreme, making it easy to share models, views
0
 -- Nathan Sobo, Programmer
0
 
0
 ##Anatomy of a Desert Plugin
0
-Desert plugins contain the standard Rails directory structure. When you want to extract part of your application into a plugin, just drag files into the `vendor/plugins` directory.
0
+Desert enables your plugins to contain the standard Rails directory structure.
0
+When you want to extract part of your application into a plugin, just drag files into the `vendor/plugins` directory.
0
 
0
     rails_root/
0
       app/
0
@@ -55,12 +57,17 @@ Desert plugins contain the standard Rails directory structure. When you want to
0
             lib/
0
               current_user.rb
0
 
0
-Load Desert by placing the following code at the __TOP__ of `config/environment.rb`:
0
+##Installation
0
+ gem install desert
0
 
0
-`config/environment.rb`
0
+##Loading Desert
0
+Require desert above the Rails Initializer at the __TOP__ of `config/environment.rb`:
0
 
0
- $LOAD_PATH.unshift File.expand_path("#{RAILS_ROOT}/vendor/desert/lib")
0
+`config/environment.rb`
0
     require "desert"
0
+ Rails::Initializer.run do |config|
0
+ ...
0
+ end
0
   
0
 
0
 Note: __AT THE TOP__
0
@@ -68,17 +75,18 @@ Note: __AT THE TOP__
0
 
0
 
0
 ##Managing Plugin Dependencies
0
-By default, Rails loads plugins in alphabetical order, making it tedious to manage dependencies. Desert will automatically load plugins in the proper order when you declare their dependencies like this:
0
+By default, Rails loads plugins in alphabetical order, making it tedious to manage dependencies.
0
+Desert will automatically load plugins in the proper order when you declare their dependencies like this:
0
 
0
 `vendor/plugins/blogs/init.rb`
0
 
0
     require_plugin 'user'
0
     require_plugin 'will_paginate'
0
 
0
-Here `user` and `will_paginate` will always be loaded before `blogs`. Note that both Desert and non-Desert plugins can be declared as dependencies.
0
+Here `user` and `will_paginate` will always be loaded before `blogs`. Note that any plugin can be declared as a dependency.
0
 
0
 ##Designed For Extensibility
0
-One of Ruby's key features is the ability to reopen classes and customize their behavior. Desert plugins give you this same power.
0
+One of Ruby's key features is the ability to reopen classes and customize their behavior. Desert gives your plugins the same power.
0
 
0
 In the user plugin:
0
 `vendor/plugins/user/app/models/user.rb`
0
@@ -114,7 +122,9 @@ In the application:
0
     end
0
 
0
 
0
-Here the `blogs` plugin overrides a method in the `User` class that's defined in the `user` plugin. The `blogs` plugin also adds a `has_one :blog` declaration to `User`. The application overrides the `blog_title` template method, defined in the `blogs` plugin.
0
+Here the `blogs` plugin overrides a method in the `User` class that's defined in the `user` plugin.
0
+The `blogs` plugin also adds a `has_one :blog` declaration to `User`.
0
+The application overrides the `blog_title` template method, defined in the `blogs` plugin.
0
 
0
 Note that controllers and helpers can be extended in the same way.
0
 
0
@@ -139,7 +149,8 @@ In the application:
0
       map.routes_from_plugin :user
0
     end
0
 
0
-Here the application adds the `users` resource from the `user` plugin and the `blogs` resource from the `blogs` plugin. Notice that there is no need to call methods on map in the plugin route files, because they are instance eval'd in the map object.
0
+Here the application adds the `users` resource from the `user` plugin and the `blogs` resource from the `blogs` plugin.
0
+Notice that there is no need to call methods on map in the plugin route files, because they are instance eval'd in the map object.
0
 
0
 ##Sharing Migrations
0
 Sharing models means sharing schema fragments, and that means sharing migrations:
0
@@ -155,7 +166,9 @@ In the `blogs` plugin:
0
       001_create_user_table.rb
0
       002_add_became_a_blogger_at_to_user.rb
0
 
0
-Here the `blogs` plugin needs to add a column to the `users` table. No problem! It just includes a migration in its `db/migrate` directory, just like a regular Rails application. When the application developer installs the plugin, he migrates the plugin in his own migration:
0
+Here the `blogs` plugin needs to add a column to the `users` table. No problem!
0
+It just includes a migration in its `db/migrate` directory, just like a regular Rails application.
0
+When the application developer installs the plugin, he migrates the plugin in his own migration:
0
       
0
 `application_root/db/migrate/009_install_user_and_blogs_plugins.rb`
0
   
0
@@ -171,7 +184,8 @@ Here the `blogs` plugin needs to add a column to the `users` table. No problem!
0
       end
0
     end
0
     
0
-Here the application migrates the `user` plugin to version 1 and the `blogs` plugin to version 2. If a subsequent version of the plugin introduces new migrations, the application developer has full control over when to apply them to his schema.
0
+Here the application migrates the `user` plugin to version 1 and the `blogs` plugin to version 2.
0
+If a subsequent version of the plugin introduces new migrations, the application developer has full control over when to apply them to his schema.
0
 
0
 ##Share Views
0
 To share views, just create templates and partials in the plugin's `app/views` directory, just as you would with a Rails application.
0
@@ -182,8 +196,8 @@ To share views, just create templates and partials in the plugin's `app/views` d
0
       ...
0
     <% end %>
0
 
0
-class InstallUserAndBlogsPlugins < ActiveRecord::Migration
0
-def self.up
0
- migrate_plugin 'user', 1
0
- migrate_plugin 'blogs', 2
0
-end
0
\ No newline at end of file
0
+ class InstallUserAndBlogsPlugins < ActiveRecord::Migration
0
+ def self.up
0
+ migrate_plugin 'user', 1
0
+ migrate_plugin 'blogs', 2
0
+ end
0
\ No newline at end of file

Comments

    No one has commented yet.