Sha256: 947bc81ec264a32e6b8201cf4455a11f9875928e14c0e58a4f9b0c528ca09ab5

Contents?: true

Size: 1005 Bytes

Versions: 14

Compression:

Stored size: 1005 Bytes

Contents

module Solve
  class Dependency
    # A reference to the artifact this dependency belongs to
    #
    # @return [Solve::Artifact]
    attr_reader :artifact

    # The name of the artifact this dependency represents
    #
    # @return [String]
    attr_reader :name

    # The constraint requirement of this dependency
    #
    # @return [Semverse::Constraint]
    attr_reader :constraint

    # @param [Solve::Artifact] artifact
    # @param [#to_s] name
    # @param [Semverse::Constraint, #to_s] constraint
    def initialize(artifact, name, constraint = Semverse::DEFAULT_CONSTRAINT)
      @artifact   = artifact
      @name       = name
      @constraint = Semverse::Constraint.coerce(constraint)
    end

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

    # @param [Object] other
    #
    # @return [Boolean]
    def ==(other)
      other.is_a?(self.class) &&
      self.artifact == other.artifact &&
      self.constraint == other.constraint
    end
    alias_method :eql?, :==
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
solve-3.1.1 lib/solve/dependency.rb
solve-3.1.0 lib/solve/dependency.rb
solve-3.0.1 lib/solve/dependency.rb
solve-3.0.0 lib/solve/dependency.rb
solve-2.0.3 lib/solve/dependency.rb
solve-2.0.2 lib/solve/dependency.rb
solve-2.0.1 lib/solve/dependency.rb
solve-2.0.0 lib/solve/dependency.rb
solve-1.2.1 lib/solve/dependency.rb
solve-1.2.0 lib/solve/dependency.rb
solve-1.1.0 lib/solve/dependency.rb
solve-1.0.0.rc3 lib/solve/dependency.rb
solve-1.0.0.rc2 lib/solve/dependency.rb
solve-1.0.0.rc1 lib/solve/dependency.rb