Sha256: a80cb0f45105366df8c0d3f177c1669da071e693ae374565af2a6067b28c4404
Contents?: true
Size: 701 Bytes
Versions: 23
Compression:
Stored size: 701 Bytes
Contents
require 'zip' module Trackler # FileBundle is a zippech archive of a directory. class FileBundle attr_reader :dir, :ignore_patterns def initialize(dir, ignore_patterns=[]) @dir = dir @ignore_patterns = ignore_patterns end def zip Zip::OutputStream.write_buffer do |io| paths.each do |path| io.put_next_entry(path.relative_path_from(dir)) io.print IO.read(path) end yield io if block_given? end end def paths Pathname.glob("#{dir}/**/*", File::FNM_DOTMATCH).reject {|file| file.directory? || ignore_patterns.any? { |pattern| file.to_s =~ pattern } }.sort end end end
Version data entries
23 entries across 23 versions & 1 rubygems