Giles said:
Is there an easy way to find out all the gems you're running in a
particular codebase? (It's a Rails app but I'd imagine the technique
has general usefulness?)
Cheap hack:
$:.map{|s|s=~Regexp.new(Regexp.escape(Config::CONFIG['libdir']+'/ruby/gems/1.8/gems/')+'(.*)/lib$');$1}.compact
(or
http://preview.tinyurl.com/ya4en4 in Firefox)
I'm sure if you dig through the RubyGems code, you'll find a better way
of specifying that directory.
I hate to admit it, because digging through the RubyGems code is
probably much more worthwhile in the long term, but cheap hacks are
totally what I need right now.
Is it the Perl-y $: thing that gives it its magic special sauce? Also,
couldn't the Regexp part work just as well without the Config stuff,
because of the minimal likelihood of a non-gem having that string in
its path?
Anyway, it works perfectly:
gilesb@a2s8 [~/railsapp]# script/console
Loading development environment.
$:.map{|s|s=~Regexp.new(Regexp.escape(Config::CONFIG['libdir']+'/ruby/gems/1.8/gems/')+'(.*)/lib$');$1}.compact
=> ["net-sftp-1.1.0", "net-ssh-1.0.10", "needle-1.3.0",
"ferret-0.10.13", "rails-1.1.6", "actionwebservice-1.1.6",
"actionmailer-1.2.5", "BlueCloth-1.0.0", "RedCloth-3.0.4",
"actionpack-1.12.5", "activesupport-1.3.1",
"activerecord-1.14.4/lib/../../activesupport", "activerecord-1.14.4",
"rake-0.7.1"]
Thanks!
Actually, wait a minute -- the app also uses ImageMagick, but that
didn't show up here.