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.
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
@@ -1,37 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'thread'
4
-
5
- class MonitorKeys
6
- def initialize(cw)
7
- @cw = cw
8
- @key_input = KeyInput.new
9
- @queue = Queue.new
10
- end
11
-
12
- def key_input
13
- @key_input ||= KeyInput.new
14
- end
15
-
16
- def empty?
17
- @queue.empty?
18
- end
19
-
20
- def have_data?
21
- ! empty?
22
- end
23
-
24
- def monitor_keys
25
- loop do
26
- get_key_input
27
- break if check_quit_key_input
28
- if @cw.quit
29
- key_input.reset
30
- break
31
- end
32
- check_sentence_navigation key_chr
33
- build_word_maybe
34
- end
35
- end
36
-
37
- end
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Params
4
-
5
- module ParamsSetup
6
-
7
- [:name, :wpm,
8
- :effective_wpm, :word_spacing,
9
- :command_line, :frequency,
10
- :author, :title,
11
- :quality, :audio_filename,
12
- :pause, :noise,
13
- :shuffle, :mark_words,
14
- :double_words, :single_words,
15
- :audio_dir, :def_word_count,
16
- :book_name, :book_dir,
17
- :play_command, :success_colour,
18
- :fail_colour, :list_colour,
19
- :ebook2cw_path
20
- ].each do |method|
21
- define_method method do |arg = nil|
22
- arg ? Params.send("#{method}=", arg) : Params.send("#{method}")
23
- end
24
- end
25
-
26
- [[:pause, :pause, true],
27
- [:un_pause, :pause, nil],
28
- [:print_letters, :print_letters, true],
29
- [:mark_words, :print_letters, nil],
30
- [:noise, :noise, true],
31
- [:no_noise, :noise, nil],
32
- [:shuffle, :shuffle, true],
33
- [:no_shuffle, :shuffle, nil],
34
- [:double_words, :double_words, true],
35
- [:single_words, :double_words, nil],
36
- [:use_ebook2cw, :use_ebook2cw, true],
37
- [:use_ruby_tone, :use_ebook2cw, nil],
38
- ].each do |bool|
39
- define_method bool[0] do
40
- Params.send("#{bool[1]}=", bool[2])
41
- @words.shuffle if((bool[1] == :shuffle) && (bool[2]))
42
- end
43
- end
44
-
45
- end
46
-
47
- extend self
48
-
49
- def init_config
50
- config do
51
- param :name, :wpm, :dictionary, :command_line, :audio_filename, :tone, :pause,
52
- :print_letters, :double_words, :word_filename, :author, :title, :quality,
53
- :frequency, :shuffle, :effective_wpm, :max, :min, :word_spacing, :noise,
54
- :begin, :end, :word_count, :including, :word_size, :size, :beginning_with,
55
- :ending_with, :mark_words, :audio_dir, :use_ebook2cw, :def_word_count,
56
- :book_dir, :book_name, :play_command, :success_colour, :fail_colour,
57
- :list_colour, :ebook2cw_path
58
- end
59
- end
60
-
61
- def param_method values, name
62
- value = values.first
63
- value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
64
- end
65
-
66
- def param_internal name
67
- attr_accessor name
68
- instance_variable_set("@#{name}", nil)
69
- define_method name do | * values|
70
- param_method values, name
71
- end
72
- end
73
-
74
- def param( * names)
75
- names.each do |name|
76
- param_internal name
77
- end
78
- end
79
-
80
- def config( & block)
81
- instance_eval( & block)
82
- end
83
-
84
- def shuffle_str
85
- shuffle ? "Shuffle: #{shuffle ? 'yes' : 'no'}\n" : nil
86
- end
87
-
88
- def word_count_str
89
- word_count ? "Word count: #{word_count}\n" : nil
90
- end
91
-
92
- def wpm_str
93
- "WPM: #{wpm}\n"
94
- end
95
-
96
- def word_size_str
97
- size ? "Word size: #{size}\n" : nil
98
- end
99
-
100
- def delim_str
101
- "#{'=' * Params.name.size}\n"
102
- end
103
-
104
- end