From 899f56d5e985b295c905ceee93eb8ddfa7e87540 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Mon, 15 Aug 2011 01:14:28 -0400 Subject: [PATCH] modify spec searching to not fail hard and to work across multiple rubygems versions --- lib/boson/libraries/gem_library.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/boson/libraries/gem_library.rb b/lib/boson/libraries/gem_library.rb index c405356..ecfefe4 100644 --- a/lib/boson/libraries/gem_library.rb +++ b/lib/boson/libraries/gem_library.rb @@ -10,7 +10,10 @@ module Boson class GemLibrary < Library #:stopdoc: def self.is_a_gem?(name) - Object.const_defined?(:Gem) && Gem::Specification.find_by_name(name).is_a?(Gem::Specification) + return false unless defined? Gem + Gem::VERSION >= '1.8.0' ? + Gem::Specification.find_all_by_name(name)[0].is_a?(Gem::Specification) : + Gem.searcher.find(name).is_a?(Gem::Specification) end handles {|source| is_a_gem?(source.to_s) } @@ -24,4 +27,4 @@ def load_source_and_set_module end #:startdoc: end -end \ No newline at end of file +end