lib/linguist/heuristics.rb in github-linguist-2.10.11 vs lib/linguist/heuristics.rb in github-linguist-2.10.13

- old
+ new

@@ -17,13 +17,22 @@ disambiguate_c(data, languages) end if languages.all? { |l| ["Perl", "Prolog"].include?(l) } disambiguate_pl(data, languages) end + if languages.all? { |l| ["ECL", "Prolog"].include?(l) } + 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 end end # .h extensions are ambigious between C, C++, and Objective-C. # We want to shortcut look for Objective-C _and_ now C++ too! @@ -41,16 +50,37 @@ matches << Language["Prolog"] if data.include?(":-") matches << Language["Perl"] if data.include?("use strict") matches end + def self.disambiguate_ecl(data, languages) + matches = [] + matches << Language["Prolog"] if data.include?(":-") + matches << Language["ECL"] if data.include?(":=") + matches + end + def self.disambiguate_ts(data, languages) matches = [] if (data.include?("</translation>")) matches << Language["XML"] else matches << Language["TypeScript"] end + matches + end + + def self.disambiguate_cl(data, languages) + matches = [] + matches << Language["Common Lisp"] if data.include?("(defun ") + matches << Language["OpenCL"] if /\/\* |\/\/ |^\}/.match(data) + matches + end + + def self.disambiguate_r(data, languages) + matches = [] + matches << Language["Rebol"] if /\bRebol\b/i.match(data) + matches << Language["R"] if data.include?("<-") matches end def self.active? !!ACTIVE