InfoQ

News

RubyGems Gets Plugins

Posted by Mirko Stocker on Apr 22, 2009

Community
Ruby
Topics
RubyGems ,
Package Managers
Tags
RubyGems

The recently released RubyGems version 1.3.2 is more than just a minor bugfix release, it also contains new features:

As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or $LOAD_PATH. Plugins must be named 'rubygems_plugin' are discovered via Gem::find_files then loaded.

An example comes from Ryan Davis: the Graph plugin generates a graph of the dependencies and information (outdated, incoming dependencies) of your installed Gems.

We talked to RubyGems maintainer Eric Hodel to learn more about the general idea of RubyGems plugins:

The feature request tracker for RubyGems has lots of stuff people want to add, and some of it can be done as a stand-alone package. There's also things you may want to do at install time that otherwise would require manual intervention from the user.

The plugins started with a patch from Neil Wilson to add install hooks to RubyGems for Debian that would make it easier to integrate the two. With his patch we added two special files that RubyGems would try to require at startup, rubygems/defaults/operating_system.rb for ruby packagers and rubygems/defaults/#{RUBY_ENGINE}.rb for ruby implementors to add special functionality. For example, Rubinius could pre-compile all the .rb files in the gem to reduce startup time.

Around the same time I added Gem.find_files that would allow gem authors to easily construct their own plugin system. RDoc uses this to automatically load its plugins.

Since it turned out rather well for RDoc I decided that RubyGems should have the same feature.

I didn't try to make the plugins have a comprehensive way to hook into every possible corner of RubyGems. I'm sure that people will want to hook into areas that aren't currently easy to access, and I hope they submit feature requests against RubyGems to help me find them. It's much easier for me to improve the API a little for a plugin than it is to maintain an entire new feature.

My hope is that creative people will provide amazing and useful things that I don't have to ship or maintain inside RubyGems.

Besides the Graph plugin, there's also rubypan to search rubypan.org and they are working on "a plugin that will create an OS X dictionary from ri data that would be updated whenever you install or uninstall a gem".

Plugin writers can hook into RubyGems pre and post install and uninstall actions, see the Gem Documentation. Writing a plugin for your own command is also straightforward: subclass Command and register it with the Gem::CommandManager.

Do you miss a feature in RubyGems that could now be provided by a plugin?

list by Roger Pack Posted Jan 18, 2010 9:14 PM
  1. Back to top

    list

    Jan 18, 2010 9:14 PM by Roger Pack

    Here's a list of plugins I know of:

    wiki.github.com/rdp/ruby_tutorials_core/rubygems

    Enjoy.
    -r

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.