asset_copier_generator
Intelligent asset management for Rails plugins.
Installation
Install the gem directly:
gem sources -a http://gems.github.com (you only have to do this once)
sudo gem install pelargir-asset_copier
Or clone the project, build the gem, and install:
git clone git://github.com/pelargir/asset_copier.git
gem build asset_copier_generator.gemspec
sudo gem install asset_copier_generator
Apply to Target Plugin
asset_copier_generator will copy the necessary files into a target plugin to enable intelligent asset management. You should then check these files in to source control. The generated files become a part of your plugin.
To install the files in your plugin, first ensure that your plugin is installed or symlinked from an existing Rails app. From the root of that Rails app, run:
script/generate asset_copier plugin_name
Where “plugin_name” is the name of the plugin you want to install into. The appropriate files will be copied into your plugin. Now, to copy assets from your plugin into your Rails app, run:
rake plugin_name:install
Your users can run this same Rake task any time they want to update files in their Rails app to reflect the assets needed by your plugin.
Usage
Once applied to a target plugin, files within the /files directory of that plugin will be copied into RAILS_ROOT whenever the installation task is run.
Files will also be copied every time the Rails server is started if the project is running in development mode. (Projects running in production mode will instead receive a warning in the log that one or more files are missing. No files will automatically be copied.)
What if you remove a file from your plugin at some future point? Simply add the file path to deleted_files. The next time the Rails server is started or the install task is run, a warning will print in the log informing the user that the file has been removed from the plugin and can also safely be removed from their Rails project.
Resources
Repository: github.com/pelargir/asset_copier Blog: matthewbass.com Author: Matthew Bass
Extraction work sponsored by Terralien