Class: Puppet::ModuleTool::Dependency
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #mime, #render, #support_format?, #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).
15
16
17
18
19
20
21
|
# File 'lib/puppet/module_tool/dependency.rb', line 15
def initialize(full_module_name, version_requirement = nil, repository = nil)
@full_module_name = full_module_name
@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
10
11
12
|
# File 'lib/puppet/module_tool/dependency.rb', line 10
def full_module_name
@full_module_name
end
|
10
11
12
|
# File 'lib/puppet/module_tool/dependency.rb', line 10
def name
@name
end
|
#repository ⇒ Object
10
11
12
|
# File 'lib/puppet/module_tool/dependency.rb', line 10
def repository
@repository
end
|
10
11
12
|
# File 'lib/puppet/module_tool/dependency.rb', line 10
def username
@username
end
|
#version_requirement ⇒ Object
10
11
12
|
# File 'lib/puppet/module_tool/dependency.rb', line 10
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.
25
26
27
|
# File 'lib/puppet/module_tool/dependency.rb', line 25
def ==(o)
self.hash == o.hash
end
|
31
32
33
|
# File 'lib/puppet/module_tool/dependency.rb', line 31
def hash
[@full_module_name, @version_requirement, @repository].hash
end
|
#to_data_hash ⇒ Object
35
36
37
38
39
40
|
# File 'lib/puppet/module_tool/dependency.rb', line 35
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
|