mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge minified files detecting methods.
This commit is contained in:
@@ -52,8 +52,7 @@ module Linguist
|
|||||||
# Return true or false
|
# Return true or false
|
||||||
def generated?
|
def generated?
|
||||||
name == 'Gemfile.lock' ||
|
name == 'Gemfile.lock' ||
|
||||||
minified_javascript? ||
|
minified_files? ||
|
||||||
minified_css? ||
|
|
||||||
compiled_coffeescript? ||
|
compiled_coffeescript? ||
|
||||||
xcode_project_file? ||
|
xcode_project_file? ||
|
||||||
generated_net_docfile? ||
|
generated_net_docfile? ||
|
||||||
@@ -71,29 +70,15 @@ module Linguist
|
|||||||
['.xib', '.nib', '.storyboard', '.pbxproj', '.xcworkspacedata', '.xcuserstate'].include?(extname)
|
['.xib', '.nib', '.storyboard', '.pbxproj', '.xcworkspacedata', '.xcuserstate'].include?(extname)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Internal: Is the blob minified JS?
|
# Internal: Is the blob minified files?
|
||||||
#
|
#
|
||||||
# Consider JS minified if the average line length is
|
# Consider a file minified if the average line length is
|
||||||
# greater then 100c.
|
# greater then 100c. Currently only JS and CSS files are
|
||||||
|
# detected by this method.
|
||||||
#
|
#
|
||||||
# Returns true or false.
|
# Returns true or false.
|
||||||
def minified_javascript?
|
def minified_files?
|
||||||
return unless extname == '.js'
|
return unless ['.js', '.css'].include? extname
|
||||||
if lines.any?
|
|
||||||
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 100
|
|
||||||
else
|
|
||||||
false
|
|
||||||
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?
|
if lines.any?
|
||||||
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 100
|
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 100
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user