Skip to content

Commit

Permalink
Nepal added
Browse files Browse the repository at this point in the history
  • Loading branch information
Slike9 committed Apr 2, 2013
1 parent 62edbd8 commit 972f108
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/phony.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
require File.expand_path '../phony/countries/moldova', __FILE__
require File.expand_path '../phony/countries/montenegro', __FILE__
require File.expand_path '../phony/countries/namibia', __FILE__
require File.expand_path '../phony/countries/nepal', __FILE__
require File.expand_path '../phony/countries/netherlands', __FILE__
require File.expand_path '../phony/countries/pakistan', __FILE__
require File.expand_path '../phony/countries/paraguay', __FILE__
Expand Down
3 changes: 2 additions & 1 deletion lib/phony/countries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,8 @@
one_of(%w(50 55 56 58 92)) >> split(3,3) | # wireless geographic
fixed(2) >> split(3,3)

country '977', todo # Nepal
# country '977' # Nepal, see special file

country '978', todo # -
country '979', todo # International Premium Rate Service (IPRS)

Expand Down
71 changes: 71 additions & 0 deletions lib/phony/countries/nepal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Nepal
# https://www.numberingplans.com/?page=dialling&sub=areacodes
# https://www.numberingplans.com/?page=plans&sub=phonenr&alpha_2_input=NP

ndcs_with_7_subscriber_digits = %w(1)

ndcs_with_6_subscriber_digits = %w(
10
11
21
23
24
25
26
27
29
31
33
35
36
37
38
41
44
46
47
49
51
53
55
56
57
61
63
64
66
67
68
69
71
75
76
77
78
79
81
82
83
84
86
87
89
91
92
93
94
95
96
97
99
)

Phony.define do
country '977',
one_of(ndcs_with_6_subscriber_digits) >> split(3,3) |
one_of(%w(98)) >> split(4,4) | # mobile
one_of(ndcs_with_7_subscriber_digits) >> split(3,4) |
fixed(2) >> split(3,3)
end


5 changes: 5 additions & 0 deletions spec/lib/phony/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@ def self.it_splits number, expected
describe 'Nauru (Republic of)' do
it_splits '6741288739', ['674', false, '128', '8739']
end
describe 'Nepal' do
it_splits '97714345678', %w(977 1 434 5678)
it_splits '97710123456', %w(977 10 123 456)
it_splits '9779812345678', %w(977 98 1234 5678)
end
describe "New Caledonia (Territoire français d'outre-mer)" do
it_splits '687747184', ['687', false, '747', '184']
end
Expand Down
3 changes: 3 additions & 0 deletions spec/lib/phony/validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ def self.it_is_correct_for(country_name, options={})
'+264 63 088 612 345',
'+264 85 1234 567']
it_is_correct_for 'Nauru (Republic of)', :samples => '+674 239 8387'
it_is_correct_for 'Nepal', :samples => ['+977 1 434 5678',
'+977 10 123 456',
'+977 98 1234 5678']
it_is_correct_for "New Caledonia (Territoire français d'outre-mer)", :samples => '+687 546 835'
it_is_correct_for 'Nicaragua', :samples => '+505 12 345 678'
it_is_correct_for 'Niger', :samples => '+227 1234 5678'
Expand Down

0 comments on commit 972f108

Please sign in to comment.