Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Prefer :format to :formatted #103

Merged
merged 1 commit into from

2 participants

@johnnyshields

No description provided.

@johnnyshields johnnyshields reopened this
@johnnyshields

ruby-head seems to be crapping out on Travis CI.

Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/latest_specs.4.8.gz)
@floere floere merged commit 5e06705 into floere:master
@floere
Owner

Cheers :)

@johnnyshields

Thanks :) See I wasn't trolling after all :trollface:

@floere
Owner

:trophy: :trollface: :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 26, 2013
  1. @johnnyshields
This page is out of date. Refresh to see the latest.
Showing with 32 additions and 30 deletions.
  1. +27 −27 README.textile
  2. +2 −2 lib/phony.rb
  3. +3 −1 lib/phony/country_codes.rb
View
54 README.textile
@@ -77,69 +77,69 @@ This will often raise an error if you try normalizing a non E164-izable number (
h3(#formatting). Formatting
-@Phony.formatted('41443643532').should == '+41 44 364 35 32'@
+@Phony.format('41443643532').should == '+41 44 364 35 32'@
-@Phony.formatted('41800112233').should == '+41 800 11 22 33'@
+@Phony.format('41800112233').should == '+41 800 11 22 33'@
-@Phony.formatted('43198110').should == '+43 1 98110'@
+@Phony.format('43198110').should == '+43 1 98110'@
-@Phony.formatted('18705551122').should == '+1 870 555 1122'@
+@Phony.format('18705551122').should == '+1 870 555 1122'@
h4(#international). International
-@Phony.formatted('18091231234', :format => :international).should == '+1 809 123 1234'@
+@Phony.format('18091231234', :format => :international).should == '+1 809 123 1234'@
-@Phony.formatted('43198110', :format => :international).should == '+43 1 98110'@
+@Phony.format('43198110', :format => :international).should == '+43 1 98110'@
-@Phony.formatted('43198110', :format => :international_absolute).should == '+43 1 98110'@
+@Phony.format('43198110', :format => :international_absolute).should == '+43 1 98110'@
-@Phony.formatted('33142278186', :format => :+).should == '+33 1 42 27 81 86'@
+@Phony.format('33142278186', :format => :+).should == '+33 1 42 27 81 86'@
-@Phony.formatted('43198110', :format => :international_relative).should == '0043 1 98110'@
+@Phony.format('43198110', :format => :international_relative).should == '0043 1 98110'@
-@Phony.formatted('4233841148', :format => :international_relative).should == '00423 384 11 48'@
+@Phony.format('4233841148', :format => :international_relative).should == '00423 384 11 48'@
h4(#spaces). With spaces
-@Phony.formatted('18091231234', :format => :international, :spaces => '').should == '+18091231234'@
+@Phony.format('18091231234', :format => :international, :spaces => '').should == '+18091231234'@
-@Phony.formatted('43198110', :format => :international, :spaces => '').should == '+43198110'@
+@Phony.format('43198110', :format => :international, :spaces => '').should == '+43198110'@
-@Phony.formatted('43198110', :format => :international_absolute, :spaces => '').should == '+43198110'@
+@Phony.format('43198110', :format => :international_absolute, :spaces => '').should == '+43198110'@
-@Phony.formatted('33142278186', :format => :+, :spaces => '').should == '+33142278186'@
+@Phony.format('33142278186', :format => :+, :spaces => '').should == '+33142278186'@
-@Phony.formatted('43198110', :format => :international_relative, :spaces => '').should == '0043198110'@
+@Phony.format('43198110', :format => :international_relative, :spaces => '').should == '0043198110'@
-@Phony.formatted('4233841148', :format => :international_relative, :spaces => '').should == '004233841148'@
+@Phony.format('4233841148', :format => :international_relative, :spaces => '').should == '004233841148'@
h4(#special). With special spaces
-@Phony.formatted('18091231234', :format => :international, :spaces => :-).should == '+1-809-123-1234'@
+@Phony.format('18091231234', :format => :international, :spaces => :-).should == '+1-809-123-1234'@
-@Phony.formatted('43198110', :format => :international, :spaces => :-).should == '+43-1-98110'@
+@Phony.format('43198110', :format => :international, :spaces => :-).should == '+43-1-98110'@
-@Phony.formatted('43198110', :format => :international_absolute, :spaces => :-).should == '+43-1-98110'@
+@Phony.format('43198110', :format => :international_absolute, :spaces => :-).should == '+43-1-98110'@
-@Phony.formatted('33142278186', :format => :+, :spaces => :-).should == '+33-1-42-27-81-86'@
+@Phony.format('33142278186', :format => :+, :spaces => :-).should == '+33-1-42-27-81-86'@
-@Phony.formatted('43198110', :format => :international_relative, :spaces => :-).should == '0043-1-98110'@
+@Phony.format('43198110', :format => :international_relative, :spaces => :-).should == '0043-1-98110'@
-@Phony.formatted('4233841148', :format => :international_relative, :spaces => :-).should == '00423-384-11-48'@
+@Phony.format('4233841148', :format => :international_relative, :spaces => :-).should == '00423-384-11-48'@
h4(#national). National
-@Phony.formatted('41443643532', :format => :national).should == '044 364 35 32'@
+@Phony.format('41443643532', :format => :national).should == '044 364 35 32'@
-@Phony.formatted('41800112233', :format => :national).should == '0800 11 22 33'@
+@Phony.format('41800112233', :format => :national).should == '0800 11 22 33'@
-@Phony.formatted('43198110', :format => :national).should == '01 98110'@
+@Phony.format('43198110', :format => :national).should == '01 98110'@
h4(#local). Local
-@Phony.formatted('41443643532', :format => :local).should == '364 35 32'@
+@Phony.format('41443643532', :format => :local).should == '364 35 32'@
-@Phony.formatted('493038625454', :format => :local).should == '386 25454'@
+@Phony.format('493038625454', :format => :local).should == '386 25454'@
h3(#splitting). Splitting
View
4 lib/phony.rb
@@ -103,10 +103,10 @@ def split! phone_number
#
def format phone_number, options = {}
raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.format(number)." unless phone_number
- formatted! phone_number.dup, options
+ format! phone_number.dup, options
end
def format! phone_number, options = {}
- @codes.formatted phone_number, options
+ @codes.format phone_number, options
end
alias formatted format
alias formatted! format!
View
4 lib/phony/country_codes.rb
@@ -50,9 +50,11 @@ def split number
[cc, *country.split(rest)]
end
- def formatted number, options = {}
+ def format number, options = {}
format_cc_ndc_local options[:format], options[:spaces] || @default_space, *split(number)
end
+ alias formatted format
+
# Formats country code and national destination code.
#
def format_cc_ndc_local format, space, cc, zero, ndc, *parts
Something went wrong with that request. Please try again.