cr.rb 4.1.1 → 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 +22 -11
- 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
@@ -153,8 +153,10 @@ class CrypticResolver::Resolver
|
|
153
153
|
abort "cr: Cancel add default dicts"
|
154
154
|
end
|
155
155
|
|
156
|
-
puts "cr: Add done" ;
|
157
|
-
|
156
|
+
puts "cr: Add done" ;
|
157
|
+
@counter.count_def_lib(display: false)
|
158
|
+
puts ; puts "#{@counter.word_count_of_def_lib} words added"
|
159
|
+
@counter.reset!
|
158
160
|
|
159
161
|
# Really added
|
160
162
|
return true
|
@@ -184,13 +186,15 @@ class CrypticResolver::Resolver::Counter
|
|
184
186
|
@resolver = resolver
|
185
187
|
end
|
186
188
|
|
187
|
-
|
189
|
+
# a.toml
|
190
|
+
# b.toml
|
191
|
+
# ...
|
188
192
|
def count_dict_words(library, dict)
|
189
193
|
dict_dir = library + "/#{dict}"
|
190
194
|
wc = 0
|
191
195
|
Dir.children(dict_dir).each do |entry|
|
192
|
-
next if File.file? entry
|
193
196
|
next unless entry.end_with?('.toml')
|
197
|
+
next if File.directory? dict_dir + "/#{entry}"
|
194
198
|
sheet_content = @resolver.load_sheet(library, dict, entry.delete_suffix('.toml'))
|
195
199
|
count = sheet_content.keys.count
|
196
200
|
|
@@ -202,12 +206,13 @@ class CrypticResolver::Resolver::Counter
|
|
202
206
|
|
203
207
|
# Count default library
|
204
208
|
def count_def_lib(display: )
|
205
|
-
|
209
|
+
path = CrypticResolver::Resolver::DEFAULT_LIB_PATH
|
210
|
+
default_lib = Dir.children path
|
206
211
|
unless default_lib.empty?
|
207
212
|
puts bold(green("Default library: ")) if display
|
208
213
|
default_lib.each do |s|
|
209
|
-
next if File.file? s
|
210
|
-
wc = count_dict_words(
|
214
|
+
next if File.file? path + "/#{s}"
|
215
|
+
wc = count_dict_words(path,s)
|
211
216
|
@word_count_of_def_lib += wc
|
212
217
|
# With color, ljust not works, so we disable color
|
213
218
|
puts("#{wc.to_s.rjust(5)} #{s}") if display
|
@@ -220,12 +225,11 @@ class CrypticResolver::Resolver::Counter
|
|
220
225
|
# Count extra library
|
221
226
|
def count_extra_lib(display: )
|
222
227
|
if path = @resolver.extra_lib_path
|
223
|
-
extra_lib = Dir.children
|
228
|
+
extra_lib = Dir.children path
|
224
229
|
unless extra_lib.empty?
|
225
|
-
|
226
|
-
puts(bold(green("\nExtra library:"))) if display
|
230
|
+
puts bold(green("\nExtra library:")) if display
|
227
231
|
extra_lib.each do |s|
|
228
|
-
next if File.file? s
|
232
|
+
next if File.file? path + "/#{s}"
|
229
233
|
wc = count_dict_words(path,s)
|
230
234
|
@word_count_of_extra_lib += wc
|
231
235
|
puts("#{wc.to_s.rjust(5)} #{s}") if display
|
@@ -249,4 +253,11 @@ class CrypticResolver::Resolver::Counter
|
|
249
253
|
end
|
250
254
|
end
|
251
255
|
|
256
|
+
|
257
|
+
def reset!
|
258
|
+
@word_count_of_two_libs = 0
|
259
|
+
@word_count_of_def_lib = 0
|
260
|
+
@word_count_of_extra_lib = 0
|
261
|
+
end
|
262
|
+
|
252
263
|
end
|