mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-14 15:32:24 +00:00
3499750785
Sync \w Github Linguist v7.2.0 Includes new way of handling `heuristics.yml` and all `./data/*` re-generated using Github Linguist [v7.2.0](https://github.com/github/linguist/releases/tag/v7.2.0) release tag. - many new languages - better vendoring detection - update doc on update&known issues.
52 lines
1003 B
Cheetah
52 lines
1003 B
Cheetah
package data
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
"gopkg.in/src-d/enry.v1/data/rule"
|
|
)
|
|
|
|
var ContentHeuristics = map[string]*Heuristics{
|
|
{{ range $ext, $rules := . -}}
|
|
{{ printf "%q" $ext }}: &Heuristics{
|
|
{{ range $rule := $rules -}}
|
|
{{template "Rule" $rule}}
|
|
{{ end -}}
|
|
},
|
|
{{ end -}}
|
|
}
|
|
|
|
{{ define "Rule" -}}
|
|
{{ if eq .Op "And" -}}
|
|
rule.And(
|
|
{{ template "Languages" .Langs -}}
|
|
{{ range $rule := .Rules -}}
|
|
{{template "Rule" $rule}}
|
|
{{ end -}}
|
|
),
|
|
{{- else if eq .Op "Or" -}}
|
|
rule.Or(
|
|
{{ template "Languages" .Langs -}}
|
|
regexp.MustCompile(`{{ .Pattern }}`),
|
|
),
|
|
{{- else if eq .Op "Not" -}}
|
|
rule.Not(
|
|
{{ template "Languages" .Langs -}}
|
|
regexp.MustCompile(`{{ .Pattern }}`),
|
|
),
|
|
{{- else if eq .Op "Always" -}}
|
|
rule.Always(
|
|
{{ template "Languages" .Langs -}}
|
|
),
|
|
{{ end -}}
|
|
{{ end -}}
|
|
|
|
|
|
{{define "Languages" -}}
|
|
{{with . -}}
|
|
rule.MatchingLanguages( {{range .}} {{printf "\"%s\"" .}}, {{end}} ),
|
|
{{ else -}}
|
|
rule.MatchingLanguages(""),
|
|
{{end -}}
|
|
{{end}}
|