about summary refs log tree commit homepage
path: root/projects/gem_plugin/lib/gem_plugin.rb
diff options
context:
space:
mode:
authorevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2008-05-24 23:06:53 +0000
committerevanweaver <evanweaver@19e92222-5c0b-0410-8929-a290d50e31e9>2008-05-24 23:06:53 +0000
commit45ff7b22b67123dd8345f3c50151e89cc91ce2b7 (patch)
treee85c8aa353e3e9f05e90ee8bf76a6593520e1b01 /projects/gem_plugin/lib/gem_plugin.rb
parentf69f3602b11dc839bb09f8c783b5ec27c54694fd (diff)
parentfa3f48f65222eb5591ef3dd9c05b6c958d564fa4 (diff)
downloadunicorn-45ff7b22b67123dd8345f3c50151e89cc91ce2b7.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@1020 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'projects/gem_plugin/lib/gem_plugin.rb')
-rw-r--r--projects/gem_plugin/lib/gem_plugin.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/projects/gem_plugin/lib/gem_plugin.rb b/projects/gem_plugin/lib/gem_plugin.rb
index 1996a61..782a990 100644
--- a/projects/gem_plugin/lib/gem_plugin.rb
+++ b/projects/gem_plugin/lib/gem_plugin.rb
@@ -105,8 +105,8 @@ module GemPlugin
     # To prevent this load requires the full path to the "init.rb" file, which
     # avoids the RubyGems autorequire magic.
     def load(needs = {})
-      sdir = File.join(Gem.dir, "specifications")
-      gems = Gem::SourceIndex.from_installed_gems(sdir)
+      sdirs = Gem::SourceIndex.installed_spec_directories
+      gems = Gem::SourceIndex.from_gems_in(sdirs)
       needs = needs.merge({"gem_plugin" => INCLUDE})
       
       gems.each do |path, gem|
@@ -128,11 +128,17 @@ module GemPlugin
           # looks like no needs were set to false, so it's good
           
           # Previously was set wrong, we already have the correct gem path!
-          #gem_dir = File.join(Gem.dir, "gems", "#{gem.name}-#{gem.version}")
-          gem_dir = File.join(Gem.dir, "gems", path)
+          gem_dir = ""
+          Gem.path.each do |gem_path|
+            gem_dir = File.join(gem_path, "gems", path)
+            break if File.exist?(gem_dir)
+          end
           
-          require File.join(gem_dir, "lib", gem.name, "init.rb")
-          @gems[gem.name] = gem_dir
+          gem_init = File.join(gem_dir, "lib", gem.name, "init.rb")
+          if File.exist?(gem_init)
+            require gem_init
+            @gems[gem.name] = gem_dir
+          end
         end
       end