phony 1.7.8 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ Phony.define do
45
45
  country '20', one_of('800') >> split(7) | # Egypt
46
46
  one_of('2', '3') >> split(8) | # Cairo/Giza, Alexandria
47
47
  fixed(2) >> split(8)
48
- # :mobile? => /^10|11|12|14|16|17|18|19*$/, :service? => /^800.*$/
48
+ # :mobile? => /^1[01246-9]\d+$/, :service? => /^800\d+$/
49
49
 
50
50
  # South Africa.
51
51
  #
@@ -96,7 +96,7 @@ Phony.define do
96
96
  # Switzerland.
97
97
  #
98
98
  country '41',
99
- match(/^(8(00|40|42|44|48))\d+$/) >> split(3,3) |
99
+ match(/^(8(00|4[0248]))\d+$/) >> split(3,3) |
100
100
  fixed(2) >> split(3,2,2)
101
101
 
102
102
 
@@ -145,7 +145,7 @@ Phony.define do
145
145
  #
146
146
  country '53',
147
147
  match(/^(5\d{3})\d+$/) >> split(4) | # Mobile
148
- match(/^(7|21|22|23|4[1-8]|3[1-3])/) >> split(7) | # Short NDCs
148
+ match(/^(7|2[123]|4[1-8]|3[1-3])/) >> split(7) | # Short NDCs
149
149
  fixed(3) >> split(7) # 3-digit NDCs
150
150
 
151
151
  # Argentine Republic.
@@ -160,7 +160,7 @@ Phony.define do
160
160
  # Brazil (Federative Republic of).
161
161
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
162
162
  #
163
- brazilian_service = /^(100|128|190|191|192|193|194|197|198|199)\d+$/
163
+ brazilian_service = /^(1(00|28|9[0-4789]))\d+$/
164
164
  country '55',
165
165
  match(brazilian_service) >> split(3,3) | # Service.
166
166
  fixed(2) >> split(4,4) # NDCs
@@ -241,7 +241,7 @@ Phony.define do
241
241
  country '98', fixed(2) >> split(3,2,2) # TODO Iran (Islamic Republic of)
242
242
 
243
243
  country '210', todo # -
244
- country '211', todo # -
244
+ country '211', todo # South Sudan
245
245
  country '212', todo # Morocco
246
246
  country '213', fixed(2) >> split(3,4) # Algeria
247
247
  country '214', todo # -
@@ -8,7 +8,7 @@
8
8
  #
9
9
 
10
10
  ndcs = [
11
- '7', # Non-geographical
11
+ '7', # Non-geographic
12
12
  '8', # Stockholm
13
13
  '10', # VOIP
14
14
  '11', # Norrköping
@@ -1,9 +1,12 @@
1
1
  # The United Kingdom uses a variable-length ndc code, thus we use a separate file to not let all_other.rb explode.
2
2
  #
3
- # Note: The United Kingdom uses a variable ndc format from length 2 to 6.
3
+ # Note: The United Kingdom uses a variable ndc format from length 2 to 5.
4
4
  #
5
- # The UK is special in formatting in that it uses a 4-4, or 3-4 formatting rule with area
6
- # codes that are 2 or 3 digits long, and a 6 formatting rule with area codes that are 4-6 digits long.
5
+ # The UK is special in formatting in that it uses:
6
+ # a 4-4 formatting rule with area codes that are 2 digits long,
7
+ # a 3-4 formatting rule with area codes that are 3 digits long,
8
+ # a 6 or 5 formatting rule with area codes that are 4 digits long, and
9
+ # a 5 or 4 formatting rule with area codes that are 5 digits long.
7
10
  #
8
11
  # To reflect this different formatting, we need to install all handlers in a row.
9
12
  # First, the area codes of length 2, without a fallback length (since this captures all), but with a nil fallback length.
@@ -18,12 +21,16 @@ area_code_2_national = Phony::NationalSplitters::Variable.new nil, [
18
21
  '24', # Coventry
19
22
  '28', # Northern Ireland
20
23
  '29', # Cardiff
24
+ '55', # Corporate
25
+ '56', # LIECS/VoIP
26
+ '70', # Personal numbers
27
+
21
28
  ]
22
29
  area_code_2_local = Phony::LocalSplitters::Fixed.instance_for [4, 4]
23
30
  handlers << Phony::NationalCode.new(area_code_2_national, area_code_2_local)
24
31
 
25
32
  area_code_3_national = Phony::NationalSplitters::Variable.new nil, [
26
- # Geographical.
33
+ # Geographic.
27
34
  #
28
35
  '113', # Leeds
29
36
  '114', # Sheffield
@@ -39,19 +46,51 @@ area_code_3_national = Phony::NationalSplitters::Variable.new nil, [
39
46
  '171', # Used for inner London until 2000
40
47
  '181', # Used for outer London until 2000
41
48
  '191', # Tyne and Wear/County Durham
49
+
42
50
  # Services.
43
51
  #
44
- '800', # Freephone
45
- '808', # Freephone
46
- '842',
52
+ '300', # Non-geographic charged at same rate as 01
53
+ '301',
54
+ '303',
55
+ '308',
56
+ '309',
57
+ '330',
58
+ '331',
59
+ '333',
60
+ '336',
61
+ '339',
62
+ '342',
63
+ '343',
64
+ '344',
65
+ '345',
66
+ '370',
67
+ '371',
68
+ '372',
69
+ '373',
70
+
71
+ # '500', # Freephone (9 digits) -- to do 0500 + 6 digits
72
+ '800', # Freephone (9 or 10 digits)
73
+ '808', # Freephone (10 digits)
74
+
75
+ '842', # Business rate
47
76
  '843',
48
77
  '844',
49
78
  '845',
50
79
  '870',
51
- '871',
80
+
81
+ '871', # Premium rate
52
82
  '872',
53
83
  '873',
84
+
54
85
  '900', # Premium rate content services
86
+ '901',
87
+ '902',
88
+ '903',
89
+ '904',
90
+ '905',
91
+ '906',
92
+ '907',
93
+
55
94
  '908', # Sexual entertainment services
56
95
  '909', # Sexual entertainment services
57
96
  '982', # Sexual entertainment services
@@ -62,31 +101,72 @@ handlers << Phony::NationalCode.new(area_code_3_national, area_code_3
62
101
  # 6 is the fallback length.
63
102
  #
64
103
  area_code_45_national = Phony::NationalSplitters::Variable.new 6, [
65
- # Geographical.
104
+ # Geographic.
66
105
  #
67
106
  '1204', # Bolton
68
- '1224', # Aberdeen
107
+ '1208', # Bodmin
108
+ '1254', # Blackburn
109
+ '1276', # Camberley
110
+ '1297', # Axminster
111
+ '1298', # Buxton
112
+ '1363', # Crediton
113
+ '1364', # Ashburton
114
+ '1384', # Dudley
115
+ '1386', # Evesham
116
+ '1404', # Honiton
117
+ '1420', # Alton
118
+ '1460', # Chard
119
+ '1461', # Gretna
120
+ '1480', # Huntingdon
121
+ '1488', # Hungerford
122
+ '1524', # Lancaster (Mixed area)
123
+ '1527', # Redditch
124
+ '1562', # Kidderminster
125
+ '1566', # Launceston
126
+ '1606', # Northwich
127
+ '1629', # Matlock
128
+ '1635', # Newbury
129
+ '1647', # Moretonhampstead
130
+ '1659', # Sanquhar
131
+ '1695', # Skelmersdale
132
+ '1726', # St Austell
133
+ '1744', # St Helens
134
+ '1750', # Selkirk
135
+ '1768', # Penrith (Mixed area)
136
+ '1827', # Tamworth
137
+ '1837', # Okehampton
138
+ '1884', # Tiverton
139
+ '1900', # Workington
140
+ '1905', # Worcester
141
+ '1935', # Yeovil
142
+ '1946', # Whitehaven (Mixed area)
143
+ '1949', # Whatton
144
+ '1963', # Wincanton
145
+ '1995', # Garstang
146
+
147
+ # Geographic.
148
+ #
149
+ '1224', # Aberdeen
69
150
  '1244', # Chester
70
151
  '1382', # Dundee
71
152
  '1429', # Hartlepool
72
153
  '1482', # Hull
73
- '1527', # Redditch
74
154
  '1582', # Luton
75
155
  '1670', # Morpeth
76
156
  '1730', # Petersfield
77
157
  '1736', # Penzance
78
- '1750', # Selkirk
79
158
  '1772', # Preston
80
159
  '1853', # Ullapool
81
- '1900', # Workington
82
- '1946', # Whitehaven
83
160
  '1947', # Whitby
161
+ # and 500 others
162
+
84
163
  # Mobile.
85
164
  #
86
165
  ('7400'..'7599').to_a,
87
166
  '7624',
88
167
  ('7700'..'7999').to_a,
89
- # Geographical.
168
+
169
+ # Geographic.
90
170
  #
91
171
  '13873', # Langholm
92
172
  '15242', # Hornby
@@ -95,7 +175,7 @@ area_code_45_national = Phony::NationalSplitters::Variable.new 6, [
95
175
  '15396', # Sedbergh
96
176
  '16973', # Wigton
97
177
  '16974', # Raughton Head
98
- '16977', # Brampton[3][4]
178
+ '16977', # Brampton
99
179
  '17683', # Appleby
100
180
  '17684', # Pooley Bridge
101
181
  '17687', # Keswick
@@ -104,6 +184,8 @@ area_code_45_national = Phony::NationalSplitters::Variable.new 6, [
104
184
  area_code_45_local = Phony::LocalSplitters::Fixed.instance_for [6]
105
185
  handlers << Phony::NationalCode.new(area_code_45_national, area_code_45_local)
106
186
 
187
+ # '16977', # Brampton -- to do 016977 + 4 digits for 169772 and 169773
188
+
107
189
  Phony.define do
108
190
  country '44', Phony::Country.new(*handlers)
109
191
  end
@@ -230,15 +230,27 @@ describe 'country descriptions' do
230
230
  Phony.split('256464441234').should == ['256', '464', '441234'] # Mubende
231
231
  end
232
232
  it 'handles UK numbers' do
233
- Phony.split('442045671113').should == ['44', '20', '4567', '1113'] # London
234
- Phony.split('442076229901').should == ['44', '20', '7622', '9901'] # Cardiff
235
- Phony.split('441136770011').should == ['44', '113', '677', '0011'] # Leeds
233
+ Phony.split('442075671113').should == ['44', '20', '7567', '1113'] # London
234
+ Phony.split('442920229901').should == ['44', '29', '2022', '9901'] # Cardiff
235
+ Phony.split('441134770011').should == ['44', '113', '477', '0011'] # Leeds
236
+ Phony.split('441412770011').should == ['44', '141', '277', '0011'] # Glasgow
236
237
  Phony.split('441382229845').should == ['44', '1382', '229845'] # Dundee
237
- Phony.split('44120499532').should == ['44', '1204', '99532'] # Bolten
238
- Phony.split('441539618756').should == ['44', '15396', '18756'] # Sedbergh
238
+ Phony.split('441204500532').should == ['44', '1204', '500532'] # Bolton
239
+ Phony.split('44120462532').should == ['44', '1204', '62532'] # Bolton
240
+ Phony.split('441539648756').should == ['44', '15396', '48756'] # Sedbergh
241
+ Phony.split('441697744555').should == ['44', '16977', '44555'] # Brampton
242
+ Phony.split('44169772333').should == ['44', '16977', '2333'] # Brampton
243
+ Phony.split('443005878323').should == ['44', '300', '587', '8323'] # Non-geographic
244
+ Phony.split('443457777334').should == ['44', '345', '777', '7334'] # Non-geographic
245
+ # Phony.split('44500557788').should == ['44', '500', '557788'] # Freefone
246
+ Phony.split('445575671113').should == ['44', '55', '7567', '1113'] # Corporate
247
+ Phony.split('445644775533').should == ['44', '56', '4477', '5533'] # LIECS/VoIP
248
+ Phony.split('447020229901').should == ['44', '70', '2022', '9901'] # Personal numbers
239
249
  Phony.split('447780605207').should == ['44', '7780', '605207'] # Mobile
240
250
  Phony.split('447480605207').should == ['44', '7480', '605207'] # Mobile
241
- Phony.split('448005878323').should == ['44', '800', '587', '8323'] # Service, regression
251
+ # Phony.split('44800557788').should == ['44', '800', '557788'] # Freefone
252
+ Phony.split('448084682355').should == ['44', '808', '468', '2355'] # Freefone
253
+ Phony.split('448005878323').should == ['44', '800', '587', '8323'] # Freefone, regression
242
254
  end
243
255
  it 'handles US numbers' do
244
256
  Phony.split('15551115511').should == ['1', '555', '111', '5511']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.8
4
+ version: 1.7.9
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: 2012-08-19 00:00:00.000000000 Z
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Fast international phone number (E164 standard) normalizing, splitting
15
15
  and formatting. Lots of formatting options: International (+.., 00..), national