Class: Puppet::ModuleTool::Dependency
- Defined in:
- lib/puppet/module_tool/dependency.rb
Instance Attribute Summary collapse
- #full_module_name ⇒ Object readonly
- #name ⇒ Object readonly
- #repository ⇒ Object readonly
- #username ⇒ Object readonly
- #version_requirement ⇒ Object readonly
Instance Method Summary collapse
-
#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
-
#to_pson(*args) ⇒ Object
Return PSON representation of this data.
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).
10 11 12 13 14 15 16 |
# File 'lib/puppet/module_tool/dependency.rb', line 10 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)
5 6 7 |
# File 'lib/puppet/module_tool/dependency.rb', line 5 def full_module_name @full_module_name end |
#name ⇒ Object (readonly)
5 6 7 |
# File 'lib/puppet/module_tool/dependency.rb', line 5 def name @name end |
#repository ⇒ Object (readonly)
5 6 7 |
# File 'lib/puppet/module_tool/dependency.rb', line 5 def repository @repository end |
#username ⇒ Object (readonly)
5 6 7 |
# File 'lib/puppet/module_tool/dependency.rb', line 5 def username @username end |
#version_requirement ⇒ Object (readonly)
5 6 7 |
# File 'lib/puppet/module_tool/dependency.rb', line 5 def version_requirement @version_requirement end |
Instance Method Details
#to_data_hash ⇒ Object
18 19 20 21 22 23 |
# File 'lib/puppet/module_tool/dependency.rb', line 18 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 |
#to_pson(*args) ⇒ Object
Return PSON representation of this data.
26 27 28 |
# File 'lib/puppet/module_tool/dependency.rb', line 26 def to_pson(*args) to_data_hash.to_pson(*args) end |