github-linguist 9.8.0 → 9.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/grammars/text.valve-cfg.json +1 -1
- data/grammars/version +1 -1
- data/lib/linguist/VERSION +1 -1
- data/lib/linguist/heuristics.rb +12 -25
- data/lib/linguist/heuristics.yml +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55d11e41a82f2517d29f01d26def41b5ea6faef0dd0c257bb5277d3ff11476b0
|
|
4
|
+
data.tar.gz: 67efc27ff8e7d3e6c247e8f93099dba0121d23a597a8c29e8c26923039ffa541
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24a24130ebe2fbb12623643eab16c3e912ab894696f24ed53d8e8b0b9065e84730cad42bb957f6a6d04e4bd80114cf26027f69bc1f8700de2b95b4a69076345a
|
|
7
|
+
data.tar.gz: 0e52cacd7bc705de28ff9a248f3c9e10b7063a2ed6ad700dc8e83267994279fd4f0821b913bae40fb65b88a4132dd8440d9b4cbe1e43ad3aad8448ea72c4d843
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"scopeName":"text.valve-cfg","patterns":[{"include":"#comments"},{"include":"#function"},{"include":"#cvar"},{"include":"#value"}],"repository":{"comments":{"patterns":[{"name":"comment.valve-cfg","match":"\\/\\/.*"},{"name":"comment.block.valve-cfg","begin":"/\\*","end":"\\*/","captures":{"0":{"name":"comment.valve-cfg"}}}]},"cvar":{"patterns":[{"match":"^\\s*(\"[A-Za-z0-9_-]*\")","captures":{"1":{"name":"support.type.property-name.valve-cfg"}}},{"match":"^\\s*('[A-Za-z0-9_-]*')","captures":{"1":{"name":"support.type.property-name.valve-cfg"}}},{"match":"^\\s*([A-Za-z0-9_-]*)","captures":{"1":{"name":"support.type.property-name.valve-cfg"}}}]},"function":{"patterns":[{"name":"support.function.valve-cfg","match":"^\\s*\\b(alias|bind_osx|bind|clear|echo|execifexists|execwithwhitelist|exec|host_writeconfig_ss|host_writeconfig|key_updatelayout|playvol|say_team|say|unbindalljoystick|unbindallmousekeyboard|unbindall)","captures":{"1":{"name":"support.function.valve-cfg"}}}]},"numeric-literal":{"patterns":[{"name":"constant.numeric.float.
|
|
1
|
+
{"scopeName":"text.valve-cfg","patterns":[{"include":"#comments"},{"include":"#function"},{"include":"#cvar"},{"include":"#value"}],"repository":{"comments":{"patterns":[{"name":"comment.valve-cfg","match":"\\/\\/.*"},{"name":"comment.block.valve-cfg","begin":"/\\*","end":"\\*/","captures":{"0":{"name":"comment.valve-cfg"}}}]},"cvar":{"patterns":[{"match":"^\\s*(\"[A-Za-z0-9_-]*\")","captures":{"1":{"name":"support.type.property-name.valve-cfg"}}},{"match":"^\\s*('[A-Za-z0-9_-]*')","captures":{"1":{"name":"support.type.property-name.valve-cfg"}}},{"match":"^\\s*([A-Za-z0-9_-]*)","captures":{"1":{"name":"support.type.property-name.valve-cfg"}}}]},"function":{"patterns":[{"name":"support.function.valve-cfg","match":"^\\s*\\b(alias|bind_osx|bind|clear|echo|execifexists|execwithwhitelist|exec|host_writeconfig_ss|host_writeconfig|key_updatelayout|playvol|say_team|say|unbindalljoystick|unbindallmousekeyboard|unbindall)","captures":{"1":{"name":"support.function.valve-cfg"}}}]},"numeric-literal":{"patterns":[{"name":"constant.numeric.float.sourcepawn","match":"[0-9]+\\.[0-9]+"},{"name":"constant.numeric.sourcepawn","match":"\\b0b[0-1]+\\b"},{"name":"constant.numeric.sourcepawn","match":"\\b0o[0-7]+\\b"},{"name":"constant.numeric.sourcepawn","match":"\\b0x[0-9a-fA-F]+\\b"},{"name":"constant.numeric.integer.sourcepawn","match":"\\b\\d+\\b"},{"name":"invalid.illegal.constant.sourcepawn","match":"\\b\\d+\\w+\\b"}]},"strings":{"name":"string.quoted.double.valve-cfg","begin":"\"","end":"\"","patterns":[{"name":"variable","match":"\\\\."}]},"value":{"begin":".","end":"\\n","patterns":[{"include":"#numeric-literal"},{"include":"#strings"}]}}}
|
data/grammars/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
9.8.
|
|
1
|
+
9.8.1
|
data/lib/linguist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
9.8.
|
|
1
|
+
9.8.1
|
data/lib/linguist/heuristics.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Linguist
|
|
|
25
25
|
|
|
26
26
|
@heuristics.each do |heuristic|
|
|
27
27
|
if heuristic.matches?(blob.name, candidates)
|
|
28
|
-
return
|
|
28
|
+
return heuristic.call(data)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -42,23 +42,22 @@ module Linguist
|
|
|
42
42
|
@heuristics
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
# Internal: Load heuristics from 'heuristics.yml'.
|
|
45
|
+
# Internal: Load heuristics from 'heuristics.yml', requiring exact language names.
|
|
46
46
|
def self.load()
|
|
47
|
-
if @heuristics
|
|
48
|
-
return
|
|
49
|
-
end
|
|
47
|
+
return if @heuristics
|
|
50
48
|
|
|
51
49
|
data = self.load_config
|
|
52
50
|
named_patterns = data['named_patterns'].map { |k,v| [k, self.to_regex(v)] }.to_h
|
|
51
|
+
languages = Language.all.to_h { |language| [language.name, language] }
|
|
53
52
|
|
|
54
|
-
data['disambiguations'].
|
|
53
|
+
@heuristics = data['disambiguations'].map do |disambiguation|
|
|
55
54
|
exts = disambiguation['extensions']
|
|
56
|
-
rules = disambiguation['rules']
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rule
|
|
55
|
+
rules = disambiguation['rules'].map do |rule|
|
|
56
|
+
names = rule['language']
|
|
57
|
+
names = [names] unless names.is_a?(Array)
|
|
58
|
+
{ 'pattern' => self.parse_rule(named_patterns, rule), 'languages' => languages.fetch_values(*names) }
|
|
60
59
|
end
|
|
61
|
-
|
|
60
|
+
new(exts, rules)
|
|
62
61
|
end
|
|
63
62
|
end
|
|
64
63
|
|
|
@@ -94,9 +93,6 @@ module Linguist
|
|
|
94
93
|
end
|
|
95
94
|
end
|
|
96
95
|
|
|
97
|
-
# Internal: Array of defined heuristics
|
|
98
|
-
@heuristics = []
|
|
99
|
-
|
|
100
96
|
# Internal
|
|
101
97
|
def initialize(exts, rules)
|
|
102
98
|
@exts = exts
|
|
@@ -110,9 +106,7 @@ module Linguist
|
|
|
110
106
|
|
|
111
107
|
# Internal: Return the heuristic's candidate languages
|
|
112
108
|
def languages
|
|
113
|
-
@rules.
|
|
114
|
-
[rule['language']].flatten(2).map { |name| Language[name] }
|
|
115
|
-
end.flatten.uniq
|
|
109
|
+
@rules.flat_map { |rule| rule['languages'] }.uniq
|
|
116
110
|
end
|
|
117
111
|
|
|
118
112
|
# Internal: Check if this heuristic matches the candidate filenames or
|
|
@@ -128,14 +122,7 @@ module Linguist
|
|
|
128
122
|
matched = @rules.find do |rule|
|
|
129
123
|
rule['pattern'].match?(data)
|
|
130
124
|
end
|
|
131
|
-
|
|
132
|
-
languages = matched['language']
|
|
133
|
-
if languages.is_a?(Array)
|
|
134
|
-
languages.map{ |l| Language[l] }
|
|
135
|
-
else
|
|
136
|
-
Language[languages]
|
|
137
|
-
end
|
|
138
|
-
end
|
|
125
|
+
matched ? matched['languages'].dup : []
|
|
139
126
|
end
|
|
140
127
|
end
|
|
141
128
|
|
data/lib/linguist/heuristics.yml
CHANGED
|
@@ -1190,7 +1190,7 @@ disambiguations:
|
|
|
1190
1190
|
pattern: '\ABEGIN:VCARD'
|
|
1191
1191
|
- extensions: ['.vim']
|
|
1192
1192
|
rules:
|
|
1193
|
-
- language: Vim9
|
|
1193
|
+
- language: Vim9 Script
|
|
1194
1194
|
pattern: '^\s*vim9script(?:\s+noclear)?\s*$'
|
|
1195
1195
|
- language: Vim script
|
|
1196
1196
|
- extensions: ['.w']
|