Provideal Plugin Utils

A small collection of utilities to deal with assets bundled within Rails plugins/engines.

The official homepgae is: github.com/provideal/provideal-plugin-utils

It provides two things. First it provides a method to install assets bundled within a Rails plugin/engine into your host application (symlink into /public/plugins/my_plugin).

Secondly it adds a :plugin option to Rails asset helper tags ‘stylesheet_link_tag’, ‘javascript_include_tag’, ‘image_path’ and ‘image_tag’.

Example:

Suppose you have a JavaScript file called foo.js bundled with your plugin ‘my_plugin’. Using <%= javascript_include_tag ‘foo.js’, :plugin => ‘my_plugin’ %> will then create the correct uri to that asset.

Installation


sudo gem install provideal-plugin-utils -s gemcutter.org

Usage


  • Install the gem

  • Make sure your plugins’ assets are organized following Rails conventions (images in public/images, stylesheets in public/stylesheets etc).

  • Trigger the installtion of your plugin assets with:

    Provideal::PluginUtils.install_assets('my_plugin', 'path to your plugins public folder')
    

    Example (called in init.rb):

    Provideal::PluginUtils.install_assets('my_plugin', File.expand_path(File.join(File.dirname(__FILE__), 'public')))
    

Known issues


This version supports only symlinking the assets. As a result this version is not supported on Windows.

Copyright


Copyright © 2009 Provideal Systems GmbH, released under the MIT license.