phony 2.0.0.beta9 → 2.0.0.beta10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDUwMWM5M2UxOGE1OGRhZGJjMDI1MzA3NGIwZTZlMzhkNDVhYTQyYQ==
4
+ M2RiYWE2YjE2ZmM4NWFjZmQyMTI1NmFiYzQxNjNiOWQzYTM3M2VjZA==
5
5
  data.tar.gz: !binary |-
6
- OGUyM2RhOWFmMzgyNzZlNmZiMTU0ZjY5MzU0YjVjZGI0ZDNhNWY1YQ==
6
+ NDg1OGQwNGMxYzZlZDYyYjFkZjM0OGQ4YTVjZTYzODJjZjAwZjdhNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2M4MWQxZmUyYzlhOTAwYjAwMGRjMzJhMTA1MTllNTRjMDcwM2QyZDQ0MWQy
10
- MjE3ZGFiZjcyMGMyY2I2YWFlNTFmODE2ZDJlNzJiMTNhYmRiZjgzOWJjNDE3
11
- MmI1MzI3YmM5YTJjNzU0YWQ5NDlmYTdhODEzYWY4NTU1MTkyYTY=
9
+ NTgxN2I0ZGVmZTZlZjU2M2Q5OGI4ZjcxMTAyMzQxMTA5N2ZkNGRiNWM5NDkx
10
+ M2FlNTNmNDA0Y2JkYjc1Yjc0M2QxNTk0Y2Q4MjBmNjFlMDUxMDBiN2JjMzg1
11
+ YTJhY2UxOGRiNjU4YzA5ZTNkMDY4YWI3NDg3ZGQ1ZmUwYTk1YmY=
12
12
  data.tar.gz: !binary |-
13
- MmM2ZTQ3MWQ2NzA5ODA2ZWYwOTlhMDk2NTgyYWNlZjhhNTFlY2MyYTQ1OTM2
14
- NzRmNjVkNTI5M2M3OTg1ZmZlMmQwMWEyZjA4OTI1NWM5YjY5ZWZiYjk0ZWM2
15
- NTEyM2NlN2ZlNmY0OTZjZjU4MmFmMWM3MTQ4NjZmYzU4YmVkM2E=
13
+ ZmVjNmYzNTY3ZDkyYzI0MDQwYTc3N2FhZjI5OWMzNjlhMDE2NTNjNTYyNzcw
14
+ MTJiNmVlN2EzYjU5ZDg2NTYwNmIzY2U1NDFhZDdiMzRmMzkxOTBjYWYyNDU5
15
+ MmEyOTBhNWM4ZWFlMThhNmVjNjI4MmU2OGY3MzI0OWUwNGNmMDU=
@@ -74,12 +74,12 @@ Phony.define do
74
74
  # France.
75
75
  #
76
76
  country '33', fixed(1) >> split(2,2,2,2) # :service? => /^8.*$/, :mobile? => /^[67].*$/
77
-
77
+
78
78
  # Spain.
79
79
  #
80
80
  country '34',
81
81
  fixed(2) >> split(3,4)
82
-
82
+
83
83
  # Hungary.
84
84
  #
85
85
  country '36',
@@ -231,7 +231,7 @@ Phony.define do
231
231
  one_of('4', '8') >> split(7) |
232
232
  match(/^(2[025679]|3[0136789]|5[23456789]|6[01234678]|7[02345679]|9[0-8])\d/) >> split(6) |
233
233
  fixed(3) >> split(5)
234
-
234
+
235
235
  # country '86' # China, see special file.
236
236
 
237
237
  # Turkey.
@@ -351,7 +351,7 @@ Phony.define do
351
351
 
352
352
  # Kenya
353
353
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Kenya
354
- country '254',
354
+ country '254',
355
355
  match(/^(7\d\d)/) >> split(6) | # mobile
356
356
  fixed(2) >> split(7) # landline
357
357
 
@@ -853,7 +853,7 @@ Phony.define do
853
853
  # Cambodia (Kingdom of)
854
854
  # http://en.wikipedia.org/wiki/Telephone_numbers_in_Cambodia
855
855
  country '855',
856
- fixed(2) >> split(3,4)
856
+ fixed(2) >> matched_split(/^\d{6}$/ => [3,3], /^\d{7}$/ => [3,4])
857
857
 
858
858
  # Lao People's Democratic Republic http://www.wtng.info/wtng-856-la.html, https://www.numberingplans.com
859
859
  country '856',
@@ -34,15 +34,15 @@ describe 'validations' do
34
34
  end
35
35
  end
36
36
  end
37
-
37
+
38
38
  it 'does not change the given number' do
39
39
  number = "123-123-1234"
40
-
40
+
41
41
  Phony.plausible? number
42
-
42
+
43
43
  number.should == '123-123-1234'
44
44
  end
45
-
45
+
46
46
  it 'handles small numbers' do
47
47
  Phony.plausible?('353').should be_false
48
48
  end
@@ -80,7 +80,7 @@ describe 'validations' do
80
80
  it 'is correct' do
81
81
  Phony.plausible?('hello').should be_false
82
82
  end
83
-
83
+
84
84
  it "is correct" do
85
85
  Phony.plausible?('+41 44 111 22 33').should be_true
86
86
  end
@@ -105,16 +105,16 @@ describe 'validations' do
105
105
  it "works with regexps" do
106
106
  Phony.plausible?('+41 44 111 22 33', cc: /4(0|1)/, ndc: /4(4|5)/).should be_true
107
107
  end
108
-
108
+
109
109
  context 'Length validation' do
110
110
  it 'works for Swiss cases' do
111
111
  Phony.plausible?('+41 44 111 22 3').should be_false # Not long enough is not ok.
112
112
  # Phony.plausible?('+41 44 111 22 33 4').should be_true # TODO Too long is ok – we don't know about extensions.
113
113
  end
114
114
  end
115
-
115
+
116
116
  context 'specific countries' do
117
-
117
+
118
118
  # TODO: more needs to be done here
119
119
  #
120
120
  it "is correct for Swiss numbers" do
@@ -178,7 +178,7 @@ describe 'validations' do
178
178
  # Sorry, still need E164 conform numbers.
179
179
  #
180
180
  Phony.plausible?('4346667777', cc: '1').should be_false
181
-
181
+
182
182
  # Automatic country checking.
183
183
  #
184
184
  Phony.plausible?('1-4346667777').should be_true
@@ -187,13 +187,13 @@ describe 'validations' do
187
187
  Phony.plausible?('1-911-123-1234').should be_false
188
188
  Phony.plausible?('143466677777').should be_false # too long
189
189
  Phony.plausible?('143466677').should be_false # too short
190
-
190
+
191
191
  # With string constraints.
192
192
  #
193
193
  Phony.plausible?('14346667777', cc: '1').should be_true
194
194
  Phony.plausible?('14346667777', ndc: '434').should be_true
195
195
  Phony.plausible?('14346667777', cc: '1', ndc: '434').should be_true
196
-
196
+
197
197
  # With regexp constraints.
198
198
  #
199
199
  Phony.plausible?('14346667777', cc: /[123]/).should be_true
@@ -323,6 +323,10 @@ describe 'validations' do
323
323
  it_is_correct_for 'Brunei Darussalam', :samples => '+673 5 523 876'
324
324
  it_is_correct_for 'Burkina Faso', :samples => '+226 1476 2312'
325
325
  it_is_correct_for 'Burundi', :samples => '+257 1234 5678'
326
+ it_is_correct_for "Cambodia", :samples => [["+855 12 236 142",
327
+ "+855 97 710 0872"],
328
+ ["+855 234 601 183",
329
+ "855 33 123 456"]]
326
330
  it_is_correct_for 'Cameroon', :samples => '+237 7372 8186'
327
331
  it_is_correct_for 'Cape Verde', :samples => '+238 642 3843'
328
332
  it_is_correct_for 'Central African Republic', :samples => '+236 1234 5678'
@@ -649,7 +653,7 @@ describe 'validations' do
649
653
  '+263 86 1235 4567']
650
654
 
651
655
  end
652
-
656
+
653
657
  end
654
-
655
- end
658
+
659
+ 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.0.0.beta9
4
+ version: 2.0.0.beta10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke