Permalink
Browse files

Fix formatting bug in UK; new UK allocations; fix test that relied on…

… a telco that changed its name
  • Loading branch information...
1 parent 2e769bb commit 3205f71fa15df1f31151fa6d29d58b03a6f06416 drhyde committed Feb 26, 2009
Showing with 27 additions and 12 deletions.
  1. +5 −0 CHANGELOG
  2. +1 −1 Makefile.PL
  3. +1 −1 build-data.realwork
  4. +1 −1 lib/Number/Phone.pm
  5. +6 −7 lib/Number/Phone/UK.pm
  6. +13 −2 t/01_uk_data.t
View
@@ -1,3 +1,8 @@
+XXXX-XX-XX 1.7 Fix formatting for valid but unallocated UK numbers;
+ One of the UK telcos whose name we check for in
+ tests renamed itself;
+ New UK allocations;
+
2008-05-27 1.6 Magic country detection now works (thanks to
Jos Boumans for reporting the bug);
New UK allocations
View
@@ -2,7 +2,7 @@ use 5.006;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Number::Phone',
- VERSION => 1.6,
+ VERSION_FROM => 'lib/Number/Phone.pm',
PREREQ_PM => {
'Scalar::Util' => 0,
'Test::More' => 0,
View
@@ -225,7 +225,7 @@ foreach my $datum (@telco_length_data) {
$format = '0+10';
} elsif($format =~ /^7 digit number/i) {
$format = '0+7';
- } elsif($format =~ /^9 digit number/i) {
+ } elsif($format =~ /^9 +digit number/i) {
$format = '0+9';
} elsif($format eq 'RTO') {
$format = '?';
View
@@ -6,7 +6,7 @@ use Scalar::Util 'blessed';
use Number::Phone::Country qw(noexport uk);
-our $VERSION = 1.6;
+our $VERSION = 1.7;
my @is_methods = qw(
is_valid is_allocated is_in_use
View
@@ -7,7 +7,7 @@ use Number::Phone::UK::Data;
use base 'Number::Phone';
-our $VERSION = 1.551;
+our $VERSION = 1.552;
my $cache = {};
@@ -70,7 +70,6 @@ sub is_valid {
$cache->{$number}->{is_valid} = (length($parsed_number) > 6 && length($parsed_number) < 11) ? 1 : 0;
return 0 unless($cache->{$number}->{is_valid});
- # die(Dumper($Number::Phone::UK::Data::db->{geo_prefices}));
$cache->{$number}->{is_fixed_line} =
$cache->{$number}->{is_geographic} =
grep { $Number::Phone::UK::Data::db->{geo_prefices}->{$_} } @retards;
@@ -115,8 +114,6 @@ sub is_valid {
}
}
}
- # use Data::Dumper;
- # print Dumper($Number::Phone::UK::Data::db);
return $cache->{$number}->{is_valid};
}
@@ -284,9 +281,11 @@ sub format {
$self = (blessed($self) && $self->isa(__PACKAGE__)) ?
$self :
__PACKAGE__->new($self);
- return '+'.country_code().' '.
- ($self->areacode() ? $self->areacode().' ' : '').
- $self->subscriber();
+ return '+'.country_code().' '.(
+ $self->areacode() ? $self->areacode().' '.$self->subscriber() :
+ !$self->is_allocated() ? substr(${$self}, 1 + length(country_code()))
+ : $self->subscriber()
+ );
}
=item country
View
@@ -6,7 +6,7 @@ use strict;
use Number::Phone::UK;
-BEGIN { $| = 1; print "1..59\n"; }
+BEGIN { $| = 1; print "1..61\n"; }
my $test = 0;
@@ -98,8 +98,9 @@ print 'not ' unless($number->is_network_service());
print 'ok '.(++$test)." network service numbers correctly identified\n";
$number = Number::Phone->new('+448450033845');
-print 'not ' unless($number->operator() eq 'Interweb Design Ltd');
+print 'not ' unless($number->operator() eq 'Edge Telecom Ltd');
print 'ok '.(++$test)." operators correctly identified\n";
+print '# '.$number->operator()."\n";
print 'not ' if(defined($number->areaname()));
print 'ok '.(++$test)." good, no area name for non-geographic numbers\n";
@@ -161,3 +162,13 @@ print 'not ' unless($number->operator() eq 'Vodafone Ltd');
print 'ok '.(++$test)." 075 mobiles have right operator\n";
print 'not ' unless($number->format() eq '+44 7500000000');
print 'ok '.(++$test)." 075 mobiles have right operator\n";
+
+print "# bugfixes\n";
+
+$number = Number::Phone->new('+441954123456');
+print 'not ' unless($number->format() eq '+44 1954123456');
+print 'ok '.(++$test)." unallocated numbers format OK\n";
+
+$number = Number::Phone->new('+441954202020');
+print 'not ' unless($number->format() eq '+44 1954 202020');
+print 'ok '.(++$test)." allocated numbers format OK\n";

0 comments on commit 3205f71

Please sign in to comment.