Permalink
Browse files

+ Oláá Portugal!

  • Loading branch information...
1 parent 393a2e7 commit f26323e95a8baa03f987257f28e501463153cd2d @floere committed Jan 20, 2011
View
@@ -24,6 +24,7 @@
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/portugal', __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__
@@ -220,7 +220,7 @@ def self.mapping
'299' => fixed(2), # Greenland
'350' => fixed(2), # Gibraltar
- '351' => fixed(2), # Portugal
+ '351' => Countries::Portugal, # Portugal
'352' => fixed(2), # Luxembourg
'353' => fixed(2), # Ireland
'354' => fixed(2), # Iceland
@@ -0,0 +1,15 @@
+# Portuguese phone numbers.
+#
+# http://en.wikipedia.org/wiki/Telephone_numbers_in_Portugal
+#
+Phony::Countries::Portugal = Phony::Country.configured :local_format => [3, 4],
+ :local_special_format => [3, 3],
+ :ndc_fallback_length => 3,
+ :ndc_mapping => {
+ :landline => [
+ '21', # Lisboa
+ '22', # Porto
+ ],
+ :mobile => ('90'..'99').to_a,
+ :service => %w{700 800} # Not exhaustive.
+ }
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe Phony::Countries::Portugal do
+
+ before(:each) do
+ @portugal = Phony::Countries::Portugal
+ end
+
+ describe "split" do
+ it "works with Lisboa" do
+ @portugal.split('211231234').should == ['21', '123', '1234']
+ end
+ it "works with Abrantes" do
+ @portugal.split('241123123').should == ['241', '123', '123']
+ end
+ it 'works with a mobile' do
+ @portugal.split('931231234').should == ['93', '123', '1234']
+ end
+ end
+
+end
View
@@ -66,6 +66,11 @@
it "should handle polish numbers" do
Phony.split('48123123123').should == ['48', '123', '123', '123']
end
+ it 'handles portuguese numbers' do
+ Phony.split('351211231234').should == ['351', '21', '123', '1234']
+ Phony.split('351241123123').should == ['351', '241', '123', '123']
+ Phony.split('351931231234').should == ['351', '93', '123', '1234']
+ end
it 'handles romanian numbers' do
Phony.split('40211231234').should == ['40', '21', '123', '1234'] # Bucureşti
Phony.split('40721231234').should == ['40', '72', '123', '1234'] # mobile

0 comments on commit f26323e

Please sign in to comment.