cr.rb 3.17.0 → 3.18.2
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 +29 -27
- data/lib/cr.rb +13 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca8565c920ad88810679a65744a52f0c9497ef3a75bab525fae5b501349912b7
|
4
|
+
data.tar.gz: f6d7f3c3f85caa6382f13492a94a34725600cb5ea57757442cd76a9b69360461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0482249c89b01522d0cb563fe4e0e647c4c4cbb602090fb1ba740fc366c892c039b02242987031494b6077df0365ff5416ccb00eb61b929a085760349f5a00
|
7
|
+
data.tar.gz: c775012412a10c1fea53f43055f7bd95add6ba9954327d77f182f157556c346de160855348847004aa634700494bdc486eed937b632ae1b5cac31c0c90ca1da4
|
data/bin/cr
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# File : cr.rb
|
5
5
|
# Authors : ccmywish <ccmywish@qq.com>
|
6
6
|
# Created on : <2021-07-08>
|
7
|
-
# Last modified : <2022-04-
|
7
|
+
# Last modified : <2022-04-15>
|
8
8
|
#
|
9
9
|
# cr:
|
10
10
|
#
|
@@ -14,6 +14,7 @@
|
|
14
14
|
#
|
15
15
|
# ------------------------------------------------------
|
16
16
|
|
17
|
+
require 'cr'
|
17
18
|
require 'tomlrb'
|
18
19
|
require 'fileutils'
|
19
20
|
|
@@ -26,8 +27,6 @@ CRYPTIC_DEFAULT_DICTS = {
|
|
26
27
|
medicine: "https://github.com/cryptic-resolver/cryptic_medicine.git"
|
27
28
|
}
|
28
29
|
|
29
|
-
CR_GEM_VERSION = "3.17.0"
|
30
|
-
|
31
30
|
|
32
31
|
####################
|
33
32
|
# helper: for color
|
@@ -156,6 +155,9 @@ def add_dict(repo)
|
|
156
155
|
exit -1
|
157
156
|
end
|
158
157
|
|
158
|
+
# Ensure the cr home dir exists
|
159
|
+
FileUtils.mkdir_p(CRYPTIC_RESOLVER_HOME)
|
160
|
+
|
159
161
|
begin
|
160
162
|
puts "cr: Adding new dictionary..."
|
161
163
|
`git -C #{CRYPTIC_RESOLVER_HOME} clone #{repo} -q`
|
@@ -211,26 +213,26 @@ end
|
|
211
213
|
#
|
212
214
|
# A info looks like this
|
213
215
|
# emacs = {
|
214
|
-
#
|
216
|
+
# name = "Emacs"
|
215
217
|
# desc = "edit macros"
|
216
|
-
#
|
218
|
+
# more = "a feature-rich editor"
|
217
219
|
# see = ["Vim"]
|
218
220
|
# }
|
219
221
|
#
|
220
222
|
# @param info [Hash] the information of the given word (mapped to a keyword in TOML)
|
221
223
|
#
|
222
224
|
def pp_info(info)
|
223
|
-
|
225
|
+
name = info['name'] || red("No name!") # keyword `or` is invalid here in Ruby
|
224
226
|
|
225
227
|
desc = info['desc']
|
226
|
-
|
228
|
+
more = info['more']
|
227
229
|
|
228
230
|
if desc
|
229
|
-
puts "\n #{
|
230
|
-
print "\n ",
|
231
|
+
puts "\n #{name}: #{desc}"
|
232
|
+
print "\n ",more,"\n" if more
|
231
233
|
else
|
232
|
-
puts "\n #{
|
233
|
-
print "\n ",
|
234
|
+
puts "\n #{name}"
|
235
|
+
print "\n ",more,"\n" if more
|
234
236
|
end
|
235
237
|
|
236
238
|
if see_also = info['see']
|
@@ -265,7 +267,7 @@ end
|
|
265
267
|
# same = "XDG downloader <=>xdg.Download" # this is correct
|
266
268
|
#
|
267
269
|
# [blah]
|
268
|
-
#
|
270
|
+
# name = "BlaH" # You may want to display a better name first
|
269
271
|
# same = "XDG downloader <=>xdg.Download" # this is correct
|
270
272
|
#
|
271
273
|
#
|
@@ -342,7 +344,7 @@ def pp_same_info(dict, word, cache_content, same_key, own_name)
|
|
342
344
|
return false
|
343
345
|
# double or more jumps
|
344
346
|
elsif same_key = info['same']
|
345
|
-
own_name = info['
|
347
|
+
own_name = info['name']
|
346
348
|
return pp_same_info(dict, same, cache_content, same_key, own_name)
|
347
349
|
else
|
348
350
|
pp_info(info)
|
@@ -391,7 +393,7 @@ def lookup(dict, file, word)
|
|
391
393
|
|
392
394
|
# synonym info print
|
393
395
|
if same_key = info['same']
|
394
|
-
own_name = info['
|
396
|
+
own_name = info['name']
|
395
397
|
pp_dict(dict)
|
396
398
|
pp_same_info(dict, word, sheet_content, same_key, own_name)
|
397
399
|
# It's also a type 1
|
@@ -401,14 +403,14 @@ def lookup(dict, file, word)
|
|
401
403
|
|
402
404
|
# normal info print
|
403
405
|
# To developer:
|
404
|
-
# The word should at least has one of `desc` and `
|
406
|
+
# The word should at least has one of `desc` and `more`
|
405
407
|
# But when none exists, this may not be considered wrong,
|
406
408
|
# Because the type2 make the case too.
|
407
409
|
#
|
408
410
|
# So, just ignore it, even if it's really a mistake(insignificant)
|
409
411
|
# by dictionary maintainers.
|
410
412
|
#
|
411
|
-
if !is_jump && (info.has_key?('desc') || info.has_key?('
|
413
|
+
if !is_jump && (info.has_key?('desc') || info.has_key?('more'))
|
412
414
|
pp_dict(dict)
|
413
415
|
pp_info(info)
|
414
416
|
type_1_exist_flag = true
|
@@ -416,7 +418,7 @@ def lookup(dict, file, word)
|
|
416
418
|
|
417
419
|
# Meanings with category specifier
|
418
420
|
# We call this meaning as type 2
|
419
|
-
categories = info.keys - ["
|
421
|
+
categories = info.keys - ["name", "desc", "more", "same", "see"]
|
420
422
|
|
421
423
|
if !categories.empty?
|
422
424
|
|
@@ -429,7 +431,7 @@ def lookup(dict, file, word)
|
|
429
431
|
categories.each do |meaning|
|
430
432
|
info0 = sheet_content[word][meaning]
|
431
433
|
if same_key = info0['same']
|
432
|
-
own_name = info0['
|
434
|
+
own_name = info0['name']
|
433
435
|
pp_same_info(dict, word, sheet_content, same_key, own_name)
|
434
436
|
else
|
435
437
|
pp_info(info0)
|
@@ -580,15 +582,15 @@ def help
|
|
580
582
|
cr: Cryptic Resolver v#{CR_GEM_VERSION} (#{$WordCount} words: default/#{$DefaultWordCount} user/#{user_words})
|
581
583
|
|
582
584
|
usage:
|
583
|
-
cr -v
|
584
|
-
cr -h
|
585
|
-
cr -c
|
586
|
-
cr -l
|
587
|
-
cr -u
|
588
|
-
cr -a
|
589
|
-
cr -d cryptic_xx
|
590
|
-
cr -s pattern
|
591
|
-
cr emacs
|
585
|
+
cr -v => Print version
|
586
|
+
cr -h => Print this help
|
587
|
+
cr -c => Print word count
|
588
|
+
cr -l => List local dictionaries
|
589
|
+
cr -u => Update all dictionaries
|
590
|
+
cr -a repo.git => Add a new dictionary
|
591
|
+
cr -d cryptic_xx => Delete a dictionary
|
592
|
+
cr -s pattern => Search words matched with pattern
|
593
|
+
cr emacs => Edit macros: a feature-rich editor
|
592
594
|
|
593
595
|
HELP
|
594
596
|
|
data/lib/cr.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# ------------------------------------------------------
|
2
|
+
# File : cr.rb
|
3
|
+
# Authors : ccmywish <ccmywish@qq.com>
|
4
|
+
# Created on : <2022-04-15>
|
5
|
+
# Last modified : <2022-04-15>
|
6
|
+
#
|
7
|
+
# cr:
|
8
|
+
#
|
9
|
+
# This file is just a lib
|
10
|
+
#
|
11
|
+
# ------------------------------------------------------
|
12
|
+
|
13
|
+
CR_GEM_VERSION = "3.18.2"
|
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: 3.
|
4
|
+
version: 3.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ccmywish
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|
@@ -48,12 +48,13 @@ extensions: []
|
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
50
|
- bin/cr
|
51
|
-
|
51
|
+
- lib/cr.rb
|
52
|
+
homepage: https://github.com/cryptic-resolver/cr.rb
|
52
53
|
licenses:
|
53
54
|
- MIT
|
54
55
|
metadata:
|
55
|
-
bug_tracker_uri: https://github.com/cryptic-resolver/cr/issues
|
56
|
-
source_code_uri: https://github.com/cryptic-resolver/cr
|
56
|
+
bug_tracker_uri: https://github.com/cryptic-resolver/cr.rb/issues
|
57
|
+
source_code_uri: https://github.com/cryptic-resolver/cr.rb
|
57
58
|
post_install_message:
|
58
59
|
rdoc_options: []
|
59
60
|
require_paths:
|
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
70
|
- !ruby/object:Gem::Version
|
70
71
|
version: '0'
|
71
72
|
requirements: []
|
72
|
-
rubygems_version: 3.3.
|
73
|
+
rubygems_version: 3.3.11
|
73
74
|
signing_key:
|
74
75
|
specification_version: 4
|
75
76
|
summary: 'cr: Cryptic Resolver'
|