From a7a123a8db9e5df923ba63bc9aa2fdc1f7205a96 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Wed, 14 Sep 2016 15:48:46 +0200 Subject: [PATCH] Add heuristic for .inc files: the #declare keyword is unique to POV-Ray. Also added #local, #macro, and #while. --- lib/linguist/heuristics.rb | 2 ++ test/test_heuristics.rb | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index 1d5196f4..2c99b476 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -202,6 +202,8 @@ module Linguist disambiguate ".inc" do |data| if /^<\?(?:php)?/.match(data) Language["PHP"] + elsif /^\s*#(declare|local|macro|while)\s/.match(data) + Language["POV-Ray SDL"] end end diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index e37da44b..62e5a050 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -122,9 +122,12 @@ class TestHeuristcs < Minitest::Test }) end + # Candidate languages = ["Assembly", "C++", "HTML", "PAWN", "PHP", + # "POV-Ray SDL", "Pascal", "SQL", "SourcePawn"] def test_inc_by_heuristics assert_heuristics({ - "PHP" => all_fixtures("PHP", "*.inc") + "PHP" => all_fixtures("PHP", "*.inc"), + "POV-Ray SDL" => all_fixtures("POV-Ray SDL", "*.inc") }) end