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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f32cecabf34fb0f987f2c33b7678f5d1de000655
4
- data.tar.gz: 38ea73121579a8b0e194021e8997b191939e3bc8
2
+ SHA256:
3
+ metadata.gz: 2607a56ec12dd2d8582bdf6848e6d43fca1559aab5b903a5ba7eddc716f8f164
4
+ data.tar.gz: 2420c8070826ac4d596885155c27b74f7bcf0e014f755ec270d0e02f91acc39b
5
5
  SHA512:
6
- metadata.gz: 3a9c6b660fba1f14a7429d73879cef6cc28790ecb8136576d580e3ad388a35cfdd12d4f8fdcee7d67b0b5427bc0a290db942359d73fa73faec06f2cc119cc2d3
7
- data.tar.gz: a0bd05411135bfdbb77dd51091445bf5d3e556c1f05a7afbe5bc60787ec8c2c276e487ec3bd60807a8f4b89b3853f25ae631de76648498f45d05e3aa8c1c3478
6
+ metadata.gz: 6081dd5de93a4706294f5fb09cbe2dc4ae2384e3ab3daebcfc26ed7de560e803b5bace946209aac1c47dd347887416e6c0c14e943064c0a3d0f98818523add2f
7
+ data.tar.gz: 658106773af6d4f17e73174f625cdbec1839d5b09bf5c1f88f455f42f83818f51f0cfefbd4cd6afcfe7a21a1a8a3b3d9d3010456a690ddd7b75ea778689232e3
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.0.0"
4
- - "2.1.0"
5
- - "2.2.3"
3
+ - "2.2.8"
4
+ - "2.3.5"
5
+ - "2.4.2"
6
6
  script:
7
7
  - rake test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.4.0
data/cw.gemspec CHANGED
@@ -18,23 +18,23 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.require_paths = ["lib", "audio", "data/text", "test"]
20
20
 
21
- spec.required_ruby_version = '>= 2.0.0'
22
- spec.add_runtime_dependency 'oga', '~> 2.8'
23
- spec.add_runtime_dependency 'httpclient'
24
- spec.add_runtime_dependency 'htmlentities', '>= 4.3.4'
25
- spec.add_runtime_dependency 'paint', '>= 1.0.1'
26
- spec.add_runtime_dependency 'rake', '>= 11.2.2'
27
- spec.add_runtime_dependency 'ruby-progressbar', '>= 1.8.1'
28
- spec.add_runtime_dependency 'wavefile', '>= 0.7.0'
21
+ spec.required_ruby_version = '>= 2.2.8'
22
+ spec.add_runtime_dependency 'oga', '~> 2.11'
23
+ spec.add_runtime_dependency 'httpclient', '~> 2.8.3'
24
+ spec.add_runtime_dependency 'htmlentities', '~> 4.3.4'
25
+ spec.add_runtime_dependency 'paint', '~> 2.0.1'
26
+ spec.add_runtime_dependency 'rake', '~> 12.3.0'
27
+ spec.add_runtime_dependency 'ruby-progressbar'
28
+ spec.add_runtime_dependency 'wavefile', '~> 0.8.1'
29
29
  spec.add_runtime_dependency 'parseconfig', '~> 1.0.8'
30
30
  spec.add_runtime_dependency 'rubyserial', '~> 0.4.0'
31
31
 
32
- spec.add_dependency 'os', '~> 0.9.6'
32
+ spec.add_dependency 'os', '~> 1.0.0'
33
33
 
34
- spec.add_development_dependency 'version', '>= 1.0.0'
35
- spec.add_development_dependency 'minitest', '>= 5.10.1'
36
- spec.add_development_dependency 'simplecov', '>= 0.12.0'
37
- spec.add_development_dependency 'yard', '~> 0.9.5'
38
- spec.add_development_dependency 'sequel', '~> 4.42.0'
39
- spec.add_development_dependency 'sqlite3', '~> 1.3.11'
34
+ spec.add_development_dependency 'version', '~> 1.1.1'
35
+ spec.add_development_dependency 'minitest', '~> 5.10.3'
36
+ spec.add_development_dependency 'simplecov', '~> 0.15.1'
37
+ spec.add_development_dependency 'yard', '~> 0.9.11'
38
+ spec.add_development_dependency 'sequel', '~> 5.2.0'
39
+ spec.add_development_dependency 'sqlite3', '~> 1.3.13'
40
40
  end
data/lib/cw.rb CHANGED
@@ -8,8 +8,8 @@ require_relative 'cw/text_helpers'
8
8
  require_relative 'cw/tone_helpers'
9
9
  require_relative 'cw/element'
10
10
  require_relative 'cw/current_word'
11
- require_relative 'cw/cw_encoding'
12
- require_relative 'cw/cw_dsl'
11
+ require_relative 'cw/encoding'
12
+ require_relative 'cw/dsl'
13
13
  require_relative 'cw/randomize'
14
14
  require_relative 'cw/sentence'
15
15
  require_relative 'cw/alphabet'
@@ -20,11 +20,11 @@ require_relative 'cw/rss_clean'
20
20
  require_relative 'cw/words'
21
21
  require_relative 'cw/cl'
22
22
  require_relative 'cw/key_input'
23
- require_relative 'cw/cw_stream'
23
+ require_relative 'cw/stream'
24
24
  require_relative 'cw/timing'
25
25
  require_relative 'cw/print'
26
26
  require_relative 'cw/audio_player'
27
- require_relative 'cw/cw_threads'
27
+ require_relative 'cw/threads'
28
28
  require_relative 'cw/book_details'
29
29
  require_relative 'cw/tester'
30
30
  require_relative 'cw/play'
@@ -48,17 +48,17 @@ if RbConfig::CONFIG['target_os'].include?('darwin')
48
48
  end
49
49
 
50
50
  def cw &block
51
- CW.new do
51
+ Core.new do
52
52
  instance_eval(&block)
53
53
  end
54
54
  end
55
55
 
56
- # CW provides Morse code generation functionality
57
- # Inherits CwDsl
56
+ # Core provides Morse code generation functionality
57
+ # Inherits Dsl
58
58
 
59
- class CW < CWG::CwDsl
59
+ class Core < CW::Dsl
60
60
 
61
- # Initialize CW class. Eval block if passed in.
61
+ # Initialize Core class. Eval block if passed in.
62
62
 
63
63
  def initialize(&block)
64
64
  super
data/lib/cw/alphabet.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Alphabet provides alphabet generation functionality
6
6
 
@@ -3,12 +3,12 @@
3
3
  require 'timeout'
4
4
  require 'os'
5
5
 
6
- module CWG
6
+ module CW
7
7
 
8
8
  class AudioPlayer
9
9
 
10
10
  include FileDetails
11
- include CWG::OStest
11
+ include CW::OStest
12
12
 
13
13
  def tone
14
14
  @tone ||= ToneGenerator.new
@@ -75,7 +75,7 @@ module CWG
75
75
  cmd = play_command + ' ' + play_filename
76
76
  @pid = ! @dry_run ? Process.spawn(cmd) : cmd
77
77
  begin
78
- Process.waitpid(@pid) if @pid.is_a?(Fixnum)
78
+ Process.waitpid(@pid) if @pid.is_a?(1.class)
79
79
  rescue Errno::ECHILD
80
80
  end
81
81
  end
data/lib/cw/book.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  class Book < Tester
6
6
 
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  class BookDetails
6
6
 
@@ -49,7 +49,7 @@ module CWG
49
49
  end
50
50
 
51
51
  def sentences_complete?
52
- if @args.has_key?(:sentences) && @args[:sentences].is_a?(Fixnum)
52
+ if @args.has_key?(:sentences) && @args[:sentences].is_a?(1.class)
53
53
  if @sentence_count_source
54
54
  @sentence_count_source = nil
55
55
  else
data/lib/cw/callsign.rb CHANGED
@@ -1,5 +1,4 @@
1
- module CWG
2
-
1
+ module CW
3
2
  class Callsign
4
3
 
5
4
  include FileDetails
data/lib/cw/cl.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Cl performs command-line processing
6
6
 
@@ -82,7 +82,7 @@ module CWG
82
82
 
83
83
  def cl_quality
84
84
  quality = Cfg.config["quality"]
85
- if quality && quality.class == Fixnum
85
+ if quality && quality.class == 1.class
86
86
  "-q #{quality} "
87
87
  else
88
88
  coarse_quality quality
@@ -1,4 +1,4 @@
1
- module CWG
1
+ module CW
2
2
 
3
3
  class CommonWords
4
4
 
@@ -66,7 +66,7 @@ module CWG
66
66
  def parse_quantity(quantity = :default)
67
67
  if quantity == :default
68
68
  return [0, 999]
69
- elsif quantity.class == Fixnum
69
+ elsif quantity.class == 1.class
70
70
  [0, quantity - 1]
71
71
  (0...quantity).collect {|q| q}
72
72
  elsif quantity.class == Range
data/lib/cw/config.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'parseconfig.rb'
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  module Cfg
6
6
 
7
- include CWG::FileDetails
7
+ include CW::FileDetails
8
8
 
9
9
  CONFIG_METHODS = [
10
10
  :name,:wpm,:effective_wpm,:frequency,:audio_filename,:audio_dir,
data/lib/cw/coreaudio.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'coreaudio'
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  class Coreaudio
6
6
 
@@ -131,7 +131,7 @@ module CWG
131
131
  # # play_tone
132
132
  # # # @words = words
133
133
  # # # p @words
134
- # # # @cw_threads = CWThreads.new(self, thread_processes)
134
+ # # # @cw_threads = Threads.new(self, thread_processes)
135
135
  # # # @cw_threads.run
136
136
  # # # reset_stdin
137
137
  # # # print.newline
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  class CurrentWord
6
6
 
@@ -1,13 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
- # class Cw_dsl provides CW's commands
3
+ # class Dsl provides CW's commands
4
4
 
5
- module CWG
5
+ module CW
6
6
 
7
- class CwDsl
7
+ class Dsl
8
8
 
9
- include CWG::Cfg
10
- include CWG::FileDetails
9
+ include CW::Cfg
10
+ include CW::FileDetails
11
11
  [:wpm, :effective_wpm, :frequency, :audio_filename,:audio_dir,
12
12
  :book_name, :book_dir, :play_command, :run_default, :command_line,
13
13
  :author, :title, :quality, :ebook2cw_path, :list_colour, :list_colour,
@@ -208,7 +208,7 @@ module CWG
208
208
  end
209
209
 
210
210
  def cw_element_match arg
211
- encs = CWG::CwEncoding.new
211
+ encs = CW::Encoding.new
212
212
  encs.match_elements arg
213
213
  end
214
214
 
@@ -286,7 +286,7 @@ module CWG
286
286
  def load_abbreviations ; load_text ABBREVIATIONS ; end
287
287
  def reverse ; @words.reverse ; end
288
288
  def double_words ; @words.double_words ; end
289
- def letters_numbers ; @words.letters_numbers ; end
289
+ def letters_numbers ; @words.letters_numbers ; end
290
290
  def load_codes ; load_text Q_CODES ; end
291
291
  def alpha ; 'a'.upto('z').collect{|ch| ch} ; end
292
292
  def vowels ; %w(a e i o u) ; end
@@ -294,7 +294,7 @@ module CWG
294
294
  def dash_letters ; %w(t m o) ; end
295
295
  def load_vowels ; @words.assign vowels ; end
296
296
  def load_consonants ; @words.assign alpha - vowels ; end
297
- def numbers ; '0'.upto('9').collect ; end
297
+ def numbers ; %w(0 1 2 3 4 5 6 7 8 9) ; end
298
298
  def load_numbers ; @words.assign numbers ; end
299
299
  def load_dots ; load_letters(dot_letters) ; end
300
300
  def load_dashes ; load_letters(dash_letters) ; end
data/lib/cw/element.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  module Element
6
5
 
7
6
  def element type
@@ -1,8 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
5
- class CwEncoding
3
+ module CW
4
+ class Encoding
6
5
 
7
6
  include FileDetails
8
7
 
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  module FileDetails
6
5
  HERE = File.dirname(__FILE__)
7
6
  WORK_DIR = Dir.pwd
data/lib/cw/key_input.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class KeyInput
6
5
 
7
6
  def initialize
data/lib/cw/numbers.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
 
data/lib/cw/os.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'os'
2
2
 
3
- module CWG
3
+ module CW
4
4
  module OStest
5
5
  def is_mac?
6
6
  OS.mac?
data/lib/cw/play.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class Play
6
5
 
7
6
  def initialize words
data/lib/cw/print.rb CHANGED
@@ -3,8 +3,7 @@
3
3
  require 'paint'
4
4
  require 'io/console'
5
5
 
6
- module CWG
7
-
6
+ module CW
8
7
  class Print
9
8
 
10
9
  class ProgressPrint
data/lib/cw/progress.rb CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  require 'ruby-progressbar'
4
4
 
5
- module CWG
6
-
5
+ module CW
7
6
  class Progress
8
7
 
9
8
  def initialize(title)
@@ -24,7 +23,5 @@ module CWG
24
23
  def increment
25
24
  @progress.increment
26
25
  end
27
-
28
26
  end
29
-
30
27
  end
data/lib/cw/randomize.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
3
+ module CW
4
4
 
5
5
  #class Randomize provides character randomising
6
6
 
@@ -71,7 +71,5 @@ module CWG
71
71
  end
72
72
  @words
73
73
  end
74
-
75
74
  end
76
-
77
75
  end
data/lib/cw/read.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #require 'wavefile'
4
4
  require 'coreaudio'
5
5
 
6
- module CWG
6
+ module CW
7
7
 
8
8
  SAMPLE_RATE = 44100
9
9
  MAGNITUDE_CUTOFF = 50000 # 200000
@@ -47,7 +47,7 @@ module CWG
47
47
  @high = Array.new(3)
48
48
  @low = Array.new(2)
49
49
  @queue = Queue.new
50
- @cw_encoding = CwEncoding.new
50
+ @cw_encoding = Encoding.new
51
51
  @print = Print.new
52
52
  @state[START] = 0
53
53
  @state[VALUE] = :low
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module CWG
4
-
3
+ module CW
5
4
  class RepeatWord < Tester
6
5
 
7
6
  #overloaded #todo
@@ -59,7 +58,7 @@ module CWG
59
58
  end
60
59
 
61
60
  def threads
62
- threads ||= CWThreads.new(self, thread_processes)
61
+ threads ||= Threads.new(self, thread_processes)
63
62
  end
64
63
 
65
64
  def run words