Skip to content

Commit

Permalink
Turkmenistan added
Browse files Browse the repository at this point in the history
  • Loading branch information
Slike9 committed Apr 2, 2013
1 parent 3a76ac6 commit 7b318ed
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/phony.rb
Expand Up @@ -46,6 +46,7 @@
require File.expand_path '../phony/countries/sweden', __FILE__
require File.expand_path '../phony/countries/taiwan', __FILE__
require File.expand_path '../phony/countries/tajikistan', __FILE__
require File.expand_path '../phony/countries/turkmenistan', __FILE__
require File.expand_path '../phony/countries/ukraine', __FILE__
require File.expand_path '../phony/countries/united_kingdom', __FILE__
require File.expand_path '../phony/countries/uruguay', __FILE__
Expand Down
3 changes: 2 additions & 1 deletion lib/phony/countries.rb
Expand Up @@ -1023,7 +1023,8 @@

# country '992' # Tajikistan (Republic of), see special file

country '993', todo # Turkmenistan
# country '993' # Turkmenistan, see special file

country '994', fixed(2) >> split(7) # Azerbaijani Republic
country '995', todo # Georgia
country '996', todo # Kyrgyz Republic
Expand Down
73 changes: 73 additions & 0 deletions lib/phony/countries/turkmenistan.rb
@@ -0,0 +1,73 @@
# Turkmenistan
# https://www.numberingplans.com/?page=dialling&sub=areacodes
# https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=TM

ndcs_with_6_subscriber_digits = %w(12)

ndcs_with_5_subscriber_digits = %w(
131
132
133
134
135
136
137
138
222
240
241
242
243
245
246
247
248
322
340
343
344
345
346
347
348
349
360
422
431
432
438
440
441
442
443
444
445
446
447
448
449
461
465
522
557
558
559
560
561
564
565
566
568
569
)

ndcs_with_4_subscriber_digits = %w(1392)

Phony.define do
country '993',
one_of(ndcs_with_4_subscriber_digits) >> trunk('8') >> split(4) |
one_of(ndcs_with_5_subscriber_digits) >> trunk('8') >> split(3,2) |
one_of(ndcs_with_6_subscriber_digits) >> trunk('8') >> split(3,3) |
one_of('6') >> trunk('8') >> split(3,4) | # mobile
fixed(3) >> trunk('8') >> split(3,2)
end
6 changes: 6 additions & 0 deletions spec/lib/phony/countries_spec.rb
Expand Up @@ -891,6 +891,12 @@ def self.it_splits number, expected
describe 'Tuvalu' do
it_splits '68893741', ['688', false, '93741']
end
describe 'Turkmenistan' do
it_splits '99312456789', %w(993 12 456 789)
it_splits '99313145678', %w(993 131 456 78)
it_splits '99313924567', %w(993 1392 4567)
it_splits '99361234567', %w(993 6 123 4567)
end
describe 'Ukraine' do
it_splits '380800123456', %w(380 800 123 456)
it_splits '380312123456', %w(380 312 123 456)
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/phony/validations_spec.rb
Expand Up @@ -505,6 +505,10 @@ def self.it_is_correct_for(country_name, options={})
'+676 84 123',
'+676 77 123 45',
'+676 89 123 45']
it_is_correct_for 'Turkmenistan', :samples => ['+993 12 456 789',
'+993 131 456 78',
'+993 1392 4567',
'+993 6 123 4567']
it_is_correct_for 'Tuvalu', :samples => '+688 93742'
it_is_correct_for 'Uzbekistan (Republic of)', :samples => '+998 78 867 4419'
it_is_correct_for 'Vanuatu (Republic of)', :samples => ['+678 7216 123', '+678 26 123']
Expand Down

0 comments on commit 7b318ed

Please sign in to comment.