r27596 - in /branches/upstream/libgeo-ipfree-perl/current: Changes META.yml lib/Geo/IPfree.pm t/basic.t

bricas-guest at users.alioth.debian.org bricas-guest at users.alioth.debian.org
Mon Dec 1 20:29:20 UTC 2008


Author: bricas-guest
Date: Mon Dec  1 20:29:17 2008
New Revision: 27596

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=27596
Log:
[svn-upgrade] Integrating new upstream version, libgeo-ipfree-perl (0.4)

Modified:
    branches/upstream/libgeo-ipfree-perl/current/Changes
    branches/upstream/libgeo-ipfree-perl/current/META.yml
    branches/upstream/libgeo-ipfree-perl/current/lib/Geo/IPfree.pm
    branches/upstream/libgeo-ipfree-perl/current/t/basic.t

Modified: branches/upstream/libgeo-ipfree-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgeo-ipfree-perl/current/Changes?rev=27596&op=diff
==============================================================================
--- branches/upstream/libgeo-ipfree-perl/current/Changes (original)
+++ branches/upstream/libgeo-ipfree-perl/current/Changes Mon Dec  1 20:29:17 2008
@@ -1,14 +1,17 @@
 Revision history for Perl extension Geo::IPfree.
-
-0.3 Nov 19 2008
-    - Add webgeo2ipct script (RT #40938)
-    - Add new data file (RT #40938, #7663)
-    - Fix all warnings (RT #24333)
-    - Handle hosts that fail nslookup (RT #18434)
-    - find_db_file() now looks in user-overridable locations before looking
-      for the shipped version.
-    - /tmp removed from possible db locations.
-    - Dist cleanup.
+
+0.4 Dec 01 2008
+    - fix "undef" test
+
+0.3 Nov 19 2008
+    - Add webgeo2ipct script (RT #40938)
+    - Add new data file (RT #40938, #7663)
+    - Fix all warnings (RT #24333)
+    - Handle hosts that fail nslookup (RT #18434)
+    - find_db_file() now looks in user-overridable locations before looking
+      for the shipped version.
+    - /tmp removed from possible db locations.
+    - Dist cleanup.
 
 0.2 Sat Mar 22 18:10 2003
     - Change sysread() to read() for better portability.
@@ -20,4 +23,4 @@
    
 0.01  Sun Oct 20 01:07:01 2002
     - Released the 1st version!
-
+

Modified: branches/upstream/libgeo-ipfree-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgeo-ipfree-perl/current/META.yml?rev=27596&op=diff
==============================================================================
--- branches/upstream/libgeo-ipfree-perl/current/META.yml (original)
+++ branches/upstream/libgeo-ipfree-perl/current/META.yml Mon Dec  1 20:29:17 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Geo-IPfree
-version:             0.3
+version:             0.4
 abstract:            Look up country of IP Address. This module make this off-line and the DB of IPs is free & small.
 license:             perl
 author:              

Modified: branches/upstream/libgeo-ipfree-perl/current/lib/Geo/IPfree.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgeo-ipfree-perl/current/lib/Geo/IPfree.pm?rev=27596&op=diff
==============================================================================
--- branches/upstream/libgeo-ipfree-perl/current/lib/Geo/IPfree.pm (original)
+++ branches/upstream/libgeo-ipfree-perl/current/lib/Geo/IPfree.pm Mon Dec  1 20:29:17 2008
@@ -21,13 +21,13 @@
 use 5.006;
 use Memoize;
 use Carp qw() ;
-use strict qw(vars) ;
+use strict qw(vars) ;
 use warnings;
 
 require Exporter;
 our @ISA = qw(Exporter);
 
-our $VERSION = '0.3';
+our $VERSION = '0.4';
 
 our @EXPORT = qw(LookUp LoadDB) ;
 our @EXPORT_OK = @EXPORT ;
@@ -65,10 +65,7 @@
 
 my $cache_expire = 1000 ;
 
-####################
-# DECLARE BASE LIB #
-####################
-
+# DECLARE BASE LIB
 {
   my $c = 0 ;
   %baseX = map { $_ => ($c++) } @baseX ;
@@ -77,10 +74,6 @@
   foreach my $Key ( keys %countrys ) { $countrys{$Key} =~ s/_/ /gs ;}
 }
 
-#######
-# NEW #
-#######
-
 sub new {
   my ($class, $db_file) = @_ ;
 
@@ -103,10 +96,6 @@
   return( $this ) ;
 }
 
-##########
-# LOADDB #
-##########
-
 sub LoadDB {
   my $this = shift ;
   my ( $db_file ) = @_ ;
@@ -117,7 +106,7 @@
 
   $this->{db} = $db_file ;
 
-  my ($handler,$buffer) ;
+  my ($handler,$buffer) ;
   $buffer=0;
   open($handler,$db_file) || Carp::croak("Failed to open database file $db_file for read!") ;
   binmode($handler) ;
@@ -143,10 +132,6 @@
   $this->{handler} = $handler ;
 }
 
-##########
-# LOOKUP #
-##########
-
 sub LookUp {
   my $this ;
   
@@ -163,8 +148,8 @@
   $ip =~ s/\.$// ;
   
   if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { $ip = nslookup($ip) ;}
-
-  return unless length $ip;
+
+  return unless length $ip;
 
   ## Since the last class is always from the same country, will try 0 and cache 0:
   my $ip_class = $ip ;
@@ -212,10 +197,6 @@
   return( $country , $countrys{$country} , $ip_class ) ;
 }
 
-##########
-# FASTER #
-##########
-
 sub Faster {
   my $this = shift ;
   
@@ -235,57 +216,36 @@
   $this->{FASTER} = 1 ;
 }
 
-###############
-# CLEAN_CACHE #
-###############
-
 sub Clean_Cache { delete $_[0]->{CACHE} ; 1 ;}
-
-############
-# NSLOOKUP #
-############
 
 sub nslookup {
   my ( $host ) = @_ ;
   require Socket ;
-  my $iaddr = Socket::inet_aton($host) ;
+  my $iaddr = Socket::inet_aton($host) ;
   $iaddr = '' if !defined $iaddr;
   my @ip = unpack('C4',$iaddr) ;
   if (! @ip && ! $_[1]) { return( &nslookup("www.$host",1) ) ;}
   return( join (".", at ip) ) ;
 }
 
-################
-# FIND_DB_FILE #
-################
-
 sub find_db_file {
-  my @locations = ( qw(/usr/local/share /usr/local/share/GeoIPfree),
-    map { $_, "$_/Geo" } @INC );
-
-  # lastly, find where this module was loaded, and try that dir
-  my ( $lib ) = ( $INC{'Geo/IPfree.pm'} =~ /^(.*?)[\\\/]+[^\\\/]+$/gs );
-  push @locations, $lib;
-
-  for my $file ( map { "$_/$def_db" } @locations ) {
-    return $file if -e $file;
-  }
-}
-
-
-#########
-# IP2NB #
-#########
+  my @locations = ( qw(/usr/local/share /usr/local/share/GeoIPfree),
+    map { $_, "$_/Geo" } @INC );
+
+  # lastly, find where this module was loaded, and try that dir
+  my ( $lib ) = ( $INC{'Geo/IPfree.pm'} =~ /^(.*?)[\\\/]+[^\\\/]+$/gs );
+  push @locations, $lib;
+
+  for my $file ( map { "$_/$def_db" } @locations ) {
+    return $file if -e $file;
+  }
+}
 
 sub ip2nb {
   my @ip = split(/\./ , $_[0]) ;
   #return( 16777216* $ip[0] + 65536* $ip[1] + 256* $ip[2] + $ip[3] ) ;
   return( ($ip[0]<<24) + ($ip[1]<<16) + ($ip[2]<<8) + $ip[3] ) ;
 }
-
-#########
-# NB2IP #
-#########
 
 sub nb2ip {
   my ( $ipn ) = @_ ;
@@ -311,10 +271,6 @@
   return( join (".", @ip) ) ;
 }
  
-#############
-# DEC2BASEX #
-#############
-
 sub dec2baseX {
   my ( $dec ) = @_ ;
   
@@ -341,10 +297,6 @@
   return( $baseX ) ;
 }
 
-#############
-# BASEX2DEC #
-#############
-
 sub baseX2dec {
   my ( $baseX ) = @_ ;
   
@@ -360,10 +312,6 @@
   return( $dec ) ;
 }
 
-#######
-# END #
-#######
-
 1;
 
 __END__
@@ -478,20 +426,20 @@
 =head1 NOTES
 
 The file ipscountry.dat is made only for Geo::IPfree and has their own format.
-To convert it see the tool "ipct2txt.pl" in the C<misc> directoy.
-
-The module looks for C<ipscountry.dat> in the following locations:
-
-=over 4
-
-=item * /usr/local/share
-
-=item * /usr/local/share/GeoIPfree
-
-=item * through @INC (as well as all @INC directories plus "/Geo")
-
-=item * from the same location that IPfree.pm was loaded
-
+To convert it see the tool "ipct2txt.pl" in the C<misc> directoy.
+
+The module looks for C<ipscountry.dat> in the following locations:
+
+=over 4
+
+=item * /usr/local/share
+
+=item * /usr/local/share/GeoIPfree
+
+=item * through @INC (as well as all @INC directories plus "/Geo")
+
+=item * from the same location that IPfree.pm was loaded
+
 =back
 
 =head1 AUTHOR

Modified: branches/upstream/libgeo-ipfree-perl/current/t/basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libgeo-ipfree-perl/current/t/basic.t?rev=27596&op=diff
==============================================================================
--- branches/upstream/libgeo-ipfree-perl/current/t/basic.t (original)
+++ branches/upstream/libgeo-ipfree-perl/current/t/basic.t Mon Dec  1 20:29:17 2008
@@ -1,41 +1,42 @@
 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 11;
 
-use Geo::IPfree;
-
+use Geo::IPfree;
 
-{ # localhost
-    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("127.0.0.1") ;
+
+{ # localhost
+    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("127.0.0.1") ;
     is($country,'ZZ');
-    ok(!defined $country_name);
-}
-
-{ # intranet
-    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("10.0.0.1") ;
-    is($country,'ZZ');
-    ok(!defined $country_name);
-}
-
-{ # www.nic.br
-    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("200.160.7.2") ;
-    is($country,'BR');
-    is($country_name, 'Brazil');
+    ok(!defined $country_name);
 }
 
-{ # www.nic.us
-    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("209.173.53.26") ;
-    is($country,'US');
-    is($country_name, 'United States');
+{ # intranet
+    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("10.0.0.1") ;
+    is($country,'ZZ');
+    ok(!defined $country_name);
 }
-
-{ # www.nic.fr
-    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("192.134.4.20") ;
+
+{ # www.nic.br
+    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("200.160.7.2") ;
+    is($country,'BR');
+    is($country_name, 'Brazil');
+}
+
+{ # www.nic.us
+    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("209.173.53.26") ;
+    is($country,'US');
+    is($country_name, 'United States');
+}
+
+{ # www.nic.fr
+    my ($country,$country_name,$ip) = Geo::IPfree::LookUp("192.134.4.20") ;
     is($country,'EU');
-    is($country_name, 'Europe');
+    is($country_name, 'Europe');
 }
 
 { # does not exist
-    ok( !defined Geo::IPfree::LookUp('dne.undef') );
+    my @result = Geo::IPfree::LookUp('dne.undef');
+    is( scalar @result, 0, 'undef result' );
 }




More information about the Pkg-perl-cvs-commits mailing list