Class: PuppetForge::Tar::Mini
- Inherits:
-
Object
- Object
- PuppetForge::Tar::Mini
- Defined in:
- lib/shared/puppet_forge/tar/mini.rb
Constant Summary collapse
- SYMLINK_FLAGS =
[2]
- VALID_TAR_FLAGS =
(0..7)
Instance Method Summary collapse
- #pack(sourcedir, destfile) ⇒ Object
-
#unpack(sourcefile, destdir) ⇒ Hash{:symbol => Array<String>}
A hash with file-category keys pointing to lists of filenames.
Instance Method Details
#pack(sourcedir, destfile) ⇒ Object
34 35 36 37 38 |
# File 'lib/shared/puppet_forge/tar/mini.rb', line 34 def pack(sourcedir, destfile) Zlib::GzipWriter.open(destfile) do |writer| Archive::Tar::Minitar.pack(sourcedir, writer) end end |
#unpack(sourcefile, destdir) ⇒ Hash{:symbol => Array<String>}
Returns a hash with file-category keys pointing to lists of filenames.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shared/puppet_forge/tar/mini.rb', line 12 def unpack(sourcefile, destdir) # directories need to be changed outside of the Minitar::unpack because directories don't have a :file_done action dirlist = [] file_lists = {} Zlib::GzipReader.open(sourcefile) do |reader| file_lists = validate_files(reader) Archive::Tar::Minitar.unpack(reader, destdir, file_lists[:valid]) do |action, name, stats| case action when :file_done FileUtils.chmod('u+rw,g+r,a-st', "#{destdir}/#{name}") when :file_start validate_entry(destdir, name) when :dir validate_entry(destdir, name) dirlist << "#{destdir}/#{name}" end end end dirlist.each {|d| File.chmod(0755, d)} file_lists end |