Class: Puppet::ModuleTool::Dependency
- Includes:
- Network::FormatSupport
- Defined in:
- lib/puppet/module_tool/dependency.rb
Instance Attribute Summary collapse
-
#full_module_name ⇒ Object
readonly
Returns the value of attribute full_module_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#version_requirement ⇒ Object
readonly
Returns the value of attribute version_requirement.
Instance Method Summary collapse
-
#==(o) ⇒ Object
(also: #eql?)
We override Object’s ==, eql, and hash so we can more easily find identical dependencies.
- #hash ⇒ Object
-
#initialize(full_module_name, version_requirement = nil, repository = nil) ⇒ Dependency
constructor
Instantiates a new module dependency with a
full_module_name
(e.g. “myuser-mymodule”), and optionalversion_requirement
(e.g. “0.0.1”) and optional repository (a URL string). - #to_data_hash ⇒ Object
Methods included from Network::FormatSupport
included, #mime, #render, #support_format?, #to_json, #to_msgpack, #to_pson
Constructor Details
#initialize(full_module_name, version_requirement = nil, repository = nil) ⇒ Dependency
Instantiates a new module dependency with a full_module_name
(e.g. “myuser-mymodule”), and optional version_requirement
(e.g. “0.0.1”) and optional repository (a URL string).
14 15 16 17 18 19 20 |
# File 'lib/puppet/module_tool/dependency.rb', line 14 def initialize(full_module_name, version_requirement = nil, repository = nil) @full_module_name = full_module_name # TODO: add error checking, the next line raises ArgumentError when +full_module_name+ is invalid @username, @name = Puppet::ModuleTool.username_and_modname_from(full_module_name) @version_requirement = version_requirement @repository = repository ? Puppet::Forge::Repository.new(repository) : nil end |
Instance Attribute Details
#full_module_name ⇒ Object (readonly)
Returns the value of attribute full_module_name.
9 10 11 |
# File 'lib/puppet/module_tool/dependency.rb', line 9 def full_module_name @full_module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/puppet/module_tool/dependency.rb', line 9 def name @name end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
9 10 11 |
# File 'lib/puppet/module_tool/dependency.rb', line 9 def repository @repository end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/puppet/module_tool/dependency.rb', line 9 def username @username end |
#version_requirement ⇒ Object (readonly)
Returns the value of attribute version_requirement.
9 10 11 |
# File 'lib/puppet/module_tool/dependency.rb', line 9 def version_requirement @version_requirement end |
Instance Method Details
#==(o) ⇒ Object Also known as: eql?
We override Object’s ==, eql, and hash so we can more easily find identical dependencies.
24 25 26 |
# File 'lib/puppet/module_tool/dependency.rb', line 24 def ==(o) self.hash == o.hash end |
#hash ⇒ Object
30 31 32 |
# File 'lib/puppet/module_tool/dependency.rb', line 30 def hash [@full_module_name, @version_requirement, @repository].hash end |
#to_data_hash ⇒ Object
34 35 36 37 38 39 |
# File 'lib/puppet/module_tool/dependency.rb', line 34 def to_data_hash result = { :name => @full_module_name } result[:version_requirement] = @version_requirement if @version_requirement && ! @version_requirement.nil? result[:repository] = @repository.to_s if @repository && ! @repository.nil? result end |