class Bundler::Resolver::SpecGroup

Attributes

activated_platforms[RW]
force_ruby_platform[RW]
name[RW]
source[RW]
version[RW]

Public Class Methods

new(specs, relevant_platforms) click to toggle source
# File bundler/resolver/spec_group.rb, line 9
def initialize(specs, relevant_platforms)
  @exemplary_spec = specs.first
  @name = @exemplary_spec.name
  @version = @exemplary_spec.version
  @source = @exemplary_spec.source

  @activated_platforms = relevant_platforms
  @specs = specs
end

Public Instance Methods

==(other) click to toggle source
# File bundler/resolver/spec_group.rb, line 39
def ==(other)
  return unless other.is_a?(SpecGroup)
  name == other.name &&
    version == other.version &&
    sorted_activated_platforms == other.sorted_activated_platforms &&
    source == other.source
end
dependencies_for_activated_platforms() click to toggle source
# File bundler/resolver/spec_group.rb, line 33
def dependencies_for_activated_platforms
  @dependencies_for_activated_platforms ||= @specs.map do |spec|
    __dependencies(spec) + metadata_dependencies(spec)
  end.flatten.uniq
end
eql?(other) click to toggle source
# File bundler/resolver/spec_group.rb, line 47
def eql?(other)
  return unless other.is_a?(SpecGroup)
  name.eql?(other.name) &&
    version.eql?(other.version) &&
    sorted_activated_platforms.eql?(other.sorted_activated_platforms) &&
    source.eql?(other.source)
end
hash() click to toggle source
# File bundler/resolver/spec_group.rb, line 55
def hash
  name.hash ^ version.hash ^ sorted_activated_platforms.hash ^ source.hash
end
to_s() click to toggle source
# File bundler/resolver/spec_group.rb, line 28
def to_s
  activated_platforms_string = sorted_activated_platforms.join(", ")
  "#{name} (#{version}) (#{activated_platforms_string})"
end
to_specs() click to toggle source
# File bundler/resolver/spec_group.rb, line 19
def to_specs
  @specs.map do |s|
    lazy_spec = LazySpecification.new(name, version, s.platform, source)
    lazy_spec.force_ruby_platform = force_ruby_platform
    lazy_spec.dependencies.replace s.dependencies
    lazy_spec
  end
end

Protected Instance Methods

sorted_activated_platforms() click to toggle source
# File bundler/resolver/spec_group.rb, line 61
def sorted_activated_platforms
  activated_platforms.sort_by(&:to_s)
end

Private Instance Methods

__dependencies(spec) click to toggle source
# File bundler/resolver/spec_group.rb, line 67
def __dependencies(spec)
  dependencies = []
  spec.dependencies.each do |dep|
    next if dep.type == :development
    dependencies << Dependency.new(dep.name, dep.requirement)
  end
  dependencies
end
metadata_dependencies(spec) click to toggle source
# File bundler/resolver/spec_group.rb, line 76
def metadata_dependencies(spec)
  return [] if spec.is_a?(LazySpecification)

  [
    metadata_dependency("Ruby", spec.required_ruby_version),
    metadata_dependency("RubyGems", spec.required_rubygems_version),
  ].compact
end
metadata_dependency(name, requirement) click to toggle source
# File bundler/resolver/spec_group.rb, line 85
def metadata_dependency(name, requirement)
  return if requirement.nil? || requirement.none?

  Dependency.new("#{name}\0", requirement)
end