Class: SemanticPuppet::Dependency::ModuleRelease

Inherits:
Object
  • Object
show all
Includes:
GraphNode
Defined in:
lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GraphNode

#<<, #add_constraint, #add_dependency, #children, #constraints, #constraints_for, #dependencies, #dependency_names, #populate_children, #satisfied?, #satisfies_constraints?, #satisfies_dependency?

Constructor Details

#initialize(source, name, version, dependencies = {}) ⇒ ModuleRelease

Create a new instance of a module release.

Parameters:



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 16

def initialize(source, name, version, dependencies = {})
  @source      = source
  @name        = name.freeze
  @version     = version.freeze

  dependencies.each do |name, range|
    add_constraint('initialize', name, range.to_s) do |node|
      range === node.version
    end

    add_dependency(name)
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 8

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 8

def version
  @version
end

Instance Method Details

#<=>(oth) ⇒ Object



34
35
36
37
38
39
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 34

def <=>(oth)
  our_key   = [ priority, name, version ]
  their_key = [ oth.priority, oth.name, oth.version ]

  return our_key <=> their_key
end

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

Returns:

  • (Boolean)


41
42
43
44
45
46
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 41

def eql?(other)
  other.is_a?(ModuleRelease) &&
    @name.eql?(other.name) &&
    @version.eql?(other.version) &&
    dependencies.eql?(other.dependencies)
end

#hashObject



49
50
51
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 49

def hash
  @name.hash ^ @version.hash
end

#priorityObject



30
31
32
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 30

def priority
  @source.priority
end

#to_sObject



53
54
55
# File 'lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb', line 53

def to_s
  "#<#{self.class} #{name}@#{version}>"
end