cr.rb 4.1.2 → 4.1.3
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/bin/cr +5 -2
- data/lib/cr/version.rb +1 -1
- data/lib/cr.rb +11 -9
- 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: 572931031815b1f284c44e722df17147b330a853439f79f0953946bfb42bb69d
|
4
|
+
data.tar.gz: 653b3090e8f85a8b962d3d62d0a3a5e362e65c4abb5db506b7b2d2091ff343ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f105ec4f493687a15e205b8ded554172a47369c5ed61a4dd0139ca335005cb73d56284c8bd881acb6f50b62fe89ae9a996a9dacecfaf0a1d0bffa53d107036bd
|
7
|
+
data.tar.gz: db01b4bdcc86d62017d043db81c561e1f5e14b56931aeaacf820b31c7f9ee8d524912dd0bdb78ef0ea011f4eb8697e8e6cd090a15e8b7888e14798a6ae060128
|
data/bin/cr
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# File : cr.rb
|
4
4
|
# Authors : ccmywish <ccmywish@qq.com>
|
5
5
|
# Created on : <2021-07-08>
|
6
|
-
# Last modified : <2023-02-
|
6
|
+
# Last modified : <2023-02-13>
|
7
7
|
#
|
8
8
|
# cr:
|
9
9
|
#
|
@@ -518,7 +518,10 @@ A info looks like this
|
|
518
518
|
|
519
519
|
# Try to match every word in all dicts
|
520
520
|
Dir.children(library).each do |dict|
|
521
|
-
|
521
|
+
|
522
|
+
path = File.join(library, dict)
|
523
|
+
next if File.file? path
|
524
|
+
sheets = Dir.children(path).select do
|
522
525
|
_1.end_with?('.toml')
|
523
526
|
end
|
524
527
|
|
data/lib/cr/version.rb
CHANGED
data/lib/cr.rb
CHANGED
@@ -186,13 +186,15 @@ class CrypticResolver::Resolver::Counter
|
|
186
186
|
@resolver = resolver
|
187
187
|
end
|
188
188
|
|
189
|
-
|
189
|
+
# a.toml
|
190
|
+
# b.toml
|
191
|
+
# ...
|
190
192
|
def count_dict_words(library, dict)
|
191
193
|
dict_dir = library + "/#{dict}"
|
192
194
|
wc = 0
|
193
195
|
Dir.children(dict_dir).each do |entry|
|
194
|
-
next if File.file? entry
|
195
196
|
next unless entry.end_with?('.toml')
|
197
|
+
next if File.directory? dict_dir + "/#{entry}"
|
196
198
|
sheet_content = @resolver.load_sheet(library, dict, entry.delete_suffix('.toml'))
|
197
199
|
count = sheet_content.keys.count
|
198
200
|
|
@@ -204,12 +206,13 @@ class CrypticResolver::Resolver::Counter
|
|
204
206
|
|
205
207
|
# Count default library
|
206
208
|
def count_def_lib(display: )
|
207
|
-
|
209
|
+
path = CrypticResolver::Resolver::DEFAULT_LIB_PATH
|
210
|
+
default_lib = Dir.children path
|
208
211
|
unless default_lib.empty?
|
209
212
|
puts bold(green("Default library: ")) if display
|
210
213
|
default_lib.each do |s|
|
211
|
-
next if File.file? s
|
212
|
-
wc = count_dict_words(
|
214
|
+
next if File.file? path + "/#{s}"
|
215
|
+
wc = count_dict_words(path,s)
|
213
216
|
@word_count_of_def_lib += wc
|
214
217
|
# With color, ljust not works, so we disable color
|
215
218
|
puts("#{wc.to_s.rjust(5)} #{s}") if display
|
@@ -222,12 +225,11 @@ class CrypticResolver::Resolver::Counter
|
|
222
225
|
# Count extra library
|
223
226
|
def count_extra_lib(display: )
|
224
227
|
if path = @resolver.extra_lib_path
|
225
|
-
extra_lib = Dir.children
|
228
|
+
extra_lib = Dir.children path
|
226
229
|
unless extra_lib.empty?
|
227
|
-
|
228
|
-
puts(bold(green("\nExtra library:"))) if display
|
230
|
+
puts bold(green("\nExtra library:")) if display
|
229
231
|
extra_lib.each do |s|
|
230
|
-
next if File.file? s
|
232
|
+
next if File.file? path + "/#{s}"
|
231
233
|
wc = count_dict_words(path,s)
|
232
234
|
@word_count_of_extra_lib += wc
|
233
235
|
puts("#{wc.to_s.rjust(5)} #{s}") if display
|