Detect minified JS

This commit is contained in:
Joshua Peek
2011-05-24 14:16:05 -05:00
parent 045a50dda8
commit d889887440
4 changed files with 8966 additions and 1 deletions

View File

@@ -63,7 +63,14 @@ module Linguist
end
def generated?
['.xib', '.nib', '.pbxproj'].include?(pathname.extname)
if ['.xib', '.nib', '.pbxproj'].include?(pathname.extname)
true
elsif pathname.extname == '.js'
# JS is minified if any lines are longer than 1000c
lines.any? { |l| l.length > 1000 }
else
false
end
end
vendored_paths = YAML.load_file(File.expand_path("../vendor.yml", __FILE__))

8936
test/fixtures/blob/jquery-1.6.1.js vendored Normal file

File diff suppressed because it is too large Load Diff

18
test/fixtures/blob/jquery-1.6.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -112,6 +112,10 @@ class TestBlob < Test::Unit::TestCase
assert blob("MainMenu.xib").generated?
assert blob("MainMenu.nib").generated?
assert blob("project.pbxproj").generated?
# Minified JS
assert !blob("jquery-1.6.1.js").generated?
assert blob("jquery-1.6.1.min.js").generated?
end
def test_vendored