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.
Instance Method Summary collapse
-
#initialize(source, data) ⇒ ModuleRelease
constructor
A new instance of ModuleRelease.
- #install(dir) ⇒ Object
- #prepare ⇒ Object
Constructor Details
#initialize(source, data) ⇒ ModuleRelease
Returns a new instance of ModuleRelease.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/puppet/forge.rb', line 127 def initialize(source, data) @data = data @metadata = = data['metadata'] name = ['name'].tr('/', '-') version = SemanticPuppet::Version.parse(['version']) release = "#{name}@#{version}" if ['dependencies'] dependencies = ['dependencies'].collect do |dep| Puppet::ModuleTool::Metadata.new.add_dependency(dep['name'], dep['version_requirement'], dep['repository']) Puppet::ModuleTool.parse_module_dependency(release, dep)[0..1] rescue ArgumentError => e raise ArgumentError, _("Malformed dependency: %{name}.") % { name: dep['name'] } + ' ' + _("Exception was: %{detail}") % { detail: e } end else dependencies = [] end super(source, name, version, dependencies.to_h) end |
Instance Attribute Details
#install_dir ⇒ Object (readonly)
Returns the value of attribute install_dir.
125 126 127 |
# File 'lib/puppet/forge.rb', line 125 def install_dir @install_dir end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
125 126 127 |
# File 'lib/puppet/forge.rb', line 125 def @metadata end |
Instance Method Details
#install(dir) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/puppet/forge.rb', line 150 def install(dir) staging_dir = 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. module_dir ensure staging_dir.rmtree if staging_dir.exist? end |
#prepare ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/puppet/forge.rb', line 169 def prepare return @unpacked_into if @unpacked_into Puppet.warning "#{@metadata['name']} has been deprecated by its author! View module on Puppet Forge for more info." if deprecated? download(@data['file_uri'], tmpfile) checksum = @data['file_sha256'] if checksum validate_checksum(tmpfile, checksum, Digest::SHA256) else checksum = @data['file_md5'] if checksum validate_checksum(tmpfile, checksum, Digest::MD5) else raise _("Forge module is missing SHA256 and MD5 checksums") end end unpack(tmpfile, tmpdir) @unpacked_into = Pathname.new(tmpdir) end |