Created
June 29, 2019 03:48
-
-
Save mattray/ced6ceececb72c3c463f1b85167524ec to your computer and use it in GitHub Desktop.
File size Foodcritic rule
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
# check the contents of the directory to see if any of the file are above 1MB | |
rule "FileSize>1MB", "Contents of files/ is larger than 1MB" do | |
tags %w{files} | |
cookbook do |path| | |
files = File.join(path, "files") | |
values = [] | |
Dir.foreach(files) do |file| | |
next if ['.', '..'].member?(file) | |
size = File.size(File.join(path,'files',file)) | |
if size > 1024*1024 # 1 megabyte | |
values += [file_match(File.join(path,'files',file))] | |
end | |
end | |
values | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment