Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
Jul 15, 2011
Ralph Churchill Respect :spaces when removing trailing space(s) d0d9a83
Ralph Churchill 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
2  lib/phony/countries.rb
@@ -496,7 +496,7 @@
496 496
497 497 country '970', fixed(2) >> split(3,2,2) # Reserved
498 498 country '971', fixed(2) >> split(3,2,2) # United Arab Emirates
499   - country '972', fixed(2) >> split(3,2,2) # Israel (State of)
  499 + country '972', default # Israel (State of)
500 500 country '973', fixed(2) >> split(3,2,2) # Bahrain (Kingdom of)
501 501 country '974', fixed(2) >> split(3,2,2) # Qatar (State of)
502 502 country '975', fixed(2) >> split(3,2,2) # Bhutan (Kingdom of)
2  lib/phony/country_codes.rb
@@ -46,7 +46,7 @@ def format_cc_ndc_local format, space, cc, ndc, *parts
46 46 cc_ndc = format_cc_ndc(format, space, cc, ndc)
47 47 local = \
48 48 if parts.empty?
49   - cc_ndc = cc_ndc.slice(0...cc_ndc.size-1)
  49 + cc_ndc = cc_ndc.slice(0...cc_ndc.rindex(space.to_s))
50 50 EMPTY_STRING
51 51 else
52 52 format_local(space, parts) unless parts.empty?
2  lib/phony/dsl.rb
@@ -74,7 +74,7 @@ def match regex, options = {}
74 74 NationalSplitters::Regex.instance_for regex, options[:on_fail_take]
75 75 end
76 76 def default
77   - NationalSplitters::Default.instance_for
  77 + none >> NationalSplitters::Default.instance_for
78 78 end
79 79
80 80 # Local splitters.
8 spec/lib/phony_spec.rb
@@ -137,6 +137,9 @@
137 137 it 'should format as a single block, respecting custom spaces' do
138 138 Phony.format('8801819372205', :spaces => :-).should == '+880-1819372205'
139 139 end
  140 + it 'should format as a single block, even without spaces' do
  141 + Phony.format('8801819372205', :spaces => '').should == '+8801819372205'
  142 + end
140 143 end
141 144 end
142 145 describe "national" do
@@ -190,6 +193,11 @@
190 193 Phony.format('414436435').should == '+41 44 364 35'
191 194 end
192 195 end
  196 + context '"unsupported" countries' do
  197 + it 'handles normalizing, then formatting' do
  198 + Phony.format(Phony.normalize('+880-321 5560 5220')).should == '+880 32155605220'
  199 + end
  200 + end
193 201 end
194 202
195 203 context "speed" do

No commit comments for this range

Something went wrong with that request. Please try again.