mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge pull request #253 from Tass/master
Binary mime type override if languages.yml says so
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.
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ module Linguist
|
|||||||
|
|
||||||
# Internal: Is the blob of JS generated by CoffeeScript?
|
# 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
|
# tell if it was generated or not. Look for a number of patterns
|
||||||
# output by the CS compiler.
|
# output by the CS compiler.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -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