From 5ffc4c0158b6178b94e3f2602e3455d8f18e98fb Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Fri, 31 Oct 2014 17:22:32 -0500 Subject: [PATCH] Starting work on Disambiguate Matlab, Objective-C, Mathematica, M, and Mercury method --- lib/linguist/heuristics.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 4c1bf295..30b4fcdf 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -25,6 +25,9 @@ module Linguist if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } result = disambiguate_cl(data, languages) end + if languages.all? { |l| ["M", "Matlab", "Mathematica", "Mercury", "Objective-C"].include?(l) } + result = disambiguate_m(data, languages) + end return result end end @@ -88,6 +91,15 @@ module Linguist matches end + def self.disambiguate_m(data, languages) + matches = [] + if (/@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data)) + matches << Language["Objective-C"] + end + # TODO add matchers for "M", "Matlab", "Mathematica", "Mercury" + matches + end + def self.active? !!ACTIVE end