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



74
75
76
77
78
79
80
81
82
# File 'lib/bundler/resolver.rb', line 74

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



72
73
74
# File 'lib/bundler/resolver.rb', line 72

def activated
  @activated
end

Instance Method Details

#activate_platform!(platform) ⇒ Object



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

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

#dependencies_for_activated_platformsObject



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

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)


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

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

#initialize_copy(o) ⇒ Object



84
85
86
87
# File 'lib/bundler/resolver.rb', line 84

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

#nameObject



104
105
106
# File 'lib/bundler/resolver.rb', line 104

def name
  @name ||= first.name
end

#platforms_for_dependency_named(dependency) ⇒ Object



133
134
135
# File 'lib/bundler/resolver.rb', line 133

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

#sourceObject



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

def source
  @source ||= first.source
end

#to_sObject



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

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

#to_specsObject



89
90
91
92
93
94
95
96
# File 'lib/bundler/resolver.rb', line 89

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



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

def version
  @version ||= first.version
end