phony 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -1
- data/lib/phony.rb +1 -0
- data/lib/phony/countries/all_other.rb +1 -1
- data/lib/phony/countries/malaysia.rb +21 -0
- data/spec/lib/phony_spec.rb +4 -0
- metadata +3 -2
data/README.textile
CHANGED
@@ -5,9 +5,11 @@ h2. Description
|
|
5
5
|
This gem can normalize, format and split E164 numbers.
|
6
6
|
"More about E164 numbers in this Wiki":http://en.wikipedia.org/wiki/E.164.
|
7
7
|
|
8
|
-
Currently handles Afghan, Austrian, Australian, Belgian, Brazilian, Chilean, Czech, Danish, Dutch, Egyptian, French, German, Greek, Hungarian, Italian, (The) Netherlands, New Zealand, Norwegian, Peruvian, Polish, Russian, Romanian, South African, Spanish, Swedish, Swiss, Liechtenstein, US, Venezuelan numbers.
|
8
|
+
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.
|
9
9
|
And to some extend, all others. Just try if it works for you.
|
10
10
|
|
11
|
+
If it doesn't, please "enter an issue":http://github.com/floere/phony/issues.
|
12
|
+
|
11
13
|
h2. Installation
|
12
14
|
|
13
15
|
<pre><code>gem install phony</code></pre>
|
data/lib/phony.rb
CHANGED
@@ -20,6 +20,7 @@ require File.expand_path '../phony/countries/germany', __FILE__
|
|
20
20
|
require File.expand_path '../phony/countries/greece', __FILE__
|
21
21
|
require File.expand_path '../phony/countries/hungary', __FILE__
|
22
22
|
require File.expand_path '../phony/countries/italy', __FILE__
|
23
|
+
require File.expand_path '../phony/countries/malaysia', __FILE__
|
23
24
|
require File.expand_path '../phony/countries/netherlands', __FILE__
|
24
25
|
require File.expand_path '../phony/countries/peru', __FILE__
|
25
26
|
require File.expand_path '../phony/countries/romania', __FILE__
|
@@ -101,7 +101,7 @@ module Phony
|
|
101
101
|
:local_format => [7]
|
102
102
|
),
|
103
103
|
|
104
|
-
'60' =>
|
104
|
+
'60' => Countries::Malaysia, # Malaysia, http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
|
105
105
|
'61' => fixed(1, # Australia
|
106
106
|
:local_format => [4, 4]
|
107
107
|
),
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Malaysian phone numbers.
|
2
|
+
#
|
3
|
+
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Malaysia
|
4
|
+
#
|
5
|
+
Phony::Countries::Malaysia = Phony::Country.configured :local_format => [8],
|
6
|
+
:ndc_fallback_length => 2,
|
7
|
+
:ndc_mapping => {
|
8
|
+
:landline => [
|
9
|
+
'2', # Singapore
|
10
|
+
'3', # Selangor & Federal Territories of Kuala Lumpur & Putrajaya & also Genting Highlands, Pahang
|
11
|
+
'4', # Kedah, Penang & Perlis
|
12
|
+
'5', # Perak & Cameron Highlands (Pahang)
|
13
|
+
'6', # Melaka, Negeri Sembilan & Muar (Johor)
|
14
|
+
'7', # Johor (except Muar)
|
15
|
+
'9', # Kelantan, Pahang (except Cameron Highlands & Genting Highlands) & Terengganu
|
16
|
+
],
|
17
|
+
:mobile => %w{ 10 11 12 13 14 153 154 156 158 16 17 18 19 },
|
18
|
+
# TODO 4+ digits service numbers
|
19
|
+
#
|
20
|
+
:service => %w{ 100 101 102 103 104 108 112 991 994 995 999 }
|
21
|
+
}
|
data/spec/lib/phony_spec.rb
CHANGED
@@ -53,6 +53,10 @@ describe Phony do
|
|
53
53
|
it "should handle italian numbers" do
|
54
54
|
Phony.split('3928061371').should == ['39', '2', '806', '1371']
|
55
55
|
end
|
56
|
+
it 'handles malay numbers' do
|
57
|
+
Phony.split('6082123456').should == ['60', '82', '123456'] # Kuching
|
58
|
+
Phony.split('60312345678').should == ['60', '3', '12345678'] # Kuala Lumpur
|
59
|
+
end
|
56
60
|
it 'handles peruvian numbers' do
|
57
61
|
Phony.split('51112341234').should == ['51', '1', '1234', '1234'] # Lima
|
58
62
|
Phony.split('51912341234').should == ['51', '9', '1234', '1234'] # mobile
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 4
|
9
|
+
version: 1.2.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/phony/countries/greece.rb
|
37
37
|
- lib/phony/countries/hungary.rb
|
38
38
|
- lib/phony/countries/italy.rb
|
39
|
+
- lib/phony/countries/malaysia.rb
|
39
40
|
- lib/phony/countries/netherlands.rb
|
40
41
|
- lib/phony/countries/peru.rb
|
41
42
|
- lib/phony/countries/romania.rb
|