Class: Rabbit::GemFinder
- Inherits:
-
Object
- Object
- Rabbit::GemFinder
- Includes:
- GetText
- Defined in:
- lib/rabbit/gem-finder.rb
Constant Summary
Constants included from GetText
Instance Method Summary collapse
- #find(name, prefix) ⇒ Object
-
#initialize(logger = nil) ⇒ GemFinder
constructor
A new instance of GemFinder.
Methods included from GetText
Constructor Details
Instance Method Details
#find(name, prefix) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rabbit/gem-finder.rb', line 27 def find(name, prefix) normalized_name = name.downcase unless normalized_name.start_with?(prefix) normalized_name = "#{prefix}#{normalized_name}" end retried = false spec = nil begin spec = Gem::Specification.find_by_name(name) rescue Gem::LoadError begin spec = Gem::Specification.find_by_name(normalized_name) rescue Gem::LoadError unless retried retried = true require "rubygems/dependency_installer" = {} if File.writable?(Gem.dir) @logger.info(_("Installing gem: %s") % normalized_name) else [:user_install] = true format = _("Installing gem in user install mode: %s") @logger.info(format % normalized_name) end installer = Gem::DependencyInstaller.new() installer.install(normalized_name, Gem::Requirement.default) retry end end end spec end |