NATO 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2df6f079b6a4a5766249d54349d8964acc403d7d
4
+ data.tar.gz: 7f5dda1cf7eb20b96eda2eb2cd3818ed1e23ab8f
5
+ SHA512:
6
+ metadata.gz: f3a61617a905376b0aec46f68b0eefecd4ba2b6097048eba0cd65c86ab82fb81567e9dcf23cdc8eff61a3482cd7ba3a94aa4dc6ec74f0a63b48df884aa81b7db
7
+ data.tar.gz: 4bb5478c0205363422a20d8a1d73a97677ab7d189c123ab1ceb5e43ca89f93a4de6887b37dd022f2250fe74a951c21a094b3e4b24d4f8811e8b454ae504ea953
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # NATO
2
2
 
3
+ [![Code Climate](https://codeclimate.com/github/lukelex/NATO.png)](https://codeclimate.com/github/lukelex/NATO)
4
+
3
5
  The NATO phonetic alphabet, more accurately known as the International
4
6
  Radiotelephony Spelling Alphabet, is the most widely used spelling
5
7
  alphabet. NATO assigns code words acrophonically to the letters of the
@@ -8,8 +10,7 @@ can be pronounced and understood by those who transmit and receive
8
10
  voice messages by radio or telephone regardless of their native
9
11
  language or the presence of transmission static.
10
12
 
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
+ The 26 code words and 10 numbers in the NATO phonetic alphabet are assigned to their respectives in the English alphabet in alphabetical order as follows:
13
14
 
14
15
  * Alfa
15
16
  * Bravo
@@ -37,6 +38,16 @@ letters of the English alphabet in alphabetical order as follows:
37
38
  * X-ray
38
39
  * Yankee
39
40
  * Zulu
41
+ * One
42
+ * Two
43
+ * Three
44
+ * Four
45
+ * Five
46
+ * Six
47
+ * Seven
48
+ * Eight
49
+ * Nine
50
+ * Zero
40
51
 
41
52
  ## Installation
42
53
 
@@ -62,7 +73,8 @@ $ gem install NATO
62
73
 
63
74
  ```ruby
64
75
  text = Text.new 'a8h43lnr0'
65
- text.to_nato # "Alfa 8 Hotel 4 3 Lima November Romeo 0"
76
+ text.to_nato # "Alfa Eight Hotel Four Three Lima November Romeo Zero"
77
+ text.pronunciation #'AL-FAH AIT HOH-TEL FOW-ER TREE LEE-MAH NO-VEM-BER ROW-ME-OH ZEE-RO'
66
78
  ```
67
79
 
68
80
  ## Contributing
@@ -1,30 +1,40 @@
1
1
  module NATO
2
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
- :p => :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
3
+ :'a' => [:Alfa, :'AL-FAH'],
4
+ :'b' => [:Bravo, :'BRAH-VOH'],
5
+ :'c' => [:Charlie, :'CHAR-LEE'],
6
+ :'d' => [:Delta, :'DELL-TAH'],
7
+ :'e' => [:Echo, :'ECK-OH'],
8
+ :'f' => [:Foxtrot, :'FOKS-TROT'],
9
+ :'g' => [:Golf, :'GOLF'],
10
+ :'h' => [:Hotel, :'HOH-TEL'],
11
+ :'i' => [:India, :'IN-DEE-AH'],
12
+ :'j' => [:Juliett, :'JEW-LEE-ETT'],
13
+ :'k' => [:Kilo, :'KEY-LOH'],
14
+ :'l' => [:Lima, :'LEE-MAH'],
15
+ :'m' => [:Mike, :'MIKE'],
16
+ :'n' => [:November, :'NO-VEM-BER'],
17
+ :'o' => [:Oscar, :'OSS-CAH'],
18
+ :'p' => [:Papa, :'PAH-PAH'],
19
+ :'q' => [:Quebec, :'KEH-BECK'],
20
+ :'r' => [:Romeo, :'ROW-ME-OH'],
21
+ :'s' => [:Sierra, :'SEE-AIR-RAH'],
22
+ :'t' => [:Tango, :'TANG-GO'],
23
+ :'u' => [:Uniform, :'YOU-NEE-FORM'],
24
+ :'v' => [:Victor, :'VIK-TAH'],
25
+ :'w' => [:Whiskey, :'WISS-KEY'],
26
+ :'x' => [:'X-ray', :'ECKS-RAY'],
27
+ :'y' => [:Yankee, :'YANG-KEY'],
28
+ :'z' => [:Zulu, :'ZOO-LOO'],
29
+ :'1' => [:One, :'WUN'],
30
+ :'2' => [:Two, :'TOO'],
31
+ :'3' => [:Three, :'TREE'],
32
+ :'4' => [:Four, :'FOW-ER'],
33
+ :'5' => [:Five, :'FIFE'],
34
+ :'6' => [:Six, :'SIX'],
35
+ :'7' => [:Seven, :'SEV-EN'],
36
+ :'8' => [:Eight, :'AIT'],
37
+ :'9' => [:Nine, :'NIN-ER'],
38
+ :'0' => [:Zero, :'ZEE-RO']
29
39
  }
30
40
  end
@@ -5,16 +5,7 @@ class NATO::Parser
5
5
 
6
6
  def natify(text)
7
7
  text.split('').map do |piece|
8
- if is_numeric? piece
9
- piece
10
- else
11
- NATO::DICTIONARY[piece.to_sym].to_s
12
- end
13
- end.join ' '
14
- end
15
-
16
- private
17
- def is_numeric?(obj)
18
- obj.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/)
8
+ NATO::DICTIONARY[piece.to_sym]
9
+ end
19
10
  end
20
11
  end
@@ -1,9 +1,21 @@
1
1
  class NATO::Text
2
- attr_reader :original, :natified
2
+ attr_reader :original, :natified, :pronunciation
3
3
 
4
4
  def initialize(sentence)
5
5
  @original = sentence
6
- @natified = NATO::Parser.instance.natify sentence
6
+
7
+ sentence_natified = NATO::Parser.instance.natify sentence
8
+
9
+ @natified = sentence_natified.map { |item| item.first }.join ' '
10
+ @pronunciation = sentence_natified.map { |item| item.last }.join ' '
11
+ end
12
+
13
+ def natified
14
+ @natified ||= ''
15
+ end
16
+
17
+ def pronunciation
18
+ @pronunciation ||= ''
7
19
  end
8
20
 
9
21
  def to_nato
@@ -1,3 +1,3 @@
1
1
  module NATO
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -8,27 +8,35 @@ module NATO
8
8
  Then { parser.should respond_to :natify }
9
9
 
10
10
  describe "short sentence without numbers" do
11
+ Given(:result) { [[:Alfa, :"AL-FAH"], [:Bravo, :"BRAH-VOH"], [:Charlie, :"CHAR-LEE"], [:Delta, :"DELL-TAH"], [:Echo, :"ECK-OH"]] }
12
+
11
13
  When(:nato) { parser.natify 'abcde' }
12
14
 
13
- Then { nato.should == 'Alfa Bravo Charlie Delta Echo' }
15
+ Then { nato.should == result }
14
16
  end
15
17
 
16
- describe "short sentence with numbers" do
18
+ describe "short sentence" do
19
+ Given(:result) { [[:Seven, :"SEV-EN"], [:Tango, :"TANG-GO"], [:Papa, :"PAH-PAH"], [:Three, :TREE], [:November, :"NO-VEM-BER"], [:Yankee, :"YANG-KEY"]] }
20
+
17
21
  When(:nato) { parser.natify '7tp3ny' }
18
22
 
19
- Then { nato.should == '7 Tango Papa 3 November Yankee' }
23
+ Then { nato.should == result }
20
24
  end
21
25
 
22
- describe "medium sentence without numbers" do
26
+ describe "medium sentence" do
27
+ Given(:result) { [[:Mike, :MIKE], [:Lima, :"LEE-MAH"], [:Oscar, :"OSS-CAH"], [:Zulu, :"ZOO-LOO"], [:Juliett, :"JEW-LEE-ETT"], [:Uniform, :"YOU-NEE-FORM"], [:Whiskey, :"WISS-KEY"], [:Sierra, :"SEE-AIR-RAH"], [:Whiskey, :"WISS-KEY"], [:Kilo, :"KEY-LOH"], [:Romeo, :"ROW-ME-OH"], [:Hotel, :"HOH-TEL"], [:Foxtrot, :"FOKS-TROT"]] }
28
+
23
29
  When(:nato) { parser.natify 'mlozjuwswkrhf' }
24
30
 
25
- Then { nato.should == 'Mike Lima Oscar Zulu Juliett Uniform Whiskey Sierra Whiskey Kilo Romeo Hotel Foxtrot' }
31
+ Then { nato.should == result }
26
32
  end
27
33
 
28
- describe "medium sentence with numbers" do
34
+ describe "medium sentence" do
35
+ Given(:result) { [[:Mike, :MIKE], [:Lima, :"LEE-MAH"], [:Zero, :"ZEE-RO"], [:One, :WUN], [:Juliett, :"JEW-LEE-ETT"], [:Uniform, :"YOU-NEE-FORM"], [:Whiskey, :"WISS-KEY"], [:Sierra, :"SEE-AIR-RAH"], [:Eight, :AIT], [:Four, :"FOW-ER"], [:Six, :SIX], [:Hotel, :"HOH-TEL"], [:Foxtrot, :"FOKS-TROT"]] }
36
+
29
37
  When(:nato) { parser.natify 'ml01juws846hf' }
30
38
 
31
- Then { nato.should == 'Mike Lima 0 1 Juliett Uniform Whiskey Sierra 8 4 6 Hotel Foxtrot' }
39
+ Then { nato.should == result }
32
40
  end
33
41
  end
34
42
  end
@@ -4,7 +4,20 @@ module NATO
4
4
  describe Text do
5
5
  Given(:text) { Text.new 'a8h43lnr0' }
6
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'] }
7
+ describe "#to_nato" do
8
+ Then { text.should respond_to :to_nato }
9
+
10
+ And { text.to_nato.should == 'Alfa Eight Hotel Four Three Lima November Romeo Zero' }
11
+ end
12
+
13
+ describe "#to_s" do
14
+ Then { text.to_s.should == ['a8h43lnr0', 'Alfa Eight Hotel Four Three Lima November Romeo Zero'] }
15
+ end
16
+
17
+ describe '#pronunciation' do
18
+ Then { text.should respond_to :pronunciation }
19
+
20
+ And { text.pronunciation.should == 'AL-FAH AIT HOH-TEL FOW-ER TREE LEE-MAH NO-VEM-BER ROW-ME-OH ZEE-RO' }
21
+ end
9
22
  end
10
23
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: NATO
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lukas Alexandre
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,49 +27,43 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec-given
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  description: NATO Phonetic Alphabet conversion tool
@@ -99,27 +90,26 @@ files:
99
90
  homepage: https://github.com/lukelex/NATO
100
91
  licenses:
101
92
  - MIT
93
+ metadata: {}
102
94
  post_install_message:
103
95
  rdoc_options: []
104
96
  require_paths:
105
97
  - lib
106
98
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
99
  requirements:
109
- - - ! '>='
100
+ - - '>='
110
101
  - !ruby/object:Gem::Version
111
102
  version: '0'
112
103
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
104
  requirements:
115
- - - ! '>='
105
+ - - '>='
116
106
  - !ruby/object:Gem::Version
117
107
  version: '0'
118
108
  requirements: []
119
109
  rubyforge_project:
120
- rubygems_version: 1.8.25
110
+ rubygems_version: 2.0.2
121
111
  signing_key:
122
- specification_version: 3
112
+ specification_version: 4
123
113
  summary: NATO Phonetic Alphabet conversion tool
124
114
  test_files:
125
115
  - spec/parser_spec.rb