[Rubygems-developers] query_command.rb question and patch

Jos Backus jos at catnook.com
Sun Apr 6 03:37:03 EDT 2008

On Sat, Apr 05, 2008 at 07:43:52PM -0700, Eric Hodel wrote:
> On Apr 3, 2008, at 21:23 PM, Jos Backus wrote:
> If you're looking for the list of locally installed gems as strings,  
> this is the best way:
> Gem.source_index.map { |name, gemspec| name }
> Gem::SourceIndex is Enumerable, so you can easily filter results if  
> you need based on the gemspec object.
Thanks Eric, looks like that will cover the local case just fine.

> > E.g for the local gem list case query_command.rb uses
> > Gem.source_index.search(name) to get a list of local gems. When  
> > calling it I
> > still see output related to updating the gem index. I'd like to  
> > avoid this
> > extra output; is that possible?
> You shouldn't see anything about updating the index for a `gem list`  
> or `gem query`, as those don't attempt to update the index.  (Only if  
> the -r flag is given.)
Understood. However, I also need the remote case to work for Puppet as it has
the ability to install the `latest' gem, so I need to be able to retrieve the
names and versions of remote gems. Pointers appreciated.

> I'd much rather improve the programmer API over adding extra things to  
> Gem::Command subclasses, as those classes are at least one level of  
> indirection away from whatever you probably want to do.
Agreed. I'm still trying to familiarize myself with the code.

> I can guide you towards the proper API calls to make if you have a  
> specific goal, but I strongly recommend avoiding directly calling  
> methods on Gem::Command subclasses.

Okay, I'll refrain from doing that then.

Jos Backus
jos at catnook.com

More information about the Rubygems-developers mailing list