mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Rename .create to .disambiguate
This commit is contained in:
@@ -34,7 +34,7 @@ module Linguist
|
|||||||
#
|
#
|
||||||
# Examples
|
# Examples
|
||||||
#
|
#
|
||||||
# create "Perl", "Prolog" do |data|
|
# disambiguate "Perl", "Prolog" do |data|
|
||||||
# if data.include?("use strict")
|
# if data.include?("use strict")
|
||||||
# Language["Perl"]
|
# Language["Perl"]
|
||||||
# elsif data.include?(":-")
|
# elsif data.include?(":-")
|
||||||
@@ -42,7 +42,7 @@ module Linguist
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
def self.create(*languages, &heuristic)
|
def self.disambiguate(*languages, &heuristic)
|
||||||
@heuristics << new(languages, &heuristic)
|
@heuristics << new(languages, &heuristic)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ module Linguist
|
|||||||
@heuristic.call(data)
|
@heuristic.call(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
create "Perl", "Prolog" do |data|
|
disambiguate "Perl", "Prolog" do |data|
|
||||||
if data.include?("use strict")
|
if data.include?("use strict")
|
||||||
Language["Perl"]
|
Language["Perl"]
|
||||||
elsif data.include?(":-")
|
elsif data.include?(":-")
|
||||||
@@ -73,7 +73,7 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "ECL", "Prolog" do |data|
|
disambiguate "ECL", "Prolog" do |data|
|
||||||
if data.include?(":-")
|
if data.include?(":-")
|
||||||
Language["Prolog"]
|
Language["Prolog"]
|
||||||
elsif data.include?(":=")
|
elsif data.include?(":=")
|
||||||
@@ -81,7 +81,7 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "IDL", "Prolog" do |data|
|
disambiguate "IDL", "Prolog" do |data|
|
||||||
if data.include?(":-")
|
if data.include?(":-")
|
||||||
Language["Prolog"]
|
Language["Prolog"]
|
||||||
else
|
else
|
||||||
@@ -89,7 +89,7 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "Common Lisp", "OpenCL" do |data|
|
disambiguate "Common Lisp", "OpenCL" do |data|
|
||||||
if data.include?("(defun ")
|
if data.include?("(defun ")
|
||||||
Language["Common Lisp"]
|
Language["Common Lisp"]
|
||||||
elsif /\/\* |\/\/ |^\}/.match(data)
|
elsif /\/\* |\/\/ |^\}/.match(data)
|
||||||
@@ -97,7 +97,7 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "Hack", "PHP" do |data|
|
disambiguate "Hack", "PHP" do |data|
|
||||||
if data.include?("<?hh")
|
if data.include?("<?hh")
|
||||||
Language["Hack"]
|
Language["Hack"]
|
||||||
elsif /<?[^h]/.match(data)
|
elsif /<?[^h]/.match(data)
|
||||||
@@ -105,7 +105,7 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "Scala", "SuperCollider" do |data|
|
disambiguate "Scala", "SuperCollider" do |data|
|
||||||
if /\^(this|super)\./.match(data) || /^\s*(\+|\*)\s*\w+\s*{/.match(data) || /^\s*~\w+\s*=\./.match(data)
|
if /\^(this|super)\./.match(data) || /^\s*(\+|\*)\s*\w+\s*{/.match(data) || /^\s*~\w+\s*=\./.match(data)
|
||||||
Language["SuperCollider"]
|
Language["SuperCollider"]
|
||||||
elsif /^\s*import (scala|java)\./.match(data) || /^\s*val\s+\w+\s*=/.match(data) || /^\s*class\b/.match(data)
|
elsif /^\s*import (scala|java)\./.match(data) || /^\s*val\s+\w+\s*=/.match(data) || /^\s*class\b/.match(data)
|
||||||
@@ -113,11 +113,11 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "AsciiDoc", "AGS Script" do |data|
|
disambiguate "AsciiDoc", "AGS Script" do |data|
|
||||||
Language["AsciiDoc"] if /^=+(\s|\n)/.match(data)
|
Language["AsciiDoc"] if /^=+(\s|\n)/.match(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
create "FORTRAN", "Forth" do |data|
|
disambiguate "FORTRAN", "Forth" do |data|
|
||||||
if /^: /.match(data)
|
if /^: /.match(data)
|
||||||
Language["Forth"]
|
Language["Forth"]
|
||||||
elsif /^([c*][^a-z]| subroutine\s)/i.match(data)
|
elsif /^([c*][^a-z]| subroutine\s)/i.match(data)
|
||||||
@@ -125,7 +125,7 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
create "F#", "Forth", "GLSL" do |data|
|
disambiguate "F#", "Forth", "GLSL" do |data|
|
||||||
if /^(: |new-device)/.match(data)
|
if /^(: |new-device)/.match(data)
|
||||||
Language["Forth"]
|
Language["Forth"]
|
||||||
elsif /^(#light|import|let|module|namespace|open|type)/.match(data)
|
elsif /^(#light|import|let|module|namespace|open|type)/.match(data)
|
||||||
|
|||||||
Reference in New Issue
Block a user