phony 1.8.4 → 1.8.5

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.
data/lib/phony.rb CHANGED
@@ -21,6 +21,7 @@ require File.expand_path '../phony/dsl', __FILE__
21
21
  # The ones that need more space to define.
22
22
  #
23
23
  require File.expand_path '../phony/countries/austria', __FILE__
24
+ require File.expand_path '../phony/countries/brazil', __FILE__
24
25
  require File.expand_path '../phony/countries/china', __FILE__
25
26
  require File.expand_path '../phony/countries/germany', __FILE__
26
27
  require File.expand_path '../phony/countries/ireland', __FILE__
@@ -41,7 +42,7 @@ module Phony
41
42
  # Phony uses a single country codes instance.
42
43
  #
43
44
  @codes = CountryCodes.instance
44
- @validators = Validators.instance
45
+ @validators = Validators.instance
45
46
 
46
47
  class << self
47
48
 
@@ -80,7 +81,7 @@ module Phony
80
81
  end
81
82
  alias formatted format
82
83
  alias formatted! format!
83
-
84
+
84
85
  # Makes a plausibility check.
85
86
  #
86
87
  # If it returns false, it is not plausible.
@@ -159,11 +159,7 @@ Phony.define do
159
159
 
160
160
  # Brazil (Federative Republic of).
161
161
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
162
- #
163
- brazilian_service = /^(1(00|28|9[0-4789]))\d+$/
164
- country '55',
165
- match(brazilian_service) >> split(3,3) | # Service.
166
- fixed(2) >> split(4,4) # NDCs
162
+ # country '55' # Brazil, see special file.
167
163
 
168
164
  # Chile.
169
165
  #
@@ -304,7 +300,7 @@ Phony.define do
304
300
  country '250',
305
301
  one_of('25') >> split(7) | # Geographic, fixed
306
302
  match(/^(7[238])/) >> split(7) | # Non-geographic, mobile
307
- one_of('06') >> split(6) # Satellite
303
+ one_of('06') >> split(6) # Satellite
308
304
 
309
305
  country '251', todo # Ethiopia
310
306
  country '252', todo # Somali Democratic Republic
@@ -428,9 +424,8 @@ Phony.define do
428
424
 
429
425
  # Estonia
430
426
  country '372',
431
- match(/^(5\d\d\d)\d+$/) >> split(4) | # Mobile
432
- match(/^((?:70|8[12])\d\d)\d+$/) >> split(4) | # Mobile
433
- fixed(3) >> split(4) # 3-digit NDCs
427
+ match(/^((5\d|8[12])\d\d)\d+$/) >> split(4) | # Mobile
428
+ fixed(3) >> split(4) # 3-digit NDCs
434
429
 
435
430
  country '373', todo # Moldova
436
431
  country '374', todo # Armenia
@@ -0,0 +1,101 @@
1
+ # Brazilian phone numbers.
2
+ #
3
+ # http://www.anatel.gov.br/hotsites/CodigosNacionaisLocalidade/TelefoneCelular-CodigosDeArea.htm
4
+ #
5
+ # Note: São Paulo recently added an extra 9 digit to all mobile phones in the 11 area code
6
+ #
7
+ ndcs = [
8
+ '11', #Sao Paulo
9
+ '12', #Sao Paulo
10
+ '13', #Sao Paulo
11
+ '14', #Sao Paulo
12
+ '15', #Sao Paulo
13
+ '16', #Sao Paulo
14
+ '17', #Sao Paulo
15
+ '18', #Sao Paulo
16
+ '19', #Sao Paulo
17
+
18
+ '21', #Rio de Janeiro
19
+ '22', #Rio de Janeiro
20
+
21
+ '24', #Rio de Janeiro
22
+
23
+
24
+ '27', #Espírito Santo
25
+ '28', #Espírito Santo
26
+
27
+
28
+ '31', #Minas Gerais
29
+ '32', #Minas Gerais
30
+ '33', #Minas Gerais
31
+ '34', #Minas Gerais
32
+ '35', #Minas Gerais
33
+ '36', #Minas Gerais
34
+ '37', #Minas Gerais
35
+ '38', #Minas Gerais
36
+
37
+
38
+ '41', #Paraná
39
+ '42', #Paraná
40
+ '43', #Paraná
41
+ '44', #Paraná
42
+ '45', #Paraná
43
+ '46', #Paraná
44
+ '47', #Santa Catarina
45
+ '48', #Santa Catarina
46
+ '49', #Santa Catarina
47
+
48
+ '51', #Rio Grande do Sul
49
+ '52', #Rio Grande do Sul
50
+ '53', #Rio Grande do Sul
51
+ '54', #Rio Grande do Sul
52
+ '55', #Rio Grande do Sul
53
+
54
+ '61', #Distrito Federal
55
+ '62', #Goiânia
56
+ '63', #Tocantins
57
+ '64', #Goiânia
58
+ '65', #Mato Grosso
59
+ '66', #Mato Grosso
60
+ '67', #Mato Grosso do Sul
61
+ '68', #Acre
62
+ '69', #Rondônia
63
+
64
+ '71', #Bahia
65
+ '72', #Bahia
66
+ '73', #Bahia
67
+ '74', #Bahia
68
+ '75', #Bahia
69
+
70
+ '77', #Bahia
71
+ '78', #Bahia
72
+ '79', #Sergipe
73
+
74
+ '81', #Pernambuco
75
+ '82', #Alagoas
76
+ '83', #Paraíba
77
+ '84', #Rio Grande do Norte
78
+ '85', #Ceará
79
+ '86', #Piauí
80
+ '87', #Pernambuco
81
+ '88', #Ceará
82
+ '89', #Piauí
83
+
84
+ '91', #Pará
85
+ '92', #Amazonas
86
+ '93', #Pará
87
+ '94', #Pará
88
+ '95', #Roraima
89
+ '96', #Amapá
90
+ '97', #Amazonas
91
+ '98', #Maranhão
92
+ '99', #Maranhão
93
+
94
+ ]
95
+ service = %w{ 100, 128, 190 191 192 193 194 197 198 199 } # State specific numbers were not added. See http://www.brasil.gov.br/navegue_por/aplicativos/agenda
96
+
97
+ Phony.define do
98
+ country '55', one_of(service) >> split(3,3) |
99
+ one_of(ndcs) >> split(4,4) |
100
+ fixed(3) >> split(4,4)
101
+ end
@@ -49,6 +49,7 @@ describe 'country descriptions' do
49
49
  end
50
50
  describe 'Brazil' do
51
51
  it_splits '551112341234', ['55', '11', '1234', '1234']
52
+ it_splits '5511981231234', ['55', '11', '9812', '31234'] # São Paulo's 9 digits mobile
52
53
  end
53
54
  describe 'Cambodia' do
54
55
  it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel)
@@ -95,7 +96,6 @@ describe 'country descriptions' do
95
96
  it_splits '37281231234', ['372', '8123', '1234'] # Mobile
96
97
  it_splits '37282231234', ['372', '8223', '1234'] # Mobile
97
98
  it_splits '37283212345', ['372', '832', '12345'] # Mobile
98
- it_splits '37270121234', ['372', '7012', '1234'] # Premium
99
99
  end
100
100
  describe 'Finland' do
101
101
  it_splits '3589123123', ['358', '9', '123', '123'] # Helsinki
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.8.4
4
+ version: 1.8.5
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-12-04 00:00:00.000000000 Z
12
+ date: 2013-01-21 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
@@ -21,6 +21,7 @@ extra_rdoc_files:
21
21
  - README.textile
22
22
  files:
23
23
  - lib/phony/countries/austria.rb
24
+ - lib/phony/countries/brazil.rb
24
25
  - lib/phony/countries/china.rb
25
26
  - lib/phony/countries/germany.rb
26
27
  - lib/phony/countries/ireland.rb