This commit is contained in:
Brandon Keepers
2014-11-27 11:40:48 -05:00
parent bf4baff363
commit e42ccf0d82
2 changed files with 15 additions and 2 deletions

View File

@@ -3,6 +3,19 @@ module Linguist
class Heuristics
ACTIVE = true
# Public: Use heuristics to detect language of the blob.
#
# blob - An object that quacks like a blob.
# possible_languages - Array of Language objects
#
# Examples
#
# Heuristics.call(FileBlob.new("path/to/file"), [
# Language["Ruby"], Language["Python"]
# ])
#
# Returns an Array with one Language if a heuristic matched, or empty if
# none matched or were inconclusive.
def self.call(blob, languages)
find_by_heuristics(blob.data, languages.map(&:name))
end