phony 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/phony.rb CHANGED
@@ -27,6 +27,7 @@ require File.expand_path '../phony/countries/greece', __FILE__
27
27
  require File.expand_path '../phony/countries/hungary', __FILE__
28
28
  require File.expand_path '../phony/countries/italy', __FILE__
29
29
  require File.expand_path '../phony/countries/netherlands', __FILE__
30
+ require File.expand_path '../phony/countries/romania', __FILE__
30
31
  require File.expand_path '../phony/countries/sweden', __FILE__
31
32
 
32
33
  require File.expand_path '../phony/country_codes', __FILE__
@@ -63,7 +63,7 @@ module Phony
63
63
  '36' => Countries::Hungary,
64
64
  '39' => Countries::Italy,
65
65
 
66
- '40' => fixed(2), # Romania
66
+ '40' => Countries::Romania,
67
67
  '41' => fixed(2, # Switzerland (Confederation of)
68
68
  :local_format => [3, 2, 2],
69
69
  :service_local_format => [3, 3],
@@ -74,8 +74,8 @@ module Phony
74
74
  # }
75
75
  ),
76
76
  '43' => Countries::Austria,
77
- '44' => fixed(2), # United Kingdom of Great Britain and Northern Ireland
78
- '45' => fixed(2), # Denmark
77
+ '44' => fixed(2), # TODO United Kingdom of Great Britain and Northern Ireland
78
+ '45' => fixed(2), # TODO Denmark
79
79
  '46' => Countries::Sweden,
80
80
  '47' => fixed(4, # Norway
81
81
  :local_format => [4]
@@ -84,7 +84,9 @@ module Phony
84
84
  :local_format => [1, 3, 3] # Approximation. Correct would be 48-xxx-xxx-xxx
85
85
  ),
86
86
  '49' => Countries::Germany,
87
-
87
+
88
+ # TODO From here on.
89
+ #
88
90
  '51' => fixed(2), # Peru
89
91
  '52' => fixed(2), # Mexico
90
92
  '53' => fixed(2), # Cuba
@@ -0,0 +1,30 @@
1
+ # Romanian phone numbers.
2
+ #
3
+ # http://en.wikipedia.org/wiki/Romania_telephone_area_codes
4
+ #
5
+ Phony::Countries::Romania = Phony::Country.configured :local_format => [3, 4], # Also captures 3, 3 on a fallback.
6
+ :local_special_format => [3, 3],
7
+ :ndc_fallback_length => 3,
8
+ :ndc_mapping => {
9
+ :landline => [
10
+ '21', # Bucureşti
11
+ '31', # Bucureşti
12
+ ],
13
+ :mobile => [
14
+ '71',
15
+ '72',
16
+ '73',
17
+ '74',
18
+ '75',
19
+ '76',
20
+ '77',
21
+ '78',
22
+ ],
23
+ :service => [
24
+ '112',
25
+ '800',
26
+ '900',
27
+ '903',
28
+ '906',
29
+ ]
30
+ }
@@ -14,12 +14,14 @@ describe Phony do
14
14
  Phony.split('31222123456').should == ['31', '222', '123456']
15
15
  end
16
16
  it "should handle egyptian numbers" do
17
- Phony.split('20233453756').should == ['20', '2', '33453756']
17
+ Phony.split('20212345678').should == ['20', '2', '12345678']
18
+ Phony.split('20951234567').should == ['20', '95', '1234567']
18
19
  end
19
20
  it "should handle french numbers" do
20
21
  Phony.split('33112345678').should == ['33', '1', '12','34','56','78']
21
22
  end
22
23
  it "should handle german numbers" do
24
+ Phony.split('4930123456').should == ['49', '30', '123', '456']
23
25
  Phony.split('4976112345').should == ['49', '761', '123', '45']
24
26
  end
25
27
  it "should handle greek numbers" do
@@ -34,6 +36,11 @@ describe Phony do
34
36
  it "should handle polish numbers" do
35
37
  Phony.split('48121123123').should == ['48', '12', '1', '123', '123']
36
38
  end
39
+ it 'handles romanian numbers' do
40
+ Phony.split('40211231234').should == ['40', '21', '123', '1234']
41
+ Phony.split('40721231234').should == ['40', '72', '123', '1234']
42
+ Phony.split('40249123123').should == ['40', '249', '123', '123']
43
+ end
37
44
  it "should handle swedish numbers" do
38
45
  Phony.split('46812345678').should == ['46', '8', '12345678']
39
46
  Phony.split('46111234567').should == ['46', '11', '1234567']
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 2
9
- version: 1.1.2
8
+ - 3
9
+ version: 1.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -35,6 +35,7 @@ files:
35
35
  - lib/phony/countries/hungary.rb
36
36
  - lib/phony/countries/italy.rb
37
37
  - lib/phony/countries/netherlands.rb
38
+ - lib/phony/countries/romania.rb
38
39
  - lib/phony/countries/sweden.rb
39
40
  - lib/phony/country.rb
40
41
  - lib/phony/country_codes.rb