Skip to content

Instantly share code, notes, and snippets.

@ninoseki
Created February 22, 2019 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninoseki/232eac8aff23b7ccc3875282e1303ea7 to your computer and use it in GitHub Desktop.
Save ninoseki/232eac8aff23b7ccc3875282e1303ea7 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require "zip"
def check(path, keyword)
Zip::File.open(path) do |zip_file|
zip_file.each do |entry|
next if entry.name.end_with? "/"
next if File.extname(entry.name).empty?
content = entry.get_input_stream.read
puts [path, entry.name, "it includes #{keyword}"].join(",") if content.include?(keyword)
end
end
end
dir = ARGV[0]
keyword = ARGV[1]
Dir.glob("/#{dir}/*.zip").each do |path|
check(path, keyword)
rescue StandardError => e
puts [path, e].join(",")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment