Merge branch 'detect-prolog' of https://github.com/tautologico/linguist into tautologico-detect-prolog

Conflicts:
	lib/linguist/blob_helper.rb
	test/test_blob.rb
This commit is contained in:
Joshua Peek
2011-07-05 16:06:22 -05:00
7 changed files with 56 additions and 3 deletions

View File

@@ -281,6 +281,9 @@ module Linguist
# If it's a .m file, try to guess the language
m_language ||
# If it's a .pl file, try to guess the language
pl_language ||
# If it's a .r file, try to guess the language
r_language ||
@@ -347,6 +350,26 @@ module Linguist
end
end
# Internal: Guess language of .pl files
#
# Returns a Language.
def pl_language
return unless extname == '.pl'
# The rules for disambiguation are:
#
# 1. Many perl files begin with a shebang
# 2. Most Prolog source files have a rule somewhere (marked by the :- operator)
# 3. Default to Perl, because it is more popular
if shebang_script == 'perl'
Language['Perl']
elsif lines.grep(/:-/).any?
Language['Prolog']
else
Language['Perl']
end
end
# Internal: Guess language of .r files.
#
# Returns a Language.

View File

@@ -590,6 +590,12 @@ Perl:
- .perl
- .psgi
Prolog:
major: true
extensions:
- .pro
- .prolog
Pure Data:
major: true
lexer: Text only