aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/creating_plugins/gems.txt
diff options
context:
space:
mode:
authorJeff Dean <jeff@zilkey.com>2008-11-16 22:27:08 -0500
committerJeff Dean <jeff@zilkey.com>2008-11-16 22:27:08 -0500
commit6b8500ce48f45f18696f6215b8a01f5cf0e328b5 (patch)
tree4782b14efb504f867a5098c810c0e4236fb69485 /railties/doc/guides/source/creating_plugins/gems.txt
parent097b4678f6d52e86a9d46ba6c862e6eb6ef7bbdd (diff)
downloadrails-6b8500ce48f45f18696f6215b8a01f5cf0e328b5.tar.gz
rails-6b8500ce48f45f18696f6215b8a01f5cf0e328b5.tar.bz2
rails-6b8500ce48f45f18696f6215b8a01f5cf0e328b5.zip
Rails guide: Added PluginGem section, reorganized the odds and ends.
Diffstat (limited to 'railties/doc/guides/source/creating_plugins/gems.txt')
-rw-r--r--railties/doc/guides/source/creating_plugins/gems.txt50
1 files changed, 50 insertions, 0 deletions
diff --git a/railties/doc/guides/source/creating_plugins/gems.txt b/railties/doc/guides/source/creating_plugins/gems.txt
new file mode 100644
index 0000000000..67d55adb3a
--- /dev/null
+++ b/railties/doc/guides/source/creating_plugins/gems.txt
@@ -0,0 +1,50 @@
+== PluginGems ==
+
+Turning your rails plugin into a gem is a simple and straightforward task. This section will cover how to turn your plugin into a gem. It will not cover how to distribute that gem.
+
+Historically rails plugins loaded the plugin's 'init.rb' file. In fact some plugins contain all of their code in that one file. To be compatible with plugins, 'init.rb' was moved to 'rails/init.rb'.
+
+It's common practice to put any developer-centric rake tasks (such as tests, rdoc and gem package tasks) in 'Rakefile'. A rake task that packages the gem might look like this:
+
+*vendor/plugins/yaffle/Rakefile:*
+
+[source, ruby]
+----------------------------------------------
+PKG_FILES = FileList[
+ '[a-zA-Z]*',
+ 'generators/**/*',
+ 'lib/**/*',
+ 'rails/**/*',
+ 'tasks/**/*',
+ 'test/**/*'
+]
+
+spec = Gem::Specification.new do |s|
+ s.name = "yaffle"
+ s.version = "0.0.1"
+ s.author = "Gleeful Yaffler"
+ s.email = "yaffle@example.com"
+ s.homepage = "http://yafflers.example.com/"
+ s.platform = Gem::Platform::RUBY
+ s.summary = "Sharing Yaffle Goodness"
+ s.files = PKG_FILES.to_a
+ s.require_path = "lib"
+ s.has_rdoc = false
+ s.extra_rdoc_files = ["README"]
+end
+
+desc 'Turn this plugin into a gem.'
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+----------------------------------------------
+
+To build and install the gem locally, run the following commands:
+
+----------------------------------------------
+cd vendor/plugins/yaffle
+rake gem
+sudo gem install pkg/yaffle-0.0.1.gem
+----------------------------------------------
+
+To test this, create a new rails app, add 'config.gem "yaffle"' to environment.rb and all of your plugin's functionality will be available to you. \ No newline at end of file