lib/linguist/heuristics.rb in github-linguist-3.1.2 vs lib/linguist/heuristics.rb in github-linguist-3.1.4
- old
+ new
@@ -1,9 +1,9 @@
module Linguist
# A collection of simple heuristics that can be used to better analyze languages.
class Heuristics
- ACTIVE = false
+ ACTIVE = true
# Public: Given an array of String language names,
# apply heuristics against the given data and return an array
# of matching languages, or nil.
#
@@ -11,27 +11,16 @@
# languages - Array of language name Strings to restrict to.
#
# Returns an array of Languages or []
def self.find_by_heuristics(data, languages)
if active?
- if languages.all? { |l| ["Objective-C", "C++"].include?(l) }
- disambiguate_c(data, languages)
- end
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
- disambiguate_pl(data, languages)
+ result = disambiguate_pl(data, languages)
end
if languages.all? { |l| ["ECL", "Prolog"].include?(l) }
- disambiguate_ecl(data, languages)
+ result = disambiguate_ecl(data, languages)
end
- if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
- disambiguate_ts(data, languages)
- end
- if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) }
- disambiguate_cl(data, languages)
- end
- if languages.all? { |l| ["Rebol", "R"].include?(l) }
- disambiguate_r(data, languages)
- end
+ return result
end
end
# .h extensions are ambigious between C, C++, and Objective-C.
# We want to shortcut look for Objective-C _and_ now C++ too!