1 2 3 4 5 6 7 |
files = ["/etc/foo", "/etc/passwd"] found = files.inject(0){|f,c| f += File.exist?(c)? 1: 0} Facter.add("found_them") do setvar {found == files.size } end |
alternative
1 |
found = files.map{|f| File.exist?(f)}.grep(true).size |
