lib/linguist/heuristics.rb in github-linguist-2.10.8 vs lib/linguist/heuristics.rb in github-linguist-2.10.9
- old
+ new
@@ -12,23 +12,31 @@
#
# 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_h(data, languages)
+ disambiguate_c(data, languages)
end
+ if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
+ disambiguate_pl(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!
#
# Returns an array of Languages or []
- # TODO rename this method as we're not strictly disambiguating between .h files here.
- def self.disambiguate_h(data, languages)
+ def self.disambiguate_c(data, languages)
matches = []
matches << Language["Objective-C"] if data.include?("@interface")
matches << Language["C++"] if data.include?("#include <cstdint>")
+ matches
+ end
+
+ def self_disambiguate_pl(data, languages)
+ matches = []
+ matches << Language["Prolog"] if data.include?(":-")
matches
end
def self.active?
!!ACTIVE