phony 2.8.2 → 2.8.3

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
  SHA1:
3
- metadata.gz: c5db8b2a510f9d2e363fc24ade7837ace9db8d9b
4
- data.tar.gz: e53b10c977d397d9b0c6dca770dbddd560b808e7
3
+ metadata.gz: 18b2b6b4d8894f7063f3f1ffdb80cc0f5ed8eb17
4
+ data.tar.gz: 9f7222a28e4ed77f6d7835078efd734f65c23e2a
5
5
  SHA512:
6
- metadata.gz: ded8e1e3d7206b255f7fe25978878a6e52866d466e5bf58bb2b382a107da7802775eb035425924b069a30a515f1300b6846ec126b508f7214033eec0aaa2763f
7
- data.tar.gz: 5c8474e09d66faed68e6111212cd0b528e2da1f47ee696773264d1b18cf3a10eb9733115bb6b879f66438dd8270a096c67d41891aafb5b29f29e00c70fc3cd1b
6
+ metadata.gz: 3dce67e5a63cf8a758548797d635e9fb11ef9fc8e146a0e30d1c4d7cff79373ff18efe5fc17f51a4ac5a1b3989747bfc05f9570e92b9440fda06cbcd31128783
7
+ data.tar.gz: ed5c196a136597a22540715db57bf7bb63128904a86db0fb0c97646ffc3bb885f188aab933829c4659dceaadee1ddee8549e4c545cf0e27e16a42aa3007f27f4
@@ -26,11 +26,11 @@ land_ndcs_with_5_digits = [
26
26
  ]
27
27
 
28
28
  mobile_ndcs_with_3_digits = [
29
- ('660'..'669').to_a, # Areeba
30
- ('620'..'629').to_a, # Orange
31
- ('650'..'659').to_a, # Cellcom
32
- ('630'..'639').to_a, # Intercel
33
- ('600'..'609').to_a # Sotelgui
29
+ *('660'..'669'), # Areeba
30
+ *('620'..'629'), # Orange
31
+ *('650'..'659'), # Cellcom
32
+ *('630'..'639'), # Intercel
33
+ *('600'..'609') # Sotelgui
34
34
  ]
35
35
 
36
36
  Phony.define do
@@ -38,7 +38,6 @@ Phony.define do
38
38
  one_of(land_ndcs_with_5_digits) >> split(2, 2) | # 2-2-2-2
39
39
  one_of(land_ndcs_with_4_digits) >> split(2, 2) | # 2-2-2-2
40
40
  one_of(mobile_ndcs_with_3_digits) >> split(2, 2, 2) | # 3-2-2-2
41
- match(/^(7\d{2})\d{6}/) >> split(2, 2) | # voip numbers
42
- fixed(3) >> split(2, 2, 2) | # catch all formatter
43
- fixed(4) >> split(2, 2) # catch all formatter
41
+ match(/^(7\d{2})\d{6}/) >> split(2, 2, 2) | # voip numbers
42
+ fixed(3) >> split(2, 2, 2)
44
43
  end
@@ -55,10 +55,11 @@ service3 = [
55
55
 
56
56
  Phony.define do
57
57
  country '31',
58
- trunk('0', :normalize => true) |
59
- one_of(service) >> split(4,3) |
60
- one_of(service3) >> split(4,3) |
61
- one_of('6') >> split(2,2,2,2) | # mobile
62
- one_of(ndcs) >> split(3,4) | # landline (geographic region)
63
- fixed(3) >> split(3,3) # 3 digit ndc
58
+ trunk('0', :normalize => true) |
59
+ one_of(service) >> split(4,3) |
60
+ match(/\A(800|900)\d{4}\z/) >> split(4) |
61
+ one_of(service3) >> split(4,3) |
62
+ one_of('6') >> split(2,2,2,2) | # mobile
63
+ one_of(ndcs) >> split(3,4) | # landline (geographic region)
64
+ fixed(3) >> split(3,3) # 3 digit ndc
64
65
  end
@@ -16,10 +16,10 @@
16
16
  mobile_ndc = [
17
17
  # Mobile [4+6].
18
18
  #
19
- ('7100'..'7599').to_a,
19
+ *('7100'..'7599'),
20
20
  '7624', # Isle of Man
21
- ('7700'..'7999').to_a,
22
- ].flatten
21
+ *('7700'..'7999')
22
+ ]
23
23
 
24
24
  two_digit_ndc = [
25
25
  # Geographic [2+8] - includes (02x) 0 and (02x) 1 as NDO.
@@ -195,7 +195,7 @@ variable_length_number = [
195
195
  '1946', # Whitehaven (Mixed area)
196
196
  '1949', # Whatton
197
197
  '1963', # Wincanton
198
- '1995', # Garstang
198
+ '1995', # Garstang
199
199
  ]
200
200
 
201
201
  four_digit_ndc = [
@@ -800,5 +800,5 @@ Phony.define do
800
800
  one_of(five_digit_ndc) >> split(5) | # 5-5
801
801
  one_of(variable_length_number) >> split(5..6) | # 4-6 and 4-5, in 40 areas.
802
802
  one_of(four_digit_ndc) >> split(6) | # 4-6
803
- fixed(4) >> split(6) # Catchall for undefined numbers.
803
+ match(/^([135789]\d{3})/) >> split(6) # Catchall for plausible unallocated numbers.
804
804
  end
@@ -13,6 +13,8 @@ describe 'plausibility' do
13
13
  #
14
14
  def self.it_is_correct_for(country_name, options={})
15
15
  samples = [*options[:samples]]
16
+ invalid_samples = [*options[:invalid_samples]]
17
+
16
18
  raise ArgumentError, ':samples option should be specified' if samples.empty?
17
19
 
18
20
  it "is correct for #{country_name}" do
@@ -31,6 +33,15 @@ describe 'plausibility' do
31
33
  "It should not validate #{value}, but does."
32
34
  end
33
35
  end
36
+
37
+ invalid_samples.each do |sample|
38
+ invalid = [*sample]
39
+
40
+ invalid.each do |value|
41
+ Phony.plausible?(value).should be_false,
42
+ "It should not validate #{value}, but does."
43
+ end
44
+ end
34
45
  end
35
46
  end
36
47
 
@@ -304,6 +315,7 @@ describe 'plausibility' do
304
315
  Phony.plausible?('+31 880 450 24').should be_false
305
316
  Phony.plausible?('+31 900 123 4567').should be_true
306
317
  Phony.plausible?('+31 900 001 00').should be_false
318
+ Phony.plausible?('+31 800 6080').should be_true
307
319
  end
308
320
 
309
321
  it 'is correct for Egypt' do
@@ -531,13 +543,13 @@ describe 'plausibility' do
531
543
  it_is_correct_for 'Guadeloupe (French Department of)', :samples => '+590 123 456 789'
532
544
  it_is_correct_for 'Guatemala (Republic of)', :samples => ['+502 19 123 456 789',
533
545
  '+502 2 123 4567']
534
- context 'test' do
535
- it_is_correct_for 'Guinea', :samples => [
536
- '+224 664 12 34 56',
537
- '+224 30 31 12 34',
538
- '+224 3041 12 34'
539
- ]
540
- end
546
+ it_is_correct_for 'Guinea', :samples => [
547
+ '+224 664 12 34 56',
548
+ '+224 30 31 12 34',
549
+ '+224 3041 12 34',
550
+ '+224 700 00 00 00'
551
+ ]
552
+
541
553
  it_is_correct_for 'Guinea-Bissau', :samples => '+245 728 6998'
542
554
  it_is_correct_for 'Guyana', :samples => '+592 263 1234'
543
555
  it_is_correct_for 'Honduras (Republic of)', :samples => '+504 12 961 637'
@@ -822,7 +834,7 @@ describe 'plausibility' do
822
834
  '+971 500 641 234',
823
835
  '+971 200 641 234']
824
836
 
825
- it_is_correct_for 'United Kingdom', :samples => ['+44 1827 50111']
837
+ it_is_correct_for 'United Kingdom', :samples => ['+44 1827 50111'], :invalid_samples => ['+44 0000 123456']
826
838
 
827
839
  it_is_correct_for 'Uruguay (Eastern Republic of)', :samples => ['+598 800 123 45',
828
840
  '+598 2 012 3456',
@@ -841,7 +853,5 @@ describe 'plausibility' do
841
853
  '+263 86 1235 4567']
842
854
 
843
855
  end
844
-
845
856
  end
846
-
847
857
  end
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: 2.8.2
4
+ version: 2.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke