Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mrchucho/phony
base: 3851473b76
...
head fork: mrchucho/phony
compare: 47d7409034
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 15, 2011
@mrchucho Respect :spaces when removing trailing space(s) d0d9a83
@mrchucho Modified "default" so it can be used alone.
I'm not sure the best way to work "default" into the DSL since it's
effectively stating that there is only a CC+NDC and no Local part.
The DSL expects both.
47d7409
View
2  lib/phony/countries.rb
@@ -496,7 +496,7 @@
country '970', fixed(2) >> split(3,2,2) # Reserved
country '971', fixed(2) >> split(3,2,2) # United Arab Emirates
- country '972', fixed(2) >> split(3,2,2) # Israel (State of)
+ country '972', default # Israel (State of)
country '973', fixed(2) >> split(3,2,2) # Bahrain (Kingdom of)
country '974', fixed(2) >> split(3,2,2) # Qatar (State of)
country '975', fixed(2) >> split(3,2,2) # Bhutan (Kingdom of)
View
2  lib/phony/country_codes.rb
@@ -46,7 +46,7 @@ def format_cc_ndc_local format, space, cc, ndc, *parts
cc_ndc = format_cc_ndc(format, space, cc, ndc)
local = \
if parts.empty?
- cc_ndc = cc_ndc.slice(0...cc_ndc.size-1)
+ cc_ndc = cc_ndc.slice(0...cc_ndc.rindex(space.to_s))
EMPTY_STRING
else
format_local(space, parts) unless parts.empty?
View
2  lib/phony/dsl.rb
@@ -74,7 +74,7 @@ def match regex, options = {}
NationalSplitters::Regex.instance_for regex, options[:on_fail_take]
end
def default
- NationalSplitters::Default.instance_for
+ none >> NationalSplitters::Default.instance_for
end
# Local splitters.
View
8 spec/lib/phony_spec.rb
@@ -137,6 +137,9 @@
it 'should format as a single block, respecting custom spaces' do
Phony.format('8801819372205', :spaces => :-).should == '+880-1819372205'
end
+ it 'should format as a single block, even without spaces' do
+ Phony.format('8801819372205', :spaces => '').should == '+8801819372205'
+ end
end
end
describe "national" do
@@ -190,6 +193,11 @@
Phony.format('414436435').should == '+41 44 364 35'
end
end
+ context '"unsupported" countries' do
+ it 'handles normalizing, then formatting' do
+ Phony.format(Phony.normalize('+880-321 5560 5220')).should == '+880 32155605220'
+ end
+ end
end
context "speed" do

No commit comments for this range

Something went wrong with that request. Please try again.