Class: PackageDetector::Visitor::Zip

Inherits:
PackageDetector::Visitor show all
Defined in:
lib/package_detector/visitor/zip.rb

Instance Method Summary collapse

Instance Method Details

#visit(package, element) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/package_detector/visitor/zip.rb', line 7

def visit(package, element)
  paths = Hash[*element.dir_struct.zip(Array.new(element.dir_struct.count, false)).flatten]
  ::Zip::ZipFile.foreach(package.path) do |zipfile|
    paths.keys.map { |file_path|
      if zipfile.name =~ Regexp.new(file_path)
        paths[file_path] = true
      end
    }
  end

  if paths.keys.select{|key| paths[key] == false }.empty?
    true
  else
    false
  end
end