Class: TarWriter

Inherits:
Gem::Package::TarWriter
  • Object
show all
Defined in:
lib/capistrano-paratrooper-chef/tar_writer.rb

Overview

Add TarWriter#add() to append content from path

Instance Method Summary collapse

Instance Method Details

#add(name) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/capistrano-paratrooper-chef/tar_writer.rb', line 49

def add(name)
  stat = File.stat(name)

  if File.directory?(name)
    mkdir(name, stat.mode, stat.mtime)
  else
    add_file(name, stat.mode, stat.mtime) do |file|
      file.write(File.read(name))
    end
  end
end

#add_file(name, mode, mtime, &block) ⇒ Object



38
39
40
41
# File 'lib/capistrano-paratrooper-chef/tar_writer.rb', line 38

def add_file(name, mode, mtime, &block)
  Gem::Package::TarHeader.set_mtime(mtime)
  add_file_orig(name, mode, &block)
end

#add_file_origObject



37
# File 'lib/capistrano-paratrooper-chef/tar_writer.rb', line 37

alias :add_file_orig :add_file

#mkdir(name, mode, mtime) ⇒ Object



44
45
46
47
# File 'lib/capistrano-paratrooper-chef/tar_writer.rb', line 44

def mkdir(name, mode, mtime)
  Gem::Package::TarHeader.set_mtime(mtime)
  mkdir_orig(name, mode)
end

#mkdir_origObject



43
# File 'lib/capistrano-paratrooper-chef/tar_writer.rb', line 43

alias :mkdir_orig :mkdir