Class: Doubleshot::Resolver::GemResolver::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/doubleshot/resolver/gem_resolver/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(artifact, name, constraint = ">= 0") ⇒ Dependency

Returns a new instance of Dependency.

Parameters:



23
24
25
26
27
28
29
30
31
32
# File 'lib/doubleshot/resolver/gem_resolver/dependency.rb', line 23

def initialize(artifact, name, constraint = ">= 0")
  @artifact = artifact
  @name = name
  @constraint = case constraint
  when Gem::Requirement
    constraint
  else
    Gem::Requirement.new(constraint)
  end
end

Instance Attribute Details

#artifactDoubleshot::Resolver::GemResolver::Artifact (readonly)

A reference to the artifact this dependency belongs to



8
9
10
# File 'lib/doubleshot/resolver/gem_resolver/dependency.rb', line 8

def artifact
  @artifact
end

#constraintGem::Requirement (readonly)

The constraint requirement of this dependency

Returns:



18
19
20
# File 'lib/doubleshot/resolver/gem_resolver/dependency.rb', line 18

def constraint
  @constraint
end

#nameString (readonly)

The name of the artifact this dependency represents

Returns:



13
14
15
# File 'lib/doubleshot/resolver/gem_resolver/dependency.rb', line 13

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Parameters:

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/doubleshot/resolver/gem_resolver/dependency.rb', line 48

def ==(other)
  other.is_a?(self.class) &&
    self.artifact == other.artifact &&
    self.constraint == other.constraint
end

#deleteDoubleshot::Resolver::GemResolver::Dependency?

Remove this dependency from the artifact it belongs to



37
38
39
40
41
42
43
# File 'lib/doubleshot/resolver/gem_resolver/dependency.rb', line 37

def delete
  unless artifact.nil?
    result = artifact.remove_dependency(self)
    @artifact = nil
    result
  end
end