lib/buildmaster/cotta/cotta_dir.rb in BuildMaster-1.0.9 vs lib/buildmaster/cotta/cotta_dir.rb in BuildMaster-1.1.9

- old
+ new

@@ -86,24 +86,27 @@ def copy_to(target) target.parent.mkdirs @system.copy_dir(@path, target.path) end - def archive(target = nil) + def archive(target = nil, &block) unless target target = parent.file("#{name}.tar") end target.write_binary do |io| writer = Gem::Package::TarWriter.new(io) do |tar_io| - archive_dir(tar_io, self) + archive_dir(tar_io, self, &block) end end target end - def archive_dir(tar_io, dir) + def archive_dir(tar_io, dir, &block) dir.list.each do |child| + if (block_given? and not yield child) + next + end stat = child.stat entry_name = child.relative_path_from(self).to_s mode = stat.mode if (stat.file?) tar_io.add_file(entry_name, mode) do |entry_output| @@ -111,10 +114,10 @@ copy_io(input, entry_output) end end elsif (stat.directory?) tar_io.mkdir(entry_name, mode) - archive_dir(tar_io, child) + archive_dir(tar_io, child, &block) end end end private :archive_dir \ No newline at end of file