Class: Puppet::ModuleTool::LocalTarball

Inherits:
SemanticPuppet::Dependency::Source show all
Defined in:
lib/puppet/module_tool/local_tarball.rb

Defined Under Namespace

Classes: ModuleRelease

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SemanticPuppet::Dependency::Source

#create_release, #priority, priority

Constructor Details

#initialize(filename, strict_semver = true) ⇒ LocalTarball

Returns a new instance of LocalTarball.



11
12
13
14
15
16
17
# File 'lib/puppet/module_tool/local_tarball.rb', line 11

def initialize(filename, strict_semver = true)
  unpack(filename, tmpdir)
  Puppet.debug "Unpacked local tarball to #{tmpdir}"

  mod = Puppet::Module.new('tarball', tmpdir, nil, strict_semver)
  @release = ModuleRelease.new(self, mod)
end

Instance Attribute Details

#releaseObject

Returns the value of attribute release.



9
10
11
# File 'lib/puppet/module_tool/local_tarball.rb', line 9

def release
  @release
end

Instance Method Details

#fetch(name) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/puppet/module_tool/local_tarball.rb', line 19

def fetch(name)
  if @release.name == name
    [ @release ]
  else
    [ ]
  end
end

#install(release, dir) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/puppet/module_tool/local_tarball.rb', line 31

def install(release, dir)
  staging_dir = release.prepare

  module_dir = dir + release.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)
end

#prepare(release) ⇒ Object



27
28
29
# File 'lib/puppet/module_tool/local_tarball.rb', line 27

def prepare(release)
  release.mod.path
end