assetsフォルダ以下にあるファイルとdeployのときに生成されるmanifest.ymlを比較して、差分があるかどうかを求めるプログラム
- 色々画像が入ってるassetsフォルダが必要
- manifest.ymlも必要
- ダウンロードしてきた、ローカルのパスをfile_pathに設定して
files = []
Dir.glob('./assets/**/*').each do |f|
scans = f.scan(%r{^\./assets/(([a-zA-Z0-9_]|/)+).+(\.[a-zA-Z]+)})
file = ""
unless scans.empty?
file = scans[0][0] + scans[0][2]
files << file
end
end
files.uniq!
manifest = File.readlines("./manifest.yml")
manifest.delete_at(0)
deploy_files = []
manifest.each do |mani|
splits = mani.split(":")
deploy_files << splits[0]
end
diff = files - deploy_files
exist_file_path = []
diff.each do |p|
file_path = "any/assets/#{p}"
if File.exist? file_path
exist_file_path << file_path
end
end
puts exist_file_path