cr.rb 4.0.0.alpha.1 → 4.0.0.alpha.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cr +36 -21
  3. data/lib/cr.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf84244ffcf5db536a394a4c7c6ad9679485be53d56baf821bca8a228dd4241b
4
- data.tar.gz: 13393a7e9fd9e86d021ef39e830de56ffa548c8159cf172af61c6631e1d2ee93
3
+ metadata.gz: 1cab1b378efd946710c171f3dc45c994c5cc76a3b6672fc25fc696aa017dbb29
4
+ data.tar.gz: b7e9b9e5d3834ac18e898e9024cf4573f15197d00cc746f50685ea30f68efc9e
5
5
  SHA512:
6
- metadata.gz: f0e9316fb7d0e073600e815292c6ef3279cec61275a94ded64ddde456784027eb15d62c239ce953f1036212a8429546240af33bba371667d3f4958a71c823afb
7
- data.tar.gz: fa316a2e6003409ba527d7ebb86ba474ebc97a3982e79826ed117a4c52b0bb6b3cfaf9b254c135db44484e9faaaee43d7fe6c956dd536dc234a934b38cf3ddc2
6
+ metadata.gz: f75f57865bd0651a336d2ca553c5745974f892ffa5841fb4a3420efd1714ae1e08835632f77c45f5610002cae1190dc1d9e49c68a46865d576f91b114a56b134
7
+ data.tar.gz: 422bc7721e40f6878bea1f47c7781e0a8fa81e982eb9dfd1fdb9e766ea4bca753c84203c231aa96b04c0de083ca711a9c4d738ed94ee08dd79b66084e3b103e7
data/bin/cr CHANGED
@@ -54,6 +54,15 @@ else
54
54
  end
55
55
 
56
56
 
57
+ # Prevent runtime error
58
+ if not CR_EXTRA_LIBRARY.nil?
59
+ if ! test('d', CR_EXTRA_LIBRARY)
60
+ puts "FATAL: Your CRYPTIC_RESOLVER_CONFIG's option 'EXTRA_LIBRARY' is NOT a legal directory!"
61
+ exit 1
62
+ end
63
+ end
64
+
65
+
57
66
  # This is used to display what you are pulling when adding dicts
58
67
  CR_DEFAULT_DICTS_USER_AND_NAMES = CR_DEFAULT_DICTS.map do |e|
59
68
  user, repo = e.split('/').last(2)
@@ -313,11 +322,11 @@ end
313
322
  # # category
314
323
  #
315
324
  # [blah]
316
- # same = "XDG downloader <=>xdg.Download" # this is correct
325
+ # same = "XDG downloader =>xdg.Download" # this is correct
317
326
  #
318
327
  # [blah]
319
328
  # name = "BlaH" # You may want to display a better name first
320
- # same = "XDG downloader <=>xdg.Download" # this is correct
329
+ # same = "XDG downloader =>xdg.Download" # this is correct
321
330
  #
322
331
  #
323
332
  def pp_same_info(library, dict, word, cache_content, same_key, own_name)
@@ -339,13 +348,13 @@ def pp_same_info(library, dict, word, cache_content, same_key, own_name)
339
348
  #
340
349
  # 'jump to' will output to user, so this is important not only inside our sheet.
341
350
  #
342
- # same = "XDM downloader<=>xdm.Download"
351
+ # same = "XDM downloader=>xdm.Download"
343
352
  #
344
- # We split 'same' key into two parts via spaceship symbol <=>, first part will
353
+ # We split 'same' key into two parts via spaceship symbol `=>`, first part will
345
354
  # output to user, the second part is for internal jump.
346
355
  #
347
356
 
348
- jump_to, same = same_key.split("<=>")
357
+ jump_to, same = same_key.split("=>")
349
358
  same = jump_to if same.nil?
350
359
 
351
360
  unless own_name
@@ -517,7 +526,7 @@ def resolve_word(word)
517
526
  index = word.chr
518
527
  case index
519
528
  when '0'..'9'
520
- index = '0123456789'
529
+ index = '0-9'
521
530
  end
522
531
 
523
532
  # cache lookup's results
@@ -543,9 +552,12 @@ cr: Not found anything.
543
552
 
544
553
  You may
545
554
  1. Use `cr -u` to update all dicts
546
- 2. Use `cr -a user/repo` to add more available dicts
547
-
548
- See: https://github.com/cryptic-resolver
555
+
556
+ 2. Use
557
+
558
+ `cr -l` to list available official dicts
559
+
560
+ `cr -a repo` to add some dicts
549
561
 
550
562
  3. Contribute to theses dicts
551
563
 
@@ -634,11 +646,11 @@ Usage:
634
646
  cr emacs => Edit macros: A feature-rich editor
635
647
  cr -c => Print word count
636
648
  cr -l => List local dicts and official dicts
637
- cr -u => Update all dicts in default library
649
+ cr -u => Update all dicts in Default library
638
650
 
639
651
  cr -a repo.git => Add a new dict
640
652
  cr -a user/repo => Add a new dict from Github
641
- cr -a reponame => Add an official dict from Github
653
+ cr -a repo => Add an official dict from Github
642
654
 
643
655
  cr -d cryptic_xx => Delete a dict
644
656
  cr -s pattern => Search words matched with pattern
@@ -716,7 +728,6 @@ def word_count(p:)
716
728
  is_there_any_dict?
717
729
 
718
730
  default_lib = Dir.children(CR_DEFAULT_LIBRARY)
719
- extra_lib = Dir.children(CR_EXTRA_LIBRARY)
720
731
 
721
732
  # Count default library
722
733
  unless default_lib.empty?
@@ -729,17 +740,21 @@ def word_count(p:)
729
740
  end
730
741
  end
731
742
 
732
- # Count extra library
733
- unless extra_lib.empty?
734
- wc = 0
735
- puts(bold(blue("\nExtra library:"))) if p
736
- extra_lib.each do |s|
737
- wc = count_dict_words(CR_EXTRA_LIBRARY,s)
738
- $ExtraLibWordCount += wc
739
- puts(" #{s.ljust(17)}: #{wc}") if p
743
+
744
+ if CR_EXTRA_LIBRARY
745
+ extra_lib = Dir.children(CR_EXTRA_LIBRARY)
746
+ # Count extra library
747
+ unless extra_lib.empty?
748
+ wc = 0
749
+ puts(bold(blue("\nExtra library:"))) if p
750
+ extra_lib.each do |s|
751
+ wc = count_dict_words(CR_EXTRA_LIBRARY,s)
752
+ $ExtraLibWordCount += wc
753
+ puts(" #{s.ljust(17)}: #{wc}") if p
754
+ end
740
755
  end
741
- $TwoLibWordCount = $DefaultLibWordCount + $ExtraLibWordCount
742
756
  end
757
+ $TwoLibWordCount = $DefaultLibWordCount + $ExtraLibWordCount
743
758
 
744
759
  if p
745
760
  puts
data/lib/cr.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # ------------------------------------------------------
12
12
 
13
- CR_GEM_VERSION = "4.0.0.alpha.1"
13
+ CR_GEM_VERSION = "4.0.0.alpha.3"
14
14
 
15
15
 
16
16
  CR_OFFICIAL_DICTS = <<-EOF
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.0.0.alpha.1
4
+ version: 4.0.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ccmywish