phony 1.7.3 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -71,6 +71,6 @@ Phony.define do
71
71
  one_of(ndcs_with_6_subscriber_digits) >> split(6) |
72
72
  one_of(freefone) >> split(6) |
73
73
  match(/^(8\d).+$/) >> split(3,4) | # mobile
74
- none >> split(0)
74
+ fixed(3) >> split(6)
75
75
 
76
76
  end
@@ -73,7 +73,9 @@ module Phony
73
73
  @international_relative_format % [cc, space, ndc] :
74
74
  @international_relative_format % [cc, nil, nil]
75
75
  when :national
76
- (ndc.empty? ? EMPTY_STRING : @national_format) % [zero, ndc]
76
+ ndc && !ndc.empty? ?
77
+ @national_format % [zero, ndc] :
78
+ @national_format % [zero, nil]
77
79
  when :local
78
80
  EMPTY_STRING
79
81
  end
@@ -49,6 +49,7 @@ module Phony
49
49
  # Element based checking.
50
50
  #
51
51
  return false unless ndc
52
+ return false if ndc.empty?
52
53
 
53
54
  # CC.
54
55
  #
@@ -121,7 +121,7 @@ describe 'country descriptions' do
121
121
  Phony.split('353801234567').should == ['353', '80', '123', '4567'] # Mobile
122
122
  Phony.split('353761234567').should == ['353', '76', '123', '4567'] # VoIP
123
123
  Phony.split('353800123456').should == ['353', '800', '123456'] # Freefone
124
- Phony.split('353000123456').should == ['353', nil, '000123456'] # No NDC/local split for unrecognized
124
+ Phony.split('353000123456').should == ['353', '000', '123456'] # Default fixed 3 split for unrecognized
125
125
  end
126
126
  it 'handles italian numbers' do
127
127
  Phony.split('3934869528').should == ['39', '3486', '952', '8'] # Mobile
@@ -62,6 +62,14 @@ describe Phony::CountryCodes do
62
62
  it 'formats correctly' do
63
63
  @countries.formatted('41443643532', :format => :national, :spaces => :-).should == '044-364-35-32'
64
64
  end
65
+ context 'specific' do
66
+ it 'formats ireland correctly' do
67
+ @countries.formatted("3533451234", :format => :national).should == '0345 1234'
68
+ end
69
+ it 'formats ireland correctly' do
70
+ @countries.formatted("353411231234", :format => :national).should == '041 123 1234'
71
+ end
72
+ end
65
73
  context 'default' do
66
74
  it "should format swiss numbers" do
67
75
  @countries.formatted('41443643532').should == '+41 44 364 35 32'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: