cw 0.0.11 → 0.0.12
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 +4 -4
- data/.gitignore +26 -3
- data/.yardoc/checksums +2 -2
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/audio/dash.wav +0 -0
- data/audio/dot.wav +0 -0
- data/audio/e_space.wav +0 -0
- data/audio/space.wav +0 -0
- data/cw.gemspec +1 -1
- data/doc/Alphabet.html +1 -1
- data/doc/AudioPlayer.html +1 -1
- data/doc/Book.html +1 -1
- data/doc/BookDetails.html +1 -1
- data/doc/CW.html +299 -125
- data/doc/CWThreads.html +1 -1
- data/doc/Cl.html +1 -1
- data/doc/CurrentWord.html +1 -1
- data/doc/CwDsl.html +1 -1
- data/doc/CwEncoding.html +1 -1
- data/doc/FileDetails.html +1 -1
- data/doc/KeyInput.html +1 -1
- data/doc/MonitorKeys.html +1 -1
- data/doc/Numbers.html +1 -1
- data/doc/Params.html +1 -1
- data/doc/Print.html +1 -1
- data/doc/Print/ProgressPrint.html +1 -1
- data/doc/Process.html +1 -1
- data/doc/Progress.html +1 -1
- data/doc/Randomize.html +1 -1
- data/doc/RepeatWord.html +1 -1
- data/doc/Rss.html +28 -26
- data/doc/Sentence.html +1 -1
- data/doc/Spoken.html +1 -1
- data/doc/Str.html +1 -1
- data/doc/Stream.html +1 -1
- data/doc/TestLetters.html +1 -1
- data/doc/TestWords.html +1 -1
- data/doc/Tester.html +1 -1
- data/doc/Timing.html +1 -1
- data/doc/ToneGenerator.html +1 -1
- data/doc/Voice.html +1 -1
- data/doc/Words.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +14 -5
- data/doc/index.html +14 -5
- data/doc/method_list.html +289 -295
- data/doc/monitor.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/cw.rb +38 -13
- data/lib/cw/cw_dsl.rb +2 -0
- data/lib/cw/rss.rb +7 -6
- data/lib/cw/str.rb +18 -17
- data/test/test_cw.rb +5 -3
- metadata +2 -1
data/doc/monitor.html
CHANGED
@@ -426,7 +426,7 @@
|
|
426
426
|
</div>
|
427
427
|
|
428
428
|
<div id="footer">
|
429
|
-
Generated on
|
429
|
+
Generated on Wed May 25 15:00:25 2016 by
|
430
430
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
431
431
|
0.8.7.6 (ruby-2.2.0).
|
432
432
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on
|
108
|
+
Generated on Wed May 25 15:00:24 2016 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.8.7.6 (ruby-2.2.0).
|
111
111
|
</div>
|
data/lib/cw.rb
CHANGED
@@ -28,25 +28,42 @@ require_relative 'cw/cw_encoding'
|
|
28
28
|
require_relative 'cw/tone_generator.rb'
|
29
29
|
require_relative 'cw/progress'
|
30
30
|
|
31
|
-
#
|
31
|
+
# CW provides Morse code generation functionality
|
32
32
|
|
33
33
|
class CW < CwDsl
|
34
34
|
|
35
35
|
attr_accessor :dry_run
|
36
36
|
attr_accessor :quit
|
37
37
|
|
38
|
+
# Test user against letters rather than words.
|
39
|
+
#
|
40
|
+
|
38
41
|
def test_letters
|
39
42
|
@inhibit_block_run = true
|
40
43
|
test_letters = TestLetters.new
|
41
44
|
test_letters.run @words
|
42
45
|
end
|
43
46
|
|
47
|
+
# Test user against complete words rather than letters.
|
48
|
+
#
|
49
|
+
|
50
|
+
def test_words
|
51
|
+
tw = TestWords.new
|
52
|
+
tw.run @words
|
53
|
+
end
|
54
|
+
|
55
|
+
# Repeat word repeats the current word if the word is entered incorrectly (or not entered at all).
|
56
|
+
#
|
57
|
+
|
44
58
|
def repeat_word
|
45
59
|
@inhibit_block_run = true
|
46
60
|
repeat_word = RepeatWord.new
|
47
61
|
repeat_word.run @words
|
48
62
|
end
|
49
63
|
|
64
|
+
# Initialize CW class. Eval block if passed in.
|
65
|
+
|
66
|
+
|
50
67
|
def initialize(&block)
|
51
68
|
|
52
69
|
super
|
@@ -56,18 +73,18 @@ class CW < CwDsl
|
|
56
73
|
run unless Params.pause if (block && ! @inhibit_block_run)
|
57
74
|
end
|
58
75
|
|
76
|
+
# Return string containing name or comment of test.
|
77
|
+
# @return [String] comment / name
|
78
|
+
|
59
79
|
def to_s
|
60
80
|
@str.to_s
|
61
81
|
end
|
62
82
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def test_words
|
69
|
-
run_word_test
|
70
|
-
end
|
83
|
+
# Play book using provided arguments.
|
84
|
+
# @param [Hash] args the options to play book with.
|
85
|
+
# @option args [Integer] :sentences Number of sentences to play
|
86
|
+
# @option args [Integer] :duration Number of minutes to play
|
87
|
+
# @option args [Boolean] :letter Mark by letter if true else mark by word
|
71
88
|
|
72
89
|
def play_book args = {}
|
73
90
|
@inhibit_block_run = true
|
@@ -77,19 +94,27 @@ class CW < CwDsl
|
|
77
94
|
book.run @words
|
78
95
|
end
|
79
96
|
|
80
|
-
|
97
|
+
# Reads RSS feed (requires an internet connection). Feed can be one of:
|
98
|
+
# - bbc:
|
99
|
+
# - reuters:
|
100
|
+
# - guardian:
|
101
|
+
# - quotation:
|
102
|
+
# @param [Symbol] source The source of the feed.
|
103
|
+
# @param [Integer] article_count Number of articles to play.
|
104
|
+
|
105
|
+
def read_rss(source, article_count = 3)
|
81
106
|
@inhibit_block_run = true
|
82
107
|
rss, = Rss.new
|
83
|
-
rss.read_rss(source,
|
108
|
+
rss.read_rss(source, article_count)
|
84
109
|
loop do
|
85
110
|
article = rss.next_article
|
86
111
|
return unless article
|
87
|
-
test_words = TestWords.new
|
88
112
|
@words.assign article
|
89
|
-
|
113
|
+
run
|
90
114
|
end
|
91
115
|
end
|
92
116
|
|
117
|
+
# Run word test
|
93
118
|
def run ; test_words ; end
|
94
119
|
|
95
120
|
alias_method :ewpm, :effective_wpm
|
data/lib/cw/cw_dsl.rb
CHANGED
data/lib/cw/rss.rb
CHANGED
@@ -9,24 +9,25 @@ class Rss
|
|
9
9
|
bbc: 'http://feeds.bbci.co.uk/news/rss.xml',
|
10
10
|
reuters: 'http://feeds.reuters.com/Reuters/worldNews?format=xml',
|
11
11
|
guardian: 'http://www.theguardian.com/world/rss',
|
12
|
-
|
12
|
+
quotation: 'http://feeds.feedburner.com/quotationspage/qotd'
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
16
|
def source src
|
17
|
-
sources.has_key?(src) ? sources[src] : sources[:
|
17
|
+
sources.has_key?(src) ? sources[src] : sources[:quotation]
|
18
18
|
end
|
19
19
|
|
20
|
-
def read_rss(src,
|
20
|
+
def read_rss(src, article_count = 3)
|
21
21
|
require 'feedjira'
|
22
22
|
require "htmlentities"
|
23
23
|
require 'sanitize'
|
24
24
|
coder = HTMLEntities.new
|
25
25
|
url = source(src)
|
26
|
-
|
26
|
+
# return a Hash - each url having a Feedjira::Feed object
|
27
|
+
feed = Feedjira::Feed.fetch_and_parse url
|
27
28
|
entry_count = 0
|
28
29
|
@rss_articles = []
|
29
|
-
|
30
|
+
feed.entries.each do |entry|
|
30
31
|
title = entry.title
|
31
32
|
unless(title.include?('VIDEO:') ||
|
32
33
|
title.include?('In pictures:') ||
|
@@ -35,7 +36,7 @@ class Rss
|
|
35
36
|
entry_count += 1
|
36
37
|
end
|
37
38
|
@rss_articles << (Sanitize.clean coder.decode words).split(',')
|
38
|
-
break if entry_count >=
|
39
|
+
break if entry_count >= article_count
|
39
40
|
end
|
40
41
|
@rss_flag = true
|
41
42
|
end
|
data/lib/cw/str.rb
CHANGED
@@ -10,16 +10,17 @@ class Str
|
|
10
10
|
|
11
11
|
def to_s
|
12
12
|
delim = delim_std_str
|
13
|
-
[
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
[
|
14
|
+
"#{Params.name}\n",
|
15
|
+
"#{delim}",
|
16
|
+
"#{wpm_str}",
|
17
|
+
shuffle_str,
|
18
|
+
word_count_str,
|
19
|
+
word_size_str,
|
20
|
+
beginning_str,
|
21
|
+
ending_str,
|
22
|
+
delim
|
23
|
+
].collect{ |prm| prm.to_s }.join
|
23
24
|
end
|
24
25
|
|
25
26
|
def stringify ary
|
@@ -27,7 +28,7 @@ class Str
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def delim_str size
|
30
|
-
"#{'=' * size}\n
|
31
|
+
"#{'=' * size}\n"
|
31
32
|
end
|
32
33
|
|
33
34
|
def delim_std_str
|
@@ -37,31 +38,31 @@ class Str
|
|
37
38
|
|
38
39
|
def shuffle_str
|
39
40
|
shuffle = Params.shuffle
|
40
|
-
shuffle ? "Shuffle: #{shuffle ? 'yes' : 'no'}\n
|
41
|
+
shuffle ? "Shuffle: #{shuffle ? 'yes' : 'no'}\n" : nil
|
41
42
|
end
|
42
43
|
|
43
44
|
def word_count_str
|
44
45
|
wc = Params.word_count
|
45
|
-
wc ? "Word count: #{wc}\n
|
46
|
+
wc ? "Word count: #{wc}\n" : nil
|
46
47
|
end
|
47
48
|
|
48
49
|
def word_size_str
|
49
50
|
size = Params.size
|
50
|
-
size ? "Word size: #{size}\n
|
51
|
+
size ? "Word size: #{size}\n" : nil
|
51
52
|
end
|
52
53
|
|
53
54
|
def beginning_str
|
54
55
|
beginning = Params.begin
|
55
|
-
beginning ? "Beginning: #{stringify beginning}\n
|
56
|
+
beginning ? "Beginning: #{stringify beginning}\n" : nil
|
56
57
|
end
|
57
58
|
|
58
59
|
def ending_str
|
59
60
|
ending = Params.end
|
60
|
-
ending ? "Ending: #{stringify ending}\n
|
61
|
+
ending ? "Ending: #{stringify ending}\n" : nil
|
61
62
|
end
|
62
63
|
|
63
64
|
def wpm_str
|
64
|
-
"WPM: #{Params.wpm}\n
|
65
|
+
"WPM: #{Params.wpm}\n"
|
65
66
|
end
|
66
67
|
|
67
68
|
end
|
data/test/test_cw.rb
CHANGED
@@ -136,7 +136,8 @@ class TestCW < MiniTest::Test
|
|
136
136
|
%q(unnamed
|
137
137
|
=======
|
138
138
|
WPM: 25
|
139
|
-
=======
|
139
|
+
=======
|
140
|
+
)
|
140
141
|
assert_equal temp, @cw.to_s
|
141
142
|
end
|
142
143
|
|
@@ -150,13 +151,14 @@ Word count: 2
|
|
150
151
|
Word size: 3
|
151
152
|
Beginning: l
|
152
153
|
Ending: x
|
153
|
-
=======
|
154
|
+
=======
|
155
|
+
)
|
154
156
|
@cw.shuffle
|
155
157
|
@cw.word_count 2
|
156
158
|
@cw.word_size 3
|
157
159
|
@cw.ending_with('x')
|
158
160
|
@cw.beginning_with('l')
|
159
|
-
assert_equal temp, @cw.to_s
|
161
|
+
assert_equal temp, @cw.to_s
|
160
162
|
end
|
161
163
|
|
162
164
|
def test_wpm_defaults_to_25_if_unset
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martyn Jago
|
@@ -281,3 +281,4 @@ signing_key:
|
|
281
281
|
specification_version: 4
|
282
282
|
summary: CW tutor / exerciser
|
283
283
|
test_files: []
|
284
|
+
has_rdoc:
|