phony 1.8.2 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -13,7 +13,8 @@ This gem can normalize, format and split E164 numbers.
13
13
 
14
14
  The (admittedly crazy) *goal* of this Gem is to be able to format/split all phone numbers in the world.
15
15
 
16
- Currently handles Abhas, Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Croatian, Cuban, Czech, Danish, Dutch, Egyptian, French, German, Ghanan, Greek, Hungarian, Italian, Irish, Kazakh, Lithuanian, Luxembourgian, Malaysian, Mexican, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, and Vietnamese numbers.
16
+ Currently handles Abhas, Afghan, Algerian, Austrian, Australian, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, Estonian, French, German, Ghanan, Gibraltar, Greek, Hungarian, Italian, Irish, Kazakh, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, and Vietnamese numbers.
17
+
17
18
  And to some extent, all others. Just try if it works for you.
18
19
 
19
20
  If it doesn't, please "enter an issue":http://github.com/floere/phony/issues.
@@ -45,7 +46,7 @@ Note that you can add constraints to the plausibility check like the country cod
45
46
  @Phony.plausible?('+41 44 111 22 33', cc: '1').should be_false@
46
47
 
47
48
  @Phony.plausible?('+41 44 111 22 33', ndc: '43').should be_false@
48
-
49
+
49
50
  @Phony.plausible?('+41 44 111 22 33', cc: '41', ndc: '44').should be_true@
50
51
 
51
52
  @Phony.plausible?('+41 44 111 22 33', cc: /4(0|2)/, ndc: /4(4|5)/).should be_false@
@@ -54,7 +55,7 @@ Note that you can add constraints to the plausibility check like the country cod
54
55
 
55
56
  h3(#normalizing). Normalizing
56
57
 
57
- This will often raise an error if you try normalizing a non E164-izable number (a number that does not contain enough information to be normalized into an E164 conform number). Use @Phony.plausible?@ for checking if it can be normalized first.
58
+ This will often raise an error if you try normalizing a non E164-izable number (a number that does not contain enough information to be normalized into an E164 conform number). Use @Phony.plausible?@ for checking if it can be normalized first.
58
59
 
59
60
  @Phony.normalize('41443643533').should == '41443643533'@
60
61
 
@@ -160,4 +161,4 @@ h3(#splitting). Splitting
160
161
 
161
162
  Note: There is also a ! version of each of these methods which
162
163
  will destroy the original string and return a new (or old) one.
163
- Just work only with the returned value, and you will be fine.
164
+ Just work only with the returned value, and you will be fine.
@@ -554,7 +554,12 @@ Phony.define do
554
554
  country '852', todo # Hong Kong, China
555
555
  country '853', todo # Macao, China
556
556
  country '854', todo # Spare code
557
- country '855', todo # Cambodia (Kingdom of)
557
+
558
+ # Cambodia (Kingdom of)
559
+ # http://en.wikipedia.org/wiki/Telephone_numbers_in_Cambodia
560
+ country '855',
561
+ fixed(2) >> split(3,4)
562
+
558
563
  country '856', todo # Lao People's Democratic Republic
559
564
  country '857', todo # Spare code
560
565
  country '858', todo # Spare code
@@ -50,6 +50,12 @@ describe 'country descriptions' do
50
50
  describe 'Brazil' do
51
51
  it_splits '551112341234', ['55', '11', '1234', '1234']
52
52
  end
53
+ describe 'Cambodia' do
54
+ it_splits '85512236142', ["855", "12", "236", "142"] # mobile (Mobitel)
55
+ it_splits '855977100872', ["855", "97", "710", "0872"] # mobile (Metfone)
56
+ it_splits '855234601183', ["855", "23", "460", "1183"] # Long fixed line (Phnom Penh)
57
+ it_splits '85533123456', ["855", "33", "123", "456"] # Regular fixed line (Kampot)
58
+ end
53
59
  describe 'Chile' do
54
60
  it_splits '5621234567', ['56', '2', '1234567'] # Santiago
55
61
  it_splits '5675123456', ['56', '75', '123456'] # Curico
@@ -200,8 +206,8 @@ describe 'country descriptions' do
200
206
  end
201
207
  describe 'The Netherlands' do
202
208
  it_splits '31612345678', ['31', '6', '12345678'] # mobile
203
- it_splits '31201234567', ['31', '20', '1234567']
204
- it_splits '31222123456', ['31', '222', '123456']
209
+ it_splits '31201234567', ['31', '20', '1234567']
210
+ it_splits '31222123456', ['31', '222', '123456']
205
211
  end
206
212
  describe 'Norway' do
207
213
  it_splits '4721234567', ['47',false,'21','23','45','67']
@@ -271,8 +277,8 @@ describe 'country descriptions' do
271
277
  end
272
278
  describe 'Sweden' do
273
279
  it { Phony.split('46812345678').should == ['46', '8', '12345678'] } # Stockholm
274
- it { Phony.split('46111234567').should == ['46', '11', '1234567'] }
275
- it { Phony.split('46125123456').should == ['46', '125', '123456'] }
280
+ it { Phony.split('46111234567').should == ['46', '11', '1234567'] }
281
+ it { Phony.split('46125123456').should == ['46', '125', '123456'] }
276
282
  end
277
283
  describe 'Switzerland' do
278
284
  it { Phony.split('41443643532').should == ['41', '44', '364', '35', '32'] } # Zurich (usually)
@@ -306,7 +312,7 @@ describe 'country descriptions' do
306
312
  it { Phony.split('441697744888').should == ['44', '16977', '44888'] } # Brampton
307
313
  it { Phony.split('441946555777').should == ['44', '1946', '555777'] } # Whitehaven
308
314
  it { Phony.split('44194662888').should == ['44', '1946', '62888'] } # Whitehaven
309
- it { Phony.split('441946722444').should == ['44', '19467', '22444'] } # Gosforth
315
+ it { Phony.split('441946722444').should == ['44', '19467', '22444'] } # Gosforth
310
316
  it { Phony.split('443005878323').should == ['44', '300', '587', '8323'] } # Non-geographic
311
317
  it { Phony.split('443457777334').should == ['44', '345', '777', '7334'] } # Non-geographic
312
318
  it { Phony.split('44500557788').should == ['44', '500', '557788'] } # Freefone 500 + 6
@@ -335,4 +341,4 @@ describe 'country descriptions' do
335
341
  end
336
342
  end
337
343
 
338
- end
344
+ 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: 1.8.2
4
+ version: 1.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Fast international phone number (E164 standard) normalizing, splitting
15
15
  and formatting. Lots of formatting options: International (+.., 00..), national