Class: Puppet::Forge::ModuleRelease
- Inherits:
-
SemanticPuppet::Dependency::ModuleRelease
- Object
- SemanticPuppet::Dependency::ModuleRelease
- Puppet::Forge::ModuleRelease
- Defined in:
- lib/puppet/forge.rb
Instance Attribute Summary collapse
-
#install_dir ⇒ Object
readonly
Returns the value of attribute install_dir.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Attributes inherited from SemanticPuppet::Dependency::ModuleRelease
Instance Method Summary collapse
-
#initialize(source, data, strict_semver = true) ⇒ ModuleRelease
constructor
A new instance of ModuleRelease.
- #install(dir) ⇒ Object
- #prepare ⇒ Object
Methods inherited from SemanticPuppet::Dependency::ModuleRelease
#<=>, #eql?, #hash, #priority, #to_s
Methods included from SemanticPuppet::Dependency::GraphNode
#<<, #<=>, #add_constraint, #add_dependency, #children, #constraints, #constraints_for, #dependencies, #dependency_names, #name, #populate_children, #satisfied?, #satisfies_constraints?, #satisfies_dependency?
Constructor Details
#initialize(source, data, strict_semver = true) ⇒ ModuleRelease
Returns a new instance of ModuleRelease.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/puppet/forge.rb', line 123 def initialize(source, data, strict_semver = true) @data = data @metadata = = data['metadata'] name = ['name'].tr('/', '-') version = SemanticPuppet::Version.parse(['version']) release = "#{name}@#{version}" if ['dependencies'] dependencies = ['dependencies'].collect do |dep| begin Puppet::ModuleTool::Metadata.new.add_dependency(dep['name'], dep['version_requirement'], dep['repository']) Puppet::ModuleTool.parse_module_dependency(release, dep, strict_semver)[0..1] rescue ArgumentError => e raise ArgumentError, "Malformed dependency: #{dep['name']}. Exception was: #{e}" end end else dependencies = [] end super(source, name, version, Hash[dependencies]) end |
Instance Attribute Details
#install_dir ⇒ Object (readonly)
Returns the value of attribute install_dir.
121 122 123 |
# File 'lib/puppet/forge.rb', line 121 def install_dir @install_dir end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
121 122 123 |
# File 'lib/puppet/forge.rb', line 121 def @metadata end |
Instance Method Details
#install(dir) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/puppet/forge.rb', line 147 def install(dir) staging_dir = self.prepare module_dir = dir + name[/-(.*)/, 1] module_dir.rmtree if module_dir.exist? # Make sure unpacked module has the same ownership as the folder we are moving it into. Puppet::ModuleTool::Applications::Unpacker.harmonize_ownership(dir, staging_dir) FileUtils.mv(staging_dir, module_dir) @install_dir = dir # Return the Pathname object representing the directory where the # module release archive was unpacked the to. return module_dir ensure staging_dir.rmtree if staging_dir.exist? end |
#prepare ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'lib/puppet/forge.rb', line 166 def prepare return @unpacked_into if @unpacked_into download(@data['file_uri'], tmpfile) validate_checksum(tmpfile, @data['file_md5']) unpack(tmpfile, tmpdir) @unpacked_into = Pathname.new(tmpdir) end |