Start on basic heuristics tests

This commit is contained in:
Ted Nyman
2013-12-15 20:06:59 -08:00
parent 0c668ee179
commit b3c6c85387
2 changed files with 27 additions and 4 deletions

View File

@@ -11,9 +11,9 @@ module Linguist
# Returns an array of language name Strings, or []
def self.find_by_heuristics(data, languages)
if languages.all? { |l| ["pod", "perl"].include?(l) }
if languages.all? { |l| ["pod", "perl"].include?(l.downcase) }
disambiguate_pod(data, languages)
elsif languages.all? { |l| ["objective-c", "c++"].include?(l) }
elsif languages.all? { |l| ["objective-c", "c++"].include?(l.downcase) }
disambiguate_h(data, languages)
end
end
@@ -27,7 +27,7 @@ module Linguist
# Returns an array of still-possible languages, or nil
def self.disambiguate_pod(data, languages)
matches = []
matches << Language["Perl"] if data.includes?("my $")
matches << Language["Perl"] if data.include?("my $")
matches
end
@@ -35,7 +35,7 @@ module Linguist
# We want to look for Objective-C.
def self.disambiguate_h(data, languages)
matches = []
matches << Language["Objective-C"] if data.includes?("NSData *") && data.includes?("@interface")
matches << Language["Objective-C"] if data.include?("@interface")
matches
end
end