cr.rb 4.1.2 → 4.1.4
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 +21 -11
- data/lib/cr/version.rb +2 -2
- data/lib/cr.rb +15 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 624c2bec73d0e1c7af063aec76ce582a38a2b73c56d8680a3d67a8f293b8695b
|
4
|
+
data.tar.gz: 49b1c1aa5c178087d94e70d3110c7a7e3b479478723be80c5ff67467c05d1634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83b2810d78b2081006474f50df69ab8765327c8c9715d491204548ac4bd5f0c17edb30c5b551a9d30c0d825d93b8d709258a13dc359aa3fce9c9e9c0379893dd
|
7
|
+
data.tar.gz: 98c6ac9a3eb0273097d24144013477c7d11cc20ed3818ac79c1779e72b0aad932573b0e39bda08ac1c8c14588ab6929dc2bad6e920e7e287df6e0454b15db9be
|
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-
|
6
|
+
# Last modified : <2023-03-22>
|
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
|
|
@@ -553,24 +556,31 @@ A info looks like this
|
|
553
556
|
# 2. List Extra library's dicts
|
554
557
|
# 3. List official dicts
|
555
558
|
def list_dicts
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
559
|
+
|
560
|
+
def _do_the_same_thing
|
561
|
+
count = 0
|
562
|
+
Dir.children(".").each do |dict|
|
563
|
+
next if File.file? dict
|
564
|
+
count += 1
|
565
|
+
prefix = (count.to_s + '.').ljust 4
|
566
|
+
puts " #{prefix}#{dict}"
|
560
567
|
end
|
561
568
|
end
|
562
569
|
|
570
|
+
Dir.chdir DEFAULT_LIB_PATH do
|
571
|
+
puts bold(green("Default library: #{DEFAULT_LIB_PATH}"))
|
572
|
+
_do_the_same_thing
|
573
|
+
end
|
574
|
+
|
563
575
|
if @extra_lib_path
|
564
576
|
puts
|
565
577
|
Dir.chdir @extra_lib_path do
|
566
|
-
puts
|
567
|
-
|
568
|
-
puts "#{blue(i+1)}. #{bold(green(dict))}"
|
569
|
-
end
|
578
|
+
puts bold(green("Extra library: #{@extra_lib_path}"))
|
579
|
+
_do_the_same_thing
|
570
580
|
end
|
571
581
|
end
|
572
582
|
|
573
|
-
puts ; puts
|
583
|
+
puts ; puts bold(green("Official dictionaries: (Add it by 'cr -a xxx')"))
|
574
584
|
puts RECOMMENDED_DICTS
|
575
585
|
end
|
576
586
|
|
data/lib/cr/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# File : version.rb
|
3
3
|
# Authors : ccmywish <ccmywish@qq.com>
|
4
4
|
# Created on : <2023-02-12>
|
5
|
-
# Last modified : <2023-
|
5
|
+
# Last modified : <2023-03-22>
|
6
6
|
#
|
7
7
|
# version:
|
8
8
|
#
|
@@ -11,6 +11,6 @@
|
|
11
11
|
|
12
12
|
module CrypticResolver
|
13
13
|
|
14
|
-
GEM_VERSION = "4.1.
|
14
|
+
GEM_VERSION = "4.1.4"
|
15
15
|
|
16
16
|
end
|
data/lib/cr.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# File : cr.rb
|
3
3
|
# Authors : ccmywish <ccmywish@qq.com>
|
4
4
|
# Created on : <2022-04-15>
|
5
|
-
# Last modified : <2023-
|
5
|
+
# Last modified : <2023-03-22>
|
6
6
|
#
|
7
7
|
# cr:
|
8
8
|
#
|
@@ -55,15 +55,14 @@ class CrypticResolver::Resolver
|
|
55
55
|
linux technology
|
56
56
|
|
57
57
|
#{yellow("Field:")}
|
58
|
-
|
59
|
-
|
58
|
+
economy medicine electronics
|
59
|
+
science math
|
60
60
|
|
61
61
|
#{yellow("Specific:")}
|
62
|
-
|
62
|
+
x86 signal
|
63
63
|
|
64
64
|
#{yellow("Feature:")}
|
65
65
|
ccmywish/CRuby-Source-Code-Dictionary
|
66
|
-
ccmywish/mruby-Source-Code-Dictionary
|
67
66
|
|
68
67
|
EOF
|
69
68
|
|
@@ -186,13 +185,15 @@ class CrypticResolver::Resolver::Counter
|
|
186
185
|
@resolver = resolver
|
187
186
|
end
|
188
187
|
|
189
|
-
|
188
|
+
# a.toml
|
189
|
+
# b.toml
|
190
|
+
# ...
|
190
191
|
def count_dict_words(library, dict)
|
191
192
|
dict_dir = library + "/#{dict}"
|
192
193
|
wc = 0
|
193
194
|
Dir.children(dict_dir).each do |entry|
|
194
|
-
next if File.file? entry
|
195
195
|
next unless entry.end_with?('.toml')
|
196
|
+
next if File.directory? dict_dir + "/#{entry}"
|
196
197
|
sheet_content = @resolver.load_sheet(library, dict, entry.delete_suffix('.toml'))
|
197
198
|
count = sheet_content.keys.count
|
198
199
|
|
@@ -204,12 +205,13 @@ class CrypticResolver::Resolver::Counter
|
|
204
205
|
|
205
206
|
# Count default library
|
206
207
|
def count_def_lib(display: )
|
207
|
-
|
208
|
+
path = CrypticResolver::Resolver::DEFAULT_LIB_PATH
|
209
|
+
default_lib = Dir.children path
|
208
210
|
unless default_lib.empty?
|
209
211
|
puts bold(green("Default library: ")) if display
|
210
212
|
default_lib.each do |s|
|
211
|
-
next if File.file? s
|
212
|
-
wc = count_dict_words(
|
213
|
+
next if File.file? path + "/#{s}"
|
214
|
+
wc = count_dict_words(path,s)
|
213
215
|
@word_count_of_def_lib += wc
|
214
216
|
# With color, ljust not works, so we disable color
|
215
217
|
puts("#{wc.to_s.rjust(5)} #{s}") if display
|
@@ -222,12 +224,11 @@ class CrypticResolver::Resolver::Counter
|
|
222
224
|
# Count extra library
|
223
225
|
def count_extra_lib(display: )
|
224
226
|
if path = @resolver.extra_lib_path
|
225
|
-
extra_lib = Dir.children
|
227
|
+
extra_lib = Dir.children path
|
226
228
|
unless extra_lib.empty?
|
227
|
-
|
228
|
-
puts(bold(green("\nExtra library:"))) if display
|
229
|
+
puts bold(green("\nExtra library:")) if display
|
229
230
|
extra_lib.each do |s|
|
230
|
-
next if File.file? s
|
231
|
+
next if File.file? path + "/#{s}"
|
231
232
|
wc = count_dict_words(path,s)
|
232
233
|
@word_count_of_extra_lib += wc
|
233
234
|
puts("#{wc.to_s.rjust(5)} #{s}") if display
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cr.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aoran Zeng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
|
-
rubygems_version: 3.4.
|
74
|
+
rubygems_version: 3.4.8
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: 'cr: Cryptic Resolver'
|