class Bundler::Resolver::SpecGroup - bundler: Ruby Standard Library Documentation

# class Bundler::Resolver::SpecGroup

### Attributes

specs[R]

### Public Class Methods

new(specs) click to toggle source

    # File bundler/resolver/spec_group.rb, line 8
    def initialize(specs)
      @specs = specs
    end

### Public Instance Methods

==(other) click to toggle source

    # File bundler/resolver/spec_group.rb, line 47
    def ==(other)
      sorted_spec_names == other.sorted_spec_names
    end

dependencies() click to toggle source

    # File bundler/resolver/spec_group.rb, line 41
    def dependencies
      @dependencies ||= @specs.flat_map do |spec|
        __dependencies(spec) + metadata_dependencies(spec)
      end.uniq.sort
    end

empty?() click to toggle source

    # File bundler/resolver/spec_group.rb, line 12
    def empty?
      @specs.empty?
    end

merge(other) click to toggle source

    # File bundler/resolver/spec_group.rb, line 51
    def merge(other)
      return false unless equivalent?(other)

      @specs |= other.specs

      true
    end

name() click to toggle source

    # File bundler/resolver/spec_group.rb, line 16
    def name
      @name ||= exemplary_spec.name
    end

source() click to toggle source

    # File bundler/resolver/spec_group.rb, line 24
    def source
      @source ||= exemplary_spec.source
    end

to_s() click to toggle source

    # File bundler/resolver/spec_group.rb, line 37
    def to_s
      sorted_spec_names.join(", ")
    end

to_specs(force_ruby_platform, most_specific_locked_platform) click to toggle source

    # File bundler/resolver/spec_group.rb, line 28
    def to_specs(force_ruby_platform, most_specific_locked_platform)
      @specs.map do |s|
        lazy_spec = LazySpecification.from_spec(s)
        lazy_spec.force_ruby_platform = force_ruby_platform
        lazy_spec.most_specific_locked_platform = most_specific_locked_platform
        lazy_spec
      end
    end

version() click to toggle source

    # File bundler/resolver/spec_group.rb, line 20
    def version
      @version ||= exemplary_spec.version
    end

### Protected Instance Methods

sorted_spec_names() click to toggle source

    # File bundler/resolver/spec_group.rb, line 61
    def sorted_spec_names
      @specs.map(&:full_name).sort
    end

### Private Instance Methods

__dependencies(spec) click to toggle source

    # File bundler/resolver/spec_group.rb, line 75
    def __dependencies(spec)
      dependencies = []
      spec.dependencies.each do |dep|
        next if dep.type == :development
        dependencies << Dependency.new(dep.name, dep.requirement)
      end
      dependencies
    end

equivalent?(other) click to toggle source

    # File bundler/resolver/spec_group.rb, line 67
    def equivalent?(other)
      name == other.name && version == other.version && source == other.source && dependencies == other.dependencies
    end

exemplary_spec() click to toggle source

    # File bundler/resolver/spec_group.rb, line 71
    def exemplary_spec
      @specs.first
    end

metadata_dependencies(spec) click to toggle source

    # File bundler/resolver/spec_group.rb, line 84
    def metadata_dependencies(spec)
      [
        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 91
    def metadata_dependency(name, requirement)
      return if requirement.nil? || requirement.none?

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