diff options
Diffstat (limited to 'lib/rubygems/resolver/specification.rb')
-rw-r--r-- | lib/rubygems/resolver/specification.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/rubygems/resolver/specification.rb b/lib/rubygems/resolver/specification.rb index 7dd4c2e829..d158225474 100644 --- a/lib/rubygems/resolver/specification.rb +++ b/lib/rubygems/resolver/specification.rb @@ -56,5 +56,34 @@ class Gem::Resolver::Specification "#{@name}-#{@version}" end + ## + # Installs this specification using the Gem::Installer +options+. The + # install method yields a Gem::Installer instance, which indicates the + # gem will be installed, or +nil+, which indicates the gem is already + # installed. + + def install options + require 'rubygems/installer' + + destination = options[:install_dir] || Gem.dir + + Gem.ensure_gem_subdirectories destination + + gem = source.download spec, destination + + installer = Gem::Installer.new gem, options + + yield installer if block_given? + + installer.install + end + + ## + # Returns true if this specification is installable on this platform. + + def installable_platform? + Gem::Platform.match spec.platform + end + end |