Kicking the tyres

This commit is contained in:
Arfon Smith
2014-07-11 10:03:49 -05:00
parent 4d83bf34f3
commit 41fc785330

View File

@@ -1,7 +1,7 @@
module Linguist module Linguist
# A collection of simple heuristics that can be used to better analyze languages. # A collection of simple heuristics that can be used to better analyze languages.
class Heuristics class Heuristics
ACTIVE = false ACTIVE = true
# Public: Given an array of String language names, # Public: Given an array of String language names,
# apply heuristics against the given data and return an array # apply heuristics against the given data and return an array
@@ -12,26 +12,28 @@ module Linguist
# #
# Returns an array of Languages or [] # Returns an array of Languages or []
def self.find_by_heuristics(data, languages) def self.find_by_heuristics(data, languages)
determined = nil
if active? if active?
if languages.all? { |l| ["Objective-C", "C++"].include?(l) } if languages.all? { |l| ["Objective-C", "C++", "C"].include?(l) }
disambiguate_c(data, languages) determined = disambiguate_c(data, languages)
end end
if languages.all? { |l| ["Perl", "Prolog"].include?(l) } if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
disambiguate_pl(data, languages) determined = disambiguate_pl(data, languages)
end end
if languages.all? { |l| ["ECL", "Prolog"].include?(l) } if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
disambiguate_ecl(data, languages) determined = disambiguate_ecl(data, languages)
end end
if languages.all? { |l| ["TypeScript", "XML"].include?(l) } if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
disambiguate_ts(data, languages) determined = disambiguate_ts(data, languages)
end end
if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
disambiguate_cl(data, languages) determined = disambiguate_cl(data, languages)
end end
if languages.all? { |l| ["Rebol", "R"].include?(l) } if languages.all? { |l| ["Rebol", "R"].include?(l) }
disambiguate_r(data, languages) determined = disambiguate_r(data, languages)
end end
end end
determined
end end
# .h extensions are ambigious between C, C++, and Objective-C. # .h extensions are ambigious between C, C++, and Objective-C.