Class: Bundler::Resolver::SpecGroup

Inherits:
Array
  • Object
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, platform_specificity_match, select_best_platform_match

Constructor Details

#initialize(a) ⇒ SpecGroup

Returns a new instance of SpecGroup



83
84
85
86
87
88
89
90
91
# File 'lib/bundler/resolver.rb', line 83

def initialize(a)
  super
  @required_by = []
  @activated_platforms = []
  @dependencies = nil
  @specs        = Hash.new do |specs, platform|
    specs[platform] = select_best_platform_match(self, platform)
  end
end

Instance Attribute Details

#activatedObject (readonly)

Returns the value of attribute activated



81
82
83
# File 'lib/bundler/resolver.rb', line 81

def activated
  @activated
end

Instance Method Details

#activate_platform!(platform) ⇒ Object



107
108
109
110
111
# File 'lib/bundler/resolver.rb', line 107

def activate_platform!(platform)
  return unless for?(platform)
  return if @activated_platforms.include?(platform)
  @activated_platforms << platform
end

#dependencies_for_activated_platformsObject



134
135
136
137
138
139
140
# File 'lib/bundler/resolver.rb', line 134

def dependencies_for_activated_platforms
  dependencies = @activated_platforms.map {|p| __dependencies[p] }
   = @activated_platforms.map do |platform|
    (@specs[platform], platform)
  end
  dependencies.concat().flatten
end

#for?(platform) ⇒ Boolean

Returns:

  • (Boolean)


125
126
127
128
# File 'lib/bundler/resolver.rb', line 125

def for?(platform)
  spec = @specs[platform]
  !spec.nil?
end

#initialize_copy(o) ⇒ Object



93
94
95
96
# File 'lib/bundler/resolver.rb', line 93

def initialize_copy(o)
  super
  @activated_platforms = o.activated.dup
end

#nameObject



113
114
115
# File 'lib/bundler/resolver.rb', line 113

def name
  @name ||= first.name
end

#platforms_for_dependency_named(dependency) ⇒ Object



142
143
144
# File 'lib/bundler/resolver.rb', line 142

def platforms_for_dependency_named(dependency)
  __dependencies.select {|_, deps| deps.map(&:name).include? dependency }.keys
end

#sourceObject



121
122
123
# File 'lib/bundler/resolver.rb', line 121

def source
  @source ||= first.source
end

#to_sObject



130
131
132
# File 'lib/bundler/resolver.rb', line 130

def to_s
  "#{name} (#{version})"
end

#to_specsObject



98
99
100
101
102
103
104
105
# File 'lib/bundler/resolver.rb', line 98

def to_specs
  @activated_platforms.map do |p|
    next unless s = @specs[p]
    lazy_spec = LazySpecification.new(name, version, s.platform, source)
    lazy_spec.dependencies.replace s.dependencies
    lazy_spec
  end.compact
end

#versionObject



117
118
119
# File 'lib/bundler/resolver.rb', line 117

def version
  @version ||= first.version
end