blob: 00131714695742a9c79f9fcc904a5593621034eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
##
# 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
def initialize set, name, version, source, platform
super()
@name = name
@platform = platform
@set = set
@source = source
@version = version
@dependencies = []
@spec = nil
end
##
# This is a null install as a locked specification is considered installed.
# +options+ are ignored.
def install options = {}
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
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
##
# A specification constructed from the lockfile is returned
def spec
@spec ||= Gem::Specification.find { |spec|
spec.name == @name and spec.version == @version
}
@spec ||= Gem::Specification.new do |s|
s.name = @name
s.version = @version
s.platform = @platform
s.dependencies.concat @dependencies
end
end
end
|