Permalink
Browse files

+ buen día Chile!

  • Loading branch information...
1 parent 28f5cab commit 67a03dad26cb4cd3eda64eca121b0e5f0fcabbde @floere committed Dec 1, 2010
Showing with 28 additions and 2 deletions.
  1. +1 −0 lib/phony.rb
  2. +1 −1 lib/phony/countries/all_other.rb
  3. +20 −0 lib/phony/countries/chile.rb
  4. +1 −1 lib/phony/countries/peru.rb
  5. +5 −0 spec/lib/phony_spec.rb
View
@@ -21,6 +21,7 @@
#
require File.expand_path '../phony/countries/all_other', __FILE__
require File.expand_path '../phony/countries/austria', __FILE__
+require File.expand_path '../phony/countries/chile', __FILE__
require File.expand_path '../phony/countries/egypt', __FILE__
require File.expand_path '../phony/countries/germany', __FILE__
require File.expand_path '../phony/countries/greece', __FILE__
@@ -95,7 +95,7 @@ def self.mapping
:local_format => [4, 4],
:service_ndcs => %w{100 128 190 191 192 193 194 197 198 199}
), # http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
- '56' => fixed(2), # TODO Chile
+ '56' => Countries::Chile,
'57' => fixed(2), # TODO Colombia (Republic of)
'58' => fixed(2), # TODO Venezuela (Bolivarian Republic of)
@@ -0,0 +1,20 @@
+# Chilean phone numbers.
+#
+# http://en.wikipedia.org/wiki/Telephone_numbers_in_Chile
+# http://www.wtng.info/wtng-56-cl.html
+#
+# TODO Totally unsure about this one, as I get contradicting infos.
+# As usual, best effort.
+#
+Phony::Countries::Chile = Phony::Country.configured :local_format => [8],
+ :local_special_format => [3, 3],
+ :ndc_fallback_length => 2,
+ :ndc_mapping => {
+ :landline => [
+ '2', # Santiago
+ ],
+ :mobile => [
+ '9',
+ ],
+ :service => %w{130 131 132 133 134 135 136 137 139 147 149}
+ }
@@ -2,7 +2,7 @@
#
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Peru
#
-Phony::Countries::Peru = Phony::Country.configured :local_format => [4, 4], # Also captures 3, 3 on a fallback.
+Phony::Countries::Peru = Phony::Country.configured :local_format => [4, 4],
:local_special_format => [3, 3],
:ndc_fallback_length => 2,
:ndc_mapping => {
View
@@ -11,6 +11,11 @@
it 'handles brazilian numbers' do
Phony.split('551112341234').should == ['55', '11', '1234', '1234']
end
+ it 'handles chilean numbers' do
+ Phony.split('5621234567').should == ['56', '2', '1234567'] # Santiago
+ Phony.split('5675123456').should == ['56', '75', '123456'] # Curico
+ Phony.split('56912345678').should == ['56', '9', '12345678'] # mobile
+ end
it 'handles danish numbers' do
Phony.split('4532121212').should == ['45', '32', '12', '12', '12']
end

0 comments on commit 67a03da

Please sign in to comment.