Prev | Current Page 123 | Next

Brad Ediger

"Advanced Rails"

In the future, more features are expected;
right now, it exists for informational purposes. Metadata is stored in the about.yml
file; here is an example from acts_as_attachment:
author: technoweenie
summary: File upload handling plugin.
homepage: http://technoweenie.stikipad.com
plugin: http://svn.techno-weenie.net/projects/plugins/acts_as_attachment
license: MIT
version: 0.3a
rails_version: 1.1.2+
* http://cheeseshop.python.org/pypi/hgsvn
Figure 3-1. Directory structure of a typical plugin
84 | Chapter 3: Rails Plugins
init.rb
This is a Ruby file run upon initialization of the plugin. Typically, it will require
files from the lib/ directory. As many plugins patch core functionality, init.rb may
extend core classes with extensions from the plugin:
require 'my_plugin'
ActionController::Base.send :include, MyPlugin::ControllerExtensions
The send hack is needed here because Module#include is a private method and, at
least for now, send bypasses access control on the receiver.*
install.rb (not shown)
This hook is run when the plugin is installed with one of the automated plugin
installation tools such as script/plugin or RaPT. It is a good idea not to do anything
mission-critical in this file, as it will not be run if the plugin is installed
manually (by checking out the source to a directory under vendor/plugins).
A typical use for the install.rb hook is to display the contents of the plugin??™s
README file:
puts IO.


Pages:
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135