phony 2.15.26 → 2.15.27
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.
- checksums.yaml +4 -4
- data/README.textile +1 -1
- data/lib/phony/countries/austria.rb +26 -22
- data/lib/phony/countries/brazil.rb +1 -1
- data/spec/functional/plausibility_spec.rb +1 -0
- data/spec/lib/phony/countries_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38db83f2fb323c25ec7338913c408d05750d7ad9
|
4
|
+
data.tar.gz: f8f17fb71c57d268d08915724f40fa7669ea511d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b290339b1ca372585f524ba0b034ae342371acd1ad84fac1f742ba2796c185d63f87788906b63a62b5f37b2c0fe51030f48b02730a86fa6846860460b124ca
|
7
|
+
data.tar.gz: da5b4bd8cf4d77a6f116e559027130341c59cdb3b33c9564b3375ab87149f13003e36e35207d0524e546c5d7427e45c6b9efbe6d00add850193c8b36b03a66e4
|
data/README.textile
CHANGED
@@ -20,7 +20,7 @@ h2. Description
|
|
20
20
|
|
21
21
|
This gem normalizes, formats and splits "*E164 phone numbers*":http://en.wikipedia.org/wiki/E.164. A valid E164 phone number *must* include a country code.
|
22
22
|
|
23
|
-
E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number. For example, the
|
23
|
+
E164 numbers are international numbers with a country dial prefix, usually an area code and a subscriber number. For example, the Australian number @+61 412 345 678@ can be broken down into the following components:
|
24
24
|
* Country Code (CC): a country code of @61@
|
25
25
|
* National Destination Code (NDC): a mobile number denoted by the @4@ (specific to Australia)
|
26
26
|
* Local Number Part: a subscriber number of @12 345 678@
|
@@ -10,20 +10,22 @@ ndcs = [
|
|
10
10
|
'732' # Linz
|
11
11
|
]
|
12
12
|
|
13
|
+
corporate_2digit = [
|
14
|
+
'57',
|
15
|
+
'59'
|
16
|
+
]
|
17
|
+
|
13
18
|
corporate = [
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'509', # -
|
25
|
-
'517', # -
|
26
|
-
'720', #
|
19
|
+
'501',
|
20
|
+
'502',
|
21
|
+
'503',
|
22
|
+
'504',
|
23
|
+
'505',
|
24
|
+
'506',
|
25
|
+
'507',
|
26
|
+
'508',
|
27
|
+
'509',
|
28
|
+
'517'
|
27
29
|
]
|
28
30
|
|
29
31
|
mobile = [
|
@@ -86,13 +88,15 @@ service = [
|
|
86
88
|
# TODO Add more details.
|
87
89
|
#
|
88
90
|
Phony.define do
|
89
|
-
country '43', trunk('0')
|
90
|
-
one_of('1')
|
91
|
-
one_of(service)
|
92
|
-
one_of(
|
93
|
-
one_of(
|
94
|
-
one_of(
|
95
|
-
one_of(
|
96
|
-
one_of(
|
97
|
-
|
91
|
+
country '43', trunk('0') |
|
92
|
+
one_of('1') >> split(3..12) | # Vienna
|
93
|
+
one_of(service) >> split(9..9) |
|
94
|
+
one_of('720') >> split(6..10) | # VoIP number length is 9..13
|
95
|
+
one_of(corporate_2digit) >> split(3..11) | # Corporate number length is 5..13
|
96
|
+
one_of(corporate) >> split(2..10) | # Corporate number length is 5..13
|
97
|
+
one_of(ndcs) >> split(6..10) |
|
98
|
+
one_of('663') >> split(6..6) | # 6 digit mobile.
|
99
|
+
one_of(mobile) >> split(4,3..9) |
|
100
|
+
one_of(mobile_2digit) >> split(7..7) | # Separate as mobile contains 676 - 67 violates the prefix rule.
|
101
|
+
fixed(4) >> split(3..9) # Number length is 7..13.
|
98
102
|
end
|
@@ -92,7 +92,7 @@ ndcs = /(11|12|13|14|15|16|17|18|19|21|22|24|27|28|31|32|33|34|35|36|37|38|41|42
|
|
92
92
|
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
|
93
93
|
|
94
94
|
special_numbers_3_4 = %w{ 0800 }
|
95
|
-
special_numbers_4 = %w{ 3003 4004 4020 }
|
95
|
+
special_numbers_4 = %w{ 3003 4003 4004 4020 }
|
96
96
|
|
97
97
|
Phony.define do
|
98
98
|
country '55',
|
@@ -46,6 +46,7 @@ describe 'plausibility' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'specific countries' do
|
49
|
+
it_is_correct_for 'Austria', :samples => '+43 720 116987' # VoIP
|
49
50
|
it_is_correct_for 'Congo', :samples => '+242 1234 56789'
|
50
51
|
it_is_correct_for 'Cook Islands', :samples => '+682 71928'
|
51
52
|
it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
|
@@ -47,6 +47,7 @@ describe 'country descriptions' do
|
|
47
47
|
it_splits '4367000000000', %w( 43 670 0000 0000 ) # Mobile
|
48
48
|
it_splits '433161234567891', %w( 43 316 1234567891 ) # Graz
|
49
49
|
it_splits '432164123456789', %w( 43 2164 123456789 ) # Rohrau
|
50
|
+
it_splits '43720116987', %w( 43 720 116987 ) # VoIP
|
50
51
|
|
51
52
|
# mobile numbers can have from 7 to 10 digits in the subscriber number
|
52
53
|
it_splits '436641234567', %w( 43 664 1234 567 )
|
@@ -149,6 +150,7 @@ describe 'country descriptions' do
|
|
149
150
|
it_splits '5508002221234', ['55', '0800', '222', '1234']
|
150
151
|
it_splits '5530032221', ['55', '3003', '2221']
|
151
152
|
it_splits '5540209999', ['55', '4020', '9999']
|
153
|
+
it_splits '5540038999', ['55', '4003', '8999']
|
152
154
|
it_splits '5540048999', ['55', '4004', '8999']
|
153
155
|
end
|
154
156
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.15.
|
4
|
+
version: 2.15.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Hanke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Fast international phone number (E164 standard) normalizing, splitting
|
14
14
|
and formatting. Lots of formatting options: International (+.., 00..), national
|