cw 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +3 -3
  3. data/VERSION +1 -1
  4. data/cw.gemspec +15 -15
  5. data/lib/cw.rb +9 -9
  6. data/lib/cw/alphabet.rb +1 -1
  7. data/lib/cw/audio_player.rb +3 -3
  8. data/lib/cw/book.rb +1 -1
  9. data/lib/cw/book_details.rb +2 -2
  10. data/lib/cw/callsign.rb +1 -2
  11. data/lib/cw/cl.rb +2 -2
  12. data/lib/cw/common_words.rb +2 -2
  13. data/lib/cw/config.rb +2 -2
  14. data/lib/cw/coreaudio.rb +2 -2
  15. data/lib/cw/current_word.rb +1 -1
  16. data/lib/cw/{cw_dsl.rb → dsl.rb} +8 -8
  17. data/lib/cw/element.rb +1 -2
  18. data/lib/cw/{cw_encoding.rb → encoding.rb} +2 -3
  19. data/lib/cw/file_details.rb +1 -2
  20. data/lib/cw/key_input.rb +1 -2
  21. data/lib/cw/numbers.rb +1 -1
  22. data/lib/cw/os.rb +1 -1
  23. data/lib/cw/play.rb +1 -2
  24. data/lib/cw/print.rb +1 -2
  25. data/lib/cw/progress.rb +1 -4
  26. data/lib/cw/randomize.rb +1 -3
  27. data/lib/cw/read.rb +2 -2
  28. data/lib/cw/repeat_word.rb +2 -3
  29. data/lib/cw/reveal.rb +1 -4
  30. data/lib/cw/rss.rb +3 -3
  31. data/lib/cw/rss_clean.rb +1 -1
  32. data/lib/cw/sentence.rb +2 -3
  33. data/lib/cw/speak.rb +1 -3
  34. data/lib/cw/spoken.rb +1 -3
  35. data/lib/cw/str.rb +1 -3
  36. data/lib/cw/{cw_stream.rb → stream.rb} +2 -5
  37. data/lib/cw/test_letters.rb +1 -2
  38. data/lib/cw/test_words.rb +1 -4
  39. data/lib/cw/tester.rb +3 -4
  40. data/lib/cw/text_helpers.rb +3 -6
  41. data/lib/cw/{cw_threads.rb → threads.rb} +2 -5
  42. data/lib/cw/timing.rb +2 -5
  43. data/lib/cw/tone_generator.rb +2 -3
  44. data/lib/cw/tone_helpers.rb +1 -2
  45. data/lib/cw/tx.rb +3 -3
  46. data/lib/cw/voice.rb +1 -3
  47. data/lib/cw/winkey.rb +1 -2
  48. data/lib/cw/words.rb +3 -6
  49. data/run_script_tests.rb +5 -5
  50. data/test/test_common_words.rb +1 -1
  51. data/test/test_config.rb +19 -19
  52. data/test/test_current_word.rb +1 -1
  53. data/test/test_cw.rb +13 -13
  54. data/test/test_cw_threads.rb +16 -16
  55. data/test/test_dsl.rb +106 -0
  56. data/test/test_filtering.rb +2 -2
  57. data/test/test_numbers.rb +24 -0
  58. data/test/test_params.rb +2 -2
  59. data/test/test_play.rb +4 -4
  60. data/test/test_stream.rb +3 -3
  61. data/test/test_tester.rb +4 -5
  62. data/test/test_timing.rb +3 -3
  63. data/test/test_tone_generator.rb +13 -13
  64. metadata +51 -49
data/lib/cw/reveal.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class Reveal < Tester
6
5
 
7
6
  def initialize
@@ -42,7 +41,5 @@ module CWG
42
41
  @reveal_buf += @popped[:value] + ' '
43
42
  end
44
43
  end
45
-
46
44
  end
47
-
48
45
  end
data/lib/cw/rss.rb CHANGED
@@ -4,7 +4,7 @@ require 'oga'
4
4
  require 'httpclient'
5
5
  require "htmlentities"
6
6
 
7
- module CWG
7
+ module CW
8
8
 
9
9
  #class Rss
10
10
 
@@ -40,8 +40,8 @@ module CWG
40
40
  unless(title.include?('VIDEO:') ||
41
41
  title.include?('In pictures:') ||
42
42
  title.include?('Morning business round-up'))
43
- clean_title = CWG::RSSClean.new(title).scrub
44
- clean_desc = CWG::RSSClean.new(description).scrub
43
+ clean_title = CW::RSSClean.new(title).scrub
44
+ clean_desc = CW::RSSClean.new(description).scrub
45
45
  # @rss_articles << Sanitize.clean(coder.decode(title)) + '. ' +
46
46
  # Sanitize.clean(coder.decode(description))
47
47
  @rss_articles << clean_title + '. ' + clean_desc
data/lib/cw/rss_clean.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'oga'
2
2
 
3
- module CWG
3
+ module CW
4
4
  class RSSClean
5
5
  def initialize(html_fragment)
6
6
  @html_fragment = html_fragment
data/lib/cw/sentence.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class Sentence
6
5
 
7
6
  attr_accessor :index #todo
@@ -48,7 +47,7 @@ module CWG
48
47
  def read_progress progress_file
49
48
  create_progress_maybe progress_file
50
49
  File.open(progress_file, 'r') {|f| @index = f.readline.to_i}
51
- unless(@index && @index.class == Fixnum)
50
+ unless(@index && @index.class == 1.class)
52
51
  reset_progress progress_file
53
52
  end
54
53
  check_end_of_book progress_file
data/lib/cw/speak.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Numbers provides the Number Testing functionality
6
6
 
@@ -9,7 +9,5 @@ module CWG
9
9
  def initialize(options = {})
10
10
  @options = options
11
11
  end
12
-
13
12
  end
14
-
15
13
  end
data/lib/cw/spoken.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Numbers provides the Number Testing functionality
6
6
 
@@ -9,7 +9,5 @@ module CWG
9
9
  def initialize(options = {})
10
10
  @options = options
11
11
  end
12
-
13
12
  end
14
-
15
13
  end
data/lib/cw/str.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Str
6
6
 
@@ -68,7 +68,5 @@ module CWG
68
68
  containing = Cfg.config["containing"]
69
69
  containing ? "Containing: #{stringify containing}\n" : nil
70
70
  end
71
-
72
71
  end
73
-
74
72
  end
@@ -1,8 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
5
- class CwStream
3
+ module CW
4
+ class Stream
6
5
 
7
6
  include Element
8
7
 
@@ -105,7 +104,5 @@ module CWG
105
104
  end
106
105
  end
107
106
  end
108
-
109
107
  end
110
-
111
108
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class TestLetters < Tester
6
5
 
7
6
  def process_input_word_maybe
data/lib/cw/test_words.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class TestWords < Tester
6
5
 
7
6
  def print_test_advice ; print.print_advice('Test Words') ; end
@@ -34,7 +33,5 @@ module CWG
34
33
  @popped = stream.pop_next_marked
35
34
  print.results(@popped) if(@popped && ! print_letters?)
36
35
  end
37
-
38
36
  end
39
-
40
37
  end
data/lib/cw/tester.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class Tester
6
5
 
7
6
  def quit ; Cfg.config.params["quit"] = true ; end
@@ -18,7 +17,7 @@ module CWG
18
17
  def key_chr ; key_input.char ; end
19
18
  def key_input ; @key_input ||= KeyInput.new ; end
20
19
  def is_relevant_char? ; key_input.is_relevant_char? ; end
21
- def stream ; @stream ||= CwStream.new ; end
20
+ def stream ; @stream ||= Stream.new ; end
22
21
  def reset_stdin ; key_input.reset_stdin ; end
23
22
  def current_word ; @current_word ||= CurrentWord.new ; end
24
23
  def init_char_timer ; timing.init_char_timer ; end
@@ -228,7 +227,7 @@ module CWG
228
227
  end
229
228
 
230
229
  def cw_threads
231
- @cw_threads ||= CWThreads.new(self, thread_processes)
230
+ @cw_threads ||= Threads.new(self, thread_processes)
232
231
  end
233
232
 
234
233
 
@@ -1,15 +1,14 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  module TextHelpers
6
5
 
7
6
  def letter_group
8
- (97..122).to_a
7
+ (97..122).collect {|e| e.chr}
9
8
  end
10
9
 
11
10
  def number_group
12
- (48..57).to_a
11
+ (48..57).collect {|e| e.chr}
13
12
  end
14
13
 
15
14
  def cw_chars chr
@@ -23,7 +22,5 @@ module CWG
23
22
  end
24
23
  temp
25
24
  end
26
-
27
25
  end
28
-
29
26
  end
@@ -1,8 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
5
- class CWThreads
3
+ module CW
4
+ class Threads
6
5
 
7
6
  attr_reader :threads
8
7
 
@@ -170,7 +169,5 @@ module CWG
170
169
  system("stty -raw echo")
171
170
  puts "\r"
172
171
  end
173
-
174
172
  end
175
-
176
173
  end
data/lib/cw/timing.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class Timing
6
5
 
7
6
  attr_accessor :delay_time
@@ -9,7 +8,7 @@ module CWG
9
8
 
10
9
  def initialize
11
10
  @delay_time = 0.0
12
- @cw_encoding = CwEncoding.new
11
+ @cw_encoding = Encoding.new
13
12
  end
14
13
 
15
14
  def cw_encoding enc
@@ -82,7 +81,5 @@ module CWG
82
81
  def append_char_delay letr, wpm, ewpm
83
82
  @delay_time += char_delay(letr, wpm, ewpm)
84
83
  end
85
-
86
84
  end
87
-
88
85
  end
@@ -2,8 +2,7 @@
2
2
 
3
3
  require 'wavefile'
4
4
 
5
- module CWG
6
-
5
+ module CW
7
6
  class ToneGenerator
8
7
 
9
8
  MUTE = false
@@ -62,7 +61,7 @@ module CWG
62
61
  end
63
62
 
64
63
  def cw_encoding
65
- @encoding ||= CwEncoding.new
64
+ @encoding ||= Encoding.new
66
65
  end
67
66
 
68
67
  def progress
@@ -1,7 +1,6 @@
1
1
  # Module ToneHelpers provides helper methods for ToneGenerator
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  module ToneHelpers
6
5
 
7
6
  TWO_PI = 2 * Math::PI
data/lib/cw/tx.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
- module CWG
3
2
 
3
+ module CW
4
4
  class Tx < Tester
5
5
 
6
6
  include ToneHelpers
@@ -374,7 +374,7 @@ module CWG
374
374
  end
375
375
 
376
376
  def cw_encoding
377
- @encoding ||= CwEncoding.new
377
+ @encoding ||= Encoding.new
378
378
  end
379
379
 
380
380
  def space_or_espace
@@ -455,7 +455,7 @@ module CWG
455
455
  end
456
456
 
457
457
  def cw_threads
458
- @cw_threads ||= CWThreads.new(self, thread_processes)
458
+ @cw_threads ||= Threads.new(self, thread_processes)
459
459
  end
460
460
 
461
461
  def tx string
data/lib/cw/voice.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Speak speaks with a voice
6
6
 
@@ -14,7 +14,5 @@ module CWG
14
14
  system("say #{words} -ospoken.wave -r#{rate} -v#{voice}")
15
15
  system("afplay spoken.wave")
16
16
  end
17
-
18
17
  end
19
-
20
18
  end
data/lib/cw/winkey.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rubyserial'
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class Winkey
6
5
 
7
6
  def initialize
data/lib/cw/words.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Words deals with words
6
6
 
@@ -139,7 +139,7 @@ module CWG
139
139
 
140
140
  def collect_words
141
141
  @words.each{ |word| ' ' + word }.
142
- collect{|wrd| wrd}.join(' ')
142
+ collect{ |wrd| wrd }.join(' ')
143
143
  end
144
144
 
145
145
  def reverse
@@ -147,7 +147,7 @@ module CWG
147
147
  end
148
148
 
149
149
  def letters_numbers
150
- letter_group.push( * number_group)
150
+ @words = letter_group.push( * number_group)
151
151
  end
152
152
 
153
153
  def random_letters(options = {})
@@ -171,9 +171,6 @@ module CWG
171
171
  end
172
172
 
173
173
  def numbers_spoken()
174
-
175
174
  end
176
-
177
175
  end
178
-
179
176
  end
data/run_script_tests.rb CHANGED
@@ -27,16 +27,16 @@ class RunScriptTests
27
27
  DB.create_table :test_runs do
28
28
  primary_key :id
29
29
  DateTime :date_time
30
- Fixnum :total_secs
30
+ Integer :total_secs
31
31
  String :result
32
32
  end
33
33
 
34
34
  DB.create_table :tests do
35
35
  primary_key :id
36
- Fixnum :test_run_id, :null => false
37
- Fixnum :script_id, :null => false
38
- Fixnum :wpm, :null => false
39
- Fixnum :ewpm, :null => false
36
+ Integer :test_run_id, :null => false
37
+ Integer :script_id, :null => false
38
+ Integer :wpm, :null => false
39
+ Integer :ewpm, :null => false
40
40
  String :duration
41
41
  end
42
42
  end
@@ -11,7 +11,7 @@ class TestCommonWords < MiniTest::Test
11
11
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
12
 
13
13
  def setup
14
- @words = CWG::CommonWords.new
14
+ @words = CW::CommonWords.new
15
15
  end
16
16
 
17
17
  def teardown
data/test/test_config.rb CHANGED
@@ -19,60 +19,60 @@ class TestConfig < MiniTest::Test
19
19
  ]
20
20
 
21
21
  def setup
22
- CWG::Cfg.reset
22
+ CW::Cfg.reset
23
23
  end
24
24
 
25
25
  def test_params_rewrite
26
- CWG::Cfg::CONFIG_METHODS.each_with_index do |label,idx|
27
- CWG::Cfg.config.params[label] = idx
26
+ CW::Cfg::CONFIG_METHODS.each_with_index do |label,idx|
27
+ CW::Cfg.config.params[label] = idx
28
28
  end
29
- 0.upto CWG::Cfg::CONFIG_METHODS.size - 1 do |idx|
30
- assert_equal(idx, CWG::Cfg.config.params[CWG::Cfg::CONFIG_METHODS[idx]])
29
+ 0.upto CW::Cfg::CONFIG_METHODS.size - 1 do |idx|
30
+ assert_equal(idx, CW::Cfg.config.params[CW::Cfg::CONFIG_METHODS[idx]])
31
31
  end
32
32
  end
33
33
 
34
34
  def test_wpm_default
35
- assert_equal "25", CWG::Cfg.config["wpm"]
35
+ assert_equal "25", CW::Cfg.config["wpm"]
36
36
  end
37
37
 
38
38
  def test_success_colour_default
39
- assert_equal "green", CWG::Cfg.config["success_colour"]
39
+ assert_equal "green", CW::Cfg.config["success_colour"]
40
40
  end
41
41
 
42
42
  def test_fail_colour_default
43
- assert_equal "red", CWG::Cfg.config["fail_colour"]
43
+ assert_equal "red", CW::Cfg.config["fail_colour"]
44
44
  end
45
45
 
46
46
  def test_list_colour_default
47
- assert_equal "default", CWG::Cfg.config["list_colour"]
47
+ assert_equal "default", CW::Cfg.config["list_colour"]
48
48
  end
49
49
 
50
50
  def test_ebook2cw_path_default
51
- assert_equal "/usr/bin/ebook2cw", CWG::Cfg.config["ebook2cw_path"]
51
+ assert_equal "/usr/bin/ebook2cw", CW::Cfg.config["ebook2cw_path"]
52
52
  end
53
53
 
54
54
  def test_run_default_default
55
- assert_equal "test_letters", CWG::Cfg.config["run_default"]
55
+ assert_equal "test_letters", CW::Cfg.config["run_default"]
56
56
  end
57
57
 
58
58
  def test_accessing_unknown_method_returns_nil
59
- refute CWG::Cfg.config["unknown"]
59
+ refute CW::Cfg.config["unknown"]
60
60
  end
61
61
 
62
62
  def test_setting_unknown_method_returns_nil
63
- CWG::Cfg.config.params["unknown"] = "something"
64
- assert_equal "something", CWG::Cfg.config["unknown"]
63
+ CW::Cfg.config.params["unknown"] = "something"
64
+ assert_equal "something", CW::Cfg.config["unknown"]
65
65
  end
66
66
 
67
67
  def test_an_existing_setting_works
68
- refute CWG::Cfg.config["exit"]
69
- CWG::Cfg.config.params["exit"] = true
70
- assert CWG::Cfg.config["exit"]
68
+ refute CW::Cfg.config["exit"]
69
+ CW::Cfg.config.params["exit"] = true
70
+ assert CW::Cfg.config["exit"]
71
71
  end
72
72
 
73
73
  def test_frequency
74
- CWG::Cfg.config.params["frequency"] = 400
75
- assert_equal 400, CWG::Cfg.config["frequency"]
74
+ CW::Cfg.config.params["frequency"] = 400
75
+ assert_equal 400, CW::Cfg.config["frequency"]
76
76
  end
77
77
  end
78
78