mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Detect minified CSS files
This commit is contained in:
@@ -53,6 +53,7 @@ module Linguist
|
|||||||
def generated?
|
def generated?
|
||||||
name == 'Gemfile.lock' ||
|
name == 'Gemfile.lock' ||
|
||||||
minified_javascript? ||
|
minified_javascript? ||
|
||||||
|
minified_css? ||
|
||||||
compiled_coffeescript? ||
|
compiled_coffeescript? ||
|
||||||
xcode_project_file? ||
|
xcode_project_file? ||
|
||||||
generated_net_docfile? ||
|
generated_net_docfile? ||
|
||||||
@@ -85,6 +86,21 @@ module Linguist
|
|||||||
end
|
end
|
||||||
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?
|
# Internal: Is the blob of JS generated by CoffeeScript?
|
||||||
#
|
#
|
||||||
# CoffeeScript is meant to output JS that would be difficult to
|
# CoffeeScript is meant to output JS that would be difficult to
|
||||||
|
|||||||
Reference in New Issue
Block a user