Created
October 6, 2014 02:04
-
-
Save pchaigno/8c7b66a6b093e6c7b97f to your computer and use it in GitHub Desktop.
Median line length for minified files
This file contains hidden or 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
def minified_files? | |
return unless ['.js', '.css'].include? extname | |
if lines.any? | |
median = lines.sort_by { |l| l.length}[lines.length / 2].length | |
puts "median line length: #{median}\n" | |
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 110 | |
else | |
false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment