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.
- checksums.yaml +5 -5
- data/.travis.yml +3 -3
- data/VERSION +1 -1
- data/cw.gemspec +15 -15
- data/lib/cw.rb +9 -9
- data/lib/cw/alphabet.rb +1 -1
- data/lib/cw/audio_player.rb +3 -3
- data/lib/cw/book.rb +1 -1
- data/lib/cw/book_details.rb +2 -2
- data/lib/cw/callsign.rb +1 -2
- data/lib/cw/cl.rb +2 -2
- data/lib/cw/common_words.rb +2 -2
- data/lib/cw/config.rb +2 -2
- data/lib/cw/coreaudio.rb +2 -2
- data/lib/cw/current_word.rb +1 -1
- data/lib/cw/{cw_dsl.rb → dsl.rb} +8 -8
- data/lib/cw/element.rb +1 -2
- data/lib/cw/{cw_encoding.rb → encoding.rb} +2 -3
- data/lib/cw/file_details.rb +1 -2
- data/lib/cw/key_input.rb +1 -2
- data/lib/cw/numbers.rb +1 -1
- data/lib/cw/os.rb +1 -1
- data/lib/cw/play.rb +1 -2
- data/lib/cw/print.rb +1 -2
- data/lib/cw/progress.rb +1 -4
- data/lib/cw/randomize.rb +1 -3
- data/lib/cw/read.rb +2 -2
- data/lib/cw/repeat_word.rb +2 -3
- data/lib/cw/reveal.rb +1 -4
- data/lib/cw/rss.rb +3 -3
- data/lib/cw/rss_clean.rb +1 -1
- data/lib/cw/sentence.rb +2 -3
- data/lib/cw/speak.rb +1 -3
- data/lib/cw/spoken.rb +1 -3
- data/lib/cw/str.rb +1 -3
- data/lib/cw/{cw_stream.rb → stream.rb} +2 -5
- data/lib/cw/test_letters.rb +1 -2
- data/lib/cw/test_words.rb +1 -4
- data/lib/cw/tester.rb +3 -4
- data/lib/cw/text_helpers.rb +3 -6
- data/lib/cw/{cw_threads.rb → threads.rb} +2 -5
- data/lib/cw/timing.rb +2 -5
- data/lib/cw/tone_generator.rb +2 -3
- data/lib/cw/tone_helpers.rb +1 -2
- data/lib/cw/tx.rb +3 -3
- data/lib/cw/voice.rb +1 -3
- data/lib/cw/winkey.rb +1 -2
- data/lib/cw/words.rb +3 -6
- data/run_script_tests.rb +5 -5
- data/test/test_common_words.rb +1 -1
- data/test/test_config.rb +19 -19
- data/test/test_current_word.rb +1 -1
- data/test/test_cw.rb +13 -13
- data/test/test_cw_threads.rb +16 -16
- data/test/test_dsl.rb +106 -0
- data/test/test_filtering.rb +2 -2
- data/test/test_numbers.rb +24 -0
- data/test/test_params.rb +2 -2
- data/test/test_play.rb +4 -4
- data/test/test_stream.rb +3 -3
- data/test/test_tester.rb +4 -5
- data/test/test_timing.rb +3 -3
- data/test/test_tone_generator.rb +13 -13
- metadata +51 -49
data/lib/cw/reveal.rb
CHANGED
data/lib/cw/rss.rb
CHANGED
@@ -4,7 +4,7 @@ require 'oga'
|
|
4
4
|
require 'httpclient'
|
5
5
|
require "htmlentities"
|
6
6
|
|
7
|
-
module
|
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 =
|
44
|
-
clean_desc =
|
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
data/lib/cw/sentence.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
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 ==
|
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
data/lib/cw/spoken.rb
CHANGED
data/lib/cw/str.rb
CHANGED
data/lib/cw/test_letters.rb
CHANGED
data/lib/cw/test_words.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
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
|
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 ||=
|
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 ||=
|
230
|
+
@cw_threads ||= Threads.new(self, thread_processes)
|
232
231
|
end
|
233
232
|
|
234
233
|
|
data/lib/cw/text_helpers.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
4
|
-
|
3
|
+
module CW
|
5
4
|
module TextHelpers
|
6
5
|
|
7
6
|
def letter_group
|
8
|
-
(97..122).
|
7
|
+
(97..122).collect {|e| e.chr}
|
9
8
|
end
|
10
9
|
|
11
10
|
def number_group
|
12
|
-
(48..57).
|
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
|
data/lib/cw/timing.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
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 =
|
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
|
data/lib/cw/tone_generator.rb
CHANGED
data/lib/cw/tone_helpers.rb
CHANGED
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 ||=
|
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 ||=
|
458
|
+
@cw_threads ||= Threads.new(self, thread_processes)
|
459
459
|
end
|
460
460
|
|
461
461
|
def tx string
|
data/lib/cw/voice.rb
CHANGED
data/lib/cw/winkey.rb
CHANGED
data/lib/cw/words.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
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
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
data/test/test_common_words.rb
CHANGED
data/test/test_config.rb
CHANGED
@@ -19,60 +19,60 @@ class TestConfig < MiniTest::Test
|
|
19
19
|
]
|
20
20
|
|
21
21
|
def setup
|
22
|
-
|
22
|
+
CW::Cfg.reset
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_params_rewrite
|
26
|
-
|
27
|
-
|
26
|
+
CW::Cfg::CONFIG_METHODS.each_with_index do |label,idx|
|
27
|
+
CW::Cfg.config.params[label] = idx
|
28
28
|
end
|
29
|
-
0.upto
|
30
|
-
assert_equal(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",
|
35
|
+
assert_equal "25", CW::Cfg.config["wpm"]
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_success_colour_default
|
39
|
-
assert_equal "green",
|
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",
|
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",
|
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",
|
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",
|
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
|
59
|
+
refute CW::Cfg.config["unknown"]
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_setting_unknown_method_returns_nil
|
63
|
-
|
64
|
-
assert_equal "something",
|
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
|
69
|
-
|
70
|
-
assert
|
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
|
-
|
75
|
-
assert_equal 400,
|
74
|
+
CW::Cfg.config.params["frequency"] = 400
|
75
|
+
assert_equal 400, CW::Cfg.config["frequency"]
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|