diff options
Diffstat (limited to 'projects/gem_plugin/lib/gem_plugin.rb')
-rw-r--r-- | projects/gem_plugin/lib/gem_plugin.rb | 18 |
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 |