phony 2.19.14 → 2.19.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f497a4a52bd0c47e845d1fa471e5465e1c949349fdcf78cf5e6f4ef6f501ee9
4
- data.tar.gz: 64bff396ac5a0a20fd27a8b8176ea71ec3fc569c129c7297e7910ae02b1a473d
3
+ metadata.gz: 45ec2d2d9ab9772ae3f05cd031cd6d4214f1a541838ac8539e5a8d60039d5119
4
+ data.tar.gz: 4998f527b3b6e2414ef7411c9736a39eaf4b9639faaca8d604a9802b1cf24d5b
5
5
  SHA512:
6
- metadata.gz: 20f087521f9e50b8fa1b31418ad24363fe97949ca7eae3b787429dbfdd2c8ee83d66a99f898033e5890e76351517fc237746084e68d33878d7a258c69179bfb8
7
- data.tar.gz: a29e55bf204811d025b7ba758ab04e3584eabb43ccefc9011c8bc4c6b1e122f5e50ad5b8f714012a35c6c4e637d5894a2272ea40810765e01de3b3c24d85497a
6
+ metadata.gz: 8fc13c0c16a9dd41bc947308ca2e0c36d59f4efce442c9d21a105aeb919ce323e8190ee0e302cd184e7145b26d6f3b3c9c42009ed6905240c7884fba98b98918
7
+ data.tar.gz: 5cdc031002c1e727a852b67897d93e3c93c3aef931f1f9a563f62d0b37af9eb137a8e81b37648b57d05f1466e8bebcf0b175cba71215b4c97d7dc80fa78a5bdc
@@ -3,14 +3,14 @@
3
3
  # Italian phone numbers.
4
4
  #
5
5
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Italy
6
- #
6
+ # https://www.itu.int/dms_pub/itu-t/oth/02/02/T020200006B0001PDFE.pdf
7
7
 
8
- ndcs_2digit = [
8
+ ndcs_1digit = [
9
9
  '02', # Milan
10
10
  '06', # Rome (including State of Vatican City) and Aprilia
11
11
  ]
12
12
 
13
- ndcs_3digit = [
13
+ ndcs_2digit = [
14
14
  '010', # Genoa
15
15
  '011', # Turin
16
16
  '015', # Biella
@@ -42,7 +42,7 @@ ndcs_3digit = [
42
42
  '099', # Taranto
43
43
  ]
44
44
 
45
- ndcs_4digit = [
45
+ ndcs_3digit = [
46
46
  '0121', # Pinerolo
47
47
  '0122', # Sestrieres, Bardonecchia and other Susa Valley mountain resorts
48
48
  '0123', # Lanzo Torinese
@@ -269,26 +269,28 @@ service = [ # Not exhaustive.
269
269
  ]
270
270
 
271
271
  Phony.define do
272
+ # Note: The 0 does not count towards NDC number length.
272
273
  country '39', trunk('', normalize: false) |
273
274
  one_of(*service) >> split(3,3) |
274
275
  one_of(*mobile) >> split(3,4,-1..1) |
275
- one_of(*ndcs_2digit) >> matched_split(
276
+ one_of(*ndcs_1digit) >> matched_split(
276
277
  /\A\d{5}\z/ => [5],
277
278
  /\A\d{6}\z/ => [4,2],
278
279
  /\A\d{7}\z/ => [4,3],
279
280
  /\A\d{8}\z/ => [4,4],
280
281
  ) |
281
- one_of(*ndcs_3digit) >> matched_split(
282
- /^1\d{6}$/ => [7],
283
- /^1\d{7}$/ => [8],
284
- /^[^1]\d{5}$/ => [6],
285
- /^[^1]\d{6}$/ => [7]
282
+ one_of(*ndcs_2digit) >> matched_split(
283
+ /\A\d{4}\z/ => [4],
284
+ /\A\d{5}\z/ => [5],
285
+ /\A\d{6}\z/ => [6],
286
+ /\A\d{7}\z/ => [7],
287
+ /\A\d{8}\z/ => [8]
286
288
  ) |
287
- one_of(*ndcs_4digit) >> matched_split(
288
- /\A\d{4}\z/ => [4],
289
- /^1\d{5}$/ => [6],
290
- /^1\d{6}$/ => [7],
291
- /^[^1]\d{4}$/ => [5],
292
- /^[^1]\d{5}$/ => [3,3]
289
+ one_of(*ndcs_3digit) >> matched_split(
290
+ /\A\d{4}\z/ => [4],
291
+ /\A1\d{5}\z/ => [6],
292
+ /\A1\d{6}\z/ => [7],
293
+ /\A[^1]\d{4}\z/ => [5],
294
+ /\A[^1]\d{5}\z/ => [3,3]
293
295
  )
294
296
  end
@@ -288,8 +288,6 @@ describe 'plausibility' do
288
288
  it_is_correct_for 'Guinea-Bissau', :samples => '+245 44 728 6998'
289
289
  it_is_correct_for 'Guyana', :samples => '+592 263 1234'
290
290
  it_is_correct_for 'Honduras (Republic of)', :samples => '+504 12 961 637'
291
- it_is_correct_for 'Italy', :samples => ['+39 0574 1234',
292
- '+39 06 49911']
293
291
  it_is_correct_for 'Iraq', :samples => ['+964 1 123 4567',
294
292
  '+964 21 113 456',
295
293
  '+964 71 1234 5678']
@@ -610,6 +608,20 @@ describe 'plausibility' do
610
608
  Phony.plausible?('+62 22 0000 0000').should be_truthy
611
609
  Phony.plausible?('+62 22 000 000 000').should be_truthy
612
610
  end
611
+
612
+ it 'is correct for Italy' do
613
+ Phony.plausible?('+39 0574 123').should be_falsy
614
+ Phony.plausible?('+39 0574 1234').should be_truthy
615
+ Phony.plausible?('+39 0574 12345').should be_falsy
616
+
617
+ Phony.plausible?('+39 085 541').should be_falsy
618
+ Phony.plausible?('+39 085 5410').should be_truthy
619
+ Phony.plausible?('+39 085 54105').should be_truthy
620
+
621
+ Phony.plausible?('+39 06 4991').should be_falsy
622
+ Phony.plausible?('+39 06 49911').should be_truthy
623
+ Phony.plausible?('+39 06 499112').should be_truthy
624
+ end
613
625
 
614
626
  it 'is correct for Russia' do
615
627
  Phony.plausible?('+7 3522 000 000').should be_truthy
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.19.14
4
+ version: 2.19.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-13 00:00:00.000000000 Z
11
+ date: 2022-07-27 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