Use filenames as a definitive answer (#2006)

* Separate find_by_extension and find_by_filename
find_by_extension now takes a path as argument and not only the file extension.
Currently only find_by_extension is used as a strategy.

* Add find_by_filename as first strategy
This commit is contained in:
Paul Chaignon
2016-12-12 21:34:33 +01:00
committed by Brandon Black
parent 9d8392dab8
commit 9b941a34f0
10 changed files with 435 additions and 29 deletions

View File

@@ -1,9 +1,10 @@
module Linguist
module Strategy
# Detects language based on filename and/or extension
# Detects language based on filename
class Filename
def self.call(blob, _)
Language.find_by_filename(blob.name.to_s)
name = blob.name.to_s
Language.find_by_filename(name)
end
end
end