lib/onering/util.rb in onering-client-0.3.4 vs lib/onering/util.rb in onering-client-0.4.0
- old
+ new
@@ -76,15 +76,19 @@
510 => 'Not Extended',
511 => 'Network Authentication Required'
}
def gem_path(name)
- if Gem::Specification.respond_to?(:find_by_name)
- return Gem::Specification.find_by_name(name).gem_dir
- else
- return Gem::SourceIndex.from_installed_gems.find_name(name).sort{|a,b|
- a.version.to_s <=> b.version.to_s
- }.last.full_gem_path
+ begin
+ if Gem::Specification.respond_to?(:find_by_name)
+ return Gem::Specification.find_by_name(name).gem_dir
+ else
+ return Gem::SourceIndex.from_installed_gems.find_name(name).sort{|a,b|
+ a.version.to_s <=> b.version.to_s
+ }.last.full_gem_path
+ end
+ rescue Gem::LoadError
+ return nil
end
end
def fact(name, default=nil)
reporter = Onering::Reporter.new()
\ No newline at end of file