2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
2013-11-18 19:34:13 -05:00
|
|
|
# A Resolver::Specification contains a subset of the information
|
2013-11-10 12:51:40 -05:00
|
|
|
# contained in a Gem::Specification. Only the information necessary for
|
|
|
|
# dependency resolution in the resolver is included.
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class Gem::Resolver::Specification
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# The dependencies of the gem for this specification
|
|
|
|
|
|
|
|
attr_reader :dependencies
|
|
|
|
|
|
|
|
##
|
|
|
|
# The name of the gem for this specification
|
|
|
|
|
|
|
|
attr_reader :name
|
|
|
|
|
|
|
|
##
|
|
|
|
# The platform this gem works on.
|
|
|
|
|
|
|
|
attr_reader :platform
|
|
|
|
|
|
|
|
##
|
|
|
|
# The set this specification came from.
|
|
|
|
|
|
|
|
attr_reader :set
|
|
|
|
|
|
|
|
##
|
|
|
|
# The source for this specification
|
|
|
|
|
|
|
|
attr_reader :source
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
##
|
|
|
|
# The Gem::Specification for this Resolver::Specification.
|
|
|
|
#
|
|
|
|
# Implementers, note that #install updates @spec, so be sure to cache the
|
|
|
|
# Gem::Specification in @spec when overriding.
|
|
|
|
|
|
|
|
attr_reader :spec
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# The version of the gem for this specification.
|
|
|
|
|
|
|
|
attr_reader :version
|
|
|
|
|
2020-12-22 18:45:19 -05:00
|
|
|
##
|
|
|
|
# The required_ruby_version constraint for this specification.
|
|
|
|
|
|
|
|
attr_reader :required_ruby_version
|
|
|
|
|
|
|
|
##
|
|
|
|
# The required_ruby_version constraint for this specification.
|
|
|
|
|
|
|
|
attr_reader :required_rubygems_version
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# Sets default instance variables for the specification.
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
@dependencies = nil
|
|
|
|
@name = nil
|
|
|
|
@platform = nil
|
|
|
|
@set = nil
|
|
|
|
@source = nil
|
|
|
|
@version = nil
|
2020-12-22 18:45:19 -05:00
|
|
|
@required_ruby_version = Gem::Requirement.default
|
|
|
|
@required_rubygems_version = Gem::Requirement.default
|
2013-11-10 12:51:40 -05:00
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
##
|
|
|
|
# Fetches development dependencies if the source does not provide them by
|
|
|
|
# default (see APISpecification).
|
|
|
|
|
|
|
|
def fetch_development_dependencies # :nodoc:
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# The name and version of the specification.
|
|
|
|
#
|
|
|
|
# Unlike Gem::Specification#full_name, the platform is not included.
|
|
|
|
|
|
|
|
def full_name
|
|
|
|
"#{@name}-#{@version}"
|
|
|
|
end
|
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
##
|
|
|
|
# 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.
|
2014-09-13 23:30:02 -04:00
|
|
|
#
|
|
|
|
# After installation #spec is updated to point to the just-installed
|
|
|
|
# specification.
|
2013-11-25 14:14:49 -05:00
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def install(options = {})
|
2013-11-25 14:14:49 -05:00
|
|
|
require 'rubygems/installer'
|
|
|
|
|
2018-09-18 04:37:18 -04:00
|
|
|
gem = download options
|
2013-11-25 14:14:49 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
installer = Gem::Installer.at gem, options
|
2013-11-25 14:14:49 -05:00
|
|
|
|
|
|
|
yield installer if block_given?
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
@spec = installer.install
|
2013-11-25 14:14:49 -05:00
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def download(options)
|
2018-09-18 04:37:18 -04:00
|
|
|
dir = options[:install_dir] || Gem.dir
|
|
|
|
|
|
|
|
Gem.ensure_gem_subdirectories dir
|
|
|
|
|
|
|
|
source.download spec, dir
|
|
|
|
end
|
|
|
|
|
2013-11-25 14:14:49 -05:00
|
|
|
##
|
|
|
|
# Returns true if this specification is installable on this platform.
|
|
|
|
|
|
|
|
def installable_platform?
|
2020-12-08 02:33:39 -05:00
|
|
|
Gem::Platform.match_spec? spec
|
2013-11-25 14:14:49 -05:00
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def local? # :nodoc:
|
|
|
|
false
|
|
|
|
end
|
2013-11-10 12:51:40 -05:00
|
|
|
end
|