cw 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.cw_config +18 -0
  3. data/.gitignore +10 -1
  4. data/LICENSE +2 -1
  5. data/README.md +212 -96
  6. data/Rakefile +15 -2
  7. data/VERSION +1 -1
  8. data/Vagrantfile +45 -0
  9. data/cw.gemspec +6 -1
  10. data/data/text/book_to_read.txt +4 -0
  11. data/data/text/english.txt +10000 -0
  12. data/example.rb +172 -106
  13. data/lib/cw.rb +10 -126
  14. data/lib/cw/alphabet.rb +53 -46
  15. data/lib/cw/audio_player.rb +83 -72
  16. data/lib/cw/book.rb +160 -185
  17. data/lib/cw/book_details.rb +38 -49
  18. data/lib/cw/cl.rb +101 -95
  19. data/lib/cw/common_words.rb +76 -0
  20. data/lib/cw/config.rb +50 -0
  21. data/lib/cw/current_word.rb +23 -24
  22. data/lib/cw/cw_dsl.rb +264 -131
  23. data/lib/cw/cw_encoding.rb +63 -69
  24. data/lib/cw/cw_stream.rb +86 -82
  25. data/lib/cw/cw_threads.rb +132 -22
  26. data/lib/cw/element.rb +60 -54
  27. data/lib/cw/file_details.rb +26 -11
  28. data/lib/cw/key_input.rb +53 -35
  29. data/lib/cw/numbers.rb +26 -19
  30. data/lib/cw/os.rb +13 -0
  31. data/lib/cw/play.rb +92 -0
  32. data/lib/cw/print.rb +102 -100
  33. data/lib/cw/process.rb +3 -0
  34. data/lib/cw/progress.rb +20 -17
  35. data/lib/cw/randomize.rb +56 -52
  36. data/lib/cw/repeat_word.rb +59 -66
  37. data/lib/cw/reveal.rb +32 -31
  38. data/lib/cw/rss.rb +52 -48
  39. data/lib/cw/sentence.rb +83 -76
  40. data/lib/cw/speak.rb +8 -4
  41. data/lib/cw/spoken.rb +8 -4
  42. data/lib/cw/str.rb +62 -30
  43. data/lib/cw/test_letters.rb +20 -28
  44. data/lib/cw/test_words.rb +25 -31
  45. data/lib/cw/tester.rb +219 -226
  46. data/lib/cw/text_helpers.rb +19 -15
  47. data/lib/cw/timing.rb +63 -67
  48. data/lib/cw/tone_generator.rb +176 -153
  49. data/lib/cw/tone_helpers.rb +15 -23
  50. data/lib/cw/voice.rb +12 -8
  51. data/lib/cw/words.rb +136 -106
  52. data/run_script_tests.rb +165 -0
  53. data/test/my_words.txt +1 -0
  54. data/test/test_common_words.rb +71 -0
  55. data/test/test_config.rb +98 -0
  56. data/test/test_current_word.rb +62 -0
  57. data/test/test_cw.rb +87 -120
  58. data/test/test_cw_threads.rb +123 -0
  59. data/test/test_filtering.rb +439 -0
  60. data/test/test_params.rb +28 -0
  61. data/test/test_play.rb +51 -0
  62. data/test/test_stream.rb +83 -83
  63. data/test/test_tester.rb +9 -27
  64. data/test/test_timing.rb +212 -0
  65. metadata +94 -12
  66. data/lib/cw/config_file.rb +0 -69
  67. data/lib/cw/monitor_keys.rb +0 -37
  68. data/lib/cw/params.rb +0 -104
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e1587225798871292fb766303aa33e8aa488d72
4
- data.tar.gz: 7d75a4190163a579f8cc88f9287e579c1657facd
3
+ metadata.gz: 7e3d3d2ac3c6f0d0768543c4140ca14035c23c65
4
+ data.tar.gz: c110606d40f04c564262883c565fe38c99fed9f3
5
5
  SHA512:
6
- metadata.gz: 85ec2d8ab4291cae6fa85f3e02700a080e4bdba7e634378de4d445c656b0b39375805978a80ce4e93fa1388c128815d96d6a4fcfab0302b451766d57661e790d
7
- data.tar.gz: 4e61d5b90e40004359ae53751555c3de33a135f02c333ce9d15fc842b0b227b09a77e84846b26841cc1bc4dff77c30f15aae1e1eb0639c130a9e799a9a9ad9cd
6
+ metadata.gz: 4794a516a4b8881d24d1bebc9f0c9bc63921b8a4eca97a8ce551ac111055d9afbd86fc290502ba36f8bec78f20ef2f6036303060c1b826430137725d03d6c7b4
7
+ data.tar.gz: 20cf42901391040da1865eb6cf6092e8ba22e707578b7fc7ae19d8df091a8f1c23a47741f27670883ebd8e93973e0374b2cb928195cf55eef7f8f0aea70709b0
@@ -0,0 +1,18 @@
1
+ wpm = 25
2
+ frequency = 450
3
+ volume = 1
4
+ book_name = book.txt
5
+ book_dir = data/text/
6
+ success_colour = green
7
+ fail_colour = red
8
+ list_colour = default
9
+ ebook2cw_path = /usr/bin/ebook2cw
10
+ run_default = test_letters
11
+ dictionary_dir = data/text/
12
+ dictionary_name = english.txt
13
+ audio_filename = audio_output
14
+ audio_dir = audio
15
+ book_name = book.txt
16
+ book_dir = data/text/
17
+ run_default = test_letters
18
+ word_count = 16
data/.gitignore CHANGED
@@ -8,7 +8,8 @@ Gemfile.lock
8
8
  *.gem
9
9
  *.rbc
10
10
  .bundle
11
- .cw_config
11
+ # .cw_config
12
+ test.sqlite
12
13
  coverage
13
14
  InstalledFiles
14
15
  lib/bundler/man
@@ -32,3 +33,11 @@ audio/audio_output.wav
32
33
  /audio/e_space.wav
33
34
  /audio/space.wav
34
35
  /audio/audio_output.wav0000.mp3
36
+ /_audio/
37
+ /_books/
38
+ /audio/audio_output
39
+ /audio/audio_output.mp30000.mp3
40
+ /data/text/book3.txt
41
+ /.yardoc/
42
+ /.yardoc/
43
+ /.yardoc/
data/LICENSE CHANGED
@@ -1,5 +1,6 @@
1
1
  CW
2
- Copyright (c) 2015 Martyn Jago <martyn.jago@btinternet.com>
2
+
3
+ Copyright (c) 2016 Martyn Jago <martyn.jago@btinternet.com>
3
4
 
4
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
6
  of this software and associated documentation files (the "Software"), to
data/README.md CHANGED
@@ -16,113 +16,229 @@ addition to generating random words, letters, and numbers that possibly match so
16
16
 
17
17
  **CW** also allows for real-time progress marking by indicating correct and incorrect characters and words copied in real-time. A follow mode also exists which prints the output just after it has played it (for `in head' practice).
18
18
 
19
- **CW** is thoroughly [documented](http://mjago.github.io/CW/), and includes a [hands-on tutorial](http://mjago.github.io/CW/mydoc_five_common_words/).
19
+ **CW** is thoroughly [documented](http://mjago.github.io/CW/), and includes a [hands-on tutorial](http://martynjago.co.uk/CW/mydoc_learning_the_alphabet/).
20
20
 
21
21
  # Installation:
22
22
 
23
23
  ```sh
24
24
  gem install cw
25
- ruby example.rb
25
+ cw example.rb
26
26
  ```
27
27
 
28
- * Note: Currently only tested on OS X, and Ruby v1.9.3 and later.
28
+ ### Note:
29
29
 
30
- # Example test-script
30
+ - Requires Ruby 2+
31
+ - Tested on OS X, and Linux.
32
+
33
+ # Example CW Script
31
34
 
32
35
  ```ruby
33
36
 
34
- # example.rb (example script)
35
-
36
- require 'cw'
37
-
38
- cw do
39
- wpm 18
40
- comment 'read book (1 sentence)'
41
- play_book(sentences: 1)
42
- end
43
-
44
- cw do
45
- wpm 18
46
- ewpm 12
47
- comment 'read book (2 minutes)'
48
- play_book(duration: 2)
49
- end
50
-
51
- cw do
52
- comment 'read rss feed (1 article)'
53
- read_rss(:reuters, 1)
54
- end
55
-
56
- cw do
57
- name 'test straight alphabet'
58
- alphabet
59
- end
60
-
61
- cw do
62
- comment 'test straight numbers'
63
- numbers
64
- end
65
-
66
- cw do
67
- wpm 18
68
- ewpm 12
69
- load_abbreviations
70
- shuffle
71
- end
72
-
73
-
74
- # ...or instantiate CW...
75
-
76
- wpm = 16
77
-
78
- test = CW.new
79
- test.comment 'test words beginning with "b" (repeat word)'
80
- test.shuffle
81
- test.wpm wpm
82
- test.beginning_with 'b'
83
- test.word_size 4
84
- test.word_count 2
85
- puts test.to_s
86
- test.repeat_word
87
-
88
- test = CW.new
89
- test.comment 'test words ending with "ing" (test letters)'
90
- test.shuffle
91
- test.wpm wpm
92
- test.ending_with 'e'
93
- test.word_size 4
94
- test.word_count 2
95
- puts test.to_s
96
- test.test_letters
97
-
98
- test = CW.new
99
- test.comment 'test words including "th" (test words)'
100
- test.shuffle
101
- test.wpm wpm
102
- test.including 'th'
103
- test.word_size 4
104
- test.word_count 2
105
- puts test.to_s
106
- test.test_words
107
-
108
- test = CW.new
109
- test.comment 'test words no longer than 6 letters (test letters)'
110
- test.shuffle
111
- test.wpm wpm
112
- test.no_longer_than 6
113
- test.word_count 2
114
- puts test.to_s
115
- test.test_letters
116
-
117
- test = CW.new
118
- test.comment 'test words no shorter than 6 letters (print letters)'
119
- test.shuffle
120
- test.wpm wpm
121
- test.no_shorter_than 6
122
- test.word_count 2
123
- puts test.to_s
124
- test.print_letters
125
- test.test_letters
37
+ # example.rb
38
+
39
+ require 'cw'
40
+
41
+ cw do
42
+ comment 'test single element letters'
43
+ wpm 15
44
+ load_alphabet :size, 1
45
+ shuffle
46
+ end
47
+
48
+ cw do
49
+ comment 'test 2 element letters'
50
+ wpm 15
51
+ load_alphabet :size, 2
52
+ shuffle
53
+ end
54
+
55
+ cw do
56
+ comment 'test less than 3 element letters'
57
+ wpm 15
58
+ load_alphabet :less_than, 3
59
+ shuffle
60
+ end
61
+
62
+ cw do
63
+ comment 'test 3 element letters'
64
+ wpm 15
65
+ load_alphabet :size, 3
66
+ shuffle
67
+ end
68
+
69
+ cw do
70
+ comment 'test less than 4 element letters'
71
+ wpm 15
72
+ load_alphabet :less_than, 4
73
+ shuffle
74
+ end
75
+
76
+ cw do
77
+ comment 'test 4 element letters'
78
+ wpm 15
79
+ load_alphabet :size, 4
80
+ shuffle
81
+ end
82
+
83
+ cw do
84
+ comment 'test alphabet vowels'
85
+ wpm 15
86
+ load_vowels
87
+ shuffle
88
+ end
89
+
90
+ cw do
91
+ comment 'test letters a..m'
92
+ wpm 18
93
+ load_alphabet("a".."m")
94
+ shuffle
95
+ end
96
+
97
+ cw do
98
+ comment 'test 8 words made with letters a..m - test by letter'
99
+ wpm 18
100
+ containing('a'..'m')
101
+ shuffle
102
+ word_count 8
103
+ end
104
+
105
+ cw do
106
+ comment 'test letters n..z'
107
+ wpm 18
108
+ load_letters('n'..'z')
109
+ shuffle
110
+ end
111
+
112
+ cw do
113
+ comment 'test 8 words made with letters n..z - test by word'
114
+ wpm 18
115
+ containing('n'..'z')
116
+ shuffle
117
+ word_count 8
118
+ test_words
119
+ end
120
+
121
+ cw do
122
+ comment 'test numbers'
123
+ wpm 20
124
+ load_numbers
125
+ shuffle
126
+ end
127
+
128
+ cw do
129
+ comment 'test alphabet - repeat until correct'
130
+ wpm 25
131
+ load_alphabet
132
+ shuffle
133
+ repeat_word
134
+ end
135
+
136
+ cw do
137
+ comment 'test 8 most common words no longer than 4 letters'
138
+ wpm 20
139
+ load_most_common_words
140
+ shuffle
141
+ no_longer_than 4
142
+ word_count 8
143
+ end
144
+
145
+ cw do
146
+ comment 'test 4 most common words no shorter than 4 letters'
147
+ wpm 20
148
+ load_most_common_words
149
+ shuffle
150
+ no_shorter_than 4
151
+ word_count 8
152
+ end
153
+
154
+ cw do
155
+ comment 'test 8 words including letter sequence "ing"'
156
+ shuffle
157
+ including('ing')
158
+ word_size 6
159
+ end
160
+
161
+ cw do
162
+ comment 'test 8 words having 6 letters - play each word twice'
163
+ shuffle
164
+ word_size 6
165
+ word_count 8
166
+ double_words
167
+ end
168
+
169
+ cw do
170
+ comment 'test 8 words beginning with "qu" - repeat whole sequence once'
171
+ wpm 20
172
+ shuffle
173
+ beginning_with 'qu'
174
+ word_count 8
175
+ repeat 1
176
+ end
177
+
178
+ cw do
179
+ comment 'test 8 words ending with "tion" - test by word'
180
+ wpm 15
181
+ shuffle
182
+ ending_with 'tion'
183
+ word_count 8
184
+ test_words
185
+ end
186
+
187
+ cw do
188
+ comment 'read one sentence of book'
189
+ wpm 20
190
+ read_book(sentences: 1)
191
+ end
192
+
193
+ cw do
194
+ comment 'read rss feed (quote of the day)'
195
+ wpm 18
196
+ read_rss(:quotation, 1)
197
+ end
198
+
199
+ cw do
200
+ comment 'test 6 common cw abbreviations'
201
+ wpm 15
202
+ load_abbreviations
203
+ shuffle
204
+ word_count 6
205
+ end
206
+
207
+ cw do
208
+ comment "test 8 Q codes by ear (no keyboard test)"
209
+ wpm 20
210
+ load_codes
211
+ shuffle
212
+ word_count 8
213
+ print_words
214
+ end
215
+
216
+ cw do
217
+ comment "test 8 words by ear - reveal words at end of test"
218
+ wpm 20
219
+ shuffle
220
+ word_count 8
221
+ reveal
222
+ end
223
+
224
+ cw do
225
+ comment "reverse alphabet"
226
+ wpm 20
227
+ load_alphabet
228
+ reverse
229
+ end
230
+
231
+ cw do
232
+ comment "load my own word set"
233
+ wpm 20
234
+ load_text("test/my_words.txt")
235
+ shuffle
236
+ word_count 4
237
+ end
238
+
239
+ # See documentation for more details - and more commands.
240
+
241
+ puts 'done'
126
242
 
127
243
  ```
128
244
 
data/Rakefile CHANGED
@@ -1,10 +1,23 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
-
4
3
  require 'rake/version_task'
4
+ require 'yard'
5
+
5
6
  Rake::VersionTask.new
6
7
 
7
8
  Rake::TestTask.new do |t|
9
+
8
10
  t.pattern = "test/test_*.rb"
9
- # t.pattern = "test/test_tester.rb"
11
+ # t.pattern = "test/test_play.rb"
12
+ end
13
+
14
+ YARD::Rake::YardocTask.new do |t|
15
+ t.files = ['lib/**/*.rb'] # optional
16
+ t.options = ['--any', '--extra', '--opts'] # optional
17
+ end
18
+
19
+ desc "Test cw_scripts and check timings"
20
+ task :test_scripts do
21
+ system "bundle exec ruby run_script_tests.rb"
22
+ puts "done"
10
23
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.3.0
@@ -0,0 +1,45 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.ssh.forward_x11 = true # useful since some audio testing programs use x11
6
+ config.vm.box = "precise64"
7
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
8
+ config.vm.provision :shell, :inline => $BOOTSTRAP_SCRIPT # see below
9
+
10
+ # enable audio drivers on VM settings
11
+ config.vm.provider :virtualbox do |vb|
12
+ if RUBY_PLATFORM =~ /darwin/
13
+ vb.customize ["modifyvm", :id, '--audio', 'coreaudio', '--audiocontroller', 'hda'] # choices: hda sb16 ac97
14
+ elsif RUBY_PLATFORM =~ /mingw|mswin|bccwin|cygwin|emx/
15
+ vb.customize ["modifyvm", :id, '--audio', 'dsound', '--audiocontroller', 'ac97']
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ $BOOTSTRAP_SCRIPT = <<EOF
22
+ set -e # Stop on any error
23
+
24
+ # --------------- SETTINGS ----------------
25
+ # Other settings
26
+ export DEBIAN_FRONTEND=noninteractive
27
+
28
+ sudo apt-get update
29
+
30
+ # ---- OSS AUDIO
31
+ sudo usermod -a -G audio vagrant
32
+ sudo apt-get install -y oss4-base oss4-dkms oss4-source oss4-gtk linux-headers-3.2.0-23 debconf-utils
33
+ sudo ln -s /usr/src/linux-headers-$(uname -r)/ /lib/modules/$(uname -r)/source || echo ALREADY SYMLINKED
34
+ sudo module-assistant prepare
35
+ sudo module-assistant auto-install -i oss4 # this can take 2 minutes
36
+ sudo debconf-set-selections <<< "linux-sound-base linux-sound-base/sound_system select OSS"
37
+ echo READY.
38
+
39
+ # have to reboot for drivers to kick in, but only the first time of course
40
+ if [ ! -f ~/runonce ]
41
+ then
42
+ sudo reboot
43
+ touch ~/runonce
44
+ fi
45
+ EOF