Class: Doubleshot::Resolver::GemResolver::Artifact
- Includes:
- Comparable
- Defined in:
- lib/doubleshot/resolver/gem_resolver/artifact.rb
Instance Attribute Summary collapse
-
#graph ⇒ Doubleshot::Resolver::GemResolver::Graph
readonly
A reference to the graph this artifact belongs to.
-
#name ⇒ String
readonly
The name of the artifact.
-
#version ⇒ Gem::Version
readonly
The version of this artifact.
Instance Method Summary collapse
- #<=>(other) ⇒ Integer
- #==(other) ⇒ Boolean (also: #eql?)
-
#delete ⇒ Doubleshot::Resolver::GemResolver::Artifact?
Remove this artifact from the graph it belongs to.
-
#dependencies ⇒ Array<Doubleshot::Resolver::GemResolver::Dependency>
Return the collection of dependencies on this instance of artifact.
-
#depends(name, constraint = ">= 0") ⇒ Doubleshot::Resolver::GemResolver::Artifact
Return the Doubleshot::Resolver::GemResolver::Dependency from the collection of dependencies with the given name and constraint.
-
#get_dependency(name, constraint) ⇒ Doubleshot::Resolver::GemResolver::Artifact?
Retrieve the dependency from the artifact with the matching name and constraint.
-
#initialize(graph, name, version) ⇒ Artifact
constructor
A new instance of Artifact.
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#graph ⇒ Doubleshot::Resolver::GemResolver::Graph (readonly)
A reference to the graph this artifact belongs to
10 11 12 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 10 def graph @graph end |
#name ⇒ String (readonly)
The name of the artifact
15 16 17 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 15 def name @name end |
#version ⇒ Gem::Version (readonly)
The version of this artifact
20 21 22 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 20 def version @version end |
Instance Method Details
#<=>(other) ⇒ Integer
102 103 104 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 102 def <=>(other) self.version <=> other.version end |
#==(other) ⇒ Boolean Also known as: eql?
92 93 94 95 96 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 92 def ==(other) other.is_a?(self.class) && self.name == other.name && self.version == other.version end |
#delete ⇒ Doubleshot::Resolver::GemResolver::Artifact?
Remove this artifact from the graph it belongs to
77 78 79 80 81 82 83 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 77 def delete unless graph.nil? result = graph.remove_artifact(self) @graph = nil result end end |
#dependencies ⇒ Array<Doubleshot::Resolver::GemResolver::Dependency>
Return the collection of dependencies on this instance of artifact
60 61 62 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 60 def dependencies @dependencies.collect { |name, dependency| dependency } end |
#depends(name, constraint = ">= 0") ⇒ Doubleshot::Resolver::GemResolver::Artifact
Return the Doubleshot::Resolver::GemResolver::Dependency from the collection of dependencies with the given name and constraint.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 46 def depends(name, constraint = ">= 0") if name.nil? raise ArgumentError, "A name must be specified. You gave: #{args}." end dependency = Dependency.new(self, name, constraint) add_dependency(dependency) self end |
#get_dependency(name, constraint) ⇒ Doubleshot::Resolver::GemResolver::Artifact?
Retrieve the dependency from the artifact with the matching name and constraint
70 71 72 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 70 def get_dependency(name, constraint) @dependencies.fetch(Graph.dependency_key(name, constraint), nil) end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/doubleshot/resolver/gem_resolver/artifact.rb', line 85 def to_s "#{name}-#{version}" end |