mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Override for binary mime type based on languages.yml
If the extension already exists in languages.yml, it's probably not a binary, but code.
This commit is contained in:
@@ -58,6 +58,15 @@ module Linguist
|
|||||||
_mime_type ? _mime_type.binary? : false
|
_mime_type ? _mime_type.binary? : false
|
||||||
end
|
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
|
# Public: Get the Content-Type header value
|
||||||
#
|
#
|
||||||
# This value is used when serving raw blobs.
|
# This value is used when serving raw blobs.
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ module Linguist
|
|||||||
return if @computed_stats
|
return if @computed_stats
|
||||||
|
|
||||||
@enum.each do |blob|
|
@enum.each do |blob|
|
||||||
# Skip binary file extensions
|
# Skip files that are likely binary
|
||||||
next if blob.binary_mime_type?
|
next if blob.likely_binary?
|
||||||
|
|
||||||
# Skip vendored or generated blobs
|
# Skip vendored or generated blobs
|
||||||
next if blob.vendored? || blob.generated? || blob.language.nil?
|
next if blob.vendored? || blob.generated? || blob.language.nil?
|
||||||
|
|||||||
@@ -24,4 +24,8 @@ class TestRepository < Test::Unit::TestCase
|
|||||||
def test_linguist_size
|
def test_linguist_size
|
||||||
assert linguist_repo.size > 30_000
|
assert linguist_repo.size > 30_000
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_binary_override
|
||||||
|
assert_equal repo(File.expand_path("../../samples/Nimrod", __FILE__)).language, Language["Nimrod"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user