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) ⇒ 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) ⇒ ModuleRelease
Returns a new instance of ModuleRelease.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/puppet/forge.rb', line 120 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| begin 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: #{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.
118 119 120 |
# File 'lib/puppet/forge.rb', line 118 def install_dir @install_dir end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
118 119 120 |
# File 'lib/puppet/forge.rb', line 118 def @metadata end |
Instance Method Details
#install(dir) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/puppet/forge.rb', line 144 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
163 164 165 166 167 168 169 170 171 |
# File 'lib/puppet/forge.rb', line 163 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 |