Heuristic for Pod vs. Perl

.pod files classified as Pod if they contain any Pod syntax
This commit is contained in:
Paul Chaignon
2016-01-16 11:21:26 +01:00
parent 470bd34349
commit d8666e5309
4 changed files with 26 additions and 0 deletions

View File

@@ -293,6 +293,14 @@ module Linguist
end
end
disambiguate ".pod" do |data|
if /^=\w+$/.match(data)
Language["Pod"]
else
Language["Perl"]
end
end
disambiguate ".pro" do |data|
if /^[^#]+:-/.match(data)
Language["Prolog"]

10
samples/Perl/Sample.pod Normal file
View File

@@ -0,0 +1,10 @@
use strict;
use warnings;
package DZT::Sample;
sub return_arrayref_of_values_passed {
my $invocant = shift;
return \@_;
}
1;

View File

@@ -155,6 +155,14 @@ class TestHeuristcs < Minitest::Test
})
end
# Candidate languages = ["Pod", "Perl"]
def test_pod_by_heuristics
assert_heuristics({
"Perl" => all_fixtures("Perl", "*.pod"),
"Pod" => all_fixtures("Pod", "*.pod")
})
end
# Candidate languages = ["IDL", "Prolog", "QMake", "INI"]
def test_pro_by_heuristics
assert_heuristics({