Sha256: 35d474f92eb895633b582570d62f753e03d07d802d7e5efe65b68ed9d5c32e26

Contents?: true

Size: 1.81 KB

Versions: 112

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

module Bundler
  class Resolver
    #
    # Represents a gem being resolved, in a format PubGrub likes.
    #
    # The class holds the following information:
    #
    # * Platforms this gem will be resolved on.
    # * The locked version of this gem resolution should favor (if any).
    # * Whether the gem should be unlocked to its latest version.
    # * The dependency explicit set in the Gemfile for this gem (if any).
    #
    class Package
      attr_reader :name, :platforms, :dependency, :locked_version

      def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, dependency: nil)
        @name = name
        @platforms = platforms
        @locked_version = locked_specs[name].first&.version
        @unlock = unlock
        @dependency = dependency || Dependency.new(name, @locked_version)
        @top_level = !dependency.nil?
        @prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
      end

      def to_s
        @name.delete("\0")
      end

      def root?
        false
      end

      def top_level?
        @top_level
      end

      def meta?
        @name.end_with?("\0")
      end

      def ==(other)
        self.class == other.class && @name == other.name
      end

      def hash
        @name.hash
      end

      def unlock?
        @unlock.empty? || @unlock.include?(name)
      end

      def ignores_prereleases?
        @prerelease == :ignore
      end

      def prerelease_specified?
        @prerelease == :consider_first
      end

      def consider_prereleases!
        @prerelease = :consider_last
      end

      def force_ruby_platform?
        @dependency.force_ruby_platform
      end

      def current_platform?
        @dependency.current_platform?
      end
    end
  end
end

Version data entries

112 entries across 112 versions & 4 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/resolver/package.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/resolver/package.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/resolver/package.rb
rubygems-update-3.5.15 bundler/lib/bundler/resolver/package.rb
bundler-2.5.15 lib/bundler/resolver/package.rb
rubygems-update-3.5.14 bundler/lib/bundler/resolver/package.rb
bundler-2.5.14 lib/bundler/resolver/package.rb
rubygems-update-3.5.13 bundler/lib/bundler/resolver/package.rb
bundler-2.5.13 lib/bundler/resolver/package.rb
rubygems-update-3.5.12 bundler/lib/bundler/resolver/package.rb
bundler-2.5.12 lib/bundler/resolver/package.rb
rubygems-update-3.5.10 bundler/lib/bundler/resolver/package.rb
bundler-2.5.10 lib/bundler/resolver/package.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/resolver/package.rb
rubygems-update-3.5.9 bundler/lib/bundler/resolver/package.rb
bundler-2.5.9 lib/bundler/resolver/package.rb
rubygems-update-3.5.8 bundler/lib/bundler/resolver/package.rb
bundler-2.5.8 lib/bundler/resolver/package.rb
rubygems-update-3.5.7 bundler/lib/bundler/resolver/package.rb
bundler-2.5.7 lib/bundler/resolver/package.rb