r2793 - in /packages/libdata-types-perl/trunk: Changes MANIFEST META.yml Makefile.PL README debian/changelog debian/control debian/rules lib/Data/Types.pm t/types.t t/zpod.t

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Tue May 23 13:45:26 UTC 2006


Author: eloy
Date: Tue May 23 13:45:26 2006
New Revision: 2793

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2793
Log:
eloy: new upstream version

Added:
    packages/libdata-types-perl/trunk/t/zpod.t
      - copied unchanged from r2792, packages/libdata-types-perl/branches/upstream/current/t/zpod.t
Modified:
    packages/libdata-types-perl/trunk/Changes
    packages/libdata-types-perl/trunk/MANIFEST
    packages/libdata-types-perl/trunk/META.yml
    packages/libdata-types-perl/trunk/Makefile.PL
    packages/libdata-types-perl/trunk/README
    packages/libdata-types-perl/trunk/debian/changelog
    packages/libdata-types-perl/trunk/debian/control
    packages/libdata-types-perl/trunk/debian/rules
    packages/libdata-types-perl/trunk/lib/Data/Types.pm
    packages/libdata-types-perl/trunk/t/types.t

Modified: packages/libdata-types-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/Changes?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/Changes (original)
+++ packages/libdata-types-perl/trunk/Changes Tue May 23 13:45:26 2006
@@ -1,4 +1,15 @@
 Revision history for Perl extension Data::Types.
+
+0.06  2006-05-23T00:45:44
+        - Added POD tests.
+        - Backwards compatibility change: Whole numbers now include 0. This is
+          more inline with accepted mathmatical definitions. See, e.g.,
+          http://en.wikipedia.org/wiki/Whole_number
+          http://mathforum.org/library/drmath/view/57052.html
+        - Added is_count() and to_count() to match whole numbers exclusive of
+          zero. These functions match the previous behavior of is_whole() and
+          to_whole().
+        - Fixed a typo in my email address.
 
 0.05    Tue Aug 26 01:21:03 2003
         - Switched to Module::Build.

Modified: packages/libdata-types-perl/trunk/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/MANIFEST?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/MANIFEST (original)
+++ packages/libdata-types-perl/trunk/MANIFEST Tue May 23 13:45:26 2006
@@ -1,8 +1,9 @@
 Build.PL
 Changes
+lib/Data/Types.pm
+Makefile.PL
 MANIFEST			This list of files
 META.yml
-Makefile.PL
 README
-lib/Data/Types.pm
 t/types.t
+t/zpod.t

Modified: packages/libdata-types-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/META.yml?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/META.yml (original)
+++ packages/libdata-types-perl/trunk/META.yml Tue May 23 13:45:26 2006
@@ -1,14 +1,17 @@
---- #YAML:1.0
+---
 name: Data-Types
-version: 0.05
+version: 0.06
+author:
+  - 'David Wheeler <david at kineticode.com>'
+abstract: Validate and convert data types.
 license: perl
-distribution_type: module
-requires: {}
-recommends: {}
-build_requires: {}
-conflicts: {}
+resources:
+  license: http://dev.perl.org/licenses/
 provides:
   Data::Types:
     file: lib/Data/Types.pm
-    version: 0.05
-generated_by: Module::Build version 0.19_05
+    version: 0.06
+generated_by: Module::Build version 0.2801
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.2.html
+  version: 1.2

Modified: packages/libdata-types-perl/trunk/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/Makefile.PL?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/Makefile.PL (original)
+++ packages/libdata-types-perl/trunk/Makefile.PL Tue May 23 13:45:26 2006
@@ -1,4 +1,5 @@
-
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+    
     unless (eval "use Module::Build::Compat 0.02; 1" ) {
       print "This module requires Module::Build to install itself.\n";
       
@@ -7,22 +8,24 @@
 	('  Install Module::Build now from CPAN?', 'y');
       
       unless ($yn =~ /^y/i) {
-	warn " *** Cannot install without Module::Build.  Exiting ...\n";
-	exit 1;
+	die " *** Cannot install without Module::Build.  Exiting ...\n";
       }
-
+      
       require Cwd;
       require File::Spec;
       require CPAN;
       
       # Save this 'cause CPAN will chdir all over the place.
       my $cwd = Cwd::cwd();
-      my $makefile = File::Spec->rel2abs($0);
       
       CPAN::Shell->install('Module::Build::Compat');
+      CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
+	or die "Couldn't install Module::Build, giving up.\n";
       
       chdir $cwd or die "Cannot chdir() back to $cwd: $!";
-      exec $^X, $makefile, @ARGV;  # Redo now that we have Module::Build
     }
+    eval "use Module::Build::Compat 0.02; 1" or die $@;
+    
     Module::Build::Compat->run_build_pl(args => \@ARGV);
-    Module::Build::Compat->write_makefile();
+    require Module::Build;
+    Module::Build::Compat->write_makefile(build_class => 'Module::Build');

Modified: packages/libdata-types-perl/trunk/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/README?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/README (original)
+++ packages/libdata-types-perl/trunk/README Tue May 23 13:45:26 2006
@@ -1,4 +1,4 @@
-Data/Types version 0.05
+Data/Types version 0.06
 =======================
 
 This module exports a number of functions that are useful for validating and
@@ -28,7 +28,7 @@
 
 COPYRIGHT AND LICENCE
 
-Copyright (c) 2002-2003, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2006, David Wheeler. All Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under the
 same terms as Perl itself.

Modified: packages/libdata-types-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/debian/changelog?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/debian/changelog (original)
+++ packages/libdata-types-perl/trunk/debian/changelog Tue May 23 13:45:26 2006
@@ -1,3 +1,11 @@
+libdata-types-perl (0.06-1) unstable; urgency=low
+
+  * New upstream release
+  * debian/control:
+   - Standards-Version: increased to 3.7.2 without additional changes
+
+ -- Krzysztof Krzyzaniak (eloy) <eloy at debian.org>  Tue, 23 May 2006 15:38:35 +0200
+
 libdata-types-perl (0.05-1) unstable; urgency=low
 
   * Initial Release (closes: #258094).

Modified: packages/libdata-types-perl/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/debian/control?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/debian/control (original)
+++ packages/libdata-types-perl/trunk/debian/control Tue May 23 13:45:26 2006
@@ -4,7 +4,7 @@
 Build-Depends-Indep: perl (>= 5.8.0-7), debhelper (>= 4.0.2), libmodule-build-perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
 Uploaders: Krzysztof Krzyzaniak (eloy) <eloy at debian.org>
-Standards-Version: 3.6.2
+Standards-Version: 3.7.2
 
 Package: libdata-types-perl
 Architecture: all

Modified: packages/libdata-types-perl/trunk/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/debian/rules?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/debian/rules (original)
+++ packages/libdata-types-perl/trunk/debian/rules Tue May 23 13:45:26 2006
@@ -7,13 +7,7 @@
 # It was later modified by Jason Kohles <email at jasonkohles.com>
 # http://www.jasonkohles.com/ to support Module::Build installed modules
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-# If set to a true value then MakeMaker's prompt function will
-# always return the default without waiting for user input.
 export PERL_MM_USE_DEFAULT=1
-
 PACKAGE=$(shell dh_listpackages)
 
 ifndef PERL
@@ -25,20 +19,14 @@
 build: build-stamp
 build-stamp:
 	dh_testdir
-
-	# Add commands to compile the package here
 	$(PERL) Build.PL installdirs=vendor
 	OPTIMIZE="-Wall -O2 -g" $(PERL) Build
-
 	touch build-stamp
 
 clean:
 	dh_testdir
 	dh_testroot
-
-	# Add commands to clean up after the build process here
 	[ ! -f Build ] || $(PERL) Build distclean
-
 	dh_clean build-stamp install-stamp
 
 install: build install-stamp
@@ -46,11 +34,8 @@
 	dh_testdir
 	dh_testroot
 	dh_clean -k
-
-	# Add commands to install the package into debian/$PACKAGE_NAME here
 	$(PERL) Build test
 	$(PERL) Build install destdir=$(TMP)
-
 	touch install-stamp
 
 binary-arch:
@@ -59,8 +44,6 @@
 binary-indep: build install
 	dh_testdir
 	dh_testroot
-#	dh_installcron
-#	dh_installmenu
 #	dh_installexamples
 	dh_installdocs README
 	dh_installchangelogs Changes

Modified: packages/libdata-types-perl/trunk/lib/Data/Types.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/lib/Data/Types.pm?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/lib/Data/Types.pm (original)
+++ packages/libdata-types-perl/trunk/lib/Data/Types.pm Tue May 23 13:45:26 2006
@@ -4,27 +4,27 @@
 require Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
-$VERSION = '0.05';
+$VERSION = '0.06';
 
 @ISA = qw(Exporter);
 
- at EXPORT_OK = qw(is_whole to_whole is_int to_int is_real to_real is_decimal
-                to_decimal is_float to_float is_string to_string
-);
+ at EXPORT_OK = qw(is_whole to_whole is_count to_count is_int to_int is_real
+                to_real is_decimal to_decimal is_float to_float is_string
+                to_string );
 
 @EXPORT = qw();
 
-%EXPORT_TAGS = ( all     => \@EXPORT_OK,
-		 whole   => [qw(is_whole to_whole)],
-		 int     => [qw(is_int to_int)],
-		 decimal => [qw(is_decimal to_decimal)],
-		 real    => [qw(is_real to_real)],
-		 float   => [qw(is_float to_float)],
-		 string  => [qw(is_string to_string)],
-		 is      => [qw(is_whole is_int is_real is_decimal is_float
-                                is_string)],
-		 to      => [qw(to_whole to_int to_real to_decimal to_float
-                                to_string)]
+%EXPORT_TAGS = (
+    all     => \@EXPORT_OK,
+    whole   => [qw(is_whole to_whole)],
+    count   => [qw(is_count to_count)],
+    int     => [qw(is_int to_int)],
+    decimal => [qw(is_decimal to_decimal)],
+    real    => [qw(is_real to_real)],
+    float   => [qw(is_float to_float)],
+    string  => [qw(is_string to_string)],
+    is      => [qw(is_whole is_int is_real is_decimal is_float is_string)],
+    to      => [qw(to_whole to_int to_real to_decimal to_float to_string)],
 );
 
 use constant DEF_PRECISION => 5;
@@ -34,12 +34,25 @@
 ################################################################################
 
 sub is_whole ($) {
+    return unless defined $_[0];
+    return unless $_[0] =~ /^\d+$/;
+    return 1;
+}
+
+sub to_whole ($) {
+    return unless defined $_[0];
+    my ($num) = $_[0] =~ /([+-]?(?:\d+(?:\.\d*)?|\.\d+))/;
+    return unless defined $num && $num >= 0;
+    sprintf "%.0f", $num;
+}
+
+sub is_count ($) {
     return unless $_[0];
     return unless $_[0] =~ /^\d+$/;
     return 1;
 }
 
-sub to_whole ($) {
+sub to_count ($) {
     return unless $_[0];
     my ($num) = $_[0] =~ /([+-]?(?:\d+(?:\.\d*)?|\.\d+))/;
     return unless $num && $num > .5;
@@ -160,6 +173,10 @@
 
 Exports is_whole() and to_whole().
 
+=item :count
+
+Exports is_count() and to_count().
+
 =item :int
 
 Exports is_int() and to_int().
@@ -202,29 +219,57 @@
 
   my $bool = is_whole($val);
 
-Returns true if $val is a whole number (exclusive of 0), and false if it is not.
+Returns true if $val is a whole number (including 0), and false if it is not.
 The regular expression used to test the wholeness of $val is C</^\d+$/>.
 
   my $bool = is_whole(1); # Returns true.
   $bool = is_whole(-1);   # Returns false.
-  $bool = is_whole(0);    # Returns false.
+  $bool = is_whole(0);    # Returns true.
 
 =head2 to_whole
 
   my $whole = to_whole($val);
 
 Converts $val to a whole number and returns it. Numbers will be rounded to the
-nearest whole. Note that since 0 (zero) is not considered a whole number by this
-module, it will not be returned. If $val is a mixture of numbers and letters,
-to_whole() will extract the first decimal number it finds and convert that
-number to a whole number.
+nearest whole. If $val is a mixture of numbers and letters, to_whole() will
+extract the first decimal number it finds and convert that number to a whole
+number.
 
   my $whole = to_whole(10);     # Returns 10.
-  $whole = to_whole(0);         # Returns undef.
-  $whole = to_whole(.22);       # Returns undef (rounded down to 0).
+  $whole = to_whole(0);         # Returns 0.
+  $whole = to_whole(.22);       # Returns 0.
   $whole = to_whole(-2);        # Returns undef.
   $whole = to_whole('foo3.56'); # Returns 4.
   $whole = to_whole('foo');     # Returns undef.
+
+=head2 is_count
+
+  my $bool = is_count($val);
+
+Returns true if $val is a counting number (1, 2, 3, ...), and false if it is
+not. The regular expression used to test whether $val is a counting number is
+C</^\d+$/>.
+
+  my $bool = is_count(1); # Returns true.
+  $bool = is_count(-1);   # Returns false.
+  $bool = is_count(0);    # Returns false.
+
+=head2 to_count
+
+  my $count = to_count($val);
+
+Converts $val to a counting number and returns it. Numbers will be rounded to
+the nearest counting number. Note that since 0 (zero) is not considered a
+counting number by this module, it will not be returned. If $val is a mixture
+of numbers and letters, to_count() will extract the first decimal number it
+finds and convert that number to a counting number.
+
+  my $count = to_count(10);     # Returns 10.
+  $count = to_count(0);         # Returns undef.
+  $count = to_count(.22);       # Returns undef (rounded down to 0).
+  $count = to_count(-2);        # Returns undef.
+  $count = to_count('foo3.56'); # Returns 4.
+  $count = to_count('foo');     # Returns undef.
 
 =head2 is_int
 
@@ -363,11 +408,11 @@
 
 =head1 BUGS
 
-Hopefully none. Contact the author if you discover any.
+Please send bug reports to <bug-data-types at rt.cpan.org>.
 
 =head1 AUTHOR
 
-David Wheeler <david at wheeler.net>
+David Wheeler <david at kineticode.com>
 
 =head1 SEE ALSO
 
@@ -389,7 +434,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2002-2003, David Wheeler. All Rights Reserved.
+Copyright (c) 2002-2006, David Wheeler. All Rights Reserved.
 
 This module is free software; you can redistribute it and/or modify it under the
 same terms as Perl itself.

Modified: packages/libdata-types-perl/trunk/t/types.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/trunk/t/types.t?rev=2793&op=diff
==============================================================================
--- packages/libdata-types-perl/trunk/t/types.t (original)
+++ packages/libdata-types-perl/trunk/t/types.t Tue May 23 13:45:26 2006
@@ -2,7 +2,7 @@
 
 use strict;
 use Test;
-BEGIN { plan tests => 145 };
+BEGIN { plan tests => 169 };
 use Data::Types qw(:all);
 ok(1); # If we made it this far, we're ok.
 
@@ -13,7 +13,7 @@
 ok( is_whole(22) );
 ok( is_whole(1) );
 ok( is_whole(700) );
-ok( ! is_whole(0) );
+ok( is_whole(0) );
 ok( ! is_whole(.22) );
 ok( ! is_whole(-33) );
 ok( ! is_whole(-0.1) );
@@ -25,16 +25,44 @@
 ok( to_whole('ri+4') == 4 );
 ok( to_whole('+45ts') == 45 );
 ok( to_whole(1.23e99) == 1) ;  # This should probably be changed somehow.
-ok( ! defined to_whole(0) );
+ok( to_whole(0) eq '0' );
 ok( ! defined to_whole('blech') );
 ok( ! defined to_whole('') );
 ok( ! defined to_whole(undef) );
-ok( ! defined to_whole('foo00') );
-ok( ! defined to_whole(.44) );
+ok( to_whole('foo00') eq '0' );
+ok( to_whole(.44) eq '0' );
 ok( ! defined to_whole('foo-33') );
 ok( ! defined to_whole(-44) );
 ok( ! defined to_whole(-0.33) );
 ok( ! defined to_whole('sep-0.1') );
+
+# Test is_count.
+ok( is_count(10) );
+ok( is_count(22) );
+ok( is_count(1) );
+ok( is_count(700) );
+ok( ! is_count(0) );
+ok( ! is_count(.22) );
+ok( ! is_count(-33) );
+ok( ! is_count(-0.1) );
+
+# Test to_count.
+ok( to_count(10) == 10 );
+ok( to_count(1) == 1 );
+ok( to_count('foo33') ==  33);
+ok( to_count('ri+4') == 4 );
+ok( to_count('+45ts') == 45 );
+ok( to_count(1.23e99) == 1) ;  # This should probably be changed somehow.
+ok( ! defined to_count(0) );
+ok( ! defined to_count('blech') );
+ok( ! defined to_count('') );
+ok( ! defined to_count(undef) );
+ok( ! defined to_count('foo00') );
+ok( ! defined to_count(.44) );
+ok( ! defined to_count('foo-33') );
+ok( ! defined to_count(-44) );
+ok( ! defined to_count(-0.33) );
+ok( ! defined to_count('sep-0.1') );
 
 # Test is_int.
 ok( is_int(10) );




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