r2791 - in /packages/libdata-types-perl/branches/upstream/current:
Changes
MANIFEST META.yml Makefile.PL README 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:38:24 UTC 2006
Author: eloy
Date: Tue May 23 13:38:23 2006
New Revision: 2791
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2791
Log:
Load /tmp/tmp.PKsGF14702/libdata-types-perl-0.06 into
packages/libdata-types-perl/branches/upstream/current.
Added:
packages/libdata-types-perl/branches/upstream/current/t/zpod.t
Modified:
packages/libdata-types-perl/branches/upstream/current/Changes
packages/libdata-types-perl/branches/upstream/current/MANIFEST
packages/libdata-types-perl/branches/upstream/current/META.yml
packages/libdata-types-perl/branches/upstream/current/Makefile.PL
packages/libdata-types-perl/branches/upstream/current/README
packages/libdata-types-perl/branches/upstream/current/lib/Data/Types.pm
packages/libdata-types-perl/branches/upstream/current/t/types.t
Modified: packages/libdata-types-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/Changes?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/Changes (original)
+++ packages/libdata-types-perl/branches/upstream/current/Changes Tue May 23 13:38:23 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/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/MANIFEST?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libdata-types-perl/branches/upstream/current/MANIFEST Tue May 23 13:38:23 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/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/META.yml?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/META.yml (original)
+++ packages/libdata-types-perl/branches/upstream/current/META.yml Tue May 23 13:38:23 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/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/Makefile.PL?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/Makefile.PL (original)
+++ packages/libdata-types-perl/branches/upstream/current/Makefile.PL Tue May 23 13:38:23 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/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/README?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/README (original)
+++ packages/libdata-types-perl/branches/upstream/current/README Tue May 23 13:38:23 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/branches/upstream/current/lib/Data/Types.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/lib/Data/Types.pm?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/lib/Data/Types.pm (original)
+++ packages/libdata-types-perl/branches/upstream/current/lib/Data/Types.pm Tue May 23 13:38:23 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/branches/upstream/current/t/types.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/t/types.t?rev=2791&op=diff
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/t/types.t (original)
+++ packages/libdata-types-perl/branches/upstream/current/t/types.t Tue May 23 13:38:23 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) );
Added: packages/libdata-types-perl/branches/upstream/current/t/zpod.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libdata-types-perl/branches/upstream/current/t/zpod.t?rev=2791&op=file
==============================================================================
--- packages/libdata-types-perl/branches/upstream/current/t/zpod.t (added)
+++ packages/libdata-types-perl/branches/upstream/current/t/zpod.t Tue May 23 13:38:23 2006
@@ -1,0 +1,23 @@
+#!perl -w
+
+# $Id: zpod.t 682 2004-09-28 05:59:10Z theory $
+
+use Test::More;
+use File::Spec;
+use File::Find;
+use strict;
+
+eval "use Test::Pod 0.95";
+
+if ($@) {
+ plan skip_all => "Test::Pod v0.95 required for testing POD";
+} else {
+ Test::Pod->import;
+ my @files;
+ my $blib = File::Spec->catfile(qw(blib lib));
+ find( sub {push @files, $File::Find::name if /\.p(l|m|od)$/}, $blib);
+ plan tests => scalar @files;
+ foreach my $file (@files) {
+ pod_file_ok($file);
+ }
+}
More information about the Pkg-perl-cvs-commits
mailing list