cw 0.2.4 → 0.3.0
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/.cw_config +18 -0
 - data/.gitignore +10 -1
 - data/LICENSE +2 -1
 - data/README.md +212 -96
 - data/Rakefile +15 -2
 - data/VERSION +1 -1
 - data/Vagrantfile +45 -0
 - data/cw.gemspec +6 -1
 - data/data/text/book_to_read.txt +4 -0
 - data/data/text/english.txt +10000 -0
 - data/example.rb +172 -106
 - data/lib/cw.rb +10 -126
 - data/lib/cw/alphabet.rb +53 -46
 - data/lib/cw/audio_player.rb +83 -72
 - data/lib/cw/book.rb +160 -185
 - data/lib/cw/book_details.rb +38 -49
 - data/lib/cw/cl.rb +101 -95
 - data/lib/cw/common_words.rb +76 -0
 - data/lib/cw/config.rb +50 -0
 - data/lib/cw/current_word.rb +23 -24
 - data/lib/cw/cw_dsl.rb +264 -131
 - data/lib/cw/cw_encoding.rb +63 -69
 - data/lib/cw/cw_stream.rb +86 -82
 - data/lib/cw/cw_threads.rb +132 -22
 - data/lib/cw/element.rb +60 -54
 - data/lib/cw/file_details.rb +26 -11
 - data/lib/cw/key_input.rb +53 -35
 - data/lib/cw/numbers.rb +26 -19
 - data/lib/cw/os.rb +13 -0
 - data/lib/cw/play.rb +92 -0
 - data/lib/cw/print.rb +102 -100
 - data/lib/cw/process.rb +3 -0
 - data/lib/cw/progress.rb +20 -17
 - data/lib/cw/randomize.rb +56 -52
 - data/lib/cw/repeat_word.rb +59 -66
 - data/lib/cw/reveal.rb +32 -31
 - data/lib/cw/rss.rb +52 -48
 - data/lib/cw/sentence.rb +83 -76
 - data/lib/cw/speak.rb +8 -4
 - data/lib/cw/spoken.rb +8 -4
 - data/lib/cw/str.rb +62 -30
 - data/lib/cw/test_letters.rb +20 -28
 - data/lib/cw/test_words.rb +25 -31
 - data/lib/cw/tester.rb +219 -226
 - data/lib/cw/text_helpers.rb +19 -15
 - data/lib/cw/timing.rb +63 -67
 - data/lib/cw/tone_generator.rb +176 -153
 - data/lib/cw/tone_helpers.rb +15 -23
 - data/lib/cw/voice.rb +12 -8
 - data/lib/cw/words.rb +136 -106
 - data/run_script_tests.rb +165 -0
 - data/test/my_words.txt +1 -0
 - data/test/test_common_words.rb +71 -0
 - data/test/test_config.rb +98 -0
 - data/test/test_current_word.rb +62 -0
 - data/test/test_cw.rb +87 -120
 - data/test/test_cw_threads.rb +123 -0
 - data/test/test_filtering.rb +439 -0
 - data/test/test_params.rb +28 -0
 - data/test/test_play.rb +51 -0
 - data/test/test_stream.rb +83 -83
 - data/test/test_tester.rb +9 -27
 - data/test/test_timing.rb +212 -0
 - metadata +94 -12
 - data/lib/cw/config_file.rb +0 -69
 - data/lib/cw/monitor_keys.rb +0 -37
 - data/lib/cw/params.rb +0 -104
 
    
        data/lib/cw/current_word.rb
    CHANGED
    
    | 
         @@ -1,37 +1,36 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            module CWG
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 5 
     | 
    
         
            +
              class CurrentWord
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                @current_word = ''
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
                include TextHelpers
         
     | 
| 
       10 
8 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @current_word = ''
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
       14 
12 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
                def push_letter letr
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @current_word += letr
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
       18 
16 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
                def to_s
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @current_word
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
       22 
20 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
                def clear
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @current_word.clear
         
     | 
| 
      
 23 
     | 
    
         
            +
                 end
         
     | 
| 
       27 
24 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                def strip
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @current_word.strip!
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def process_letter letr
         
     | 
| 
      
 30 
     | 
    
         
            +
                  letr.downcase!
         
     | 
| 
      
 31 
     | 
    
         
            +
                  push_letter letr
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
              def process_letter letr
         
     | 
| 
       33 
     | 
    
         
            -
                letr.downcase!
         
     | 
| 
       34 
     | 
    
         
            -
                push_letter letr
         
     | 
| 
       35 
34 
     | 
    
         
             
              end
         
     | 
| 
       36 
35 
     | 
    
         | 
| 
       37 
36 
     | 
    
         
             
            end
         
     | 
    
        data/lib/cw/cw_dsl.rb
    CHANGED
    
    | 
         @@ -2,175 +2,308 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            # class Cw_dsl provides CW's commands
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            module CWG
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              class CwDsl
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                include CWG::Cfg
         
     | 
| 
      
 10 
     | 
    
         
            +
                include CWG::FileDetails
         
     | 
| 
      
 11 
     | 
    
         
            +
                [:wpm, :effective_wpm, :frequency, :audio_filename,:audio_dir,
         
     | 
| 
      
 12 
     | 
    
         
            +
                 :book_name, :book_dir, :play_command, :run_default, :command_line,
         
     | 
| 
      
 13 
     | 
    
         
            +
                 :author, :title, :quality, :ebook2cw_path, :list_colour, :list_colour,
         
     | 
| 
      
 14 
     | 
    
         
            +
                 :success_colour, :fail_colour, :name, :tone, :volume, :print_words
         
     | 
| 
      
 15 
     | 
    
         
            +
                ].each do |method|
         
     | 
| 
      
 16 
     | 
    
         
            +
                  define_method method do |arg = nil|
         
     | 
| 
      
 17 
     | 
    
         
            +
                    arg ? Cfg.config.params[method.to_s] = arg :
         
     | 
| 
      
 18 
     | 
    
         
            +
                      Cfg.config[method.to_s]
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
       6 
21 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @words, @cl, @str =
         
     | 
| 
      
 24 
     | 
    
         
            +
                               Words.new, Cl.new, Str.new
         
     | 
| 
      
 25 
     | 
    
         
            +
                  Cfg.reset
         
     | 
| 
      
 26 
     | 
    
         
            +
                  load_common_words# unless @words.exist?
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
       8 
28 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                def words= words
         
     | 
| 
      
 30 
     | 
    
         
            +
                  @words.add words
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
       10 
32 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 33 
     | 
    
         
            +
                def word_size(size = nil)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  if size
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Cfg.config.params["size"] = size
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @words.word_size size
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                  Cfg.config["size"]
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
       12 
40 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              MOST_COMMON_WORDS = TEXT + 'most_common_words.txt'
         
     | 
| 
       17 
     | 
    
         
            -
              ABBREVIATIONS     = TEXT + 'abbreviations.txt'
         
     | 
| 
       18 
     | 
    
         
            -
              Q_CODES           = TEXT + 'q_codes.txt'
         
     | 
| 
      
 41 
     | 
    
         
            +
                def word_spacing(spacing)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  Cfg.config.params["word_spacing"] = spacing.to_i
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
       19 
44 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                 
     | 
| 
       22 
     | 
    
         
            -
                  Words.new, Cl.new, Str.new
         
     | 
| 
       23 
     | 
    
         
            -
                Params.init_config
         
     | 
| 
       24 
     | 
    
         
            -
                config_defaults
         
     | 
| 
       25 
     | 
    
         
            -
                config_files
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
                # Test user against letters rather than words.
         
     | 
| 
      
 46 
     | 
    
         
            +
                #
         
     | 
| 
       27 
47 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
       31 
     | 
    
         
            -
                   
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                  dictionary     COMMON_WORDS
         
     | 
| 
       34 
     | 
    
         
            -
                }
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
                def test_letters
         
     | 
| 
      
 49 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
      
 50 
     | 
    
         
            +
                  test_letters = TestLetters.new
         
     | 
| 
      
 51 
     | 
    
         
            +
                  test_letters.run @words
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
       36 
53 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                 
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
       40 
     | 
    
         
            -
                   
     | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
       42 
     | 
    
         
            -
                 
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
                #todo
         
     | 
| 
      
 55 
     | 
    
         
            +
                #    def tx
         
     | 
| 
      
 56 
     | 
    
         
            +
                #      @words.add ["abc"]
         
     | 
| 
      
 57 
     | 
    
         
            +
                #      Cfg.config.params["no_run"] = true
         
     | 
| 
      
 58 
     | 
    
         
            +
                #      tx = Tx.new
         
     | 
| 
      
 59 
     | 
    
         
            +
                #      tx.listen @words
         
     | 
| 
      
 60 
     | 
    
         
            +
                #    end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                # Test user against complete words rather than letters.
         
     | 
| 
      
 63 
     | 
    
         
            +
                #
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                def test_words
         
     | 
| 
      
 66 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
      
 67 
     | 
    
         
            +
                  tw = TestWords.new
         
     | 
| 
      
 68 
     | 
    
         
            +
                  tw.run @words
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
       44 
70 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                 
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
                # Repeat word repeats the current word if the word is entered incorrectly
         
     | 
| 
      
 72 
     | 
    
         
            +
                # (or not entered at all).
         
     | 
| 
       48 
73 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
                def repeat_word
         
     | 
| 
      
 75 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
      
 76 
     | 
    
         
            +
                  repeat_word = RepeatWord.new
         
     | 
| 
      
 77 
     | 
    
         
            +
                  repeat_word.run @words
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
       52 
79 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                 
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
                # Reveal words only at end of test.
         
     | 
| 
      
 81 
     | 
    
         
            +
                # Useful for learning to copy `in the head'
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                def reveal
         
     | 
| 
      
 84 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
      
 85 
     | 
    
         
            +
                  reveal = Reveal.new
         
     | 
| 
      
 86 
     | 
    
         
            +
                  reveal.run @words
         
     | 
| 
       57 
87 
     | 
    
         
             
                end
         
     | 
| 
       58 
     | 
    
         
            -
                Params.size
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
88 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 89 
     | 
    
         
            +
                def sending_practice
         
     | 
| 
      
 90 
     | 
    
         
            +
                  Params.sending_practice = true
         
     | 
| 
      
 91 
     | 
    
         
            +
                  print_letters (:print_early)
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
       65 
93 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                @ 
     | 
| 
       68 
     | 
    
         
            -
                 
     | 
| 
       69 
     | 
    
         
            -
               
     | 
| 
      
 94 
     | 
    
         
            +
                # Play book using provided arguments.
         
     | 
| 
      
 95 
     | 
    
         
            +
                # @param [Hash] args the options to play book with.
         
     | 
| 
      
 96 
     | 
    
         
            +
                # @option args [Integer] :sentences Number of sentences to play
         
     | 
| 
      
 97 
     | 
    
         
            +
                # @option args [Integer] :duration  Number of minutes to play
         
     | 
| 
      
 98 
     | 
    
         
            +
                # @option args [Boolean] :letter Mark by letter if true else mark by word
         
     | 
| 
       70 
99 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
                def read_book args = {}
         
     | 
| 
      
 101 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
      
 102 
     | 
    
         
            +
                  details = BookDetails.new
         
     | 
| 
      
 103 
     | 
    
         
            +
                  details.arguments(args)
         
     | 
| 
      
 104 
     | 
    
         
            +
                  book = Book.new details
         
     | 
| 
       75 
105 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                 
     | 
| 
       78 
     | 
    
         
            -
                @words.including letters
         
     | 
| 
       79 
     | 
    
         
            -
              end
         
     | 
| 
      
 106 
     | 
    
         
            +
                  book.run @words
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
       80 
108 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                @words.containing letters
         
     | 
| 
       83 
     | 
    
         
            -
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
                # Convert book to mp3.
         
     | 
| 
       84 
110 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
                def convert_book args = {}
         
     | 
| 
      
 112 
     | 
    
         
            +
                  details = BookDetails.new
         
     | 
| 
      
 113 
     | 
    
         
            +
                  details.arguments(args)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  book = Book.new details
         
     | 
| 
      
 115 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
      
 116 
     | 
    
         
            +
                  book.convert
         
     | 
| 
      
 117 
     | 
    
         
            +
                end
         
     | 
| 
       89 
118 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                 
     | 
| 
       92 
     | 
    
         
            -
                 
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
      
 119 
     | 
    
         
            +
                # Reads RSS feed (requires an internet connection). Feed can be one of:
         
     | 
| 
      
 120 
     | 
    
         
            +
                # - bbc:
         
     | 
| 
      
 121 
     | 
    
         
            +
                # - reuters:
         
     | 
| 
      
 122 
     | 
    
         
            +
                # - guardian:
         
     | 
| 
      
 123 
     | 
    
         
            +
                # - quotation:
         
     | 
| 
      
 124 
     | 
    
         
            +
                # @param [Symbol] source The source of the feed.
         
     | 
| 
      
 125 
     | 
    
         
            +
                # @param [Integer] article_count Number of articles to play.
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                def read_rss(source, article_count = 3)
         
     | 
| 
      
 128 
     | 
    
         
            +
                  rss, = Rss.new
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                  # don't go online if CW_ENV == test
         
     | 
| 
      
 131 
     | 
    
         
            +
                  if(ENV["CW_ENV"] == "test")
         
     | 
| 
      
 132 
     | 
    
         
            +
                    @words.assign ['test', 'rss', 'stub']
         
     | 
| 
      
 133 
     | 
    
         
            +
                    return
         
     | 
| 
      
 134 
     | 
    
         
            +
                  end
         
     | 
| 
      
 135 
     | 
    
         
            +
                  rss.read_rss(source, article_count)
         
     | 
| 
      
 136 
     | 
    
         
            +
                  loop do
         
     | 
| 
      
 137 
     | 
    
         
            +
                    article = rss.next_article
         
     | 
| 
      
 138 
     | 
    
         
            +
                    return unless article
         
     | 
| 
      
 139 
     | 
    
         
            +
                    @words.assign article
         
     | 
| 
      
 140 
     | 
    
         
            +
                    run
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
      
 142 
     | 
    
         
            +
                end
         
     | 
| 
       94 
143 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
      
 144 
     | 
    
         
            +
                def shuffle
         
     | 
| 
      
 145 
     | 
    
         
            +
                  @words.shuffle unless(ENV["CW_ENV"] == "test")
         
     | 
| 
      
 146 
     | 
    
         
            +
                end
         
     | 
| 
       98 
147 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
      
 148 
     | 
    
         
            +
                def word_count(wordcount)
         
     | 
| 
      
 149 
     | 
    
         
            +
                  Cfg.config.params["word_count"] = wordcount
         
     | 
| 
      
 150 
     | 
    
         
            +
                  @words.count wordcount
         
     | 
| 
      
 151 
     | 
    
         
            +
                end
         
     | 
| 
       102 
152 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 153 
     | 
    
         
            +
                def beginning_with(* letters)
         
     | 
| 
      
 154 
     | 
    
         
            +
                  Cfg.config.params["begin"] = letters
         
     | 
| 
      
 155 
     | 
    
         
            +
                  @words.beginning_with
         
     | 
| 
      
 156 
     | 
    
         
            +
                end
         
     | 
| 
       107 
157 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
      
 158 
     | 
    
         
            +
                def ending_with(* letters)
         
     | 
| 
      
 159 
     | 
    
         
            +
                  Cfg.config.params["end"] = letters
         
     | 
| 
      
 160 
     | 
    
         
            +
                  @words.ending_with
         
     | 
| 
      
 161 
     | 
    
         
            +
                end
         
     | 
| 
       111 
162 
     | 
    
         | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
      
 163 
     | 
    
         
            +
                def including(* letters)
         
     | 
| 
      
 164 
     | 
    
         
            +
                  Cfg.config.params["including"] = letters
         
     | 
| 
      
 165 
     | 
    
         
            +
                  @words.including
         
     | 
| 
      
 166 
     | 
    
         
            +
                end
         
     | 
| 
       115 
167 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
      
 168 
     | 
    
         
            +
                def containing(* letters)
         
     | 
| 
      
 169 
     | 
    
         
            +
                  Cfg.config.params["containing"] = letters
         
     | 
| 
      
 170 
     | 
    
         
            +
                  @words.containing
         
     | 
| 
      
 171 
     | 
    
         
            +
                end
         
     | 
| 
       119 
172 
     | 
    
         | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 173 
     | 
    
         
            +
                def repeat mult
         
     | 
| 
      
 174 
     | 
    
         
            +
                  @words.repeat mult
         
     | 
| 
      
 175 
     | 
    
         
            +
                end
         
     | 
| 
       123 
176 
     | 
    
         | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 177 
     | 
    
         
            +
                def no_longer_than(max)
         
     | 
| 
      
 178 
     | 
    
         
            +
                  @words.no_longer_than max
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
       126 
180 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
      
 181 
     | 
    
         
            +
                def no_shorter_than(min)
         
     | 
| 
      
 182 
     | 
    
         
            +
                  @words.no_shorter_than min
         
     | 
| 
      
 183 
     | 
    
         
            +
                end
         
     | 
| 
       130 
184 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
      
 185 
     | 
    
         
            +
                def random_letters_numbers(options = {})
         
     | 
| 
      
 186 
     | 
    
         
            +
                  options.merge!(letters_numbers: true)
         
     | 
| 
      
 187 
     | 
    
         
            +
                  @words.random_letters_numbers options
         
     | 
| 
      
 188 
     | 
    
         
            +
                end
         
     | 
| 
       134 
189 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
      
 190 
     | 
    
         
            +
                def random_letters(options = {})
         
     | 
| 
      
 191 
     | 
    
         
            +
                  @words.random_letters(options)
         
     | 
| 
      
 192 
     | 
    
         
            +
                end
         
     | 
| 
       138 
193 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
      
 194 
     | 
    
         
            +
                def random_numbers(options = {})
         
     | 
| 
      
 195 
     | 
    
         
            +
                  @words.random_numbers(options)
         
     | 
| 
      
 196 
     | 
    
         
            +
                end
         
     | 
| 
       142 
197 
     | 
    
         | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 198 
     | 
    
         
            +
                def alphabet(options = {reverse: nil})
         
     | 
| 
      
 199 
     | 
    
         
            +
                  @words.alphabet(options)
         
     | 
| 
      
 200 
     | 
    
         
            +
                end
         
     | 
| 
       146 
201 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
      
 202 
     | 
    
         
            +
                def numbers(options = {reverse: nil})
         
     | 
| 
      
 203 
     | 
    
         
            +
                  @words.numbers(options)
         
     | 
| 
      
 204 
     | 
    
         
            +
                end
         
     | 
| 
       150 
205 
     | 
    
         | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
      
 206 
     | 
    
         
            +
                def numbers_spoken()
         
     | 
| 
      
 207 
     | 
    
         
            +
                  #todo
         
     | 
| 
      
 208 
     | 
    
         
            +
                end
         
     | 
| 
       152 
209 
     | 
    
         | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
      
 210 
     | 
    
         
            +
                def cw_element_match arg
         
     | 
| 
      
 211 
     | 
    
         
            +
                  encs = CWG::CwEncoding.new
         
     | 
| 
      
 212 
     | 
    
         
            +
                  encs.match_elements arg
         
     | 
| 
      
 213 
     | 
    
         
            +
                end
         
     | 
| 
       154 
214 
     | 
    
         | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
      
 215 
     | 
    
         
            +
                def letter_range args
         
     | 
| 
      
 216 
     | 
    
         
            +
                  @words.assign alpha
         
     | 
| 
      
 217 
     | 
    
         
            +
                  Cfg.config.params["including"] = args
         
     | 
| 
      
 218 
     | 
    
         
            +
                  @words.including
         
     | 
| 
      
 219 
     | 
    
         
            +
                end
         
     | 
| 
       159 
220 
     | 
    
         | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
      
 221 
     | 
    
         
            +
                def load_alphabet(* args)
         
     | 
| 
      
 222 
     | 
    
         
            +
                  @words.assign alpha if args.empty?
         
     | 
| 
      
 223 
     | 
    
         
            +
                  return if args.empty?
         
     | 
| 
      
 224 
     | 
    
         
            +
                  if args[0].class == Range
         
     | 
| 
      
 225 
     | 
    
         
            +
                    @words.assign letter_range(args)
         
     | 
| 
      
 226 
     | 
    
         
            +
                    return
         
     | 
| 
      
 227 
     | 
    
         
            +
                  end
         
     | 
| 
      
 228 
     | 
    
         
            +
                  @words.assign cw_element_match(args)
         
     | 
| 
      
 229 
     | 
    
         
            +
                end
         
     | 
| 
       163 
230 
     | 
    
         | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 231 
     | 
    
         
            +
                def load_text(filename)
         
     | 
| 
      
 232 
     | 
    
         
            +
                  Cfg.config.params["dictionary"] = filename
         
     | 
| 
      
 233 
     | 
    
         
            +
                  @words.load_text filename
         
     | 
| 
      
 234 
     | 
    
         
            +
                end
         
     | 
| 
       168 
235 
     | 
    
         | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
                 
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
      
 236 
     | 
    
         
            +
                def load_words(args)
         
     | 
| 
      
 237 
     | 
    
         
            +
                  @words.load args
         
     | 
| 
      
 238 
     | 
    
         
            +
                end
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
                def run_default
         
     | 
| 
      
 241 
     | 
    
         
            +
                  Cfg.config["run_default"] || :test_letters
         
     | 
| 
      
 242 
     | 
    
         
            +
                end
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                def print_letters
         
     | 
| 
      
 245 
     | 
    
         
            +
                  Cfg.config.params["print_letters"] = true
         
     | 
| 
      
 246 
     | 
    
         
            +
                end
         
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
      
 248 
     | 
    
         
            +
                def run
         
     | 
| 
      
 249 
     | 
    
         
            +
                  return if Cfg.config["no_run"]
         
     | 
| 
      
 250 
     | 
    
         
            +
                  self.send run_default
         
     | 
| 
      
 251 
     | 
    
         
            +
                end
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
                def no_run
         
     | 
| 
      
 254 
     | 
    
         
            +
                  Cfg.config.params["no_run"] = true
         
     | 
| 
       173 
255 
     | 
    
         
             
                end
         
     | 
| 
       174 
     | 
    
         
            -
              end
         
     | 
| 
       175 
256 
     | 
    
         | 
| 
      
 257 
     | 
    
         
            +
                def noise
         
     | 
| 
      
 258 
     | 
    
         
            +
                  Cfg.config.params["noise"] = true
         
     | 
| 
      
 259 
     | 
    
         
            +
                end
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
                def no_noise
         
     | 
| 
      
 262 
     | 
    
         
            +
                  Cfg.config.params["noise"] = nil
         
     | 
| 
      
 263 
     | 
    
         
            +
                end
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
                def use_ebook2cw
         
     | 
| 
      
 266 
     | 
    
         
            +
                  Cfg.config.params["use_ebook2cw"] = true
         
     | 
| 
      
 267 
     | 
    
         
            +
                end
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
                def use_ruby_tone
         
     | 
| 
      
 270 
     | 
    
         
            +
                  Cfg.config.params["use_ebook2cw"] = nil
         
     | 
| 
      
 271 
     | 
    
         
            +
                end
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
                def words                  ; @words.all                     ; end
         
     | 
| 
      
 274 
     | 
    
         
            +
                def load_common_words      ; @words.load 1000               ; end
         
     | 
| 
      
 275 
     | 
    
         
            +
                def load_most_common_words ; @words.load 500                ; end
         
     | 
| 
      
 276 
     | 
    
         
            +
                def load_abbreviations     ; load_text ABBREVIATIONS        ; end
         
     | 
| 
      
 277 
     | 
    
         
            +
                def reverse                ;  @words.reverse                ; end
         
     | 
| 
      
 278 
     | 
    
         
            +
                def double_words           ; @words.double_words            ; end
         
     | 
| 
      
 279 
     | 
    
         
            +
                def letters_numbers        ;      @words.letters_numbers    ; end
         
     | 
| 
      
 280 
     | 
    
         
            +
                def load_codes             ; load_text Q_CODES              ; end
         
     | 
| 
      
 281 
     | 
    
         
            +
                def alpha                  ; 'a'.upto('z').collect{|ch| ch} ; end
         
     | 
| 
      
 282 
     | 
    
         
            +
                def vowels                 ; ['a','e','i','o','u']          ; end
         
     | 
| 
      
 283 
     | 
    
         
            +
                def dot_letters            ; ['e','i','s','h']              ; end
         
     | 
| 
      
 284 
     | 
    
         
            +
                def dash_letters           ; ['t','m','o']                  ; end
         
     | 
| 
      
 285 
     | 
    
         
            +
                def load_vowels            ; @words.assign vowels           ; end
         
     | 
| 
      
 286 
     | 
    
         
            +
                def load_consonants        ; @words.assign alpha - vowels   ; end
         
     | 
| 
      
 287 
     | 
    
         
            +
                def numbers                ; '0'.upto('9').collect{|ch| ch} ; end
         
     | 
| 
      
 288 
     | 
    
         
            +
                def load_numbers           ; @words.assign numbers          ; end
         
     | 
| 
      
 289 
     | 
    
         
            +
                def load_dots              ; load_letters(dot_letters)      ; end
         
     | 
| 
      
 290 
     | 
    
         
            +
                def load_dashes            ; load_letters(dash_letters)     ; end
         
     | 
| 
      
 291 
     | 
    
         
            +
                def to_s                   ; @str.to_s                      ; end
         
     | 
| 
      
 292 
     | 
    
         
            +
                def list                   ; Print.new.list self.to_s; puts ; end
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                alias_method :ewpm,                  :effective_wpm
         
     | 
| 
      
 295 
     | 
    
         
            +
                alias_method :comment,               :name
         
     | 
| 
      
 296 
     | 
    
         
            +
                alias_method :word_length,           :word_size
         
     | 
| 
      
 297 
     | 
    
         
            +
                alias_method :load_letters,          :load_alphabet
         
     | 
| 
      
 298 
     | 
    
         
            +
                alias_method :word_shuffle,          :shuffle
         
     | 
| 
      
 299 
     | 
    
         
            +
                alias_method :repeat_letter,         :repeat_word
         
     | 
| 
      
 300 
     | 
    
         
            +
                alias_method :having_size_of,        :word_size
         
     | 
| 
      
 301 
     | 
    
         
            +
                alias_method :number_of_words,       :word_count
         
     | 
| 
      
 302 
     | 
    
         
            +
                alias_method :words_including,       :including
         
     | 
| 
      
 303 
     | 
    
         
            +
                alias_method :words_ending_with,     :ending_with
         
     | 
| 
      
 304 
     | 
    
         
            +
                alias_method :random_alphanumeric,   :random_letters_numbers
         
     | 
| 
      
 305 
     | 
    
         
            +
                alias_method :words_beginning_with,  :beginning_with
         
     | 
| 
      
 306 
     | 
    
         
            +
                alias_method :words_no_longer_than,  :no_longer_than
         
     | 
| 
      
 307 
     | 
    
         
            +
                alias_method :words_no_shorter_than, :no_shorter_than
         
     | 
| 
      
 308 
     | 
    
         
            +
              end
         
     | 
| 
       176 
309 
     | 
    
         
             
            end
         
     |