NATO 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/NATO.gemspec +25 -0
- data/README.md +71 -0
- data/Rakefile +1 -0
- data/lib/NATO.rb +9 -0
- data/lib/NATO/dictionary.rb +30 -0
- data/lib/NATO/parser.rb +20 -0
- data/lib/NATO/text.rb +16 -0
- data/lib/NATO/version.rb +3 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/text_spec.rb +10 -0
- metadata +125 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Lukas Alexandre
|
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/NATO.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'NATO/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "NATO"
|
8
|
+
spec.version = NATO::VERSION
|
9
|
+
spec.authors = ["Lukas Alexandre"]
|
10
|
+
spec.email = ["lukasalexandre@me.com"]
|
11
|
+
spec.description = %q{NATO Phonetic Alphabet conversion tool}
|
12
|
+
spec.summary = %q{NATO Phonetic Alphabet conversion tool}
|
13
|
+
spec.homepage = "https://github.com/lukelex/NATO"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec-given"
|
25
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# NATO
|
2
|
+
|
3
|
+
The NATO phonetic alphabet, more accurately known as the International
|
4
|
+
Radiotelephony Spelling Alphabet, is the most widely used spelling
|
5
|
+
alphabet. NATO assigns code words acrophonically to the letters of the
|
6
|
+
English alphabet so that critical combinations of letters and numbers
|
7
|
+
can be pronounced and understood by those who transmit and receive
|
8
|
+
voice messages by radio or telephone regardless of their native
|
9
|
+
language or the presence of transmission static.
|
10
|
+
|
11
|
+
The 26 code words in the NATO phonetic alphabet are assigned to the 26
|
12
|
+
letters of the English alphabet in alphabetical order as follows:
|
13
|
+
|
14
|
+
* Alfa
|
15
|
+
* Bravo
|
16
|
+
* Charlie
|
17
|
+
* Delta
|
18
|
+
* Echo
|
19
|
+
* Foxtrot
|
20
|
+
* Golf
|
21
|
+
* Hotel
|
22
|
+
* India
|
23
|
+
* Juliett
|
24
|
+
* Kilo
|
25
|
+
* Lima
|
26
|
+
* Mike
|
27
|
+
* November
|
28
|
+
* Oscar
|
29
|
+
* Papa
|
30
|
+
* Quebec
|
31
|
+
* Romeo
|
32
|
+
* Sierra
|
33
|
+
* Tango
|
34
|
+
* Uniform
|
35
|
+
* Victor
|
36
|
+
* Whiskey
|
37
|
+
* X-ray
|
38
|
+
* Yankee
|
39
|
+
* Zulu
|
40
|
+
|
41
|
+
## Installation
|
42
|
+
|
43
|
+
Add this line to your application's Gemfile:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
gem 'NATO'
|
47
|
+
```
|
48
|
+
|
49
|
+
And then execute:
|
50
|
+
|
51
|
+
```
|
52
|
+
$ bundle
|
53
|
+
```
|
54
|
+
|
55
|
+
Or install it yourself as:
|
56
|
+
|
57
|
+
```
|
58
|
+
$ gem install NATO
|
59
|
+
```
|
60
|
+
|
61
|
+
## Usage
|
62
|
+
|
63
|
+
TODO: Write usage instructions here
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
1. Fork it
|
68
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
69
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
70
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
71
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/NATO.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module NATO
|
2
|
+
DICTIONARY = {
|
3
|
+
:a => :Alfa,
|
4
|
+
:b => :Bravo,
|
5
|
+
:c => :Charlie,
|
6
|
+
:d => :Delta,
|
7
|
+
:e => :Echo,
|
8
|
+
:f => :Foxtrot,
|
9
|
+
:g => :Golf,
|
10
|
+
:h => :Hotel,
|
11
|
+
:i => :India,
|
12
|
+
:j => :Juliett,
|
13
|
+
:k => :Kilo,
|
14
|
+
:l => :Lima,
|
15
|
+
:m => :Mike,
|
16
|
+
:n => :November,
|
17
|
+
:o => :Oscar,
|
18
|
+
:o => :Papa,
|
19
|
+
:q => :Quebec,
|
20
|
+
:r => :Romeo,
|
21
|
+
:s => :Sierra,
|
22
|
+
:t => :Tango,
|
23
|
+
:u => :Uniform,
|
24
|
+
:v => :Victor,
|
25
|
+
:w => :Whiskey,
|
26
|
+
:x => :'X-ray',
|
27
|
+
:y => :Yankee,
|
28
|
+
:z => :Zulu
|
29
|
+
}
|
30
|
+
end
|
data/lib/NATO/parser.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
class NATO::Parser
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
def natify(text)
|
7
|
+
text.split('').map do |piece|
|
8
|
+
if is_numeric? piece
|
9
|
+
piece
|
10
|
+
else
|
11
|
+
NATO::DICTIONARY[piece.to_sym].to_s || piece
|
12
|
+
end
|
13
|
+
end.join ' '
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def is_numeric?(obj)
|
18
|
+
obj.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
|
19
|
+
end
|
20
|
+
end
|
data/lib/NATO/text.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class NATO::Text
|
2
|
+
attr_reader :original, :natified
|
3
|
+
|
4
|
+
def initialize(sentence)
|
5
|
+
@original = sentence
|
6
|
+
@natified = NATO::Parser.instance.natify sentence
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_nato
|
10
|
+
@natified
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
[@original, @natified]
|
15
|
+
end
|
16
|
+
end
|
data/lib/NATO/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
data/spec/text_spec.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module NATO
|
4
|
+
describe Text do
|
5
|
+
Given(:text) { Text.new 'a8h43lnr0' }
|
6
|
+
|
7
|
+
Then { text.to_nato.should == 'Alfa 8 Hotel 4 3 Lima November Romeo 0' }
|
8
|
+
And { text.to_s.should == ['a8h43lnr0', 'Alfa 8 Hotel 4 3 Lima November Romeo 0'] }
|
9
|
+
end
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: NATO
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lukas Alexandre
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec-given
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: NATO Phonetic Alphabet conversion tool
|
79
|
+
email:
|
80
|
+
- lukasalexandre@me.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- NATO.gemspec
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- lib/NATO.rb
|
92
|
+
- lib/NATO/dictionary.rb
|
93
|
+
- lib/NATO/parser.rb
|
94
|
+
- lib/NATO/text.rb
|
95
|
+
- lib/NATO/version.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
- spec/text_spec.rb
|
98
|
+
homepage: https://github.com/lukelex/NATO
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.8.25
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: NATO Phonetic Alphabet conversion tool
|
123
|
+
test_files:
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
- spec/text_spec.rb
|