r2413 - in
packages/libnet-cidr-lite-perl/branches/upstream/current: . t
Niko Tyni
ntyni-guest at costa.debian.org
Fri Mar 17 22:21:43 UTC 2006
Author: ntyni-guest
Date: 2006-03-17 22:21:42 +0000 (Fri, 17 Mar 2006)
New Revision: 2413
Added:
packages/libnet-cidr-lite-perl/branches/upstream/current/META.yml
packages/libnet-cidr-lite-perl/branches/upstream/current/t/pod.t
packages/libnet-cidr-lite-perl/branches/upstream/current/t/podcov.t
Modified:
packages/libnet-cidr-lite-perl/branches/upstream/current/Changes
packages/libnet-cidr-lite-perl/branches/upstream/current/Lite.pm
packages/libnet-cidr-lite-perl/branches/upstream/current/MANIFEST
packages/libnet-cidr-lite-perl/branches/upstream/current/README
packages/libnet-cidr-lite-perl/branches/upstream/current/t/base.t
Log:
Load /tmp/tmp.qvnrvv/libnet-cidr-lite-perl-0.20 into
packages/libnet-cidr-lite-perl/branches/upstream/current.
Modified: packages/libnet-cidr-lite-perl/branches/upstream/current/Changes
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/Changes 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/Changes 2006-03-17 22:21:42 UTC (rev 2413)
@@ -1,5 +1,18 @@
Revision history for Perl extension Net::CIDR::Lite.
+0.20 Sun Feb 12 01:00:00 2006
+ - Fix error message on mask values.
+0.19 Sat Jan 30 01:00:00 2006
+ - Allow net mask of zero.
+0.18 Sat May 20 01:00:00 2005
+ - Documented bin_find().
+ - Added pod tests. Watch my kwalitee go up! Woohoo!
+0.17 Wed May 18 12:00:00 2005
+ - Fixed last fix and corresponding test.
+0.16 Wed May 18 10:00:00 2005
+ - Fixed divide by zero on find with empty spanner.
+ Reported by jgmyers via rt.cpan.org.
+ - Fixed pod errors.
0.15 Wed Apr 16 13:00:00 2003
- Fixed # of tests in test.pl. Thanks to CPAN testers.
- Squelched '-w' warning about doubly declared lexical variable.
Modified: packages/libnet-cidr-lite-perl/branches/upstream/current/Lite.pm
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/Lite.pm 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/Lite.pm 2006-03-17 22:21:42 UTC (rev 2413)
@@ -4,7 +4,7 @@
use vars qw($VERSION);
use Carp qw(confess);
-$VERSION = '0.15';
+$VERSION = '0.20';
my %masks;
my @fields = qw(PACK UNPACK NBITS MASKS);
@@ -37,7 +37,7 @@
my ($ip, $mask) = split "/", shift;
$self->_init($ip) || confess "Can't determine ip format" unless %$self;
confess "Bad mask $mask"
- unless $mask =~ /^\d+$/ and 2 <= $mask and $mask <= $self->{NBITS};
+ unless $mask =~ /^\d+$/ and $mask <= $self->{NBITS}-8;
$mask += 8;
my $start = $self->{PACK}->($ip) & $self->{MASKS}[$mask]
or confess "Bad ip address: $ip";
@@ -294,12 +294,12 @@
Net::CIDR::Lite::Span->new(@_);
}
-sub ranges {
+sub _ranges {
sort keys %{shift->{RANGES}};
}
-sub packer { shift->{PACK} }
-sub unpacker { shift->{UNPACK} }
+sub _packer { shift->{PACK} }
+sub _unpacker { shift->{UNPACK} }
package Net::CIDR::Lite::Span;
use Carp qw(confess);
@@ -315,14 +315,14 @@
my $self = shift;
my $ranges = $self->{RANGES};
if (@_ && !$self->{PACK}) {
- $self->{PACK} = $_[0]->packer;
- $self->{UNPACK} = $_[0]->unpacker;
+ $self->{PACK} = $_[0]->_packer;
+ $self->{UNPACK} = $_[0]->_unpacker;
}
while (@_) {
my ($cidr, $label) = (shift, shift);
$cidr = Net::CIDR::Lite->new($cidr) unless ref($cidr);
$cidr->clean;
- for my $ip ($cidr->ranges) {
+ for my $ip ($cidr->_ranges) {
push @{$ranges->{$ip}}, $label;
}
}
@@ -337,6 +337,7 @@
my $in_range;
$self->prep_find unless $self->{FIND};
return {} unless @_;
+ return { map { $_ => {} } @_ } unless @{$self->{FIND}};
return $self->bin_find(@_) if @_/@{$self->{FIND}} < $self->{PCT};
my @ips = sort map { $pack->($_) || confess "Bad IP: $_" } @_;
my $last;
@@ -359,6 +360,7 @@
my $self = shift;
return {} unless @_;
$self->prep_find unless $self->{FIND};
+ return { map { $_ => {} } @_ } unless @{$self->{FIND}};
my $pack = $self->{PACK};
my $unpack = $self->{UNPACK};
my $find = $self->{FIND};
@@ -438,6 +440,8 @@
=head1 METHODS
+=over 4
+
=item new()
$cidr = Net::CIDR::Lite->new
@@ -518,6 +522,10 @@
but if more addresses are added to the cidr object, prep_find() must
be called on the cidr object.
+=item $cidr->bin_find()
+
+Same as find(), but forces a binary search. See also prep_find.
+
=item $cidr->prep_find()
$cidr->prep_find($num);
@@ -550,9 +558,13 @@
$href = $spanner->find(@ip_addresses);
Look up which range(s) ip addresses are in, and return a lookup table
-of the results, with the keys being the ip addresses, and the value an
+of the results, with the keys being the ip addresses, and the value a
hash reference of which address ranges the ip address is in.
+=item $spanner->bin_find()
+
+Same as find(), but forces a binary search. See also prep_find.
+
=item $spanner->prep_find()
$spanner->prep_find($num);
@@ -572,6 +584,8 @@
unnecessary leading zeros, removes null blocks from IPv6
addresses, etc.
+=back
+
=head1 CAVEATS
Garbage in/garbage out. This module does do validation, but maybe
Modified: packages/libnet-cidr-lite-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/MANIFEST 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/MANIFEST 2006-03-17 22:21:42 UTC (rev 2413)
@@ -2,5 +2,8 @@
Lite.pm
Makefile.PL
MANIFEST
+META.yml
README
-test.pl
+t/base.t
+t/pod.t
+t/podcov.t
Added: packages/libnet-cidr-lite-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/META.yml 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/META.yml 2006-03-17 22:21:42 UTC (rev 2413)
@@ -0,0 +1,10 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Net-CIDR-Lite
+version: 0.20
+version_from: Lite.pm
+installdirs: site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Modified: packages/libnet-cidr-lite-perl/branches/upstream/current/README
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/README 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/README 2006-03-17 22:21:42 UTC (rev 2413)
@@ -10,7 +10,7 @@
make test
make install
-See tests (in the test.pl file) for an example.
+See tests (in the test.pl file) for examples.
COPYRIGHT AND LICENCE
Modified: packages/libnet-cidr-lite-perl/branches/upstream/current/t/base.t
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/t/base.t 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/t/base.t 2006-03-17 22:21:42 UTC (rev 2413)
@@ -8,9 +8,9 @@
use Test;
use strict;
$|++;
-BEGIN { plan tests => 28 };
+BEGIN { plan tests => 34 };
use Net::CIDR::Lite;
-ok(1); # If we made it this far, we're ok.
+ok(1); # If we made it this far, we are ok.
#########################
@@ -92,3 +92,22 @@
my @list_zero = Net::CIDR::Lite->new('0.0.0.0/32')->list_range;
ok(scalar(@list_zero), 1);
ok($list_zero[0], '0.0.0.0-0.0.0.0');
+
+my @list_all = Net::CIDR::Lite->new('0.0.0.0/0')->list_range;
+ok(scalar(@list_all), 1);
+ok($list_all[0], '0.0.0.0-255.255.255.255');
+
+# Empty result from spanner find
+my $empty_cidr = Net::CIDR::Lite->new();
+my $empty_spanner = $empty_cidr->spanner();
+my $empty_href = $empty_spanner->find("127.0.0.1");
+ok(ref($empty_href), 'HASH');
+ok(ref($empty_href->{"127.0.0.1"}), 'HASH');
+ok(! %{$empty_href->{"127.0.0.1"}});
+
+# Bad addr test
+my $err_cidr = Net::CIDR::Lite->new;
+$err_cidr->add("209.152.214.112/30");
+eval { $err_cidr->add("209.152.214.112/33") };
+ok($@ =~ /Bad mask/);
+
Added: packages/libnet-cidr-lite-perl/branches/upstream/current/t/pod.t
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/t/pod.t 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/t/pod.t 2006-03-17 22:21:42 UTC (rev 2413)
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+
+use strict;
+
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
Added: packages/libnet-cidr-lite-perl/branches/upstream/current/t/podcov.t
===================================================================
--- packages/libnet-cidr-lite-perl/branches/upstream/current/t/podcov.t 2006-03-17 22:21:38 UTC (rev 2412)
+++ packages/libnet-cidr-lite-perl/branches/upstream/current/t/podcov.t 2006-03-17 22:21:42 UTC (rev 2413)
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+
+use strict;
+
+use Test::More;
+eval "use Test::Pod::Coverage";
+plan skip_all => "Test::Pod::Coverage required for testing pod coverage" if $@;
+all_pod_coverage_ok();
More information about the Pkg-perl-cvs-commits
mailing list