Detect minified CSS files

This commit is contained in:
Xidorn Quan
2013-03-01 16:15:56 +08:00
parent cf6eeec22a
commit 4398cda9a5

View File

@@ -53,6 +53,7 @@ module Linguist
def generated?
name == 'Gemfile.lock' ||
minified_javascript? ||
minified_css? ||
compiled_coffeescript? ||
xcode_project_file? ||
generated_net_docfile? ||
@@ -85,6 +86,21 @@ module Linguist
end
end
# Internal: Is the blob minified CSS?
#
# Consider CSS minified if the average line length is
# greater than 100c.
#
# Returns true or false.
def minified_css?
return unless extname == '.css'
if lines.any?
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 100
else
false
end
end
# Internal: Is the blob of JS generated by CoffeeScript?
#
# CoffeeScript is meant to output JS that would be difficult to