this is not directly related to jekyll. I just updated ruby to 2.5 from 2.2. Jekyll works no problem.
I use a rake file to minimize files, and that has broken. I mostly have it working, but there is a line that prints the total compression and it is giving me NaN now.
require "reduce"
desc "Minify _site/"
task :minify do
puts "\n## Compressing static assets"
original = 0.0
compressed = 0
Dir.glob("_site/**/*.*") do |file|
case File.extname(file)
when ".css", ".html", ".js", ".xml" #no images cause it don't work
puts "Processing: #{file}"
original += File.size(file).to_f
min = Reduce.reduce(file)
File.open(file, "w") do |f|
f.write(min)
end
compressed += File.size(file)
else
puts "Skipping: #{file}"
end
end
puts "Total compression %0.2f\%" % (((original-compressed)/original)*100)
puts "deploying to s3"
sh %{s3_website push}
end
This line: puts "Total compression %0.2f\%" % (((original-compressed)/original)*100)
is the problem I think.
I see that the variable (?) is now incorrect, as is it just exits with an error saying to use double %. So I changed it to:
puts "Total compression %0.0f%%" % (((original-compressed)/original)*100)
and now it is NaN. I have tried a few different iterations of that line but get NaN on them too.
Any idea what is wrong? I think it is some sort of simple syntax issue, but I am not a ruby person so I don’t quite see it.
I think that it works fine as is, but I like seeing the amount of compression.