import Data::AnyBoolean from my personal repo

git-svn-id: svn://127.0.0.1/Perl/Data::AnyBoolean/trunk@119 0c1c3402-1be1-de11-8092-0022686faf23
This commit is contained in:
Zane C. B-H 2010-04-28 15:35:42 +00:00
commit d2d0efb963
10 changed files with 345 additions and 0 deletions

View File

@ -0,0 +1,10 @@
blib*
Makefile
Makefile.old
Build
_build*
pm_to_blib*
*.tar.gz
.lwpcookies
Data-AnyBollean-*
cover_db

4
Data-AnyBoolean/Changes Normal file
View File

@ -0,0 +1,4 @@
Revision history for Data-AnyBoolean
0.0.0 2009-12-25/23:55
-Initial release.

8
Data-AnyBoolean/MANIFEST Normal file
View File

@ -0,0 +1,8 @@
Changes
MANIFEST
Makefile.PL
README
lib/Data/AnyBoolean.pm
t/00-load.t
t/pod-coverage.t
t/pod.t

View File

@ -0,0 +1,19 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Data::AnyBoolean',
AUTHOR => 'Zane C. Bowers <vvelox@vvelox.net>',
VERSION_FROM => 'lib/Data/AnyBoolean.pm',
ABSTRACT_FROM => 'lib/Data/AnyBoolean.pm',
($ExtUtils::MakeMaker::VERSION >= 6.3002
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Data-AnyBoolean-*' },
);

43
Data-AnyBoolean/README Normal file
View File

@ -0,0 +1,43 @@
Data-AnyBollean
Provides handling for a wider variety of boolean data
possibilities.
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the
perldoc command.
perldoc Data::AnyBollean
You can also look for information at:
RT, CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-AnyBollean
AnnoCPAN, Annotated CPAN documentation
http://annocpan.org/dist/Data-AnyBollean
CPAN Ratings
http://cpanratings.perl.org/d/Data-AnyBollean
Search CPAN
http://search.cpan.org/dist/Data-AnyBollean/
COPYRIGHT AND LICENCE
Copyright (C) 2009 Zane C. Bowers
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

View File

@ -0,0 +1,167 @@
package Data::AnyBoolean;
use warnings;
use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(anyBool);
our @EXPORT_OK = qw(anyBool);
our %EXPORT_TAGS = (DEFAULT => [qw(anyBool)]);
=head1 NAME
Data::AnyBoolean - Check none Perl boolean values.
=head1 VERSION
Version 0.0.0
=cut
our $VERSION = '0.0.0';
=head1 SYNOPSIS
use Data::AnyBoolean;
if(anyBool( 'yes' )){
print 'True'
}
if(anyBool( 'no' )){
print 'True'
}
Any of the items below are considered false.
undef
/^[Nn][Oo]$/
/^[Ff][Aa][Ll][Ss][Ee]$/
/^[Ff]$/
/^[Oo][Ff][Ff]$/
Any of the items below are considered true.
/^[Yy][Ee][Ss]$/
/^[Tt][Rr][Uu][Ee]$/
/^[Tt]$/
/^[Oo][Nn]$/
If any of the above are not matched, it is evaulated as a standard
Perl boolean.
=head1 FUNCTIONS
=head2 anyBool
This returns '0' or '1' after checking the value passed
for the boolean check.
=cut
sub anyBool{
my $bool=$_[0];
if (!defined( $bool )) {
return 0;
}
#yes/no
if ($bool =~/^[Yy][Ee][Ss]$/) {
return 1;
}
if ($bool =~/^[Nn][Oo]$/) {
return 0;
}
#true/false
if ($bool =~/^[Tt][Rr][Uu][Ee]$/) {
return 1;
}
if ($bool =~/^[Ff][Aa][Ll][Ss][Ee]$/) {
return 0;
}
#on/off
if ($bool =~/^[Oo][Nn]$/) {
return 1;
}
if ($bool =~/^[Oo][Ff][Ff]$/) {
return 0;
}
#t/f
if ($bool =~/^[Tt]$/) {
return 1;
}
if ($bool =~/^[Ff]$/) {
return 0;
}
#try it the perl way
if ( $bool ) {
return 1
}
return 0;
}
=head1 AUTHOR
Zane C. Bowers, C<< <vvelox at vvelox.net> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-data-anybollean at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-AnyBollean>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Data::AnyBoolean
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-AnyBoolean>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Data-AnyBoolean>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Data-AnyBoolean>
=item * Search CPAN
L<http://search.cpan.org/dist/Data-AnyBoolean/>
=back
=head1 ACKNOWLEDGEMENTS
=head1 COPYRIGHT & LICENSE
Copyright 2009 Zane C. Bowers, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1; # End of Data::AnyBoolean

View File

@ -0,0 +1,9 @@
#!perl -T
use Test::More tests => 1;
BEGIN {
use_ok( 'Data::AnyBoolean' );
}
diag( "Testing Data::AnyBoolean $Data::AnyBoolean::VERSION, Perl $], $^X" );

View File

@ -0,0 +1,55 @@
#!perl -T
use strict;
use warnings;
use Test::More tests => 3;
sub not_in_file_ok {
my ($filename, %regex) = @_;
open( my $fh, '<', $filename )
or die "couldn't open $filename for reading: $!";
my %violated;
while (my $line = <$fh>) {
while (my ($desc, $regex) = each %regex) {
if ($line =~ $regex) {
push @{$violated{$desc}||=[]}, $.;
}
}
}
if (%violated) {
fail("$filename contains boilerplate text");
diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
} else {
pass("$filename contains no boilerplate text");
}
}
sub module_boilerplate_ok {
my ($module) = @_;
not_in_file_ok($module =>
'the great new $MODULENAME' => qr/ - The great new /,
'boilerplate description' => qr/Quick summary of what the module/,
'stub function definition' => qr/function[12]/,
);
}
TODO: {
local $TODO = "Need to replace the boilerplate text";
not_in_file_ok(README =>
"The README is used..." => qr/The README is used/,
"'version information here'" => qr/to provide version information/,
);
not_in_file_ok(Changes =>
"placeholder date/time" => qr(Date/time)
);
module_boilerplate_ok('lib/Data/AnyBoolean.pm');
}

View File

@ -0,0 +1,18 @@
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
all_pod_coverage_ok();

12
Data-AnyBoolean/t/pod.t Normal file
View File

@ -0,0 +1,12 @@
#!perl -T
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();