Class: Semantic::Dependency::ModuleRelease
- Includes:
- GraphNode
- Defined in:
- lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb
Direct Known Subclasses
Puppet::Forge::ModuleRelease, Puppet::ModuleTool::InstalledModules::ModuleRelease, Puppet::ModuleTool::LocalTarball::ModuleRelease
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(oth) ⇒ Object
-
#initialize(source, name, version, dependencies = {}) ⇒ ModuleRelease
constructor
Create a new instance of a module release.
- #priority ⇒ Object
- #to_s ⇒ Object
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/puppet/vendor/semantic/lib/semantic/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
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb', line 8 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb', line 8 def version @version end |
Instance Method Details
#<=>(oth) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb', line 34 def <=>(oth) # Note that prior to ruby 2.3.0, if a <=> method threw an exception, ruby # would silently rescue the exception and return nil from <=> (which causes # the derived == comparison to return false). Starting in ruby 2.3.0, this # behavior changed and the exception is actually thrown. Some comments at: # https://bugs.ruby-lang.org/issues/7688 # # So simply return nil here if any of the needed fields are not available, # since attempting to access a missing field is one way to force an exception. # This doesn't help if the <=> use below throws an exception, but it # handles the most typical cause. return nil if !oth.respond_to?(:priority) || !oth.respond_to?(:name) || !oth.respond_to?(:version) our_key = [ priority, name, version ] their_key = [ oth.priority, oth.name, oth.version ] return our_key <=> their_key end |
#priority ⇒ Object
30 31 32 |
# File 'lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb', line 30 def priority @source.priority end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb', line 55 def to_s "#<#{self.class} #{name}@#{version}>" end |