Permalink
Browse files

+ 1.2.4, Malaysia

  • Loading branch information...
1 parent 03555a3 commit 0fb354a660aaeba4aab4b6febcc99216538797ce @floere committed Jan 1, 2011
Showing with 33 additions and 3 deletions.
  1. +1 −1 README.textile
  2. +4 −0 history.textile
  3. +1 −0 lib/phony.rb
  4. +1 −1 lib/phony/countries/all_other.rb
  5. +21 −0 lib/phony/countries/malaysia.rb
  6. +1 −1 phony.gemspec
  7. +4 −0 spec/lib/phony_spec.rb
View
@@ -5,7 +5,7 @@ h2. Description
This gem can normalize, format and split E164 numbers.
"More about E164 numbers in this Wiki":http://en.wikipedia.org/wiki/E.164.
-Currently handles Afghan, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, South Korean, Spanish, Swedish, Swiss, Turkish, Liechtenstein, US, Venezuelan numbers.
+Currently handles Afghan, Austrian, Australian, Belgian, Brazilian, Chilean, Chinese, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, Malaysian, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, South Korean, Spanish, Swedish, Swiss, Turkish, Liechtenstein, US, Venezuelan numbers.
And to some extend, all others. Just try if it works for you.
If it doesn't, please "enter an issue":http://github.com/floere/phony/issues.
View
@@ -1,3 +1,7 @@
+h2. Version 1.2.4
+
+* hanke: Malaysia.
+
h2. Version 1.2.3
* hanke: South Korea.
View
@@ -20,6 +20,7 @@
require File.expand_path '../phony/countries/greece', __FILE__
require File.expand_path '../phony/countries/hungary', __FILE__
require File.expand_path '../phony/countries/italy', __FILE__
+require File.expand_path '../phony/countries/malaysia', __FILE__
require File.expand_path '../phony/countries/netherlands', __FILE__
require File.expand_path '../phony/countries/peru', __FILE__
require File.expand_path '../phony/countries/romania', __FILE__
@@ -101,7 +101,7 @@ def self.mapping
:local_format => [7]
),
- '60' => fixed(2), # TODO Malaysia, http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
+ '60' => Countries::Malaysia, # Malaysia, http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
'61' => fixed(1, # Australia
:local_format => [4, 4]
),
@@ -0,0 +1,21 @@
+# Malaysian phone numbers.
+#
+# http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
+#
+Phony::Countries::Malaysia = Phony::Country.configured :local_format => [8],
+ :ndc_fallback_length => 2,
+ :ndc_mapping => {
+ :landline => [
+ '2', # Singapore
+ '3', # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
+ '4', # Kedah, Penang & Perlis
+ '5', # Perak & Cameron Highlands (Pahang)
+ '6', # Melaka, Negeri Sembilan & Muar (Johor)
+ '7', # Johor (except Muar)
+ '9', # Kelantan, Pahang (except Cameron Highlands & Genting Highlands) & Terengganu
+ ],
+ :mobile => %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 },
+ # TODO 4+ digits service numbers
+ #
+ :service => %w{ 100 101 102 103 104 108 112 991 994 995 999 }
+ }
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'phony'
- s.version = '1.2.3'
+ s.version = '1.2.4'
s.authors = ['Florian Hanke']
s.email = 'florian.hanke+phony@gmail.com'
s.homepage = 'http://github.com/floere/phony'
View
@@ -53,6 +53,10 @@
it "should handle italian numbers" do
Phony.split('3928061371').should == ['39', '2', '806', '1371']
end
+ it 'handles malay numbers' do
+ Phony.split('6082123456').should == ['60', '82', '123456'] # Kuching
+ Phony.split('60312345678').should == ['60', '3', '12345678'] # Kuala Lumpur
+ end
it 'handles peruvian numbers' do
Phony.split('51112341234').should == ['51', '1', '1234', '1234'] # Lima
Phony.split('51912341234').should == ['51', '9', '1234', '1234'] # mobile

0 comments on commit 0fb354a

Please sign in to comment.