Skip to content
Browse files

+ Moved Chile to main file, - Chile special file, + Spec

  • Loading branch information...
1 parent 6f14f18 commit 9e4da685317be92965aa5933e22924d3f044ef8a @floere committed
Showing with 9 additions and 19 deletions.
  1. +0 −1 lib/phony.rb
  2. +5 −1 lib/phony/countries.rb
  3. +0 −14 lib/phony/countries/chile.rb
  4. +4 −3 spec/lib/phony/countries_spec.rb
View
1 lib/phony.rb
@@ -18,7 +18,6 @@
# The ones that need more space to define.
#
require File.expand_path '../phony/countries/austria', __FILE__
-require File.expand_path '../phony/countries/chile', __FILE__
require File.expand_path '../phony/countries/china', __FILE__
require File.expand_path '../phony/countries/germany', __FILE__
require File.expand_path '../phony/countries/hungary', __FILE__
View
6 lib/phony/countries.rb
@@ -135,7 +135,11 @@
# :service? => brazilian_service, :mobile? => ?
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Brazil
- # country '56' # Chile, see special file.
+ # Chile.
+ #
+ country '56', match(/^(13[0-79]|14[79])\d+$/) >> split(3,3) | # Service
+ one_of('2', '9') >> split(8) | # Santiago, Mobile
+ fixed(2) >> split(8) # 2-digit NDCs
# TODO Colombia.
#
View
14 lib/phony/countries/chile.rb
@@ -1,14 +0,0 @@
-# Chilean phone numbers.
-#
-# http://en.wikipedia.org/wiki/Telephone_numbers_in_Chile
-# http://www.wtng.info/wtng-56-cl.html
-#
-# Note: Totally unsure about this one, as I get contradicting infos (see links above).
-# As usual, best effort.
-#
-service = %w{130 131 132 133 134 135 136 137 139 147 149}
-
-Phony.define do
- country '56', one_of(*service) >> split(3,3) |
- one_of('2', '9', :max_length => 2) >> split(8) # Santiago (2) and mobile.
-end
View
7 spec/lib/phony/countries_spec.rb
@@ -36,9 +36,10 @@
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
+ Phony.split('5621234567').should == ['56', '2', '1234567'] # Santiago
+ Phony.split('5675123456').should == ['56', '75', '123456'] # Curico
+ Phony.split('56912345678').should == ['56', '9', '12345678'] # Mobile
+ Phony.split('56137123456').should == ['56', '137', '123', '456'] # Service
end
it 'handles chinese numbers' do
Phony.split('862112345678').should == ['86', '21', '1234', '5678'] # Shanghai

0 comments on commit 9e4da68

Please sign in to comment.
Something went wrong with that request. Please try again.