phony 2.19.11 → 2.20.13
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 +4 -4
 - data/README.textile +5 -1
 - data/lib/phony/countries/brazil.rb +2 -2
 - data/lib/phony/countries/italy.rb +34 -17
 - data/lib/phony/countries/japan.rb +51 -2
 - data/lib/phony/countries/vietnam.rb +3 -0
 - data/lib/phony/countries.rb +41 -21
 - data/lib/phony/country_codes.rb +13 -0
 - data/spec/functional/config_spec.rb +5 -5
 - data/spec/functional/plausibility_spec.rb +49 -7
 - data/spec/lib/phony/countries_spec.rb +20 -9
 - data/spec/lib/phony/country_codes_spec.rb +78 -55
 - data/spec/lib/phony/country_spec.rb +13 -13
 - data/spec/lib/phony/dsl_spec.rb +6 -2
 - data/spec/lib/phony/local_splitters/regex_spec.rb +12 -15
 - data/spec/lib/phony/national_code_spec.rb +15 -45
 - data/spec/lib/phony/national_splitters/fixed_spec.rb +12 -16
 - data/spec/lib/phony/national_splitters/none_spec.rb +3 -3
 - data/spec/lib/phony/national_splitters/variable_spec.rb +9 -13
 - data/spec/lib/phony/vanity_spec.rb +4 -4
 - metadata +15 -15
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a8a3040e536d7eba5507cc4ca91be6ea1acbf1706a31ad54d3fadc9baadbffd2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7646e570c51156f9a931af73c75ea5548d27e802663647517a31bf0f64278047
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5339eca176062f10c68f27e7174fb91ddb8df1a3133f452f02b5262bdca14a1bbfe7074375a231e0dabceaee25bf83210ce755c561982c97d1f27dae11b786f3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4b40657f420fd789a95c0ed9903cb911d9829a1822cdcc283498380aa816812637dddadf429a040c1ae1d65c2c69823682698d27437819c4451eb884373423b0
         
     | 
    
        data/README.textile
    CHANGED
    
    | 
         @@ -104,7 +104,11 @@ For example, when just loading the NANP CC, the retained memory usage is ~63kB. 
     | 
|
| 
       104 
104 
     | 
    
         | 
| 
       105 
105 
     | 
    
         
             
            h2. List of Handled Countries
         
     | 
| 
       106 
106 
     | 
    
         | 
| 
       107 
     | 
    
         
            -
            Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
         
     | 
| 
      
 107 
     | 
    
         
            +
            Mildly unmaintained list: Abhas, Afghan, Algerian, Argentina, Austrian, Australian, Azerbaijani, Belgian, Brazilian, Cambodian, Chilean, Chinese, Croatian, Cuban, Cypriot, Czech, Danish, Dutch, Egyptian, El Salvadorian, Estonian, French, German, Ghanan, Gibraltar, Greek, Haiti, Hong Kong, Hungarian, Indian, Iran, Irish, Israel, Italian, Japanese, Kazakh, Liberian, Lithuanian, Luxembourgian, Malaysian, Malta, Mauritian, Mexican, Monaco, Morocco, New Zealand, Nigerian, Norwegian, Peruvian, Polish, Romanian, Russian, Rwandan, Seychelles, Singapore, Slovakian, South African, South Korean, South Osetian, Spanish, Sri Lankan, Sudan, Swedish, Swiss, Thailand, Tunisian, Turkish, Liechtenstein, UK, US, Venezuelan, Vietnamese, and Zambian numbers.
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            h2. Proud Sponsors
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            * Renuo AG (July 22 –): "Github":https://github.com/renuo, "Homepage":https://www.renuo.ch
         
     | 
| 
       108 
112 
     | 
    
         | 
| 
       109 
113 
     | 
    
         
             
            h2. License
         
     | 
| 
       110 
114 
     | 
    
         | 
| 
         @@ -4,7 +4,7 @@ 
     | 
|
| 
       4 
4 
     | 
    
         
             
            #
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # NDC Reference
         
     | 
| 
       7 
     | 
    
         
            -
            #  
     | 
| 
      
 7 
     | 
    
         
            +
            # https://www.gov.br/anatel/pt-br/regulado/numeracao/plano-de-numeracao-brasileiro
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
             # 11 #Sao Paulo
         
     | 
| 
       10 
10 
     | 
    
         
             
             # 12 #Sao Paulo
         
     | 
| 
         @@ -99,7 +99,7 @@ special_numbers_4 = %w{ 3003 4003 4004 4020 } 
     | 
|
| 
       99 
99 
     | 
    
         
             
            Phony.define do
         
     | 
| 
       100 
100 
     | 
    
         
             
              country '55',
         
     | 
| 
       101 
101 
     | 
    
         
             
                match(/^#{ndcs}9\d{8}$/)     >> split(5,4) |
         
     | 
| 
       102 
     | 
    
         
            -
                match(/^#{ndcs}\d{ 
     | 
| 
      
 102 
     | 
    
         
            +
                match(/^#{ndcs}[2-5]\d{7}$/) >> split(4,4) |
         
     | 
| 
       103 
103 
     | 
    
         
             
                one_of(special_numbers_3_4)  >> split(3,4) |
         
     | 
| 
       104 
104 
     | 
    
         
             
                one_of(special_numbers_4)    >> split(4) |
         
     | 
| 
       105 
105 
     | 
    
         
             
                one_of(service)              >> split(3) |
         
     | 
| 
         @@ -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 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
            ndcs_1digit = [
         
     | 
| 
       9 
9 
     | 
    
         
             
              '02', # Milan
         
     | 
| 
       10 
10 
     | 
    
         
             
              '06', # Rome (including State of Vatican City) and Aprilia
         
     | 
| 
       11 
11 
     | 
    
         
             
            ]
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
            ndcs_3digit = [
         
     | 
| 
       46 
46 
     | 
    
         
             
              '0121', # Pinerolo
         
     | 
| 
       47 
47 
     | 
    
         
             
              '0122', # Sestrieres, Bardonecchia and other Susa Valley mountain resorts
         
     | 
| 
       48 
48 
     | 
    
         
             
              '0123', # Lanzo Torinese
         
     | 
| 
         @@ -256,7 +256,8 @@ ndcs_4digit = [ 
     | 
|
| 
       256 
256 
     | 
    
         
             
            # but this was not frozen so easily.
         
     | 
| 
       257 
257 
     | 
    
         
             
            mobile = %w(300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399)
         
     | 
| 
       258 
258 
     | 
    
         | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
      
 259 
     | 
    
         
            +
            # Not exhaustive.
         
     | 
| 
      
 260 
     | 
    
         
            +
            service = [
         
     | 
| 
       260 
261 
     | 
    
         
             
             '112',
         
     | 
| 
       261 
262 
     | 
    
         
             
             '113',
         
     | 
| 
       262 
263 
     | 
    
         
             
             '115',
         
     | 
| 
         @@ -268,22 +269,38 @@ service = [ # Not exhaustive. 
     | 
|
| 
       268 
269 
     | 
    
         
             
             '1530'
         
     | 
| 
       269 
270 
     | 
    
         
             
            ]
         
     | 
| 
       270 
271 
     | 
    
         | 
| 
      
 272 
     | 
    
         
            +
            # Not exhaustive. Unused below - just for info purposes.
         
     | 
| 
      
 273 
     | 
    
         
            +
            free_of_charge_services = [
         
     | 
| 
      
 274 
     | 
    
         
            +
              '800',
         
     | 
| 
      
 275 
     | 
    
         
            +
              '803'
         
     | 
| 
      
 276 
     | 
    
         
            +
            ]
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
       271 
278 
     | 
    
         
             
            Phony.define do
         
     | 
| 
      
 279 
     | 
    
         
            +
              # Note: The 0 does not count towards NDC number length.
         
     | 
| 
       272 
280 
     | 
    
         
             
              country '39', trunk('', normalize: false) |
         
     | 
| 
       273 
281 
     | 
    
         
             
                            one_of(*service)     >> split(3,3) |
         
     | 
| 
       274 
282 
     | 
    
         
             
                            one_of(*mobile)      >> split(3,4,-1..1) |
         
     | 
| 
       275 
     | 
    
         
            -
                             
     | 
| 
       276 
     | 
    
         
            -
                             
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
                               
     | 
| 
       279 
     | 
    
         
            -
                               
     | 
| 
       280 
     | 
    
         
            -
                               
     | 
| 
      
 283 
     | 
    
         
            +
                            match(/^(800)\d{6}$/) >> split(6) | # 3-6, Special handling for 800 numbers.
         
     | 
| 
      
 284 
     | 
    
         
            +
                            match(/^(803)\d{3}$/) >> split(3) | # 3-3, Special handling for 803 numbers.
         
     | 
| 
      
 285 
     | 
    
         
            +
                            one_of(*ndcs_1digit) >> matched_split(
         
     | 
| 
      
 286 
     | 
    
         
            +
                              /\A\d{5}\z/ => [5],
         
     | 
| 
      
 287 
     | 
    
         
            +
                              /\A\d{6}\z/ => [4,2],
         
     | 
| 
      
 288 
     | 
    
         
            +
                              /\A\d{7}\z/ => [4,3],
         
     | 
| 
      
 289 
     | 
    
         
            +
                              /\A\d{8}\z/ => [4,4],
         
     | 
| 
      
 290 
     | 
    
         
            +
                              /\A\d{9}\z/ => [4,5]
         
     | 
| 
       281 
291 
     | 
    
         
             
                            ) |
         
     | 
| 
       282 
     | 
    
         
            -
                            one_of(* 
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
             
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
       286 
     | 
    
         
            -
             
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
      
 292 
     | 
    
         
            +
                            one_of(*ndcs_2digit) >> matched_split(
         
     | 
| 
      
 293 
     | 
    
         
            +
                              /\A\d{4}\z/ => [4],
         
     | 
| 
      
 294 
     | 
    
         
            +
                              /\A\d{5}\z/ => [5],
         
     | 
| 
      
 295 
     | 
    
         
            +
                              /\A\d{6}\z/ => [6],
         
     | 
| 
      
 296 
     | 
    
         
            +
                              /\A\d{7}\z/ => [7],
         
     | 
| 
      
 297 
     | 
    
         
            +
                              /\A\d{8}\z/ => [8]
         
     | 
| 
      
 298 
     | 
    
         
            +
                            ) |
         
     | 
| 
      
 299 
     | 
    
         
            +
                            one_of(*ndcs_3digit) >> matched_split(
         
     | 
| 
      
 300 
     | 
    
         
            +
                              /\A\d{4}\z/ => [4],
         
     | 
| 
      
 301 
     | 
    
         
            +
                              /\A1\d{5}\z/ => [6],
         
     | 
| 
      
 302 
     | 
    
         
            +
                              /\A1\d{6}\z/ => [7],
         
     | 
| 
      
 303 
     | 
    
         
            +
                              /\A[^1]\d{4}\z/ => [5],
         
     | 
| 
      
 304 
     | 
    
         
            +
                              /\A[^1]\d{5}\z/ => [3,3]
         
     | 
| 
       288 
305 
     | 
    
         
             
                            )
         
     | 
| 
       289 
306 
     | 
    
         
             
            end
         
     | 
| 
         @@ -403,7 +403,56 @@ Phony.define do 
     | 
|
| 
       403 
403 
     | 
    
         
             
              country '81',
         
     | 
| 
       404 
404 
     | 
    
         
             
                trunk('0', normalize: true, format: true, split: true) |
         
     | 
| 
       405 
405 
     | 
    
         
             
                one_of(%w(20 50 60 70 90))             >> split(4,4) | # mobile, VoIP telephony
         
     | 
| 
      
 406 
     | 
    
         
            +
                match(/\A(597)9[0178]\d+\z/)           >> split(2,4) |
         
     | 
| 
       406 
407 
     | 
    
         
             
                one_of(ndcs_with_5_subscriber_numbers) >> split(1,4) |
         
     | 
| 
      
 408 
     | 
    
         
            +
                match(/\A(4)70[019]\d+\z/)             >> split(4,4) |
         
     | 
| 
      
 409 
     | 
    
         
            +
                match(/\A(4)71\d+\z/)                  >> split(4,4) |
         
     | 
| 
      
 410 
     | 
    
         
            +
                match(/\A(4)20\d+\z/)                  >> split(4,4) |
         
     | 
| 
      
 411 
     | 
    
         
            +
                match(/\A(4)29[02-69]\d+\z/)           >> split(4,4) |
         
     | 
| 
      
 412 
     | 
    
         
            +
                match(/\A(15)4[018]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 413 
     | 
    
         
            +
                match(/\A(22)3[014-9]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 414 
     | 
    
         
            +
                match(/\A(25)[04][01]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 415 
     | 
    
         
            +
                match(/\A(25)5[0-69]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 416 
     | 
    
         
            +
                match(/\A(25)[68][01]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 417 
     | 
    
         
            +
                match(/\A(25)7[015-9]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 418 
     | 
    
         
            +
                match(/\A(25)917\d+\z/)                >> split(3,4) |
         
     | 
| 
      
 419 
     | 
    
         
            +
                match(/\A(25)999\d+\z/)                >> split(3,4) |
         
     | 
| 
      
 420 
     | 
    
         
            +
                match(/\A(26)4[016-9]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 421 
     | 
    
         
            +
                match(/\A(28)3[0134]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 422 
     | 
    
         
            +
                match(/\A(28)9[0-5]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 423 
     | 
    
         
            +
                match(/\A(29)17\d+\z/)                 >> split(3,4) |
         
     | 
| 
      
 424 
     | 
    
         
            +
                match(/\A(29)3[015-9]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 425 
     | 
    
         
            +
                match(/\A(42)21\d+\z/)                 >> split(3,4) |
         
     | 
| 
      
 426 
     | 
    
         
            +
                match(/\A(42)8[01456]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 427 
     | 
    
         
            +
                match(/\A(47)5[019]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 428 
     | 
    
         
            +
                match(/\A(47)9[019]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 429 
     | 
    
         
            +
                match(/\A(59)8[019]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 430 
     | 
    
         
            +
                match(/\A(59)9[01]\d+\z/)              >> split(3,4) |
         
     | 
| 
      
 431 
     | 
    
         
            +
                match(/\A(79)4[0-59]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 432 
     | 
    
         
            +
                match(/\A(79)5[01569]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 433 
     | 
    
         
            +
                match(/\A(79)6[0167]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 434 
     | 
    
         
            +
                match(/\A(82)4[0-39]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 435 
     | 
    
         
            +
                match(/\A(82)9[019]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 436 
     | 
    
         
            +
                match(/\A(82)92[1-9]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 437 
     | 
    
         
            +
                match(/\A(82)94[1-3]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 438 
     | 
    
         
            +
                match(/\A(82)96[0-47-9]\d+\z/)         >> split(3,4) |
         
     | 
| 
      
 439 
     | 
    
         
            +
                match(/\A(82)965[01346-9]\d+\z/)       >> split(3,4) |
         
     | 
| 
      
 440 
     | 
    
         
            +
                match(/\A(82)966[1-9]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 441 
     | 
    
         
            +
                match(/\A(83)76[6-8]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 442 
     | 
    
         
            +
                match(/\A(83)7[01789]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 443 
     | 
    
         
            +
                match(/\A(83)8[01]\d+\z/)              >> split(3,4) |
         
     | 
| 
      
 444 
     | 
    
         
            +
                match(/\A(86)36[23]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 445 
     | 
    
         
            +
                match(/\A(86)5[0-389]\d+\z/)           >> split(3,4) |
         
     | 
| 
      
 446 
     | 
    
         
            +
                match(/\A(86)55[23]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 447 
     | 
    
         
            +
                match(/\A(86)[01]\d+\z/)               >> split(3,4) |
         
     | 
| 
      
 448 
     | 
    
         
            +
                match(/\A(86)9[178]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 449 
     | 
    
         
            +
                match(/\A(86)72\d+\z/)                 >> split(3,4) |
         
     | 
| 
      
 450 
     | 
    
         
            +
                match(/\A(86)8[019]\d+\z/)             >> split(3,4) |
         
     | 
| 
      
 451 
     | 
    
         
            +
                match(/\A(86)9[0145]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 452 
     | 
    
         
            +
                match(/\A(86)99[014-9]\d+\z/)          >> split(3,4) |
         
     | 
| 
      
 453 
     | 
    
         
            +
                match(/\A(99)331\d+\z/)                >> split(3,4) |
         
     | 
| 
      
 454 
     | 
    
         
            +
                match(/\A(99)34[357]\d+\z/)            >> split(3,4) |
         
     | 
| 
      
 455 
     | 
    
         
            +
                match(/\A(99)4[0178]\d+\z/)            >> split(3,4) |
         
     | 
| 
       407 
456 
     | 
    
         
             
                one_of(ndcs_with_6_subscriber_numbers) >> split(2,4) |
         
     | 
| 
       408 
457 
     | 
    
         
             
                one_of(%w(120))                        >> split(3,3) | # freephone
         
     | 
| 
       409 
458 
     | 
    
         
             
                one_of(%w(800))                        >> split(3,4) | # freephone
         
     | 
| 
         @@ -414,6 +463,6 @@ Phony.define do 
     | 
|
| 
       414 
463 
     | 
    
         
             
                one_of(ndcs_with_8_subscriber_numbers) >> split(4,4) |
         
     | 
| 
       415 
464 
     | 
    
         
             
                # TODO: 91(NDC) N(S)N length: 5-13 - Non-geographic number (Direct subscriber telephone service (legacy))
         
     | 
| 
       416 
465 
     | 
    
         
             
                fixed(2) >> split(4,4),
         
     | 
| 
       417 
     | 
    
         
            -
                : 
     | 
| 
       418 
     | 
    
         
            -
                : 
     | 
| 
      
 466 
     | 
    
         
            +
                local_space: :-,
         
     | 
| 
      
 467 
     | 
    
         
            +
                space: :-
         
     | 
| 
       419 
468 
     | 
    
         
             
            end
         
     | 
| 
         @@ -127,6 +127,9 @@ Phony.define do 
     | 
|
| 
       127 
127 
     | 
    
         
             
                one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
         
     | 
| 
       128 
128 
     | 
    
         
             
                one_of(ndcs_with_8_subscriber_digits) >> split(4,4) |
         
     | 
| 
       129 
129 
     | 
    
         
             
                one_of(mobile_with_trunk)             >> split(5..8)|
         
     | 
| 
      
 130 
     | 
    
         
            +
                one_of('1900')                        >> matched_split(
         
     | 
| 
      
 131 
     | 
    
         
            +
                  /\A\d{4}\z/ => [4],
         
     | 
| 
      
 132 
     | 
    
         
            +
                  /\A\d{6}\z/ => [6]) | # Premium rate
         
     | 
| 
       130 
133 
     | 
    
         
             
                # Govt reserved
         
     | 
| 
       131 
134 
     | 
    
         
             
                fixed(80)                             >> split(5)   |
         
     | 
| 
       132 
135 
     | 
    
         
             
                fixed(69)                             >> split(1,5)
         
     | 
    
        data/lib/phony/countries.rb
    CHANGED
    
    | 
         @@ -232,6 +232,7 @@ Phony.define do 
     | 
|
| 
       232 
232 
     | 
    
         
             
              # http://www.itu.int/oth/T020200002C/en
         
     | 
| 
       233 
233 
     | 
    
         
             
              country '57',
         
     | 
| 
       234 
234 
     | 
    
         
             
                match(/\A(3\d\d)\d+\z/) >> split(3,4) | # mobile (300 310 311 312 313 315 316)
         
     | 
| 
      
 235 
     | 
    
         
            +
                match(/\A(60\d)\d+\z/) >> split(3,4) |
         
     | 
| 
       235 
236 
     | 
    
         
             
                fixed(1) >> split(3,4)
         
     | 
| 
       236 
237 
     | 
    
         | 
| 
       237 
238 
     | 
    
         
             
              # Venezuela (Bolivarian Republic of)
         
     | 
| 
         @@ -362,12 +363,29 @@ Phony.define do 
     | 
|
| 
       362 
363 
     | 
    
         
             
                trunk('', :normalize => false) |
         
     | 
| 
       363 
364 
     | 
    
         
             
                fixed(2) >> split(2,2,2,2)
         
     | 
| 
       364 
365 
     | 
    
         | 
| 
       365 
     | 
    
         
            -
               
     | 
| 
      
 366 
     | 
    
         
            +
              # Burkina Faso
         
     | 
| 
      
 367 
     | 
    
         
            +
              # http://www.wtng.info/wtng-226-bf.html
         
     | 
| 
      
 368 
     | 
    
         
            +
              # https://en.wikipedia.org/wiki/Telephone_numbers_in_Burkina_Faso
         
     | 
| 
      
 369 
     | 
    
         
            +
              #
         
     | 
| 
      
 370 
     | 
    
         
            +
              # There is no trunk code for this country and several of the mobile prefixes start with 0
         
     | 
| 
      
 371 
     | 
    
         
            +
              country '226',
         
     | 
| 
      
 372 
     | 
    
         
            +
                trunk('', normalize: false) |
         
     | 
| 
      
 373 
     | 
    
         
            +
                none >> split(2,2,2,2)
         
     | 
| 
      
 374 
     | 
    
         
            +
             
     | 
| 
       366 
375 
     | 
    
         
             
              country '227', none >> split(4,4) # Niger http://www.wtng.info/wtng-227-ne.html
         
     | 
| 
       367 
376 
     | 
    
         
             
              country '228', none >> split(4,4) # Togolese Republic http://www.wtng.info/wtng-228-tg.html
         
     | 
| 
       368 
377 
     | 
    
         
             
              country '229', none >> split(4,4) # Benin http://www.itu.int/oth/T0202000017/en
         
     | 
| 
       369 
378 
     | 
    
         | 
| 
       370 
     | 
    
         
            -
               
     | 
| 
      
 379 
     | 
    
         
            +
              # Mauritius
         
     | 
| 
      
 380 
     | 
    
         
            +
              # http://www.wtng.info/wtng-230-mu.html
         
     | 
| 
      
 381 
     | 
    
         
            +
              # https://en.wikipedia.org/wiki/Telephone_numbers_in_Mauritius
         
     | 
| 
      
 382 
     | 
    
         
            +
              #
         
     | 
| 
      
 383 
     | 
    
         
            +
              # There is no trunk code for this country.
         
     | 
| 
      
 384 
     | 
    
         
            +
              country '230',
         
     | 
| 
      
 385 
     | 
    
         
            +
                none >> matched_split(
         
     | 
| 
      
 386 
     | 
    
         
            +
                  /^5\d{7}$/ => [1,3,4], # Mobile
         
     | 
| 
      
 387 
     | 
    
         
            +
                  /^[246]\d{6}$/ => [3,4], # Landline
         
     | 
| 
      
 388 
     | 
    
         
            +
                )
         
     | 
| 
       371 
389 
     | 
    
         | 
| 
       372 
390 
     | 
    
         
             
              # Liberia
         
     | 
| 
       373 
391 
     | 
    
         
             
              # https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=LR
         
     | 
| 
         @@ -476,7 +494,7 @@ Phony.define do 
     | 
|
| 
       476 
494 
     | 
    
         
             
                one_of('802') >> split(3,3) | # national rate
         
     | 
| 
       477 
495 
     | 
    
         
             
                one_of(%w(251 252 271 272 281 282 293)) >> split(3,2) |
         
     | 
| 
       478 
496 
     | 
    
         
             
                one_of(%w(21 23 24 26)) >> split(3,3) |
         
     | 
| 
       479 
     | 
    
         
            -
                one_of(%w(82 84 86)) >> split(4,3) | # mobile
         
     | 
| 
      
 497 
     | 
    
         
            +
                one_of(%w(82 83 84 85 86 87)) >> split(4,3) | # mobile
         
     | 
| 
       480 
498 
     | 
    
         
             
                one_of('89') >> split(4,3) | # satellite GMPCS
         
     | 
| 
       481 
499 
     | 
    
         
             
                one_of('7') >> split(4,4) | # universal access
         
     | 
| 
       482 
500 
     | 
    
         
             
                one_of('9') >> split(4,4) | # premium rate
         
     | 
| 
         @@ -488,28 +506,22 @@ Phony.define do 
     | 
|
| 
       488 
506 
     | 
    
         
             
              # http://www.wtng.info/wtng-260-zm.html
         
     | 
| 
       489 
507 
     | 
    
         
             
              # https://github.com/googlei18n/libphonenumber/
         
     | 
| 
       490 
508 
     | 
    
         
             
              # https://en.wikipedia.org/wiki/Telephone_numbers_in_Zambia
         
     | 
| 
      
 509 
     | 
    
         
            +
             
     | 
| 
       491 
510 
     | 
    
         
             
              country '260',
         
     | 
| 
       492 
511 
     | 
    
         
             
                trunk('0') |
         
     | 
| 
       493 
     | 
    
         
            -
                match(/^(76|77|95|96|97)/) >> split(3, 4) | # Mobile
         
     | 
| 
      
 512 
     | 
    
         
            +
                match(/^(75|76|77|94|95|96|97)/) >> split(3, 4) | # Mobile
         
     | 
| 
       494 
513 
     | 
    
         
             
                match(/^(800)/)          >> split(3,3) | # Toll free
         
     | 
| 
       495 
514 
     | 
    
         
             
                match(/^(21[1-8])/)      >> split(6)     # Fixed
         
     | 
| 
       496 
515 
     | 
    
         | 
| 
       497 
     | 
    
         
            -
              # Madagascar 
     | 
| 
      
 516 
     | 
    
         
            +
              # Madagascar
         
     | 
| 
       498 
517 
     | 
    
         
             
              # https://en.wikipedia.org/wiki/Telephone_numbers_in_Madagascar
         
     | 
| 
       499 
518 
     | 
    
         
             
              # http://www.itu.int/oth/T020200007F/en
         
     | 
| 
       500 
519 
     | 
    
         
             
              country '261',
         
     | 
| 
       501 
     | 
    
         
            -
                      # none >> matched_split(
         
     | 
| 
       502 
     | 
    
         
            -
                      #     /\A20\d+\z/ => [2,2,3,2], # Telecom Malagasy (Telma)
         
     | 
| 
       503 
     | 
    
         
            -
                      #     /\A32\d+\z/ => [2,2,3,2], # mobile Orange Madagascar
         
     | 
| 
       504 
     | 
    
         
            -
                      #     /\A33\d+\z/ => [2,2,3,2], # mobile Airtel Madagascar
         
     | 
| 
       505 
     | 
    
         
            -
                      #     /\A34\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
         
     | 
| 
       506 
     | 
    
         
            -
                      #     /\A38\d+\z/ => [2,2,3,2], # mobile Telecom Malagasy (Telma)
         
     | 
| 
       507 
     | 
    
         
            -
                      #     /\A39\d+\z  => [2,2,3,2]  # mobile Blueline
         
     | 
| 
       508 
     | 
    
         
            -
                      # ),
         
     | 
| 
       509 
520 
     | 
    
         
             
                      match(/\A(20)\d+\z/) >> split(2,3,2) | # fix Telecom Malagasy (Telma)
         
     | 
| 
       510 
521 
     | 
    
         
             
                      match(/\A(32)\d+\z/) >> split(2,3,2) | # mobile Orange Madagascar
         
     | 
| 
       511 
522 
     | 
    
         
             
                      match(/\A(33)\d+\z/) >> split(2,3,2) | # mobile Airtel Madagascar
         
     | 
| 
       512 
523 
     | 
    
         
             
                      match(/\A(34)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
         
     | 
| 
      
 524 
     | 
    
         
            +
                      match(/\A(37)\d+\z/) >> split(2,3,2) | # mobile Orange Madagascar
         
     | 
| 
       513 
525 
     | 
    
         
             
                      match(/\A(38)\d+\z/) >> split(2,3,2) | # mobile Telecom Malagasy (Telma)
         
     | 
| 
       514 
526 
     | 
    
         
             
                      match(/\A(39)\d+\z/) >> split(2,3,2)   # mobile Blueline Madagascar
         
     | 
| 
       515 
527 
     | 
    
         | 
| 
         @@ -635,12 +647,12 @@ Phony.define do 
     | 
|
| 
       635 
647 
     | 
    
         
             
                      match(/^(2[467]\d{2})\d{4}$/)       >> split(2,2)     | # 4-digit NDC
         
     | 
| 
       636 
648 
     | 
    
         
             
                      match(/^(6\d[18])\d+$/)             >> split(3,3)     | # mobile
         
     | 
| 
       637 
649 
     | 
    
         
             
                      match(/^(60\d{2})\d{8}$/)           >> split(2,2,2,2) | # mobile machine to machine
         
     | 
| 
       638 
     | 
    
         
            -
                      match(/^((2[^467]|[ 
     | 
| 
       639 
     | 
    
         
            -
                      match(/^((2[^467]|[ 
     | 
| 
       640 
     | 
    
         
            -
                      match(/^((2[^467]|[ 
     | 
| 
       641 
     | 
    
         
            -
                      match(/^((2[^467]|[ 
     | 
| 
       642 
     | 
    
         
            -
                      match(/^((2[^467]|[ 
     | 
| 
       643 
     | 
    
         
            -
                      match(/^((2[^467]|[ 
     | 
| 
      
 650 
     | 
    
         
            +
                      match(/^((2[^467]|[2-9]\d))\d{4}$/) >> split(2,2)     | # 2-digit NDC Regular 6 digits number
         
     | 
| 
      
 651 
     | 
    
         
            +
                      match(/^((2[^467]|[2-9]\d))\d{4}$/) >> split(2,2)     | # 2-digit NDC Regular 6 digits number
         
     | 
| 
      
 652 
     | 
    
         
            +
                      match(/^((2[^467]|[2-9]\d))\d{5}$/) >> split(2,2,1)   | # 2-digit NDC Regular 6 digits number w/ 1 digit extension
         
     | 
| 
      
 653 
     | 
    
         
            +
                      match(/^((2[^467]|[2-9]\d))\d{6}$/) >> split(2,2,2)   | # 2-digit NDC Regular 8 digits number or 6 digits with 2 digits extension
         
     | 
| 
      
 654 
     | 
    
         
            +
                      match(/^((2[^467]|[2-9]\d))\d{7}$/) >> split(2,2,3)   | # 2-digit NDC Regular 6 digits with 4 digits extension
         
     | 
| 
      
 655 
     | 
    
         
            +
                      match(/^((2[^467]|[2-9]\d))\d{8}$/) >> split(2,2,4)   | # 2-digit NDC Regular 6 digits number with 4 digits extension
         
     | 
| 
       644 
656 
     | 
    
         
             
                      match(/^(\d{2})\d{3}$/)             >> split(2,2,1)     # fallback for 5 digit number
         
     | 
| 
       645 
657 
     | 
    
         | 
| 
       646 
658 
     | 
    
         
             
              # country '353' # Republic of Ireland, see special file.
         
     | 
| 
         @@ -910,7 +922,14 @@ Phony.define do 
     | 
|
| 
       910 
922 
     | 
    
         
             
                      )
         
     | 
| 
       911 
923 
     | 
    
         | 
| 
       912 
924 
     | 
    
         
             
              country '671', todo # Spare code
         
     | 
| 
       913 
     | 
    
         
            -
             
     | 
| 
      
 925 
     | 
    
         
            +
             
     | 
| 
      
 926 
     | 
    
         
            +
              # Australian External Territories https://en.wikipedia.org/wiki/Telephone_numbers_in_Norfolk_Island
         
     | 
| 
      
 927 
     | 
    
         
            +
              # Norfolk Island
         
     | 
| 
      
 928 
     | 
    
         
            +
              country '672',
         
     | 
| 
      
 929 
     | 
    
         
            +
                      fixed(1) >> split(2,3) |
         
     | 
| 
      
 930 
     | 
    
         
            +
                      match(/^(2\d+)$/) >> split(3) | # Fixed
         
     | 
| 
      
 931 
     | 
    
         
            +
                      match(/^(5\d+)$/) >> split(3) # Mobile
         
     | 
| 
      
 932 
     | 
    
         
            +
             
     | 
| 
       914 
933 
     | 
    
         
             
              country '673', fixed(1) >> split(3, 3) # Brunei Darussalam http://www.wtng.info/wtng-673-bn.html
         
     | 
| 
       915 
934 
     | 
    
         
             
              country '674', none >> split(3, 4) # Nauru (Republic of) http://www.wtng.info/wtng-674-nr.html
         
     | 
| 
       916 
935 
     | 
    
         | 
| 
         @@ -982,7 +1001,7 @@ Phony.define do 
     | 
|
| 
       982 
1001 
     | 
    
         
             
                          /\A\d+\z/ => [2,3] # geographic
         
     | 
| 
       983 
1002 
     | 
    
         
             
                      )
         
     | 
| 
       984 
1003 
     | 
    
         | 
| 
       985 
     | 
    
         
            -
              country '686', none >> split( 
     | 
| 
      
 1004 
     | 
    
         
            +
              country '686', none >> split(8) # Kiribati (Republic of) https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=KI
         
     | 
| 
       986 
1005 
     | 
    
         
             
              country '687', none >> split(3,3) # New Caledonia (Territoire français d'outre-mer) http://www.wtng.info/wtng-687-nc.html
         
     | 
| 
       987 
1006 
     | 
    
         
             
              country '688', none >> split(5) # Tuvalu http://www.wtng.info/wtng-688-tv.html
         
     | 
| 
       988 
1007 
     | 
    
         
             
              country '689', none >> split(2,2,2,2) # French Polynesia (Territoire français d'outre-mer) http://www.wtng.info/wtng-689-pf.html
         
     | 
| 
         @@ -1053,6 +1072,7 @@ Phony.define do 
     | 
|
| 
       1053 
1072 
     | 
    
         | 
| 
       1054 
1073 
     | 
    
         
             
              # Lao People's Democratic Republic http://www.wtng.info/wtng-856-la.html, https://www.numberingplans.com
         
     | 
| 
       1055 
1074 
     | 
    
         
             
              country '856',
         
     | 
| 
      
 1075 
     | 
    
         
            +
                      trunk('0') |
         
     | 
| 
       1056 
1076 
     | 
    
         
             
                      one_of('30') >> split(3,4) | # geographic
         
     | 
| 
       1057 
1077 
     | 
    
         
             
                      one_of('20') >> split(4,4) | # mobile
         
     | 
| 
       1058 
1078 
     | 
    
         
             
                      fixed(2) >> split(3,3) # geographic
         
     | 
    
        data/lib/phony/country_codes.rb
    CHANGED
    
    | 
         @@ -100,6 +100,17 @@ module Phony 
     | 
|
| 
       100 
100 
     | 
    
         
             
                  return false unless (4..16) === normalized.size # unless hints[:check_length] == false
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
       102 
102 
     | 
    
         
             
                  country, cc, rest = partial_split normalized
         
     | 
| 
      
 103 
     | 
    
         
            +
                  
         
     | 
| 
      
 104 
     | 
    
         
            +
                  # Was a country calling code given?
         
     | 
| 
      
 105 
     | 
    
         
            +
                  #
         
     | 
| 
      
 106 
     | 
    
         
            +
                  if ccc = hints[:ccc]
         
     | 
| 
      
 107 
     | 
    
         
            +
                    cc, ndc, *local = split ccc
         
     | 
| 
      
 108 
     | 
    
         
            +
                    
         
     | 
| 
      
 109 
     | 
    
         
            +
                    raise ArgumentError.new("The provided ccc option is too long and includes more than a cc ('#{cc}') and ndc ('#{ndc}'). It also includes '#{local.join}'.") unless local.size == 1 && local[0].empty?
         
     | 
| 
      
 110 
     | 
    
         
            +
                    
         
     | 
| 
      
 111 
     | 
    
         
            +
                    hints[:cc] = cc
         
     | 
| 
      
 112 
     | 
    
         
            +
                    hints[:ndc] = ndc
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
       103 
114 
     | 
    
         | 
| 
       104 
115 
     | 
    
         
             
                  # Country code plausible?
         
     | 
| 
       105 
116 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -109,6 +120,8 @@ module Phony 
     | 
|
| 
       109 
120 
     | 
    
         
             
                  # Country specific tests.
         
     | 
| 
       110 
121 
     | 
    
         
             
                  #
         
     | 
| 
       111 
122 
     | 
    
         
             
                  country.plausible? rest, hints
         
     | 
| 
      
 123 
     | 
    
         
            +
                rescue ArgumentError
         
     | 
| 
      
 124 
     | 
    
         
            +
                  raise
         
     | 
| 
       112 
125 
     | 
    
         
             
                rescue StandardError
         
     | 
| 
       113 
126 
     | 
    
         
             
                  return false
         
     | 
| 
       114 
127 
     | 
    
         
             
                end
         
     | 
| 
         @@ -18,27 +18,27 @@ describe 'Phony::Config' do 
     | 
|
| 
       18 
18 
     | 
    
         
             
                it 'does not fail when loading all' do
         
     | 
| 
       19 
19 
     | 
    
         
             
                  Phony::Config.load
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                  Phony.split('15551115511'). 
     | 
| 
      
 21 
     | 
    
         
            +
                  expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
         
     | 
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
       23 
23 
     | 
    
         
             
                it 'raises when a CC is used that has not been loaded.' do
         
     | 
| 
       24 
24 
     | 
    
         
             
                  Phony::Config.load('41')
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                  expect { Phony.split('15551115511') }.to raise_error
         
     | 
| 
      
 26 
     | 
    
         
            +
                  expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
28 
     | 
    
         
             
                it 'raises when a CC is used that has not been loaded.' do
         
     | 
| 
       29 
29 
     | 
    
         
             
                  Phony::Config.load(only: ['41'])
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                  expect { Phony.split('15551115511') }.to raise_error
         
     | 
| 
      
 31 
     | 
    
         
            +
                  expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         
             
                it 'raises when a CC is used that has not been loaded.' do
         
     | 
| 
       34 
34 
     | 
    
         
             
                  Phony::Config.load(except: ['1'])
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                  expect { Phony.split('15551115511') }.to raise_error
         
     | 
| 
      
 36 
     | 
    
         
            +
                  expect { Phony.split('15551115511') }.to raise_error(Phony::SplittingError)
         
     | 
| 
       37 
37 
     | 
    
         
             
                end
         
     | 
| 
       38 
38 
     | 
    
         
             
                it 'does not raise when a CC is used that has been loaded.' do
         
     | 
| 
       39 
39 
     | 
    
         
             
                  Phony::Config.load(except: ['41'])
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                  Phony.split('15551115511'). 
     | 
| 
      
 41 
     | 
    
         
            +
                  expect(Phony.split('15551115511')).to eq ['1', '555', '111', '5511']
         
     | 
| 
       42 
42 
     | 
    
         
             
                end
         
     | 
| 
       43 
43 
     | 
    
         
             
              end
         
     | 
| 
       44 
44 
     | 
    
         
             
            end
         
     | 
| 
         @@ -25,11 +25,11 @@ describe 'plausibility' do 
     | 
|
| 
       25 
25 
     | 
    
         
             
                      incorrect = [shortest.sub(/\d\s*\z/, '')] # , longest + '0']
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
                      correct.each do |value|
         
     | 
| 
       28 
     | 
    
         
            -
                        Phony.plausible?(value). 
     | 
| 
      
 28 
     | 
    
         
            +
                        expect(Phony.plausible?(value)).to be_truthy,
         
     | 
| 
       29 
29 
     | 
    
         
             
                          "It should validate #{value}, but does not."
         
     | 
| 
       30 
30 
     | 
    
         
             
                      end
         
     | 
| 
       31 
31 
     | 
    
         
             
                      incorrect.each do |value|
         
     | 
| 
       32 
     | 
    
         
            -
                        Phony.plausible?(value). 
     | 
| 
      
 32 
     | 
    
         
            +
                        expect(Phony.plausible?(value)).to be_falsey,
         
     | 
| 
       33 
33 
     | 
    
         
             
                          "It should not validate #{value}, but does."
         
     | 
| 
       34 
34 
     | 
    
         
             
                      end
         
     | 
| 
       35 
35 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -38,7 +38,7 @@ describe 'plausibility' do 
     | 
|
| 
       38 
38 
     | 
    
         
             
                      invalid = [*sample]
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                      invalid.each do |value|
         
     | 
| 
       41 
     | 
    
         
            -
                        Phony.plausible?(value). 
     | 
| 
      
 41 
     | 
    
         
            +
                        expect(Phony.plausible?(value)).to be_falsey,
         
     | 
| 
       42 
42 
     | 
    
         
             
                          "It should not validate #{value}, but does."
         
     | 
| 
       43 
43 
     | 
    
         
             
                      end
         
     | 
| 
       44 
44 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -51,6 +51,14 @@ describe 'plausibility' do 
     | 
|
| 
       51 
51 
     | 
    
         
             
                  it_is_correct_for 'Bosnia and Herzegovina', :samples => ['+387 66 666 666',
         
     | 
| 
       52 
52 
     | 
    
         
             
                                                                           '+387 37 123 456',
         
     | 
| 
       53 
53 
     | 
    
         
             
                                                                           '+387 33 222 111']
         
     | 
| 
      
 54 
     | 
    
         
            +
                  it 'is correct for Brasil' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                    Phony.plausible?('+55 67 998280912').should be_truthy
         
     | 
| 
      
 56 
     | 
    
         
            +
                    Phony.plausible?('+55 67 98280912').should be_falsey
         
     | 
| 
      
 57 
     | 
    
         
            +
                    Phony.plausible?('+55 11 12345678').should be_falsey
         
     | 
| 
      
 58 
     | 
    
         
            +
                    Phony.plausible?('+55 11 123456789').should be_falsey
         
     | 
| 
      
 59 
     | 
    
         
            +
                    Phony.plausible?('+55 11 023456789').should be_falsey
         
     | 
| 
      
 60 
     | 
    
         
            +
                    Phony.plausible?('+55 11 22345678').should be_truthy
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
       54 
62 
     | 
    
         
             
                  it 'is correct for Bulgaria' do
         
     | 
| 
       55 
63 
     | 
    
         
             
                      Phony.plausible?('+359 2 1234567').should be_truthy
         
     | 
| 
       56 
64 
     | 
    
         
             
                      Phony.plausible?('+359 30 12345').should be_truthy
         
     | 
| 
         @@ -179,6 +187,14 @@ describe 'plausibility' do 
     | 
|
| 
       179 
187 
     | 
    
         
             
                      Phony.plausible?('+359 998 123456').should be_truthy
         
     | 
| 
       180 
188 
     | 
    
         
             
                      Phony.plausible?('+359 999 123456').should be_truthy
         
     | 
| 
       181 
189 
     | 
    
         
             
                  end
         
     | 
| 
      
 190 
     | 
    
         
            +
                  it_is_correct_for 'Colombia', :samples => ['+57 601 411 1899',
         
     | 
| 
      
 191 
     | 
    
         
            +
                                                             '+57 602 111 2222',
         
     | 
| 
      
 192 
     | 
    
         
            +
                                                             '+57 603 111 2222',
         
     | 
| 
      
 193 
     | 
    
         
            +
                                                             '+57 604 111 2222',
         
     | 
| 
      
 194 
     | 
    
         
            +
                                                             '+57 605 111 2222',
         
     | 
| 
      
 195 
     | 
    
         
            +
                                                             '+57 606 111 2222',
         
     | 
| 
      
 196 
     | 
    
         
            +
                                                             '+57 607 111 2222',
         
     | 
| 
      
 197 
     | 
    
         
            +
                                                             '+57 608 111 2222']
         
     | 
| 
       182 
198 
     | 
    
         
             
                  it_is_correct_for 'Congo', :samples => '+242 1234 56789'
         
     | 
| 
       183 
199 
     | 
    
         
             
                  it_is_correct_for 'Cook Islands', :samples => '+682  71928'
         
     | 
| 
       184 
200 
     | 
    
         
             
                  it_is_correct_for 'Costa Rica', :samples => '+506 2 234 5678'
         
     | 
| 
         @@ -280,13 +296,12 @@ describe 'plausibility' do 
     | 
|
| 
       280 
296 
     | 
    
         
             
                  it_is_correct_for 'Guinea-Bissau', :samples => '+245 44 728 6998'
         
     | 
| 
       281 
297 
     | 
    
         
             
                  it_is_correct_for 'Guyana', :samples => '+592 263 1234'
         
     | 
| 
       282 
298 
     | 
    
         
             
                  it_is_correct_for 'Honduras (Republic of)', :samples => '+504 12 961 637'
         
     | 
| 
       283 
     | 
    
         
            -
                  it_is_correct_for 'Italy', :samples => ['+39 0574 1234']
         
     | 
| 
       284 
299 
     | 
    
         
             
                  it_is_correct_for 'Iraq', :samples => ['+964 1 123 4567',
         
     | 
| 
       285 
300 
     | 
    
         
             
                                                         '+964 21 113 456',
         
     | 
| 
       286 
301 
     | 
    
         
             
                                                         '+964 71 1234 5678']
         
     | 
| 
       287 
302 
     | 
    
         | 
| 
       288 
303 
     | 
    
         | 
| 
       289 
     | 
    
         
            -
                  it_is_correct_for 'Kiribati (Republic of)', :samples => '+686   
     | 
| 
      
 304 
     | 
    
         
            +
                  it_is_correct_for 'Kiribati (Republic of)', :samples => '+686  34814527'
         
     | 
| 
       290 
305 
     | 
    
         
             
                  it_is_correct_for "Democratic People's Republic of Korea", :samples => ['+850 2 123 45',
         
     | 
| 
       291 
306 
     | 
    
         
             
                                                                                          '+850 2 123 456 789',
         
     | 
| 
       292 
307 
     | 
    
         
             
                                                                                          '+850 2 381 2356',
         
     | 
| 
         @@ -329,6 +344,7 @@ describe 'plausibility' do 
     | 
|
| 
       329 
344 
     | 
    
         
             
                                                               '+261 32 34 546 78',
         
     | 
| 
       330 
345 
     | 
    
         
             
                                                               '+261 33 34 546 78',
         
     | 
| 
       331 
346 
     | 
    
         
             
                                                               '+261 34 34 546 78',
         
     | 
| 
      
 347 
     | 
    
         
            +
                                                               '+261 37 34 546 78',
         
     | 
| 
       332 
348 
     | 
    
         
             
                                                               '+261 38 34 546 78']
         
     | 
| 
       333 
349 
     | 
    
         
             
                  it 'is incorrect for Madagascar' do
         
     | 
| 
       334 
350 
     | 
    
         
             
                    Phony.plausible?('+261 20 012 345 678').should be_falsey
         
     | 
| 
         @@ -348,7 +364,8 @@ describe 'plausibility' do 
     | 
|
| 
       348 
364 
     | 
    
         
             
                  it_is_correct_for 'Marshall Islands (Republic of the)', :samples => '+692  372 7183'
         
     | 
| 
       349 
365 
     | 
    
         
             
                  it_is_correct_for 'Martinique (French Department of)', :samples => '+596 596 123 456'
         
     | 
| 
       350 
366 
     | 
    
         
             
                  it_is_correct_for 'Mauritania', :samples => '+222  1234 5678'
         
     | 
| 
       351 
     | 
    
         
            -
                  it_is_correct_for 'Mauritius', :samples => '+230   
     | 
| 
      
 367 
     | 
    
         
            +
                  it_is_correct_for 'Mauritius', :samples => ['+230  5 695 2277',
         
     | 
| 
      
 368 
     | 
    
         
            +
                                                              '+230  260 0070']
         
     | 
| 
       352 
369 
     | 
    
         
             
                  it_is_correct_for 'Micronesia (Federated States of)', :samples => '+691  766 7914'
         
     | 
| 
       353 
370 
     | 
    
         
             
                  it_is_correct_for 'Moldova', :samples => ['+373 800 123 45',
         
     | 
| 
       354 
371 
     | 
    
         
             
                                                            '+373 22 123 345',
         
     | 
| 
         @@ -574,7 +591,9 @@ describe 'plausibility' do 
     | 
|
| 
       574 
591 
     | 
    
         
             
                                                                                  '+598 805 123 45']
         
     | 
| 
       575 
592 
     | 
    
         
             
                  it_is_correct_for 'Vietnam', :samples => ['+84 24 41234567',
         
     | 
| 
       576 
593 
     | 
    
         
             
                                                            '+84 28 41234567',
         
     | 
| 
       577 
     | 
    
         
            -
                                                            '+84 23 61234567' 
     | 
| 
      
 594 
     | 
    
         
            +
                                                            '+84 23 61234567',
         
     | 
| 
      
 595 
     | 
    
         
            +
                                                            '+84 1900 1212',
         
     | 
| 
      
 596 
     | 
    
         
            +
                                                            '+84 1900 541234']
         
     | 
| 
       578 
597 
     | 
    
         
             
                  it_is_correct_for 'Yemen', :samples => [['+967 1 234 567', '+967 1 234 5678'],
         
     | 
| 
       579 
598 
     | 
    
         
             
                                                          '+967 7 234 567',
         
     | 
| 
       580 
599 
     | 
    
         
             
                                                          '+967 77 123 4567',
         
     | 
| 
         @@ -602,6 +621,29 @@ describe 'plausibility' do 
     | 
|
| 
       602 
621 
     | 
    
         
             
                    Phony.plausible?('+62 22 000 000 000').should be_truthy
         
     | 
| 
       603 
622 
     | 
    
         
             
                  end
         
     | 
| 
       604 
623 
     | 
    
         | 
| 
      
 624 
     | 
    
         
            +
                  it 'is correct for Italy' do
         
     | 
| 
      
 625 
     | 
    
         
            +
                    Phony.plausible?('+39 0574 123').should be_falsy
         
     | 
| 
      
 626 
     | 
    
         
            +
                    Phony.plausible?('+39 0574 1234').should be_truthy
         
     | 
| 
      
 627 
     | 
    
         
            +
                    Phony.plausible?('+39 0574 12345').should be_falsy
         
     | 
| 
      
 628 
     | 
    
         
            +
             
     | 
| 
      
 629 
     | 
    
         
            +
                    Phony.plausible?('+39 085 541').should be_falsy
         
     | 
| 
      
 630 
     | 
    
         
            +
                    Phony.plausible?('+39 085 5410').should be_truthy
         
     | 
| 
      
 631 
     | 
    
         
            +
                    Phony.plausible?('+39 085 54105').should be_truthy
         
     | 
| 
      
 632 
     | 
    
         
            +
             
     | 
| 
      
 633 
     | 
    
         
            +
                    Phony.plausible?('+39 06 4991').should be_falsy
         
     | 
| 
      
 634 
     | 
    
         
            +
                    Phony.plausible?('+39 06 49911').should be_truthy
         
     | 
| 
      
 635 
     | 
    
         
            +
                    Phony.plausible?('+39 06 499112').should be_truthy
         
     | 
| 
      
 636 
     | 
    
         
            +
             
     | 
| 
      
 637 
     | 
    
         
            +
                    Phony.plausible?('+39 800 081631').should be_truthy
         
     | 
| 
      
 638 
     | 
    
         
            +
                    Phony.plausible?('+39 800 0816311').should be_falsy
         
     | 
| 
      
 639 
     | 
    
         
            +
             
     | 
| 
      
 640 
     | 
    
         
            +
                    Phony.plausible?('+39 803 08163').should be_falsy
         
     | 
| 
      
 641 
     | 
    
         
            +
                    Phony.plausible?('+39 803 081').should be_truthy
         
     | 
| 
      
 642 
     | 
    
         
            +
             
     | 
| 
      
 643 
     | 
    
         
            +
                    Phony.plausible?('+39 06 8323074181').should be_falsy
         
     | 
| 
      
 644 
     | 
    
         
            +
                    Phony.plausible?('+39 06 832307418').should be_truthy
         
     | 
| 
      
 645 
     | 
    
         
            +
                  end
         
     | 
| 
      
 646 
     | 
    
         
            +
             
     | 
| 
       605 
647 
     | 
    
         
             
                  it 'is correct for Russia' do
         
     | 
| 
       606 
648 
     | 
    
         
             
                    Phony.plausible?('+7 3522 000 000').should be_truthy
         
     | 
| 
       607 
649 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -5,7 +5,7 @@ require 'spec_helper' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            describe 'country descriptions' do
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              def self.it_splits number, expected
         
     | 
| 
       8 
     | 
    
         
            -
                it { Phony.split(number). 
     | 
| 
      
 8 
     | 
    
         
            +
                it { expect(Phony.split(number)).to eq expected }
         
     | 
| 
       9 
9 
     | 
    
         
             
              end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              describe 'regression' do
         
     | 
| 
         @@ -147,9 +147,8 @@ describe 'country descriptions' do 
     | 
|
| 
       147 
147 
     | 
    
         
             
                end
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
149 
     | 
    
         
             
                describe 'Brazil' do
         
     | 
| 
       150 
     | 
    
         
            -
                  it_splits ' 
     | 
| 
      
 150 
     | 
    
         
            +
                  it_splits '551122341234', ['55', '11', '2234', '1234']
         
     | 
| 
       151 
151 
     | 
    
         
             
                  it_splits '5511981231234', ['55', '11', '98123', '1234'] # São Paulo's 9 digits mobile
         
     | 
| 
       152 
     | 
    
         
            -
                  it_splits '552181231234', ['55', '21', '8123', '1234']
         
     | 
| 
       153 
152 
     | 
    
         
             
                  it_splits '5521981231234', ['55', '21', '98123', '1234'] # Rio de Janeiro's 9 digits mobile
         
     | 
| 
       154 
153 
     | 
    
         
             
                  it_splits '551931311234', ['55', '19', '3131', '1234']
         
     | 
| 
       155 
154 
     | 
    
         
             
                  it_splits '5531991311234', ['55', '31', '99131', '1234'] # Belo Horizonte's 9th digit
         
     | 
| 
         @@ -157,6 +156,7 @@ describe 'country descriptions' do 
     | 
|
| 
       157 
156 
     | 
    
         
             
                  it_splits '5579991311234', ['55', '79', '99131', '1234'] # Sergipe's 9th digit
         
     | 
| 
       158 
157 
     | 
    
         
             
                  it_splits '5547991311234', ['55', '47', '99131', '1234'] # Santa Catarina's 9th digit
         
     | 
| 
       159 
158 
     | 
    
         
             
                  it_splits '5541991311234', ['55', '41', '99131', '1234'] # Parana's 9th digit
         
     | 
| 
      
 159 
     | 
    
         
            +
                  it_splits '556734212121', ['55', '67', '3421', '2121']
         
     | 
| 
       160 
160 
     | 
    
         | 
| 
       161 
161 
     | 
    
         
             
                  context 'mobile numbers' do
         
     | 
| 
       162 
162 
     | 
    
         
             
                    %w{
         
     | 
| 
         @@ -240,7 +240,7 @@ describe 'country descriptions' do 
     | 
|
| 
       240 
240 
     | 
    
         
             
                  end
         
     | 
| 
       241 
241 
     | 
    
         
             
                end
         
     | 
| 
       242 
242 
     | 
    
         
             
                describe 'Colombia' do
         
     | 
| 
       243 
     | 
    
         
            -
                  it_splits '5711234567', ['57', '1', '123', '4567']
         
     | 
| 
      
 243 
     | 
    
         
            +
                  it_splits '5711234567', ['57', '1', '123', '4567'] # Outdated.
         
     | 
| 
       244 
244 
     | 
    
         
             
                  it_splits '573101234567', ['57', '310', '123', '4567'] # mobile
         
     | 
| 
       245 
245 
     | 
    
         
             
                end
         
     | 
| 
       246 
246 
     | 
    
         
             
                describe 'Croatia' do
         
     | 
| 
         @@ -460,8 +460,9 @@ describe 'country descriptions' do 
     | 
|
| 
       460 
460 
     | 
    
         
             
                  it_splits '3934869528123',['39', '348', '695', '2812', '3']  # Mobile (8-digit subscriber no - new)
         
     | 
| 
       461 
461 
     | 
    
         
             
                  it_splits '393357210488', ['39', '335', '721', '0488'] # Mobile
         
     | 
| 
       462 
462 
     | 
    
         
             
                  it_splits '393248644272', ['39', '324', '864', '4272'] # Mobile
         
     | 
| 
       463 
     | 
    
         
            -
                  it_splits ' 
     | 
| 
       464 
     | 
    
         
            -
                  it_splits ' 
     | 
| 
      
 463 
     | 
    
         
            +
                  it_splits '390612341',    ['39', '06', '12341']        # Roma 5 digit
         
     | 
| 
      
 464 
     | 
    
         
            +
                  it_splits '3906123412',   ['39', '06', '1234', '12']   # Roma 6 digit
         
     | 
| 
      
 465 
     | 
    
         
            +
                  it_splits '39061234123',  ['39', '06', '1234', '123']  # Roma 7 digit
         
     | 
| 
       465 
466 
     | 
    
         
             
                  it_splits '390612341234', ['39', '06', '1234', '1234'] # Roma 8 digit
         
     | 
| 
       466 
467 
     | 
    
         
             
                  it_splits '3902888388',   ['39', '02', '8883', '88'] # Milano 6 digit
         
     | 
| 
       467 
468 
     | 
    
         
             
                  it_splits '39028883888',  ['39', '02', '8883', '888'] # Milano 7 digit
         
     | 
| 
         @@ -527,6 +528,8 @@ describe 'country descriptions' do 
     | 
|
| 
       527 
528 
     | 
    
         
             
                  it_splits '352545258',       ['352', '54', '52', '58']
         
     | 
| 
       528 
529 
     | 
    
         
             
                  it_splits '352818181',       ['352', '81', '81', '81']
         
     | 
| 
       529 
530 
     | 
    
         
             
                  it_splits '3523572141',      ['352', '35', '72', '14', '1']
         
     | 
| 
      
 531 
     | 
    
         
            +
                  it_splits '3522634731',      ['352', '26', '34', '73', '1']
         
     | 
| 
      
 532 
     | 
    
         
            +
                  it_splits '352264412701',    ['352', '26', '44', '12', '701']
         
     | 
| 
       530 
533 
     | 
    
         
             
                end
         
     | 
| 
       531 
534 
     | 
    
         
             
                describe 'Macedonia' do
         
     | 
| 
       532 
535 
     | 
    
         
             
                  it_splits '38921234567', ['389', '2', '123', '4567'] # Skopje
         
     | 
| 
         @@ -592,6 +595,10 @@ describe 'country descriptions' do 
     | 
|
| 
       592 
595 
     | 
    
         
             
                  it_splits '31222123456', ['31', '222', '123', '456']
         
     | 
| 
       593 
596 
     | 
    
         
             
                  it_splits '3197012345678', ['31', '970', '1234', '5678'] # machine-to-machine
         
     | 
| 
       594 
597 
     | 
    
         
             
                end
         
     | 
| 
      
 598 
     | 
    
         
            +
                describe 'Norfolk Island' do
         
     | 
| 
      
 599 
     | 
    
         
            +
                  it_splits '672321234', ['672', '3', '21', '234'] # fixed
         
     | 
| 
      
 600 
     | 
    
         
            +
                  it_splits '672351234', ['672', '3', '51', '234'] # mobile
         
     | 
| 
      
 601 
     | 
    
         
            +
                end
         
     | 
| 
       595 
602 
     | 
    
         
             
                describe 'Norway' do
         
     | 
| 
       596 
603 
     | 
    
         
             
                  it_splits '4721234567', ['47',false,'21','23','45','67']
         
     | 
| 
       597 
604 
     | 
    
         
             
                  it_splits '4731234567', ['47',false,'31','23','45','67']
         
     | 
| 
         @@ -850,6 +857,8 @@ describe 'country descriptions' do 
     | 
|
| 
       850 
857 
     | 
    
         
             
                  it_splits '842841234567', ['84', '28', '4123', '4567'] # Ho Chi Minh City
         
     | 
| 
       851 
858 
     | 
    
         
             
                  it_splits '84341234567', ['84', '34', '1234567'] # Viettel
         
     | 
| 
       852 
859 
     | 
    
         
             
                  it_splits '84841234567', ['84', '84', '1234567'] # Vinaphone
         
     | 
| 
      
 860 
     | 
    
         
            +
                  it_splits '8419001212', ['84', '1900', '1212'] # Vinaphone
         
     | 
| 
      
 861 
     | 
    
         
            +
                  it_splits '841900541234', ['84', '1900', '541234'] # Vinaphone
         
     | 
| 
       853 
862 
     | 
    
         
             
                end
         
     | 
| 
       854 
863 
     | 
    
         
             
                describe 'Zambia' do
         
     | 
| 
       855 
864 
     | 
    
         
             
                  it_splits '260211123456', ['260', '211', '123456']     # Fixed
         
     | 
| 
         @@ -870,7 +879,8 @@ describe 'country descriptions' do 
     | 
|
| 
       870 
879 
     | 
    
         
             
                  it_splits '6737932744', %w(673 7 932 744)
         
     | 
| 
       871 
880 
     | 
    
         
             
                end
         
     | 
| 
       872 
881 
     | 
    
         
             
                describe 'Burkina Faso' do
         
     | 
| 
       873 
     | 
    
         
            -
                  it_splits '22667839323', ['226', false, ' 
     | 
| 
      
 882 
     | 
    
         
            +
                  it_splits '22667839323', ['226', false, '67', '83', '93', '23']
         
     | 
| 
      
 883 
     | 
    
         
            +
                  it_splits '22601234567', ['226', false, '01', '23', '45', '67'] # 0 not removed.
         
     | 
| 
       874 
884 
     | 
    
         
             
                end
         
     | 
| 
       875 
885 
     | 
    
         
             
                describe 'Burundi' do
         
     | 
| 
       876 
886 
     | 
    
         
             
                  it_splits '25712345678', ['257', false, '1234', '5678']
         
     | 
| 
         @@ -1011,7 +1021,7 @@ describe 'country descriptions' do 
     | 
|
| 
       1011 
1021 
     | 
    
         
             
                  it_splits '96287901456', %w(962 8790 1456)
         
     | 
| 
       1012 
1022 
     | 
    
         
             
                end
         
     | 
| 
       1013 
1023 
     | 
    
         
             
                describe 'Kiribati (Republic of)' do
         
     | 
| 
       1014 
     | 
    
         
            -
                  it_splits ' 
     | 
| 
      
 1024 
     | 
    
         
            +
                  it_splits '68634814527', ['686', false, '34814527']
         
     | 
| 
       1015 
1025 
     | 
    
         
             
                end
         
     | 
| 
       1016 
1026 
     | 
    
         
             
                describe "Democratic People's Republic of Korea" do
         
     | 
| 
       1017 
1027 
     | 
    
         
             
                  it_splits '850212345', %w(850 2 123 45)
         
     | 
| 
         @@ -1084,7 +1094,8 @@ describe 'country descriptions' do 
     | 
|
| 
       1084 
1094 
     | 
    
         
             
                  it_splits '22212345678', ['222', false, '1234', '5678']
         
     | 
| 
       1085 
1095 
     | 
    
         
             
                end
         
     | 
| 
       1086 
1096 
     | 
    
         
             
                describe 'Mauritius' do
         
     | 
| 
       1087 
     | 
    
         
            -
                  it_splits '23059518919', ['230', false, ' 
     | 
| 
      
 1097 
     | 
    
         
            +
                  it_splits '23059518919', ['230', false, '5', '951', '8919']
         
     | 
| 
      
 1098 
     | 
    
         
            +
                  it_splits '2302600070', ['230', false, '260', '0070']
         
     | 
| 
       1088 
1099 
     | 
    
         
             
                end
         
     | 
| 
       1089 
1100 
     | 
    
         
             
                describe 'Micronesia (Federated States of)' do
         
     | 
| 
       1090 
1101 
     | 
    
         
             
                  it_splits '6911991754', ['691', false, '199', '1754']
         
     |