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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +26 -3
  3. data/.yardoc/checksums +2 -2
  4. data/.yardoc/object_types +0 -0
  5. data/.yardoc/objects/root.dat +0 -0
  6. data/audio/dash.wav +0 -0
  7. data/audio/dot.wav +0 -0
  8. data/audio/e_space.wav +0 -0
  9. data/audio/space.wav +0 -0
  10. data/cw.gemspec +1 -1
  11. data/doc/Alphabet.html +1 -1
  12. data/doc/AudioPlayer.html +1 -1
  13. data/doc/Book.html +1 -1
  14. data/doc/BookDetails.html +1 -1
  15. data/doc/CW.html +299 -125
  16. data/doc/CWThreads.html +1 -1
  17. data/doc/Cl.html +1 -1
  18. data/doc/CurrentWord.html +1 -1
  19. data/doc/CwDsl.html +1 -1
  20. data/doc/CwEncoding.html +1 -1
  21. data/doc/FileDetails.html +1 -1
  22. data/doc/KeyInput.html +1 -1
  23. data/doc/MonitorKeys.html +1 -1
  24. data/doc/Numbers.html +1 -1
  25. data/doc/Params.html +1 -1
  26. data/doc/Print.html +1 -1
  27. data/doc/Print/ProgressPrint.html +1 -1
  28. data/doc/Process.html +1 -1
  29. data/doc/Progress.html +1 -1
  30. data/doc/Randomize.html +1 -1
  31. data/doc/RepeatWord.html +1 -1
  32. data/doc/Rss.html +28 -26
  33. data/doc/Sentence.html +1 -1
  34. data/doc/Spoken.html +1 -1
  35. data/doc/Str.html +1 -1
  36. data/doc/Stream.html +1 -1
  37. data/doc/TestLetters.html +1 -1
  38. data/doc/TestWords.html +1 -1
  39. data/doc/Tester.html +1 -1
  40. data/doc/Timing.html +1 -1
  41. data/doc/ToneGenerator.html +1 -1
  42. data/doc/Voice.html +1 -1
  43. data/doc/Words.html +1 -1
  44. data/doc/_index.html +1 -1
  45. data/doc/file.README.html +14 -5
  46. data/doc/index.html +14 -5
  47. data/doc/method_list.html +289 -295
  48. data/doc/monitor.html +1 -1
  49. data/doc/top-level-namespace.html +1 -1
  50. data/lib/cw.rb +38 -13
  51. data/lib/cw/cw_dsl.rb +2 -0
  52. data/lib/cw/rss.rb +7 -6
  53. data/lib/cw/str.rb +18 -17
  54. data/test/test_cw.rb +5 -3
  55. 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 Mon May 23 21:20:17 2016 by
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 Mon May 23 21:20:15 2016 by
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
- # class CW provides Morse code generation functionality
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
- def run_word_test
64
- test_words = TestWords.new
65
- test_words.run @words
66
- end
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
- def read_rss(source, show_count = 3)
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, show_count)
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
- test_words.run @words
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
@@ -4,6 +4,8 @@
4
4
 
5
5
  class CwDsl
6
6
 
7
+ attr_accessor :cl
8
+
7
9
  HERE = File.dirname(__FILE__) + '/'
8
10
  TEXT = HERE + '../../data/text/'
9
11
  COMMON_WORDS = TEXT + 'common_words.txt'
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
- quotations: 'http://feeds.feedburner.com/quotationspage/qotd'
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[:quotations]
17
+ sources.has_key?(src) ? sources[src] : sources[:quotation]
18
18
  end
19
19
 
20
- def read_rss(src, show_count = 3)
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
- feed = Feedjira::Feed.fetch_and_parse url # returns a Hash, with each url having a Feedjira::Feed object
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
- entry = feed.entries.each do |entry|
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 >= show_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
- ["\n#{Params.name}\r",
14
- "\n#{delim}",
15
- "#{wpm_str}\n",
16
- shuffle_str,
17
- word_count_str,
18
- word_size_str,
19
- beginning_str,
20
- ending_str,
21
- delim].
22
- collect{ |prm| prm.to_s }.join
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\r"
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\r" : nil
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\r" : nil
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\r" : nil
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\r" : nil
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\r" : nil
61
+ ending ? "Ending: #{stringify ending}\n" : nil
61
62
  end
62
63
 
63
64
  def wpm_str
64
- "WPM: #{Params.wpm}\n\r"
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.strip()
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.11
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: