cr.rb 4.1.2 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cr +5 -2
  3. data/lib/cr/version.rb +1 -1
  4. data/lib/cr.rb +11 -9
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4956248002fc5393f2a85f894239434599f1c10535f90f8f7f80c5996a7b395
4
- data.tar.gz: 4000408dedca70e9234130de2fbf66df60e6973c895f806667e6401e458b5090
3
+ metadata.gz: 572931031815b1f284c44e722df17147b330a853439f79f0953946bfb42bb69d
4
+ data.tar.gz: 653b3090e8f85a8b962d3d62d0a3a5e362e65c4abb5db506b7b2d2091ff343ab
5
5
  SHA512:
6
- metadata.gz: 425899ebb33d5fc54080dc4c50583e678442d8f6110f1dfbe1134e96ea5d1d9c2c34665575b0145ec374fdd71d88f8646817be930f44ece8437d9967b2de92c2
7
- data.tar.gz: 84f8c04209eec1c16183eabb511b9a9fd686008e0aaa1cc8525238f61f50195a0b8623010dd7a6fbfab9f7eea0391d06c73fcd123ac77e8fa77a729c4f3cbe41
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-12>
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
- sheets = Dir.children(File.join(library, dict)).select do
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
@@ -11,6 +11,6 @@
11
11
 
12
12
  module CrypticResolver
13
13
 
14
- GEM_VERSION = "4.1.2"
14
+ GEM_VERSION = "4.1.3"
15
15
 
16
16
  end
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
- default_lib = Dir.children(CrypticResolver::Resolver::DEFAULT_LIB_PATH)
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(CrypticResolver::Resolver::DEFAULT_LIB_PATH,s)
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(path)
228
+ extra_lib = Dir.children path
226
229
  unless extra_lib.empty?
227
- wc = 0
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cr.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aoran Zeng