Permalink
Browse files

+ Annyeonhaseyo, South Korea!

  • Loading branch information...
1 parent 271a3c3 commit 5fd6965c450426d1b7efda84edbbc6042d6dab06 @floere committed Jan 1, 2011
Showing with 23 additions and 2 deletions.
  1. +1 −0 lib/phony.rb
  2. +2 −2 lib/phony/countries/all_other.rb
  3. +15 −0 lib/phony/countries/south_korea.rb
  4. +5 −0 spec/lib/phony_spec.rb
View
@@ -23,6 +23,7 @@
require File.expand_path '../phony/countries/netherlands', __FILE__
require File.expand_path '../phony/countries/peru', __FILE__
require File.expand_path '../phony/countries/romania', __FILE__
+require File.expand_path '../phony/countries/south_korea', __FILE__
require File.expand_path '../phony/countries/sweden', __FILE__
require File.expand_path '../phony/country_codes', __FILE__
@@ -101,7 +101,7 @@ def self.mapping
:local_format => [7]
),
- '60' => fixed(2), # TODO Malaysia
+ '60' => fixed(2), # TODO Malaysia, http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
'61' => fixed(1, # Australia
:local_format => [4, 4]
),
@@ -114,7 +114,7 @@ def self.mapping
'66' => fixed(2), # TODO Thailand
'81' => fixed(2), # TODO Japan
- '82' => fixed(2), # TODO Korea (Republic of)
+ '82' => Countries::SouthKorea, # Korea (Republic of), http://en.wikipedia.org/wiki/Telephone_numbers_in_South_Korea
'84' => fixed(2), # TODO Viet Nam (Socialist Republic of)
'86' => Countries::China, # China (People's Republic of), http://en.wikipedia.org/wiki/Telephone_numbers_in_China
@@ -0,0 +1,15 @@
+# South Korean (Republic of Korea) phone numbers.
+#
+# http://en.wikipedia.org/wiki/Telephone_numbers_in_South_Korea
+#
+Phony::Countries::SouthKorea = Phony::Country.configured :local_format => [4, 4],
+ :ndc_fallback_length => 2,
+ :ndc_mapping => {
+ :landline => [
+ '2', # Seoul
+ ],
+ :mobile => %w{ 10 11 12 13 14 15 16 17 18 19 },
+ # TODO 4-digit services, like "unreasonable infringement of livelihood report" number :)
+ #
+ :service => %w{ 30 50 60 70 80 100 101 105 106 107 108 109 111 112 113 114 115 116 117 118 119 120 121 122 123 125 127 128 129 131 132 134 141 182 188 }
+ }
@@ -69,6 +69,11 @@
it 'handles russian numbers' do
Phony.split('78122345678').should == ['7', '812', '234', '56', '78']
end
+ it 'handles south korean numbers' do
+ Phony.split('82212345678').should == ['82', '2', '1234', '5678'] # Seoul
+ Phony.split('825112345678').should == ['82', '51', '1234', '5678'] # Busan
+ Phony.split('821027975588').should == ['82', '10', '2797', '5588'] # mobile
+ end
it "should handle swedish numbers" do
Phony.split('46812345678').should == ['46', '8', '12345678']
Phony.split('46111234567').should == ['46', '11', '1234567']

0 comments on commit 5fd6965

Please sign in to comment.