Class: Bundler::Resolver::SpecGroup
- Inherits:
-
Array
- Object
- Array
- Bundler::Resolver::SpecGroup
show all
- Includes:
- GemHelpers
- Defined in:
- lib/bundler/resolver.rb
Constant Summary
Constants included
from GemHelpers
GemHelpers::GENERICS, GemHelpers::GENERIC_CACHE
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from GemHelpers
generic, generic_local_platform
Constructor Details
Returns a new instance of SpecGroup.
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/bundler/resolver.rb', line 76
def initialize(a)
super
@required_by = []
@activated = []
@dependencies = nil
@specs = {}
ALL.each do |p|
@specs[p] = reverse.find {|s| s.match_platform(p) }
end
end
|
Instance Attribute Details
#activated ⇒ Object
Returns the value of attribute activated.
74
75
76
|
# File 'lib/bundler/resolver.rb', line 74
def activated
@activated
end
|
#required_by ⇒ Object
Returns the value of attribute required_by.
74
75
76
|
# File 'lib/bundler/resolver.rb', line 74
def required_by
@required_by
end
|
Instance Method Details
109
110
111
112
113
114
115
116
117
|
# File 'lib/bundler/resolver.rb', line 109
def activate_platform(platform)
unless @activated.include?(platform)
if for?(platform, nil)
@activated << platform
return __dependencies[platform] || []
end
end
[]
end
|
145
146
147
|
# File 'lib/bundler/resolver.rb', line 145
def dependencies_for_activated_platforms
@activated.map {|p| __dependencies[p] }.flatten
end
|
#for?(platform, required_ruby_version) ⇒ Boolean
131
132
133
134
135
136
137
138
139
|
# File 'lib/bundler/resolver.rb', line 131
def for?(platform, required_ruby_version)
if spec = @specs[platform]
if required_ruby_version && spec.respond_to?(:required_ruby_version) && spec_required_ruby_version = spec.required_ruby_version
spec_required_ruby_version.satisfied_by?(required_ruby_version.gem_version)
else
true
end
end
end
|
#initialize_copy(o) ⇒ Object
88
89
90
91
92
|
# File 'lib/bundler/resolver.rb', line 88
def initialize_copy(o)
super
@required_by = o.required_by.dup
@activated = o.activated.dup
end
|
#name ⇒ Object
119
120
121
|
# File 'lib/bundler/resolver.rb', line 119
def name
@name ||= first.name
end
|
149
150
151
|
# File 'lib/bundler/resolver.rb', line 149
def platforms_for_dependency_named(dependency)
__dependencies.select {|_, deps| deps.map(&:name).include? dependency }.keys
end
|
#source ⇒ Object
127
128
129
|
# File 'lib/bundler/resolver.rb', line 127
def source
@source ||= first.source
end
|
#to_s ⇒ Object
141
142
143
|
# File 'lib/bundler/resolver.rb', line 141
def to_s
"#{name} (#{version})"
end
|
#to_specs ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/bundler/resolver.rb', line 94
def to_specs
specs = {}
@activated.each do |p|
next unless s = @specs[p]
platform = generic(Gem::Platform.new(s.platform))
next if specs[platform]
lazy_spec = LazySpecification.new(name, version, platform, source)
lazy_spec.dependencies.replace s.dependencies
specs[platform] = lazy_spec
end
specs.values
end
|
#version ⇒ Object
123
124
125
|
# File 'lib/bundler/resolver.rb', line 123
def version
@version ||= first.version
end
|