Sha256: b1b5f92ab170a3ab345df9d8a02277fc27d0c129ddb850b8d71f3c775fbc25a5

Contents?: true

Size: 1.66 KB

Versions: 30

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

module Bundler
  class Resolver
    class SpecGroup
      def initialize(specs)
        @specs = specs
      end

      def empty?
        @specs.empty?
      end

      def name
        @name ||= exemplary_spec.name
      end

      def version
        @version ||= exemplary_spec.version
      end

      def source
        @source ||= exemplary_spec.source
      end

      def to_specs(force_ruby_platform)
        @specs.map do |s|
          lazy_spec = LazySpecification.from_spec(s)
          lazy_spec.force_ruby_platform = force_ruby_platform
          lazy_spec
        end
      end

      def to_s
        sorted_spec_names.join(", ")
      end

      def dependencies
        @dependencies ||= @specs.map do |spec|
          __dependencies(spec) + metadata_dependencies(spec)
        end.flatten.uniq
      end

      protected

      def sorted_spec_names
        @sorted_spec_names ||= @specs.map(&:full_name).sort
      end

      private

      def exemplary_spec
        @specs.first
      end

      def __dependencies(spec)
        dependencies = []
        spec.dependencies.each do |dep|
          next if dep.type == :development
          dependencies << Dependency.new(dep.name, dep.requirement)
        end
        dependencies
      end

      def metadata_dependencies(spec)
        [
          metadata_dependency("Ruby", spec.required_ruby_version),
          metadata_dependency("RubyGems", spec.required_rubygems_version),
        ].compact
      end

      def metadata_dependency(name, requirement)
        return if requirement.nil? || requirement.none?

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

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
rubygems-update-3.5.15 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.15 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.14 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.14 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.13 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.13 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.12 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.12 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.10 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.10 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.9 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.9 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.8 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.8 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.7 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.7 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.6 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.6 lib/bundler/resolver/spec_group.rb
rubygems-update-3.5.5 bundler/lib/bundler/resolver/spec_group.rb
bundler-2.5.5 lib/bundler/resolver/spec_group.rb