clausewitz-spelling 0.2.17 → 0.2.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/clausewitz/spelling/checker.rb +25 -21
- data/lib/clausewitz/spelling/results.rb +35 -0
- data/lib/clausewitz/spelling/version.rb +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: ddafbaefcfa38ddf7a3fb270d49d88bf12833b63423e4ca39ecfff7a2fb24763
|
4
|
+
data.tar.gz: 2a3b7a8111741d88c2c198f64c442485d3cabaa42f29eadc0812e6969fb52162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e1976d6d96abf18f713a6d14c6649669700f377642cfeba128e4ec7943d80c5c05a91c8e229b9e187c71065ed9e6d06381da50ca428a2d556f3afb65564db23
|
7
|
+
data.tar.gz: a8513b7b18b001182918c55861aca28760c1fff2c7e38ede6d5777a82d93905c21d4a975f7794fbd0ab84acd974adb88a42de96575a5aebfaa500facbcfb79ca
|
data/Gemfile.lock
CHANGED
@@ -26,31 +26,27 @@ module Clausewitz; module Spelling
|
|
26
26
|
@commit_range = opts[:commit_range]
|
27
27
|
|
28
28
|
@check_cache = {}
|
29
|
-
|
30
|
-
load_dictionaries!
|
29
|
+
@loaded_dicts = {}
|
31
30
|
end
|
32
31
|
|
33
|
-
def
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
config.select_dialect(@dialect_map[config.name])
|
38
|
-
end
|
32
|
+
def load_dictionary!(config)
|
33
|
+
if @dialect_map.key?(config.name)
|
34
|
+
config.select_dialect(@dialect_map[config.name])
|
35
|
+
end
|
39
36
|
|
40
|
-
|
37
|
+
dict = FFI::Hunspell.dict(config.full_name)
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
39
|
+
@custom_dicts.each do |custom_dict|
|
40
|
+
path = @custom_dict_root.join("#{config.full_name}_#{custom_dict}")
|
41
|
+
path = Pathname.new("#{path}.dic")
|
42
|
+
if path.exist?
|
43
|
+
dict.add_dic(path.to_s)
|
44
|
+
else
|
45
|
+
$stderr.puts("Could not load dictionary '#{path}', skipping...")
|
50
46
|
end
|
51
|
-
|
52
|
-
@loaded_dicts[config.name] = dict
|
53
47
|
end
|
48
|
+
|
49
|
+
@loaded_dicts[config.name] = dict
|
54
50
|
end
|
55
51
|
|
56
52
|
def check_file(filepath)
|
@@ -90,14 +86,22 @@ module Clausewitz; module Spelling
|
|
90
86
|
end
|
91
87
|
|
92
88
|
checks = contents.map do |lang_name, entries|
|
93
|
-
lc = language_config(lang_name)
|
94
89
|
if @commit_range
|
95
90
|
ignore = entries&.keys&.select do |key|
|
96
91
|
!changed_keys.include?(key)
|
97
92
|
end
|
98
93
|
end
|
99
94
|
ignore ||= []
|
100
|
-
|
95
|
+
lc = language_config(lang_name)
|
96
|
+
begin
|
97
|
+
load_dictionary!(lc) unless @loaded_dicts.keys.include?(lang_name)
|
98
|
+
rescue ArgumentError => e
|
99
|
+
if e.message =~ /unable to find the dictionary/
|
100
|
+
MissingLangResult.new(lc.clausewitz_name)
|
101
|
+
end
|
102
|
+
else
|
103
|
+
check_entries(entries, lc, ignore)
|
104
|
+
end
|
101
105
|
end
|
102
106
|
FileResults.new(filepath, checks)
|
103
107
|
end
|
@@ -84,6 +84,41 @@ module Clausewitz; module Spelling
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
class MissingLangResult
|
88
|
+
def initialize(lang)
|
89
|
+
@lang = lang
|
90
|
+
end
|
91
|
+
|
92
|
+
def ignored?
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
def ignored
|
97
|
+
[]
|
98
|
+
end
|
99
|
+
|
100
|
+
def failed?
|
101
|
+
true
|
102
|
+
end
|
103
|
+
|
104
|
+
def failures
|
105
|
+
[]
|
106
|
+
end
|
107
|
+
|
108
|
+
def size
|
109
|
+
0
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_s
|
113
|
+
to_str
|
114
|
+
end
|
115
|
+
|
116
|
+
def to_str(indent = 0)
|
117
|
+
firstspacer = ' ' * indent
|
118
|
+
"#{firstspacer}#{@lang} failed - missing #{@lang} dictionaries!".red
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
87
122
|
class IgnoredLangResult
|
88
123
|
def initialize(lang)
|
89
124
|
@lang = lang
|