cr.rb 4.0.0.alpha.3 → 4.0.0.alpha.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 +26 -12
- data/lib/cr.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c4ff483935b5b1015fb9d412056e041e81fd3fa7b94c47c8b5de8be517f8740
|
4
|
+
data.tar.gz: 2a207377d5dc6bf441d3940d5c142965d944ba6f05de3de7053800bd7b59fb29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddd0207e0248b713e3304f6c6781b2f186a7ba3bdc02a4a4823e9def133cfd2209d8295987217d1df92733811efc0a2beb09daa904d85305aee97a9955dda146
|
7
|
+
data.tar.gz: 51a67072c4631628d6a6f840e819665c2e26309cc62be9d060cc658b5b8eb19b512557c92d8840f56a32e3777211d6c114870a15208403b647bb7147ec4ca418
|
data/bin/cr
CHANGED
@@ -570,18 +570,35 @@ NotFound
|
|
570
570
|
end
|
571
571
|
|
572
572
|
|
573
|
+
#
|
574
|
+
# Delegate to `search_word_internal`
|
575
|
+
#
|
576
|
+
def search_word(pattern)
|
577
|
+
found_or_not1 = false
|
578
|
+
found_or_not2 = false
|
579
|
+
|
580
|
+
found_or_not1 = search_word_internal(pattern, CR_DEFAULT_LIBRARY)
|
581
|
+
if CR_EXTRA_LIBRARY
|
582
|
+
found_or_not2 = search_word_internal(pattern, CR_EXTRA_LIBRARY)
|
583
|
+
end
|
584
|
+
|
585
|
+
if (found_or_not1 == false) && (found_or_not2 == false)
|
586
|
+
puts red("cr: No words match with #{pattern.inspect}")
|
587
|
+
puts
|
588
|
+
end
|
589
|
+
end
|
573
590
|
|
574
591
|
#
|
575
|
-
# This `
|
592
|
+
# This `search_word_internal` routine is quite like `resolve_word`
|
576
593
|
# Notice:
|
577
594
|
# We handle two cases
|
578
595
|
#
|
579
596
|
# 1. the 'pattern' is the regexp itself
|
580
|
-
# 2. the 'pattern' is like '/
|
597
|
+
# 2. the 'pattern' is like '/blah/'
|
581
598
|
#
|
582
599
|
# The second is what Ruby and Perl users like to do, handle it!
|
583
600
|
#
|
584
|
-
def
|
601
|
+
def search_word_internal(pattern, library)
|
585
602
|
|
586
603
|
if pattern.nil?
|
587
604
|
puts bold(red("cr: Need an argument!"))
|
@@ -596,24 +613,24 @@ def search_word(pattern)
|
|
596
613
|
regexp = %r[#{pattern}]
|
597
614
|
end
|
598
615
|
|
599
|
-
|
616
|
+
found_or_not = false
|
600
617
|
|
601
618
|
#
|
602
619
|
# Try to match every word in all dicts
|
603
620
|
#
|
604
|
-
Dir.children(
|
605
|
-
sheets = Dir.children(File.join(
|
621
|
+
Dir.children(library).each do |dict|
|
622
|
+
sheets = Dir.children(File.join(library, dict)).select do
|
606
623
|
_1.end_with?('.toml')
|
607
624
|
end
|
608
625
|
|
609
626
|
similar_words_in_a_dict = []
|
610
627
|
|
611
628
|
sheets.each do |sheet|
|
612
|
-
sheet_content = load_sheet(dict, File.basename(sheet,'.toml'))
|
629
|
+
sheet_content = load_sheet(library, dict, File.basename(sheet,'.toml'))
|
613
630
|
|
614
631
|
sheet_content.keys.each do
|
615
632
|
if _1 =~ regexp
|
616
|
-
|
633
|
+
found_or_not = true
|
617
634
|
similar_words_in_a_dict << _1
|
618
635
|
end
|
619
636
|
end
|
@@ -629,10 +646,7 @@ def search_word(pattern)
|
|
629
646
|
puts
|
630
647
|
end
|
631
648
|
end
|
632
|
-
|
633
|
-
puts red("cr: No words match with #{regexp.inspect}")
|
634
|
-
puts
|
635
|
-
end
|
649
|
+
return found_or_not
|
636
650
|
end
|
637
651
|
|
638
652
|
|
data/lib/cr.rb
CHANGED