Permalink
Browse files

+ for now, do not change the outer API – change it in the next major …

…version
  • Loading branch information...
1 parent 14a2518 commit 09dee517495c504ce430ce8c321b3d73c3fcb029 @floere committed May 17, 2012
Showing with 12 additions and 10 deletions.
  1. +3 −1 lib/phony.rb
  2. +1 −2 lib/phony/country_codes.rb
  3. +8 −7 spec/lib/phony_spec.rb
View
@@ -63,7 +63,9 @@ def split phone_number
split! phone_number.dup
end
def split! phone_number
- @codes.split phone_number
+ parts = @codes.split phone_number
+ parts.delete_at 1
+ parts
end
# Formats a E164 number according to local customs.
@@ -38,8 +38,7 @@ def normalize number
#
def split number
country_handler, cc, rest = split_cc number
- zero, *rest = country_handler.split(rest)
- [cc, *rest.compact]
+ [cc, *country_handler.split(rest)]
end
def formatted number, options = {}
@@ -172,11 +172,9 @@
it "should format austrian numbers" do
Phony.format('43198110', :format => :national).should == '01 98110'
end
- # TODO
- #
- # it "should format US numbers without a leading zero" do
- # Phony.format('14159224711', :format => :national).should == '415 922 4711'
- # end
+ it "should format US numbers without a leading zero" do
+ Phony.format('14159224711', :format => :national).should == '415 922 4711'
+ end
end
describe "local" do
it "should format swiss numbers" do
@@ -217,8 +215,11 @@
end
end
context '"unsupported" countries' do
- it 'handles normalizing, then formatting' do
- Phony.format(Phony.normalize('+880-321 5560 5220')).should == '+880 32155605220'
+ it 'handles formatting' do
+ Phony.format('88032155605220').should == '+880 32155605220'
+ end
+ it 'handles normalizing' do
+ Phony.normalize('+880-321 5560 5220').should == '88032155605220'
end
end
end

0 comments on commit 09dee51

Please sign in to comment.