[Rubygems-developers] Gem methods?

Jeremy Hinegardner jeremy at hinegardner.org
Thu Oct 9 17:33:58 EDT 2008


On Thu, Oct 09, 2008 at 11:20:31AM -0700, Chad Woolley wrote:
> On Thu, Oct 9, 2008 at 10:18 AM, Jeremy Hinegardner
> <jeremy at hinegardner.org>wrote:
> 
> >
> > > In addition is there a way to access a gemspec from code?
> >
> > See the first 3 lines of the is_active? method above for a way to search
> > for a gemspec.
> >
> 
> I think Gem::SourceIndex.from_installed_gems would probably be cleaner and
> more forward-compatible - especially since I'm pretty sure there are bugs in
> this area.

Its the same line of code, I was avoiding from_installed_gems because of the
*deprecated parameter, which at the moment I wrote the snippet I was thinking
was meaning the method was deprecated instead of just the parameter. 

Snippet:

   Gem::SourceIndex.from_gems_in( *Gem::SourceIndex.installed_spec_directories )

Gem::SourceIndex.from_installed_gems:

  def from_installed_gems(*deprecated)
    if deprecated.empty?
      from_gems_in(*installed_spec_directories)
    else
      from_gems_in(*deprecated) # HACK warn
    end 
  end 

So if the method is still around, but the usage with a parameter is deprecated
then yes, using Gem::SourceIndex.from_installed_gems would be more forward
compatible.

enjoy,

-jeremy

-- 
========================================================================
 Jeremy Hinegardner                              jeremy at hinegardner.org 



More information about the Rubygems-developers mailing list