NATO 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -60,7 +60,10 @@ $ gem install NATO
60
60
 
61
61
  ## Usage
62
62
 
63
- TODO: Write usage instructions here
63
+ ```ruby
64
+ text = Text.new 'a8h43lnr0'
65
+ text.to_nato # "Alfa 8 Hotel 4 3 Lima November Romeo 0"
66
+ ```
64
67
 
65
68
  ## Contributing
66
69
 
@@ -15,7 +15,7 @@ module NATO
15
15
  :m => :Mike,
16
16
  :n => :November,
17
17
  :o => :Oscar,
18
- :o => :Papa,
18
+ :p => :Papa,
19
19
  :q => :Quebec,
20
20
  :r => :Romeo,
21
21
  :s => :Sierra,
@@ -8,13 +8,13 @@ class NATO::Parser
8
8
  if is_numeric? piece
9
9
  piece
10
10
  else
11
- NATO::DICTIONARY[piece.to_sym].to_s || piece
11
+ NATO::DICTIONARY[piece.to_sym].to_s
12
12
  end
13
13
  end.join ' '
14
14
  end
15
15
 
16
16
  private
17
17
  def is_numeric?(obj)
18
- obj.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
18
+ obj.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/)
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module NATO
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ module NATO
4
+ describe Parser do
5
+ Given(:parser) { Parser.instance }
6
+
7
+ describe "#natify" do
8
+ Then { parser.should respond_to :natify }
9
+
10
+ describe "short sentence without numbers" do
11
+ When(:nato) { parser.natify 'abcde' }
12
+
13
+ Then { nato.should == 'Alfa Bravo Charlie Delta Echo' }
14
+ end
15
+
16
+ describe "short sentence with numbers" do
17
+ When(:nato) { parser.natify '7tp3ny' }
18
+
19
+ Then { nato.should == '7 Tango Papa 3 November Yankee' }
20
+ end
21
+
22
+ describe "medium sentence without numbers" do
23
+ When(:nato) { parser.natify 'mlozjuwswkrhf' }
24
+
25
+ Then { nato.should == 'Mike Lima Oscar Zulu Juliett Uniform Whiskey Sierra Whiskey Kilo Romeo Hotel Foxtrot' }
26
+ end
27
+
28
+ describe "medium sentence with numbers" do
29
+ When(:nato) { parser.natify 'ml01juws846hf' }
30
+
31
+ Then { nato.should == 'Mike Lima 0 1 Juliett Uniform Whiskey Sierra 8 4 6 Hotel Foxtrot' }
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: NATO
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - lib/NATO/parser.rb
94
94
  - lib/NATO/text.rb
95
95
  - lib/NATO/version.rb
96
+ - spec/parser_spec.rb
96
97
  - spec/spec_helper.rb
97
98
  - spec/text_spec.rb
98
99
  homepage: https://github.com/lukelex/NATO
@@ -121,5 +122,6 @@ signing_key:
121
122
  specification_version: 3
122
123
  summary: NATO Phonetic Alphabet conversion tool
123
124
  test_files:
125
+ - spec/parser_spec.rb
124
126
  - spec/spec_helper.rb
125
127
  - spec/text_spec.rb