cr.rb 4.1.5 → 4.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1f71eca516d37dabb6a73e90451407b6c936b2d0139b2b6b92fbadd07005454
4
- data.tar.gz: ddedd7585a404db9aa922b829ffc359eaa10162fc950077fff5bec427905539a
3
+ metadata.gz: 7f2acb1b5dc93e60b954ae421a5e177694a14317b9883dfd54da40dbaefb2d97
4
+ data.tar.gz: e603d108e83f7f2b0ed1fc64d27ef2974a15a1ca44b7eb8de24b00869a2e5ef6
5
5
  SHA512:
6
- metadata.gz: 7bd500805cde6c9b3a28edd6fb0f1209254362f1701871af85f6d8631e5586e653dcb183707caa04c41e7dc54248503a0b420db6358e16397fc3aca623079b6a
7
- data.tar.gz: c2e28a15e1e1daf5b8435d01e62c633719eac7cb3e88bca724e13eeaaa1dac483b05bfa360510042b7743c323a33a638ca503f2b1e616e6a431d8622d125fcc3
6
+ metadata.gz: b568278c452502f466d4c3730e842df0757409612a2fddb322df44aa090a20deefaa208d5006cb066f6f65911efd8173b4fbb3c74790e50261420b05de5a2583
7
+ data.tar.gz: f0e2510cd01776c54878964a6e4bdaf7c6c3002e121e7ccaa2cc5d9e6bdd28ab92bddcfffe678514a0bd18668309485c7651968346c241fc30c9e3835c0631d3
data/exe/cr CHANGED
@@ -3,7 +3,7 @@
3
3
  # File : cr.rb
4
4
  # Authors : Aoran Zeng <ccmywish@qq.com>
5
5
  # Created on : <2021-07-08>
6
- # Last modified : <2023-05-09>
6
+ # Last modified : <2023-05-14>
7
7
  #
8
8
  # cr:
9
9
  #
@@ -29,12 +29,13 @@ module CrypticResolver::CLI
29
29
 
30
30
  case option
31
31
  when '-l' then reslvr.list_dicts
32
- when '-c' then reslvr.word_count
32
+ when '-c' then reslvr.count_words
33
33
  when '-u' then reslvr.update_dicts
34
- when '-s' then reslvr.search_word args.shift
35
- when '-a' then reslvr.add_dict args.shift
36
- when '-d' then reslvr.del_dict args.shift
37
- else reslvr.resolve_word option end
34
+ when '-s' then reslvr.search_related_words args.shift
35
+ when '-a' then reslvr.add_dict args.shift
36
+ when '-d' then reslvr.del_dict args.shift
37
+ else reslvr.resolve_word option
38
+ end
38
39
  end
39
40
 
40
41
 
data/lib/cr/counter.rb CHANGED
@@ -1,21 +1,18 @@
1
1
  # ---------------------------------------------------------------
2
2
  # File : counter.rb
3
3
  # Authors : Aoran Zeng <ccmywish@qq.com>
4
- # Created on : <2023-05-09>
5
- # Last modified : <2023-05-09>
4
+ # Created on : <2022-03-06>
5
+ # Last modified : <2023-05-14>
6
6
  #
7
7
  # counter:
8
8
  #
9
9
  # Count words in dictionaries.
10
- #
11
- # ----------
12
- # Changelog:
13
- #
14
- # <2023-05-09> Moved from lib/cr.rb
15
10
  # ---------------------------------------------------------------
16
11
 
17
12
  class CrypticResolver::Resolver::Counter
18
13
 
14
+ using Rainbow
15
+
19
16
  attr_accessor :word_count_of_two_libs, # def_lib + extra_lib
20
17
  :word_count_of_def_lib,
21
18
  :word_count_of_extra_lib,
data/lib/cr/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # File : version.rb
3
3
  # Authors : Aoran Zeng <ccmywish@qq.com>
4
4
  # Created on : <2023-02-12>
5
- # Last modified : <2023-05-09>
5
+ # Last modified : <2023-05-15>
6
6
  #
7
7
  # version:
8
8
  #
@@ -11,6 +11,6 @@
11
11
 
12
12
  module CrypticResolver
13
13
 
14
- GEM_VERSION = "4.1.5"
14
+ GEM_VERSION = "4.1.6"
15
15
 
16
16
  end
data/lib/cr.rb CHANGED
@@ -2,22 +2,20 @@
2
2
  # File : cr.rb
3
3
  # Authors : Aoran Zeng <ccmywish@qq.com>
4
4
  # Created on : <2022-04-15>
5
- # Last modified : <2023-05-09>
5
+ # Last modified : <2023-05-14>
6
6
  #
7
7
  # cr:
8
8
  #
9
9
  # This file is the lib of `cr.rb``
10
10
  # ------------------------------------------------------
11
11
 
12
- require 'colorator'
12
+ require 'rainbow/refinement'
13
13
  require_relative 'cr/version'
14
14
 
15
- class String
16
- def underline = "\e[4m#{self}\e[0m"
17
- end
18
-
19
15
  class CrypticResolver::Resolver
20
16
 
17
+ using Rainbow
18
+
21
19
  require_relative 'cr/counter'
22
20
 
23
21
  # Notice that we only update the Default library, not Extra library
@@ -277,8 +275,6 @@ A info looks like this
277
275
  end
278
276
 
279
277
 
280
-
281
- #
282
278
  # Lookup the given word in a sheet (a toml file) and also print.
283
279
  # The core idea is that:
284
280
  #
@@ -367,7 +363,6 @@ A info looks like this
367
363
  end
368
364
 
369
365
 
370
- #
371
366
  # The main procedure of `cr`
372
367
  #
373
368
  # 1. Search the default library first
@@ -422,16 +417,15 @@ A info looks like this
422
417
  end
423
418
 
424
419
 
425
- #
426
420
  # Delegate to `search_word_internal`
427
421
  #
428
- def search_word(pattern)
422
+ def search_related_words(pattern)
429
423
  found_or_not1 = false
430
424
  found_or_not2 = false
431
425
 
432
- found_or_not1 = search_word_internal(pattern, DEFAULT_LIB_PATH)
426
+ found_or_not1 = search_related_words_internal(pattern, DEFAULT_LIB_PATH)
433
427
  if @extra_lib_path
434
- found_or_not2 = search_word_internal(pattern, @extra_lib_path)
428
+ found_or_not2 = search_related_words_internal(pattern, @extra_lib_path)
435
429
  end
436
430
 
437
431
  if (found_or_not1 == false) && (found_or_not2 == false)
@@ -439,8 +433,9 @@ A info looks like this
439
433
  end
440
434
  end
441
435
 
436
+
437
+ # This routine is quite like `resolve_word`
442
438
  #
443
- # This `search_word_internal` routine is quite like `resolve_word`
444
439
  # Notice:
445
440
  # We handle two cases
446
441
  #
@@ -449,7 +444,7 @@ A info looks like this
449
444
  #
450
445
  # The second is what Ruby and Perl users like to do, handle it!
451
446
  #
452
- def search_word_internal(pattern, library)
447
+ def search_related_words_internal(pattern, library)
453
448
 
454
449
  if pattern.nil?
455
450
  abort "cr: Need an argument!".bold.red
@@ -532,7 +527,7 @@ A info looks like this
532
527
  end
533
528
 
534
529
 
535
- def word_count
530
+ def count_words
536
531
  @counter.count!(display: true)
537
532
  end
538
533
 
@@ -542,6 +537,8 @@ end
542
537
 
543
538
  class CrypticResolver::Resolver
544
539
 
540
+ using Rainbow
541
+
545
542
  require 'tomlrb'
546
543
  require 'fileutils'
547
544
 
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.5
4
+ version: 4.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aoran Zeng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-09 00:00:00.000000000 Z
11
+ date: 2023-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: colorator
42
+ name: rainbow
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.1'
47
+ version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.1'
54
+ version: '3.1'
55
55
  description: |
56
56
  This command line tool `cr` is used to record and explain cryptic commands, acronyms(initialism), abbreviations and so forth in daily life.
57
57
  Not only can it be used in computer filed via our default sheet cryptic_computer, but also you can use this to manage your own knowledge base easily.
@@ -89,5 +89,5 @@ requirements: []
89
89
  rubygems_version: 3.4.8
90
90
  signing_key:
91
91
  specification_version: 4
92
- summary: 'cr: Cryptic Resolver'
92
+ summary: Resolve cryptic commands/acronyms on the command line
93
93
  test_files: []