vail 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +82 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/vail +29 -0
- data/config/default.yaml +11 -0
- data/lib/vail/config.rb +4 -0
- data/lib/vail/dot_dash.rb +4 -0
- data/lib/vail/generator.rb +58 -0
- data/lib/vail/translate.rb +35 -0
- data/lib/vail.rb +10 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/vail/generator_spec.rb +102 -0
- data/spec/vail/translate_spec.rb +14 -0
- data/spec/vail_spec.rb +4 -0
- metadata +169 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "beep", "~> 0.0.1"
|
6
|
+
gem "trollop"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.6.0"
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.6.2"
|
14
|
+
gem "rcov", ">= 0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
beep (0.0.1)
|
5
|
+
diff-lcs (1.1.2)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.6.2)
|
8
|
+
bundler (~> 1.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
rake (0.9.1)
|
12
|
+
rcov (0.9.9)
|
13
|
+
rspec (2.6.0)
|
14
|
+
rspec-core (~> 2.6.0)
|
15
|
+
rspec-expectations (~> 2.6.0)
|
16
|
+
rspec-mocks (~> 2.6.0)
|
17
|
+
rspec-core (2.6.3)
|
18
|
+
rspec-expectations (2.6.0)
|
19
|
+
diff-lcs (~> 1.1.2)
|
20
|
+
rspec-mocks (2.6.0)
|
21
|
+
trollop (1.16.2)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
beep (~> 0.0.1)
|
28
|
+
bundler (~> 1.0.0)
|
29
|
+
jeweler (~> 1.6.2)
|
30
|
+
rcov
|
31
|
+
rspec (~> 2.6.0)
|
32
|
+
trollop
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Rory McKinley
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
= vail
|
2
|
+
|
3
|
+
vail converts text into audible Morse code. It currently uses the beep gem to interact with the PC speaker - so this means it is restricted to Linux distros that have the beep commandline utility available.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Due to vail's reliance on beep, prior to installing the vail gem (or running the executable after cloning the repo), you will need the beep utility to be installed. AFAIK, this would restrict usage to Linux distros or related systems that have the beep utility available. After that, it is as simple as:
|
8
|
+
|
9
|
+
gem install vail
|
10
|
+
|
11
|
+
== Customisable Settings
|
12
|
+
|
13
|
+
* duration - this can be set for a dot or a dash and the units are milliseconds
|
14
|
+
* pause - this is the time in milliseconds that vail will pause for before proceeding to the next set of instructions, This can be applied to a dot, a dash, a letter or a group of letters (Vail uses spaces to distinguish groups of letters)
|
15
|
+
* frequency - of the sound generated, in Hz. It is applied to both dots and dashes
|
16
|
+
* repetitions - the number of times the provided string will be repeated
|
17
|
+
|
18
|
+
== Usage - executable
|
19
|
+
|
20
|
+
The vail executable can be run to output Morse code from the commandline. Executing is as simple as:
|
21
|
+
|
22
|
+
vail
|
23
|
+
|
24
|
+
You will be prompted to enter the text and you sould be rewarded with a sequence of beeps representing the dots and dashes for the various letters. To exit, simply hit Ctrl-C.
|
25
|
+
|
26
|
+
There are currently two commandline options available. These allow you to export the current default settings for the gem and import settings from a specified file. A brief description of these two options can also be found by running:
|
27
|
+
|
28
|
+
vail --help
|
29
|
+
|
30
|
+
=== Export settings
|
31
|
+
|
32
|
+
The settings are dumped as YAML, and the output can be redirected to a file of your choice to server as a template for a custom settings file:
|
33
|
+
|
34
|
+
vail -e > current_settings.yaml
|
35
|
+
|
36
|
+
When the export parameter is provided, vail exits after outputting the settings.
|
37
|
+
|
38
|
+
=== Importing settings
|
39
|
+
|
40
|
+
Settings may be imported to override the default settings for the gem. An exported file may be used as a template for the import file. The settings imported will only be used for that execution of the binary and they will temporarily override the default settings. Currently, there is no user-friendly way to do this permanenently.
|
41
|
+
|
42
|
+
vail -i /path/to/custom/settings
|
43
|
+
|
44
|
+
== Usage - in Ruby code
|
45
|
+
|
46
|
+
To use the vail module in Ruby code is reasonably simple - just bear in mind that it is subject to the same restrictions as the executable (linux only, requires the beep utility):
|
47
|
+
|
48
|
+
require 'rubygems'
|
49
|
+
require 'vail'
|
50
|
+
|
51
|
+
Vail::Generator.new.to_morse("E")
|
52
|
+
|
53
|
+
=== Providing custom settings
|
54
|
+
|
55
|
+
The default settings can be overridden by passing a hash of custom settings - in the code below, only the repetitions are optional. Excluding any of the other options will result in Vail puking horribly :)
|
56
|
+
|
57
|
+
@settings = {
|
58
|
+
"dot" => { "duration" => 100, "pause" => 200 },
|
59
|
+
"dash" => { "duration" => 300, "pause" => 400 },
|
60
|
+
"frequency" => 250,
|
61
|
+
"letter" => { "pause" => 100 },
|
62
|
+
"group" => { "pause" => 200 },
|
63
|
+
"repetitions" => 2
|
64
|
+
}
|
65
|
+
|
66
|
+
Vail::Generator.new(@settings).to_morse("T")
|
67
|
+
|
68
|
+
== Contributing to vail
|
69
|
+
|
70
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
71
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
72
|
+
* Fork the project
|
73
|
+
* Start a feature/bugfix branch
|
74
|
+
* Commit and push until you are happy with your contribution
|
75
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
76
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
77
|
+
|
78
|
+
== Copyright
|
79
|
+
|
80
|
+
Copyright (c) 2011 Rory McKinley. See LICENSE.txt for
|
81
|
+
further details.
|
82
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "vail"
|
18
|
+
gem.homepage = "http://github.com/rorymckinley/vail"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A simple gem to generate audible morse code}
|
21
|
+
gem.description = %Q{Vail generates audible morse code. Currently it only works on Linux distros that have hte beep utility installed. This is hopefully a temporary limitation}
|
22
|
+
gem.email = "rorymckinley@gmail.com"
|
23
|
+
gem.authors = ["Rory McKinley"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rake/rdoctask'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "vail #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/vail
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
require 'rubygems'
|
4
|
+
require 'trollop'
|
5
|
+
require 'vail'
|
6
|
+
|
7
|
+
trap("INT") do
|
8
|
+
puts "\nExiting......."
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
opts = Trollop::options do
|
13
|
+
opt :export, "Output current default settings"
|
14
|
+
opt :import, "Run with settings in provided YAML file", :type => String
|
15
|
+
end
|
16
|
+
|
17
|
+
if opts[:export]
|
18
|
+
puts YAML::dump(Vail::Generator.new.settings)
|
19
|
+
else
|
20
|
+
settings = {}
|
21
|
+
|
22
|
+
settings = opts[:import] ? YAML::load(IO.read(opts[:import])) : {}
|
23
|
+
|
24
|
+
while true
|
25
|
+
puts "Please enter the text for conversion:"
|
26
|
+
text = gets.strip
|
27
|
+
Vail::Generator.new(settings).to_morse(text)
|
28
|
+
end
|
29
|
+
end
|
data/config/default.yaml
ADDED
data/lib/vail/config.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Vail
|
2
|
+
class Generator
|
3
|
+
def initialize(config={})
|
4
|
+
config = YAML.load(IO.read(ConfigPath)) if config.empty?
|
5
|
+
|
6
|
+
@config = config.merge (
|
7
|
+
{
|
8
|
+
Dot => { "duration" => config["dot"]["duration"], "pause" => config["dot"]["pause"] },
|
9
|
+
Dash => { "duration" => config["dash"]["duration"], "pause" => config["dash"]["pause"]}
|
10
|
+
}
|
11
|
+
)
|
12
|
+
@config["repetitions"] ||= 1
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_morse(phrase)
|
16
|
+
instructions = build_instructions(phrase)
|
17
|
+
|
18
|
+
(@config["repetitions"].times.inject([]) { |r,i| r << instructions }).each do |instruction_set|
|
19
|
+
instruction_set.each do |i|
|
20
|
+
execute_instruction(i)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def settings
|
26
|
+
@config.reject { |key, value| [Dot,Dash].include? key }
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def build_instructions(phrase)
|
32
|
+
instructions = []
|
33
|
+
|
34
|
+
phrase.each_char do |char|
|
35
|
+
if char == " "
|
36
|
+
instructions << { :command => :sleep, :instruction => @config["group"]["pause"].to_f/1000.0}
|
37
|
+
else
|
38
|
+
morse = Translate.to_morse(char)
|
39
|
+
instructions << {
|
40
|
+
:command => :sound,
|
41
|
+
:instruction => morse.map { |dotdash| { :duration => @config[dotdash]["duration"], :pause => @config[dotdash]["pause"], :frequency => @config["frequency"] }}
|
42
|
+
}
|
43
|
+
instructions << { :command => :sleep, :instruction => @config["letter"]["pause"].to_f/1000.0}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
instructions
|
48
|
+
end
|
49
|
+
|
50
|
+
def execute_instruction(instruction)
|
51
|
+
if instruction[:command] == :sound
|
52
|
+
Beep::Sound.generate(instruction[:instruction])
|
53
|
+
else
|
54
|
+
sleep(instruction[:instruction])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Vail
|
2
|
+
class Translate
|
3
|
+
Morse = {
|
4
|
+
"a" => [Dot, Dash],
|
5
|
+
"b" => [Dash, Dot, Dot, Dot],
|
6
|
+
"c" => [Dash, Dot, Dash, Dot],
|
7
|
+
"d" => [Dash, Dot, Dot],
|
8
|
+
"e" => [Dot],
|
9
|
+
"f" => [Dot, Dot, Dash, Dot],
|
10
|
+
"g" => [Dash, Dash, Dot],
|
11
|
+
"h" => [Dot, Dot, Dot, Dot],
|
12
|
+
"i" => [Dot, Dot],
|
13
|
+
"j" => [Dot, Dash, Dash, Dash ],
|
14
|
+
"k" => [Dash, Dot, Dash ],
|
15
|
+
"l" => [Dot, Dash, Dot, Dot],
|
16
|
+
"m" => [Dash, Dash],
|
17
|
+
"n" => [Dash, Dot],
|
18
|
+
"o" => [Dash, Dash, Dash],
|
19
|
+
"p" => [Dot, Dash, Dash, Dot],
|
20
|
+
"q" => [Dash, Dash, Dot, Dash],
|
21
|
+
"r" => [Dot, Dash, Dot],
|
22
|
+
"s" => [Dot, Dot, Dot],
|
23
|
+
"t" => [Dash],
|
24
|
+
"u" => [Dot, Dot, Dash],
|
25
|
+
"v" => [Dot, Dot, Dot, Dash],
|
26
|
+
"w" => [Dot, Dash, Dash],
|
27
|
+
"x" => [Dash, Dot, Dot, Dash],
|
28
|
+
"y" => [Dash, Dot, Dash, Dash],
|
29
|
+
"z" => [Dash, Dash, Dot, Dot]
|
30
|
+
}
|
31
|
+
def self.to_morse(letter)
|
32
|
+
Morse[letter.downcase] || []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/vail.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'beep'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
['vail/config', 'vail/dot_dash', 'vail/translate', 'vail/generator'].each do |f|
|
5
|
+
require File.join(File.dirname(__FILE__), f)
|
6
|
+
end
|
7
|
+
|
8
|
+
module Vail
|
9
|
+
ConfigPath = File.join(File.dirname(__FILE__), '..', 'config', 'default.yaml')
|
10
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'vail'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Vail::Generator do
|
4
|
+
before(:each) do
|
5
|
+
@settings = {
|
6
|
+
"dot" => { "duration" => 100, "pause" => 200 },
|
7
|
+
"dash" => { "duration" => 300, "pause" => 400 },
|
8
|
+
"frequency" => 250,
|
9
|
+
"letter" => { "pause" => 100 },
|
10
|
+
"group" => { "pause" => 200 }
|
11
|
+
}
|
12
|
+
end
|
13
|
+
it "should load default settings upon initialisation if none are provided" do
|
14
|
+
IO.should_receive(:read).with(Vail::ConfigPath).and_return('blah')
|
15
|
+
YAML.should_receive(:load).with('blah').and_return(@settings)
|
16
|
+
Vail::Generator.new
|
17
|
+
end
|
18
|
+
it "should generate the sound for a letter with a single dot" do
|
19
|
+
Vail::Translate.should_receive(:to_morse).with('E').and_return([Vail::Dot])
|
20
|
+
Beep::Sound.should_receive(:generate).with([{ :duration => 100, :pause => 200, :frequency => 250 }])
|
21
|
+
|
22
|
+
Vail::Generator.new(@settings).to_morse("E")
|
23
|
+
end
|
24
|
+
it "should generate the sound for a letter with a single dash" do
|
25
|
+
Vail::Translate.should_receive(:to_morse).with('T').and_return([Vail::Dash])
|
26
|
+
Beep::Sound.should_receive(:generate).with([{ :duration => 300, :pause => 400, :frequency => 250 }])
|
27
|
+
|
28
|
+
Vail::Generator.new(@settings).to_morse("T")
|
29
|
+
end
|
30
|
+
it "should generate morse for a letter that has a multiple dots and dashes" do
|
31
|
+
sound_parameters = [
|
32
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
33
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
34
|
+
{ :duration => 100, :pause => 200, :frequency => 250 }
|
35
|
+
]
|
36
|
+
Vail::Translate.should_receive(:to_morse).with('G').and_return([Vail::Dash, Vail::Dash, Vail::Dot])
|
37
|
+
Beep::Sound.should_receive(:generate).with(sound_parameters)
|
38
|
+
|
39
|
+
Vail::Generator.new(@settings).to_morse("G")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should provide an additional pause after a letter is completed" do
|
43
|
+
Vail::Translate.stub!(:to_morse).and_return([Vail::Dash, Vail::Dash, Vail::Dot])
|
44
|
+
Beep::Sound.should_receive(:generate)
|
45
|
+
|
46
|
+
g = Vail::Generator.new(@settings)
|
47
|
+
g.should_receive(:sleep).with(@settings["letter"]["pause"].to_f/1000.0)
|
48
|
+
g.to_morse("G")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should generate morse for a group of letters" do
|
52
|
+
sound_parameters_G = [
|
53
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
54
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
55
|
+
{ :duration => 100, :pause => 200, :frequency => 250 }
|
56
|
+
]
|
57
|
+
sound_parameters_O = [
|
58
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
59
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
60
|
+
{ :duration => 300, :pause => 400, :frequency => 250 },
|
61
|
+
]
|
62
|
+
Vail::Translate.stub!(:to_morse).with('G').and_return([Vail::Dash, Vail::Dash, Vail::Dot])
|
63
|
+
Vail::Translate.stub!(:to_morse).with('O').and_return([Vail::Dash, Vail::Dash, Vail::Dash])
|
64
|
+
|
65
|
+
Beep::Sound.should_receive(:generate).with(sound_parameters_G).ordered
|
66
|
+
Beep::Sound.should_receive(:generate).with(sound_parameters_O).ordered
|
67
|
+
|
68
|
+
g = Vail::Generator.new(@settings)
|
69
|
+
g.should_receive(:sleep).with(@settings["letter"]["pause"].to_f/1000.0).twice
|
70
|
+
g.to_morse("GO")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should pause between groups of words" do
|
74
|
+
Vail::Translate.stub!(:to_morse).with('G').and_return([Vail::Dash, Vail::Dash, Vail::Dot])
|
75
|
+
Vail::Translate.stub!(:to_morse).with('O').and_return([Vail::Dash, Vail::Dash, Vail::Dash])
|
76
|
+
|
77
|
+
Beep::Sound.stub!(:generate)
|
78
|
+
|
79
|
+
g = Vail::Generator.new(@settings)
|
80
|
+
g.should_receive(:sleep).with(@settings["letter"]["pause"].to_f/1000.0).twice.ordered
|
81
|
+
g.should_receive(:sleep).with(@settings["group"]["pause"].to_f/1000.0).ordered
|
82
|
+
g.should_receive(:sleep).with(@settings["letter"]["pause"].to_f/1000.0).twice.ordered
|
83
|
+
g.to_morse("GO GO")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should allow a phrase to be repeated" do
|
87
|
+
Vail::Translate.stub!(:to_morse).with('G').and_return([Vail::Dash, Vail::Dash, Vail::Dot])
|
88
|
+
Vail::Translate.stub!(:to_morse).with('O').and_return([Vail::Dash, Vail::Dash, Vail::Dash])
|
89
|
+
|
90
|
+
Beep::Sound.stub!(:generate)
|
91
|
+
|
92
|
+
g = Vail::Generator.new(@settings.merge("repetitions" => 2))
|
93
|
+
g.should_receive(:sleep).with(@settings["letter"]["pause"].to_f/1000.0).exactly(8).times
|
94
|
+
g.should_receive(:sleep).with(@settings["group"]["pause"].to_f/1000.0).twice
|
95
|
+
g.to_morse("GO GO")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should be able to return the current settings object including any defaults applied" do
|
99
|
+
Vail::Generator.new(@settings).settings.should == @settings.merge("repetitions" => 1)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Vail::Translate do
|
4
|
+
it "should return a morse representation of a letter" do
|
5
|
+
("a".."z").each do |l|
|
6
|
+
Vail::Translate.to_morse(l).should_not be_empty
|
7
|
+
end
|
8
|
+
end
|
9
|
+
it "should not be case-sensitive" do
|
10
|
+
("A".."Z").each do |l|
|
11
|
+
Vail::Translate.to_morse(l).should_not be_empty
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/vail_spec.rb
ADDED
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Rory McKinley
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-13 00:00:00 +02:00
|
18
|
+
default_executable: vail
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: beep
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 0
|
30
|
+
- 1
|
31
|
+
version: 0.0.1
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: trollop
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rspec
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 2
|
57
|
+
- 6
|
58
|
+
- 0
|
59
|
+
version: 2.6.0
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: bundler
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 1
|
72
|
+
- 0
|
73
|
+
- 0
|
74
|
+
version: 1.0.0
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 1
|
87
|
+
- 6
|
88
|
+
- 2
|
89
|
+
version: 1.6.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id005
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rcov
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *id006
|
106
|
+
description: Vail generates audible morse code. Currently it only works on Linux distros that have hte beep utility installed. This is hopefully a temporary limitation
|
107
|
+
email: rorymckinley@gmail.com
|
108
|
+
executables:
|
109
|
+
- vail
|
110
|
+
extensions: []
|
111
|
+
|
112
|
+
extra_rdoc_files:
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.rdoc
|
115
|
+
files:
|
116
|
+
- .document
|
117
|
+
- .rspec
|
118
|
+
- Gemfile
|
119
|
+
- Gemfile.lock
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.rdoc
|
122
|
+
- Rakefile
|
123
|
+
- VERSION
|
124
|
+
- bin/vail
|
125
|
+
- config/default.yaml
|
126
|
+
- lib/vail.rb
|
127
|
+
- lib/vail/config.rb
|
128
|
+
- lib/vail/dot_dash.rb
|
129
|
+
- lib/vail/generator.rb
|
130
|
+
- lib/vail/translate.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
- spec/vail/generator_spec.rb
|
133
|
+
- spec/vail/translate_spec.rb
|
134
|
+
- spec/vail_spec.rb
|
135
|
+
has_rdoc: true
|
136
|
+
homepage: http://github.com/rorymckinley/vail
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 2418559716878960855
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
version: "0"
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
161
|
+
requirements: []
|
162
|
+
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 1.3.7
|
165
|
+
signing_key:
|
166
|
+
specification_version: 3
|
167
|
+
summary: A simple gem to generate audible morse code
|
168
|
+
test_files: []
|
169
|
+
|