Merge pull request #253 from Tass/master

Binary mime type override if languages.yml says so
This commit is contained in:
Ted Nyman
2013-02-21 21:49:09 -08:00
4 changed files with 16 additions and 3 deletions

View File

@@ -58,6 +58,15 @@ module Linguist
_mime_type ? _mime_type.binary? : false
end
# Internal: Is the blob binary according to its mime type,
# overriding it if we have better data from the languages.yml
# database.
#
# Return true or false
def likely_binary?
binary_mime_type? and not Language.find_by_filename(name)
end
# Public: Get the Content-Type header value
#
# This value is used when serving raw blobs.

View File

@@ -86,7 +86,7 @@ module Linguist
# Internal: Is the blob of JS generated by CoffeeScript?
#
# CoffeScript is meant to output JS that would be difficult to
# CoffeeScript is meant to output JS that would be difficult to
# tell if it was generated or not. Look for a number of patterns
# output by the CS compiler.
#

View File

@@ -67,8 +67,8 @@ module Linguist
return if @computed_stats
@enum.each do |blob|
# Skip binary file extensions
next if blob.binary_mime_type?
# Skip files that are likely binary
next if blob.likely_binary?
# Skip vendored or generated blobs
next if blob.vendored? || blob.generated? || blob.language.nil?

View File

@@ -24,4 +24,8 @@ class TestRepository < Test::Unit::TestCase
def test_linguist_size
assert linguist_repo.size > 30_000
end
def test_binary_override
assert_equal repo(File.expand_path("../../samples/Nimrod", __FILE__)).language, Language["Nimrod"]
end
end