cw 0.3.3 → 0.4.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 (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
@@ -11,7 +11,7 @@ class TestCurrentWord < MiniTest::Test
11
11
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
12
 
13
13
  def setup
14
- @word = CWG::CurrentWord.new
14
+ @word = CW::CurrentWord.new
15
15
  end
16
16
 
17
17
  def teardown
data/test/test_cw.rb CHANGED
@@ -6,12 +6,12 @@ require 'minitest/autorun'
6
6
  require 'minitest/pride'
7
7
  require_relative '../lib/cw'
8
8
 
9
- class TestCW < MiniTest::Test
9
+ class TestCore < MiniTest::Test
10
10
 
11
11
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
12
 
13
13
  def setup
14
- @cw = CW.new
14
+ @cw = Core.new
15
15
  @cw.no_run
16
16
  end
17
17
 
@@ -24,12 +24,12 @@ class TestCW < MiniTest::Test
24
24
  end
25
25
 
26
26
  def test_os_play_command
27
- obj = CWG::AudioPlayer.new
27
+ obj = CW::AudioPlayer.new
28
28
  assert ('afplay' == obj.os_play_command) || ('ossplay' == obj.os_play_command)
29
29
  end
30
30
 
31
31
  def test_cw_class
32
- assert_equal CW, @cw.class
32
+ assert_equal Core, @cw.class
33
33
  end
34
34
 
35
35
  def test_name_is_nil_if_unnamed
@@ -45,14 +45,14 @@ class TestCW < MiniTest::Test
45
45
  assert_equal %w(the of and to a), @cw.words.first(5)
46
46
  end
47
47
 
48
- def test_CW_takes_a_block
49
- CW.new {
48
+ def test_Core_takes_a_block
49
+ Core.new {
50
50
  no_run
51
51
  }
52
52
  end
53
53
 
54
54
  def test_words_loads_words
55
- cw = CW.new {
55
+ cw = Core.new {
56
56
  no_run
57
57
  }
58
58
  assert_equal 1000, cw.words.size
@@ -62,7 +62,7 @@ class TestCW < MiniTest::Test
62
62
 
63
63
  def test_no_run_aliases_no_run
64
64
  time = Time.now
65
- cw = CW.new {
65
+ cw = Core.new {
66
66
  no_run
67
67
  }
68
68
  cw.words = %w(some words)
@@ -70,7 +70,7 @@ class TestCW < MiniTest::Test
70
70
  end
71
71
 
72
72
  def test_load_common_words_loads_common_words
73
- cw = CW.new {
73
+ cw = Core.new {
74
74
  no_run
75
75
  }
76
76
  cw.words = %w(some words)
@@ -460,7 +460,7 @@ Ending: x
460
460
 
461
461
  # def test_cl_echo_returns_correct_string
462
462
  # str = ''
463
- # CW.new do
463
+ # Core.new do
464
464
  # str = @cl.cl_echo('some words')
465
465
  # no_run
466
466
  # end
@@ -469,19 +469,19 @@ Ending: x
469
469
 
470
470
  def test_words_exist
471
471
  temp = nil
472
- CW.new do
472
+ Core.new do
473
473
  words = 'some words added here'
474
474
  temp = words
475
475
  no_run
476
476
  end
477
477
  assert_equal(4, temp.split.size)
478
- CW.new do
478
+ Core.new do
479
479
  @words.add 'a couple of words'
480
480
  temp = words
481
481
  no_run
482
482
  end
483
483
  assert_equal(4, temp.split.size)
484
- CW.new do
484
+ Core.new do
485
485
  @words.add nil
486
486
  temp = words
487
487
  no_run
@@ -4,31 +4,31 @@ $VERBOSE = nil #FIXME
4
4
 
5
5
  require 'minitest/autorun'
6
6
  require 'minitest/pride'
7
- require_relative '../lib/cw/cw_threads.rb'
7
+ require_relative '../lib/cw/threads.rb'
8
8
 
9
- class TestCWStream < MiniTest::Test
9
+ class TestThreads < MiniTest::Test
10
10
 
11
11
  ROOT = File.expand_path File.dirname(__FILE__) + '/../../'
12
12
 
13
- def a_thread
14
- @test_var = 2 + 3
13
+ def setup
14
+ @test_var = 0
15
+ @threads = CW::Threads.new(self, [:a_thread])
15
16
  end
16
17
 
17
- def sleep_thread
18
- sleep 100
18
+ def teardown
19
+ @threads = nil
19
20
  end
20
21
 
21
- def setup
22
- @test_var = 0
23
- @threads = CWG::CWThreads.new(self, [:a_thread])
22
+ def a_thread
23
+ @test_var = 2 + 3
24
24
  end
25
25
 
26
- def teardown
27
- @cw = nil
26
+ def sleep_thread
27
+ sleep 100
28
28
  end
29
29
 
30
- def test_cw_threads
31
- assert true
30
+ def test_threads_class
31
+ assert_equal CW::Threads, @threads.class
32
32
  end
33
33
 
34
34
  def test_threads_exposes_name
@@ -49,7 +49,7 @@ class TestCWStream < MiniTest::Test
49
49
 
50
50
  # failed on one build
51
51
  # def test_kill_thread_kills_thread
52
- # threads = CWG::CWThreads.new(self, [:sleep_thread])
52
+ # threads = CW::Threads.new(self, [:sleep_thread])
53
53
  # threads.start_threads
54
54
  # thread = threads.threads[0]
55
55
  # assert_equal "run", thread[:thread].status
@@ -68,7 +68,7 @@ class TestCWStream < MiniTest::Test
68
68
  # end
69
69
  #
70
70
  def test_handles_multiple_threads
71
- threads = CWG::CWThreads.new(self, [:a_thread, :sleep_thread])
71
+ threads = CW::Threads.new(self, [:a_thread, :sleep_thread])
72
72
  threads.start_threads
73
73
  assert threads.threads[0][:thread].is_a? Thread
74
74
  assert threads.threads[1][:thread].is_a? Thread
@@ -96,7 +96,7 @@ class TestCWStream < MiniTest::Test
96
96
 
97
97
  #todo Too fragile!
98
98
  # def test_kill_open_threads_kills_threads
99
- # threads = CWThreads.new(self, [:sleep_thread, :a_thread])
99
+ # threads = Threads.new(self, [:sleep_thread, :a_thread])
100
100
  # threads.start_threads
101
101
  # thread0 = threads.threads[0]
102
102
  # assert_equal "run", thread0[:thread].status
data/test/test_dsl.rb ADDED
@@ -0,0 +1,106 @@
1
+ require 'simplecov'
2
+ $VERBOSE = nil #FIXME
3
+ SimpleCov.start
4
+
5
+ require 'minitest/autorun'
6
+ require 'minitest/pride'
7
+ require_relative '../lib/cw'
8
+
9
+ class TestNumbers < MiniTest::Test
10
+
11
+ ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
+
13
+ def setup
14
+ @dsl = CW::Dsl.new
15
+ end
16
+
17
+ def teardown
18
+ @dsl = nil
19
+ end
20
+
21
+ def test_words_returns_words
22
+ words = @dsl.words
23
+ assert words.is_a? Array
24
+ assert_equal 1000, words.size
25
+ assert_equal 'the', words.first
26
+ end
27
+
28
+ def test_load_common_words_returns_words
29
+ words = @dsl.load_common_words
30
+ assert words.is_a? Array
31
+ assert_equal 1000, words.size
32
+ assert_equal 'the', words.first
33
+ end
34
+
35
+ def test_most_load_most_common_words_returns_words
36
+ words = @dsl.load_most_common_words
37
+ assert words.is_a? Array
38
+ assert_equal 500, words.size
39
+ assert_equal 'the', words.first
40
+ end
41
+
42
+ def test_load_abbreviations
43
+ words = @dsl.load_abbreviations
44
+ assert words.is_a? Array
45
+ assert_equal 85, words.size
46
+ assert_equal 'abt', words.first
47
+ end
48
+
49
+ def test_reverse
50
+ @dsl.words = %w[a b c]
51
+ assert_equal CW::Dsl, @dsl.class
52
+ @dsl.reverse
53
+ assert_equal 'c', @dsl.words.first
54
+ end
55
+
56
+ def test_double_words
57
+ @dsl.words = %w[a b]
58
+ @dsl.double_words
59
+ assert_equal %w[a a b b], @dsl.words
60
+ end
61
+
62
+ def test_letters_numbers
63
+ assert_equal %w[a b c d e], @dsl.letters_numbers[0..4]
64
+ assert_equal %w[y z], @dsl.words[24..25]
65
+ assert_equal %w[0 1], @dsl.words[26..27]
66
+ assert_equal %w[8 9], @dsl.words[34..35]
67
+ end
68
+
69
+ def test_random_numbers
70
+ @dsl.random_numbers
71
+ assert_equal Array, @dsl.words.class
72
+ assert_equal 50, @dsl.words.size
73
+ @dsl.words.each do |wrd|
74
+ assert wrd.size == 4
75
+ assert wrd.to_i > 0
76
+ assert wrd.to_i < 10000
77
+ end
78
+ end
79
+
80
+ def test_random_letters
81
+ @dsl.random_letters
82
+ assert_equal Array, @dsl.words.class
83
+ assert_equal 50, @dsl.words.size
84
+ @dsl.words.each do |wrd|
85
+ assert wrd.size == 4
86
+ end
87
+ end
88
+
89
+ def test_random_letters_numbers
90
+ @dsl.random_letters_numbers
91
+ assert_equal Array, @dsl.words.class
92
+ assert_equal 50, @dsl.words.size
93
+ @dsl.words.each do |wrd|
94
+ assert wrd.size == 4
95
+ end
96
+ end
97
+
98
+ def test_alphabet
99
+ @dsl.alphabet
100
+ assert_equal ["a b c d e f g h i j k l m n o p q r s t u v w x y z"], @dsl.words
101
+ end
102
+
103
+ def test_numbers
104
+ assert_equal ['0', '1', '2', '3', '4'], @dsl.numbers[0..4]
105
+ end
106
+ end
@@ -6,12 +6,12 @@ require 'minitest/autorun'
6
6
  require 'minitest/pride'
7
7
  require_relative '../lib/cw'
8
8
 
9
- class TestCW < MiniTest::Test
9
+ class TestFiltering < MiniTest::Test
10
10
 
11
11
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
12
 
13
13
  def setup
14
- @cw = CW.new
14
+ @cw = Core.new
15
15
  @cw.no_run
16
16
  end
17
17
 
@@ -0,0 +1,24 @@
1
+ require 'simplecov'
2
+ $VERBOSE = nil #FIXME
3
+ SimpleCov.start
4
+
5
+ require 'minitest/autorun'
6
+ require 'minitest/pride'
7
+ require_relative '../lib/cw'
8
+
9
+ class TestNumbers < MiniTest::Test
10
+
11
+ ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
+
13
+ def setup
14
+ @dsl = CW::Dsl.new
15
+ end
16
+
17
+ def teardown
18
+ @dsl = nil
19
+ end
20
+
21
+ def test_numbers
22
+ assert_equal ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], @dsl.numbers
23
+ end
24
+ end
data/test/test_params.rb CHANGED
@@ -12,7 +12,7 @@ class TestStr < MiniTest::Test
12
12
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
13
13
 
14
14
  def setup
15
- @str = CWG::Str.new
15
+ @str = CW::Str.new
16
16
  end
17
17
 
18
18
  def test_stringify
@@ -20,7 +20,7 @@ class TestStr < MiniTest::Test
20
20
  end
21
21
 
22
22
  # def test_beginning_str
23
- # cw = CW.new {
23
+ # cw = Core.new {
24
24
  # no_run
25
25
  # assert_equal '', @str.beginning_str
26
26
  # }
data/test/test_play.rb CHANGED
@@ -9,7 +9,7 @@ class TestPlay < MiniTest::Test
9
9
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
10
10
 
11
11
  def setup
12
- @p = CWG::Play.new('words')
12
+ @p = CW::Play.new('words')
13
13
  end
14
14
 
15
15
  def teardown
@@ -17,12 +17,12 @@ class TestPlay < MiniTest::Test
17
17
  end
18
18
 
19
19
  def test_play_object_takes_a_word_parameter
20
- play = CWG::Play.new('words object')
20
+ play = CW::Play.new('words object')
21
21
  assert_equal 'words object', play.instance_variable_get('@words')
22
22
  end
23
23
 
24
24
  def test_audio_instantiates_AudioPlayer_object
25
- assert_equal CWG::AudioPlayer, @p.audio.class
25
+ assert_equal CW::AudioPlayer, @p.audio.class
26
26
  end
27
27
 
28
28
  def test_init_play_words_timeout_sets_start_play_time
@@ -42,7 +42,7 @@ class TestPlay < MiniTest::Test
42
42
  end
43
43
 
44
44
  def test_add_space
45
- words = CWG::Words.new
45
+ words = CW::Words.new
46
46
  words.assign ['some','words']
47
47
 
48
48
  assert_equal 'some words ', @p.add_space(words)
data/test/test_stream.rb CHANGED
@@ -4,7 +4,7 @@ SimpleCov.start
4
4
  require 'minitest/autorun'
5
5
  require 'minitest/pride'
6
6
  require_relative '../lib/cw/element'
7
- require_relative '../lib/cw/cw_stream'
7
+ require_relative '../lib/cw/stream'
8
8
 
9
9
  # class TestStreamMatching < MiniTest::Test
10
10
  # def setup
@@ -140,10 +140,10 @@ require_relative '../lib/cw/cw_stream'
140
140
  # end
141
141
  # end
142
142
 
143
- class TestCwStream < MiniTest::Test
143
+ class TestStream < MiniTest::Test
144
144
 
145
145
  def setup
146
- @stream = CWG::CwStream.new
146
+ @stream = CW::Stream.new
147
147
  end
148
148
 
149
149
  def teardown
data/test/test_tester.rb CHANGED
@@ -9,7 +9,7 @@ class TestTester < MiniTest::Test
9
9
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
10
10
 
11
11
  def setup
12
- @object = CWG::Tester.new
12
+ @object = CW::Tester.new
13
13
 
14
14
  end
15
15
 
@@ -27,18 +27,17 @@ class TestTester < MiniTest::Test
27
27
  end
28
28
 
29
29
  def test_quit
30
- CWG::Cfg.config.params["quit"] = false
30
+ CW::Cfg.config.params["quit"] = false
31
31
  refute @object.quit?
32
32
  @object.quit
33
33
  assert @object.quit?
34
34
  end
35
35
 
36
36
  def test_print_instantiates_Print_object
37
- assert_equal CWG::Print, @object.print.class
37
+ assert_equal CW::Print, @object.print.class
38
38
  end
39
39
 
40
40
  def test_timing_instantiates_Timing_object
41
- assert_equal CWG::Timing, @object.timing.class
41
+ assert_equal CW::Timing, @object.timing.class
42
42
  end
43
-
44
43
  end
data/test/test_timing.rb CHANGED
@@ -11,7 +11,7 @@ class TestTiming < MiniTest::Test
11
11
  ROOT = File.expand_path File.dirname(__FILE__) + '/../'
12
12
 
13
13
  def setup
14
- @timing = CWG::Timing.new
14
+ @timing = CW::Timing.new
15
15
  end
16
16
 
17
17
  def teardown
@@ -36,8 +36,8 @@ class TestTiming < MiniTest::Test
36
36
  assert_equal 0.0, @timing.delay_time
37
37
  end
38
38
 
39
- def test_initialize_initializes_instance_of_CwEncoding
40
- assert_equal CWG::CwEncoding, @timing.instance_variable_get(:@cw_encoding).class
39
+ def test_initialize_initializes_instance_of_Encoding
40
+ assert_equal CW::Encoding, @timing.instance_variable_get(:@cw_encoding).class
41
41
  end
42
42
 
43
43
  def test_cw_encoding_returns_an_encoding