Created
February 22, 2019 07:51
-
-
Save ninoseki/232eac8aff23b7ccc3875282e1303ea7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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