[Rubygems-developers] Custom Gemspec Attribute

John Barnette jbarnette at gmail.com
Sun Aug 15 15:05:22 EDT 2010


Hey Jim,

On Sun, Aug 15, 2010 at 11:34 AM, Jim Freeze <rubygems at freeze.org> wrote:
> Is there a way to add a custom attribute to a gem spec? We want to be
> able to define a gem as an adhearsion component so that we can search
> all the installed gems that are ahn_components.

Not right now, no. I've had a branch that adds a #meta hash to
Specification around for a while, but changing gemspec is fraught with
terror and I haven't been brave enough to merge it yet. :(

You can fake it with the current version of RubyGems by using
Gem#find_files and examining the paths that it returns. Keep in mind
that it looks through ALL available versions of all gems, as well as
the load path. Really really bad example off the top of my head:

# let's pretend all adhearsion components must have a
lib/adhearsion/component.txt file

component_gems = Gem.find_files("adhearsion/component.txt").
  map { |f| %r|/([^/]+)/lib| =~ f && $1.split("-")[0..-2].join("-") }.uniq


~ j.


More information about the Rubygems-developers mailing list