brasspounder 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72e0224deeace91a82ce5022d7b4984b3cfa41cc
4
+ data.tar.gz: 708b2bc4301581b758cdfc87565766021ecc5c1d
5
+ SHA512:
6
+ metadata.gz: c8e42d992b18f389a65ab170eb9adb5aaebc075bce7b971476c2c0ff209dd282691d95318b572423e2161d4976fa1de88fbef7c4099428a183e6d9fc77395560
7
+ data.tar.gz: 1d506b7e4d10fa93cceb1798232625b6298eb40ce8a3627a4f04dc0d862ebd16d9e7fdaf817c31c10012004ea97a56155f88720df3e9183888b385595a262c2e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in brasspounder.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Robie Lutsey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Brasspounder
2
+
3
+ Brasspounder is a program for sending CW (aka morse code) through the default sound device of your computer. At present it only works on OS X. If people want it, a Windows version is possible.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'brasspounder'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install brasspounder
18
+
19
+ ## Usage
20
+
21
+ Usage: brasspounder [args] FILENAME
22
+ -s, --speed SPEED speed of code. Must be one of:slow, [norm], fast
23
+ -t, --tone TONE tone in Hz [600]
24
+ -v, --[no-]verbose echo characters to screen while sending? On by default.
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it ( http://github.com/<my-github-username>/brasspounder/fork )
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/brasspounder ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/brasspounder'
4
+ require "optparse"
5
+ require 'timeout'
6
+
7
+ args = {speed: :norm, tone: 600, verbose: true}
8
+
9
+ option_parser = OptionParser.new do |opts|
10
+ opts.banner = "Usage: brasspounder [args] FILENAME"
11
+
12
+ opts.on('-s', '--speed SPEED', [:slow, :norm, :fast], 'speed of code. Must be one of: slow, [norm], fast') do |speed|
13
+ speed = speed.to_sym
14
+ unless [:slow, :norm, :fast].include? speed
15
+ raise ArgumentError, "speed must be either slow, norm or fast"
16
+ end
17
+ args[:speed] = speed
18
+ end
19
+
20
+ opts.on('-t', '--tone TONE', 'tone in Hz [600]', Integer) do |tone|
21
+ unless tone > 1 && tone.integer?
22
+ raise ArgumentError, "tone must be a positive number. 600 is a good default"
23
+ end
24
+ args[:tone] = tone
25
+ end
26
+
27
+ opts.on('-v', '--[no-]verbose', "echo characters to screen while sending? On by default.") do |v|
28
+ args[:verbose]= v
29
+ end
30
+ end
31
+
32
+ option_parser.parse!
33
+
34
+ lines = ""
35
+
36
+ begin
37
+ timeout(2) do
38
+ input = ARGF.readlines.each { |line| lines += " #{line.chomp.downcase}" }
39
+ end
40
+ rescue Timeout::Error => ex
41
+ puts "No input in 2 seconds. You must supply a filename at the command line or pipe in data"
42
+ puts "\nCtrl-c to kill\n\n"
43
+ input = "To copy some text supply a file path or unix pipeline"
44
+ # return nil
45
+ end
46
+
47
+ sample_text = "To copy some text supply a file path or unix pipeline"
48
+
49
+ brasspounder = Brasspounder::Runner.new
50
+
51
+ begin
52
+ if lines.length > 0
53
+ puts "\nCtrl-c to kill.\n\n"
54
+ brasspounder.run(lines, args[:speed], args[:tone], args[:verbose])
55
+ else
56
+ brasspounder.run(sample_text, args[:speed], args[:tone], args[:verbose])
57
+ end
58
+ rescue Interrupt => e
59
+ puts "\n\nGood bye"
60
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'brasspounder/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "brasspounder"
8
+ spec.version = Brasspounder::VERSION
9
+ spec.authors = ["Robie Lutsey"]
10
+ spec.email = ["robie1373@gmail.com"]
11
+ spec.summary = %q{Converts text to CW (morse code)}
12
+ spec.description = %q{Feed brasspounder (ham radio slang for CW operator) some text and it will send the text in CW. Optionally will print the text to STDOUT.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake", "~> 10.1.1"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_dependency "gentone", "~> 0.0"
26
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "./brasspounder/version"
2
+ require_relative "./brasspounder/pounder"
3
+ require_relative "./brasspounder/sender"
4
+
5
+ module Brasspounder
6
+ class Runner
7
+ def run(text, speed = :norm, freq = 600, verbose = true)
8
+ sender = Sender.new(speed, freq, verbose)
9
+ sender.send text
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,42 @@
1
+ module Brasspounder
2
+ class Pounder
3
+ def initialize(dit_length, freq)
4
+ @dit_length = dit_length
5
+ @freq = freq
6
+ @g = Gentone::Generator.new
7
+ end
8
+
9
+ def pound(symbol)
10
+ symbol.each do |element|
11
+ eval element
12
+ element_pause
13
+ end
14
+ letter_pause
15
+ end
16
+
17
+ def dit_length
18
+ @dit_length
19
+ end
20
+
21
+ def dit
22
+ @g.generate(dit_length, @freq)
23
+ end
24
+
25
+ def dah
26
+ @g.generate(3 * dit_length, @freq)
27
+ end
28
+
29
+ def element_pause
30
+ sleep dit_length / 1_000.0
31
+ end
32
+
33
+ def letter_pause
34
+ sleep dit_length * 3 / 1_000.0
35
+ end
36
+
37
+ def word_pause
38
+ sleep dit_length * 7 / 1_000.0
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,89 @@
1
+ require "gentone"
2
+
3
+ module Brasspounder
4
+ class Sender
5
+ def initialize(speed, freq, verbose)
6
+ speeds = {fast: 40, norm: 60, slow: 120}
7
+ @pounder = Pounder.new(speeds[speed], freq)
8
+ @verbose = verbose
9
+ end
10
+
11
+ def characters
12
+ {
13
+ a: %w{dit dah},
14
+ b: %w{dah dit dit dit},
15
+ c: %w{dah dit dah dit},
16
+ d: %w{dah dit dit},
17
+ e: %w{dit},
18
+ f: %w{dit dit dah dit},
19
+ g: %w{dah dah dit},
20
+ h: %w{dit dit dit dit},
21
+ i: %w{dit dit},
22
+ j: %w{dit dah dah dah},
23
+ k: %w{dah dit dah},
24
+ l: %w{dit dah dit dit},
25
+ m: %w{dah dah},
26
+ n: %w{dah dit},
27
+ o: %w{dah dah dah},
28
+ p: %w{dit dah dah dit},
29
+ q: %w{dah dah dit dah},
30
+ r: %w{dit dah dit},
31
+ s: %w{dit dit dit},
32
+ t: %w{dah},
33
+ u: %w{dit dit dah},
34
+ v: %w{dit dit dit dah},
35
+ w: %w{dit dah dah},
36
+ x: %w{dah dit dit dah},
37
+ y: %w{dah dit dah dah},
38
+ z: %w{dah dah dit dit},
39
+ :"1" => %w{dit dah dah dah dah},
40
+ :"2" => %w{dit dit dah dah dah},
41
+ :"3" => %w{dit dit dit dah dah},
42
+ :"4" => %w{dit dit dit dit dah},
43
+ :"5" => %w{dit dit dit dit dit},
44
+ :"6" => %w{dah dit dit dit dit},
45
+ :"7" => %w{dah dah dit dit dit},
46
+ :"8" => %w{dah dah dah dit dit},
47
+ :"9" => %w{dah dah dah dah dit},
48
+ :"0" => %w{dah dah dah dah dah},
49
+ :"." => %w{dit dah dit dah dit dah},
50
+ :"," => %w{dah dah dit dit dah dah},
51
+ :"/" => %w{dah dit dit dah dit},
52
+ :"?" => %w{dit dit dah dah dit dit},
53
+ :" " => %w{word_pause}
54
+ }
55
+ end
56
+
57
+ def prosigns
58
+ {
59
+ cq: %w{dah dit dah dit dah dah dit dah},
60
+ ar: %w{dit dah dit dah dit},
61
+ kn: %w{dah dit dah dah dit},
62
+ bk: %w{dah dit dit dit dah dit dah},
63
+ sk: %w{dit dit dit dah dit dah},
64
+ cl: %w{dah dit dah dit dit dah dit dit}
65
+ }
66
+ end
67
+
68
+ def send(string)
69
+ string.split.each do |word|
70
+ if prosigns.keys.include? word.to_sym
71
+ if @verbose
72
+ print word
73
+ end
74
+ @pounder.pound prosigns[word.to_sym]
75
+ else
76
+ "#{word} ".each_char do |character|
77
+ if @verbose
78
+ print character
79
+ end
80
+ if characters.keys.include? character.to_sym
81
+ @pounder.pound characters[character.to_sym]
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ end
89
+ end
@@ -0,0 +1,3 @@
1
+ module Brasspounder
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brasspounder do
4
+ it 'should have a version number' do
5
+ Brasspounder::VERSION.should_not be_nil
6
+ end
7
+
8
+ it 'should do something useful' do
9
+ false.should be_true
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'brasspounder'
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: brasspounder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Robie Lutsey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 10.1.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 10.1.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gentone
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.0'
69
+ description: Feed brasspounder (ham radio slang for CW operator) some text and it
70
+ will send the text in CW. Optionally will print the text to STDOUT.
71
+ email:
72
+ - robie1373@gmail.com
73
+ executables:
74
+ - brasspounder
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/brasspounder
86
+ - brasspounder.gemspec
87
+ - lib/brasspounder.rb
88
+ - lib/brasspounder/pounder.rb
89
+ - lib/brasspounder/sender.rb
90
+ - lib/brasspounder/version.rb
91
+ - spec/brasspounder_spec.rb
92
+ - spec/spec_helper.rb
93
+ homepage: ''
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.0.3
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Converts text to CW (morse code)
117
+ test_files:
118
+ - spec/brasspounder_spec.rb
119
+ - spec/spec_helper.rb