2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2013-12-07 20:22:39 -05:00
|
|
|
##
|
|
|
|
# The LockSpecification comes from a lockfile (Gem::RequestSet::Lockfile).
|
|
|
|
#
|
|
|
|
# A LockSpecification's dependency information is pre-filled from the
|
|
|
|
# lockfile.
|
|
|
|
|
|
|
|
class Gem::Resolver::LockSpecification < Gem::Resolver::Specification
|
|
|
|
|
2016-02-01 07:43:26 -05:00
|
|
|
attr_reader :sources
|
|
|
|
|
|
|
|
def initialize set, name, version, sources, platform
|
2013-12-07 20:22:39 -05:00
|
|
|
super()
|
|
|
|
|
|
|
|
@name = name
|
|
|
|
@platform = platform
|
|
|
|
@set = set
|
2016-02-01 07:43:26 -05:00
|
|
|
@source = sources.first
|
|
|
|
@sources = sources
|
2013-12-07 20:22:39 -05:00
|
|
|
@version = version
|
|
|
|
|
|
|
|
@dependencies = []
|
|
|
|
@spec = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# This is a null install as a locked specification is considered installed.
|
|
|
|
# +options+ are ignored.
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def install options = {}
|
2013-12-07 20:22:39 -05:00
|
|
|
destination = options[:install_dir] || Gem.dir
|
|
|
|
|
|
|
|
if File.exist? File.join(destination, 'specifications', spec.spec_name) then
|
|
|
|
yield nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Adds +dependency+ from the lockfile to this specification
|
|
|
|
|
|
|
|
def add_dependency dependency # :nodoc:
|
|
|
|
@dependencies << dependency
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def pretty_print q # :nodoc:
|
|
|
|
q.group 2, '[LockSpecification', ']' do
|
|
|
|
q.breakable
|
|
|
|
q.text "name: #{@name}"
|
|
|
|
|
|
|
|
q.breakable
|
|
|
|
q.text "version: #{@version}"
|
|
|
|
|
|
|
|
unless @platform == Gem::Platform::RUBY then
|
|
|
|
q.breakable
|
|
|
|
q.text "platform: #{@platform}"
|
|
|
|
end
|
|
|
|
|
|
|
|
unless @dependencies.empty? then
|
|
|
|
q.breakable
|
|
|
|
q.text 'dependencies:'
|
|
|
|
q.breakable
|
|
|
|
q.pp @dependencies
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-07 20:22:39 -05:00
|
|
|
##
|
|
|
|
# A specification constructed from the lockfile is returned
|
|
|
|
|
|
|
|
def spec
|
2014-09-13 23:30:02 -04:00
|
|
|
@spec ||= Gem::Specification.find { |spec|
|
|
|
|
spec.name == @name and spec.version == @version
|
|
|
|
}
|
|
|
|
|
2013-12-07 20:22:39 -05:00
|
|
|
@spec ||= Gem::Specification.new do |s|
|
|
|
|
s.name = @name
|
|
|
|
s.version = @version
|
|
|
|
s.platform = @platform
|
|
|
|
|
|
|
|
s.dependencies.concat @dependencies
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|