phony 2.16.10 → 2.16.11

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: 7f43e15c89c7a3584c6306f5db30348a8af3b9fae66fac55672d446515902ec6
4
- data.tar.gz: 807035a30b1b445ff66f764178dd7d1a2bb5054ae57a525860aedf11c138dd5e
3
+ metadata.gz: 12a40a0fe9dcbc578b3f99963bef86135596894d1145cfe3582ddb088ca918f1
4
+ data.tar.gz: 58959c59c7641ed3ab70f0586bb64100bd599d2e2e0dce4c4bf46522d0231ba8
5
5
  SHA512:
6
- metadata.gz: 95ae5fa19472f69c75c4151fb1ce21112c3e8b2b82bfd466e3bcbecb7a0ec2aefaa8c8b6743b05bd059086138ae00f4c4c46baa094c7b972eb84a4bc08c4673f
7
- data.tar.gz: f270781a365518eda490f6e50534868d352594d81d47fa31771d4f26d4f773baea3bd37b08c1e123244843cc2e273116c92c45578005093e9aa51f1191b65d75
6
+ metadata.gz: cef3550f87ea1c9b33e80358389b435c52a765445035d9f61a9c7ceee3c44e921a14505e34a88eb13fcc61b9378a104179512cf1024252bcc0510fce778a843c
7
+ data.tar.gz: 01a79012341a7758151d66b80877cc2dc865a1bafb605b897d2667a8dadbf3ed44fe7e00d04ef437b86abbd42a63231490b5e4d346592c8d7e4cc735ab544d60
@@ -10,6 +10,20 @@ ndcs = [
10
10
  '7', # Johor (except Muar)
11
11
  '9', # Kelantan, Pahang (except Cameron Highlands & Genting Highlands) & Terengganu
12
12
  ]
13
+
14
+ ndcs_two_digits = [
15
+ '80', # Domestic access code from East Malaysia to Brunei
16
+ '81', # Reserved number for future use
17
+ '82', # Sarawak – Kuching, Samarahan and Serian
18
+ '83', # Sarawak – Sri Aman and Betong
19
+ '84', # Sarawak – Sibu, Sarikei, Mukah and Kapit
20
+ '85', # Sarawak – Miri, Limbang and Lawas
21
+ '86', # Sarawak – Bintulu and Belaga
22
+ '87', # Labuan Interior Division, Sabah
23
+ '88', # Sabah – Kota Kinabalu and Kudat
24
+ '89', # Sabah – Lahad Datu, Sandakan and Tawau
25
+ ]
26
+
13
27
  mobile = %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 }
14
28
  # service = %w{ 100 101 102 103 104 108 991 994 995 999 } # Emergeny and Service numbers, only 3 digits long
15
29
  freephone = %w{ 300 700 800 }
@@ -23,6 +37,7 @@ Phony.define do
23
37
  one_of(freephone) >> split(2,4) | # Freephone, Tollfree, Forwarding
24
38
  # one_of(service) >> none | # Service
25
39
  one_of(mobile) >> split(3,4..5) | # Mobile
40
+ one_of(ndcs_two_digits) >> split(6) | # 2-digit NDCs
26
41
  one_of(ndcs) >> split(7) | # 1-digit NDCs
27
42
  one_of(ndcs_eight) >> split(8) | # 1-digit NDCs
28
43
  fixed(2) >> split(8) # 2-digit NDCs (Also, fallback)
@@ -589,6 +589,8 @@ describe 'plausibility' do
589
589
 
590
590
  it 'is correct for Malaysia' do
591
591
  Phony.plausible?('+60 5 123 1234').should be_truthy # Non Selangor Landline
592
+ Phony.plausible?('+60 3 1234 1234').should be_truthy # Selangor Landline
593
+ Phony.plausible?('+60 88 123 123').should be_truthy # Landline Sabah – Kota Kinabalu and Kudat
592
594
  end
593
595
 
594
596
  it 'is correct for Japan' do
@@ -641,7 +641,7 @@ describe 'country descriptions' do
641
641
  it_splits '79991234567', ['7', '999', '123', '45', '67'] # Russia 3-digit
642
642
  it_splits '7840121212', ['7', '840', '12', '1212'] # Abhasia
643
643
  it_splits '7799121212', ['7', '799', '12', '1212'] # Kazachstan
644
- it_splits '7995344121212', ['7','995344','12','1212'] # South Osetia
644
+ it_splits '7995344121212', ['7', '995', '344','12','1212'] # South Osetia
645
645
  it_splits '7209175276', ['7', '209', '17', '5276'] # Fantasy number
646
646
  end
647
647
 
@@ -1,74 +1,70 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Phony do
4
-
5
- describe described_class::NormalizationError do
6
- it 'is correctly raised on normalize' do
7
- expect do
8
- described_class.normalize('000')
9
- end.to raise_error(described_class::NormalizationError)
10
- end
11
- it 'is correctly raised on normalize' do
12
- expect do
13
- described_class.normalize('000')
14
- end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
15
- end
16
- it 'is correctly raised on normalize!' do
17
- expect do
18
- described_class.normalize!('000')
19
- end.to raise_error(described_class::NormalizationError)
20
- end
21
- it 'is correctly raised on normalize!' do
22
- expect do
23
- described_class.normalize!('000')
24
- end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
25
- end
3
+ describe Phony::NormalizationError do
4
+ it 'is correctly raised on normalize' do
5
+ expect do
6
+ Phony.normalize('000')
7
+ end.to raise_error(Phony::NormalizationError)
26
8
  end
9
+ it 'is correctly raised on normalize' do
10
+ expect do
11
+ Phony.normalize('000')
12
+ end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
13
+ end
14
+ it 'is correctly raised on normalize!' do
15
+ expect do
16
+ Phony.normalize!('000')
17
+ end.to raise_error(Phony::NormalizationError)
18
+ end
19
+ it 'is correctly raised on normalize!' do
20
+ expect do
21
+ Phony.normalize!('000')
22
+ end.to raise_error(%Q{Phony could not normalize the given number. Is it a phone number?})
23
+ end
24
+ end
25
+
26
+ describe Phony::SplittingError do
27
+ it 'is correctly raised on split' do
28
+ expect do
29
+ Phony.split('000')
30
+ end.to raise_error(Phony::SplittingError)
31
+ end
32
+ it 'is correctly raised on split' do
33
+ expect do
34
+ Phony.split('000')
35
+ end.to raise_error(%Q{Phony could not split the given number. Is "000" a phone number?})
36
+ end
37
+ it 'is correctly raised on split!' do
38
+ expect do
39
+ Phony.split!('000')
40
+ end.to raise_error(Phony::SplittingError)
41
+ end
42
+ it 'is correctly raised on split!' do
43
+ expect do
44
+ Phony.split!('000')
45
+ end.to raise_error(%Q{Phony could not split the given number. Is it a phone number?})
46
+ end
47
+ end
27
48
 
28
- describe described_class::SplittingError do
29
- it 'is correctly raised on split' do
30
- expect do
31
- described_class.split('000')
32
- end.to raise_error(described_class::SplittingError)
33
- end
34
- it 'is correctly raised on split' do
35
- expect do
36
- described_class.split('000')
37
- end.to raise_error(%Q{Phony could not split the given number. Is "000" a phone number?})
38
- end
39
- it 'is correctly raised on split!' do
40
- expect do
41
- described_class.split!('000')
42
- end.to raise_error(described_class::SplittingError)
43
- end
44
- it 'is correctly raised on split!' do
45
- expect do
46
- described_class.split!('000')
47
- end.to raise_error(%Q{Phony could not split the given number. Is it a phone number?})
48
- end
49
+ describe Phony::FormattingError do
50
+ it 'is correctly raised on format' do
51
+ expect do
52
+ Phony.format('000')
53
+ end.to raise_error(Phony::FormattingError)
54
+ end
55
+ it 'is correctly raised on format' do
56
+ expect do
57
+ Phony.format('000')
58
+ end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
59
+ end
60
+ it 'is correctly raised on format!' do
61
+ expect do
62
+ Phony.format!('000')
63
+ end.to raise_error(Phony::FormattingError)
49
64
  end
50
-
51
- describe described_class::FormattingError do
52
- it 'is correctly raised on format' do
53
- expect do
54
- described_class.format('000')
55
- end.to raise_error(described_class::FormattingError)
56
- end
57
- it 'is correctly raised on format' do
58
- expect do
59
- described_class.format('000')
60
- end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
61
- end
62
- it 'is correctly raised on format!' do
63
- expect do
64
- described_class.format!('000')
65
- end.to raise_error(described_class::FormattingError)
66
- end
67
- it 'is correctly raised on format!' do
68
- expect do
69
- described_class.format!('000')
70
- end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
71
- end
65
+ it 'is correctly raised on format!' do
66
+ expect do
67
+ Phony.format!('000')
68
+ end.to raise_error(%Q{Phony could not format the given number. Is it a phone number?})
72
69
  end
73
-
74
70
  end
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.16.10
4
+ version: 2.16.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-03 00:00:00.000000000 Z
11
+ date: 2019-02-15 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