r67403 - in /branches/upstream/libboolean-perl/current: Changes MANIFEST META.yml Makefile.PL README inc/Module/Install/AckXXX.pm inc/Module/Install/ManifestSkip.pm inc/Module/Install/VersionCheck.pm lib/boolean.pm t/autobox.t t/boolean.t
carnil at users.alioth.debian.org
carnil at users.alioth.debian.org
Fri Jan 14 20:43:07 UTC 2011
Author: carnil
Date: Fri Jan 14 20:43:01 2011
New Revision: 67403
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=67403
Log:
[svn-upgrade] new version libboolean-perl (0.24)
Added:
branches/upstream/libboolean-perl/current/inc/Module/Install/VersionCheck.pm
branches/upstream/libboolean-perl/current/t/autobox.t
Modified:
branches/upstream/libboolean-perl/current/Changes
branches/upstream/libboolean-perl/current/MANIFEST
branches/upstream/libboolean-perl/current/META.yml
branches/upstream/libboolean-perl/current/Makefile.PL
branches/upstream/libboolean-perl/current/README
branches/upstream/libboolean-perl/current/inc/Module/Install/AckXXX.pm
branches/upstream/libboolean-perl/current/inc/Module/Install/ManifestSkip.pm
branches/upstream/libboolean-perl/current/lib/boolean.pm
branches/upstream/libboolean-perl/current/t/boolean.t
Modified: branches/upstream/libboolean-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/Changes?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/Changes (original)
+++ branches/upstream/libboolean-perl/current/Changes Fri Jan 14 20:43:01 2011
@@ -1,3 +1,12 @@
+---
+version: 0.24
+date: Thu Jan 13 15:27:09 EST 2011
+changes:
+- @Schwern++ found out how to make true and false immutable.
+ Kudos to #strategicdata++.
+- Document the boolean() function.
+- Added is_true and is_false methods.
+- Added boolean, is_true, and is_false autobox methods
---
version: 0.23
date: Thu Sep 16 19:27:54 PDT 2010
Modified: branches/upstream/libboolean-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/MANIFEST?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/MANIFEST (original)
+++ branches/upstream/libboolean-perl/current/MANIFEST Fri Jan 14 20:43:01 2011
@@ -8,6 +8,7 @@
inc/Module/Install/ManifestSkip.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/ReadmeFromPod.pm
+inc/Module/Install/VersionCheck.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/boolean.pm
@@ -15,5 +16,6 @@
MANIFEST This list of files
META.yml
README
+t/autobox.t
t/boolean.t
t/export.t
Modified: branches/upstream/libboolean-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/META.yml?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/META.yml (original)
+++ branches/upstream/libboolean-perl/current/META.yml Fri Jan 14 20:43:01 2011
@@ -17,8 +17,11 @@
directory:
- inc
- t
+recommends:
+ Readonly: 0
+ autobox: 0
requires:
perl: 5.005003
resources:
license: http://dev.perl.org/licenses/
-version: 0.23
+version: 0.24
Modified: branches/upstream/libboolean-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/Makefile.PL?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/Makefile.PL (original)
+++ branches/upstream/libboolean-perl/current/Makefile.PL Fri Jan 14 20:43:01 2011
@@ -4,6 +4,10 @@
all_from 'lib/boolean.pm';
readme_from;
manifest_skip;
+version_check;
ack_xxx;
+recommends 'Readonly';
+recommends 'autobox';
+
WriteAll;
Modified: branches/upstream/libboolean-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/README?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/README (original)
+++ branches/upstream/libboolean-perl/current/README Fri Jan 14 20:43:01 2011
@@ -6,6 +6,15 @@
do &always if true;
do &never if false;
+
+ do &maybe if boolean($value)->is_true;
+
+ With autobox:
+
+ use autobox;
+ use boolean;
+
+ do &maybe if $value->is_true;
and:
@@ -34,14 +43,6 @@
This module provides basic Boolean support, by defining two special
objects: "true" and "false".
-IMPLEMENTATION NOTE
- Version 0.20 is a complete rewrite from version 0.12. The old version
- used XS and had some fundamental flaws. The new version is pure Perl and
- is more correct. The new version depends on overload.pm to make the true
- and false objects return 1 and 0 respectively.
-
- The "null" support found in 0.12 was also removed as superfluous.
-
RATIONALE
When sharing data between programming languages, it is important to
support the same group of basic types. In Perlish programming languages,
@@ -68,6 +69,10 @@
the value is the "false" object with the isFalse function described
below.
+ boolean($scalar)
+ Casts the scalar value to a boolean value. If $scalar is true, it
+ returns "boolean::true", otherwise it returns "boolean::false".
+
isTrue($scalar)
Returns "boolean::true" if the scalar passed to it is the
"boolean::true" object. Returns "boolean::false" otherwise.
@@ -81,13 +86,36 @@
"boolean::true" or "boolean::false" object. Returns "boolean::false"
otherwise.
+METHODS
+ Since true and false return objects, you can call methods on them.
+
+ $boolean->is_true
+ Same as isTrue($boolean).
+
+ $boolean->is_false
+ Same as isFalse($boolean).
+
+ autobox Methods
+ If you use "boolean" with "autobox" you can call the following methods
+ on any scalar:
+
+ $scalar->boolean
+ Same as boolean($scalar).
+
+ $scalar->is_true
+ Same as isTrue(boolean($scalar)).
+
+ $scalar->is_false
+ Same as isFalse(boolean($scalar)).
+
EXPORTABLES
- By default this module exports the "true" and "false" functions.
+ By default this module exports the "true", "false" and "boolean"
+ functions.
The module also defines these export tags:
:all
- Exports "true", "false", "isTrue", "isFalse", "isBoolean"
+ Exports "true", "false", "boolean", "isTrue", "isFalse", "isBoolean"
:test
Exports "isTrue", "isFalse", "isBoolean"
@@ -96,7 +124,7 @@
Ingy döt Net <ingy at cpan.org>
COPYRIGHT
- Copyright (c) 2007, 2008, 2010. Ingy döt Net.
+ Copyright (c) 2007, 2008, 2010, 2011. Ingy döt Net.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Modified: branches/upstream/libboolean-perl/current/inc/Module/Install/AckXXX.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/inc/Module/Install/AckXXX.pm?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/inc/Module/Install/AckXXX.pm (original)
+++ branches/upstream/libboolean-perl/current/inc/Module/Install/AckXXX.pm Fri Jan 14 20:43:01 2011
@@ -8,7 +8,7 @@
use vars qw($VERSION @ISA);
BEGIN {
- $VERSION = '0.10';
+ $VERSION = '0.11';
@ISA = 'Module::Install::Base';
}
Modified: branches/upstream/libboolean-perl/current/inc/Module/Install/ManifestSkip.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/inc/Module/Install/ManifestSkip.pm?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/inc/Module/Install/ManifestSkip.pm (original)
+++ branches/upstream/libboolean-perl/current/inc/Module/Install/ManifestSkip.pm Fri Jan 14 20:43:01 2011
@@ -8,7 +8,7 @@
use vars qw($VERSION @ISA);
BEGIN {
- $VERSION = '0.12';
+ $VERSION = '0.14';
@ISA = 'Module::Install::Base';
}
@@ -18,7 +18,7 @@
my $self = shift;
return unless $self->is_admin;
- print "Updating $skip_file\n";
+ print "manifest_skip\n";
my $keepers;
if (-e $skip_file) {
@@ -69,7 +69,7 @@
^todo
^ToDo$
## avoid OS X finder files
-^\.DS_Store$
+\.DS_Store$
## skip komodo project files
\.kpf$
## ignore emacs and vim backup files
Added: branches/upstream/libboolean-perl/current/inc/Module/Install/VersionCheck.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/inc/Module/Install/VersionCheck.pm?rev=67403&op=file
==============================================================================
--- branches/upstream/libboolean-perl/current/inc/Module/Install/VersionCheck.pm (added)
+++ branches/upstream/libboolean-perl/current/inc/Module/Install/VersionCheck.pm Fri Jan 14 20:43:01 2011
@@ -1,0 +1,74 @@
+#line 1
+package Module::Install::VersionCheck;
+use strict;
+use warnings;
+use 5.008003;
+
+use Module::Install::Base;
+
+my $DEFAULT = '0.00';
+
+use vars qw($VERSION @ISA);
+BEGIN {
+ $VERSION = '0.11';
+ @ISA = 'Module::Install::Base';
+}
+
+sub version_check {
+ my $self = shift;
+ return unless $self->is_admin;
+
+ my $module_version = $self->_get_module_version();
+ my $changes_version = $self->_get_changes_version();
+ my $git_tag_version = $self->_get_git_tag_version();
+
+ $self->_report(
+ $module_version,
+ $changes_version,
+ $git_tag_version,
+ );
+}
+
+sub _get_module_version {
+ my $self = shift;
+ return $DEFAULT unless $self->admin->{extensions};
+ my ($metadata) = grep {
+ ref($_) eq 'Module::Install::Metadata';
+ } @{$self->admin->{extensions}};
+ return $DEFAULT unless $metadata;
+ return $metadata->{values}{version} || $DEFAULT;
+}
+
+sub _get_changes_version {
+ my $self = shift;
+ return $DEFAULT unless -e 'Changes';
+ open IN, 'Changes' or die "Can't open 'Changes' for input: $!";
+ my $text = do {local $/; <IN>};
+ $text =~ /\b(\d\.\d\d)\b/ or return $DEFAULT;
+ return $1;
+}
+
+sub _get_git_tag_version {
+ my $self = shift;
+ return $DEFAULT unless -e '.git';
+ require Capture::Tiny;
+ my $text = Capture::Tiny::capture_merged(sub { system('git tag') });
+ my $version = $DEFAULT;
+ for (split "\n", $text) {
+ if (/\b(\d\.\d\d)\b/ and $1 > $version) {
+ $version = $1;
+ }
+ }
+ return $version;
+}
+
+sub _report {
+ my $self = shift;
+ print "version_check @_\n";
+}
+
+1;
+
+=encoding utf8
+
+#line 107
Modified: branches/upstream/libboolean-perl/current/lib/boolean.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/lib/boolean.pm?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/lib/boolean.pm (original)
+++ branches/upstream/libboolean-perl/current/lib/boolean.pm Fri Jan 14 20:43:01 2011
@@ -2,7 +2,7 @@
use 5.005003;
use strict;
# use warnings;
-$boolean::VERSION = '0.23';
+$boolean::VERSION = '0.24';
my ($true, $false);
@@ -22,14 +22,22 @@
my ($true_val, $false_val, $bool_vals);
BEGIN {
- $true = do {bless \(my $t = 1), 'boolean'};
- $false = do {bless \(my $f = 0), 'boolean'};
+ my $have_readonly = eval { require Readonly };
+
+ my $t = 1;
+ my $f = 0;
+ if ( $have_readonly ) {
+ Readonly::Scalar($t => $t);
+ Readonly::Scalar($f => $f);
+ }
+
+ $true = do {bless \$t, 'boolean'};
+ $false = do {bless \$f, 'boolean'};
$true_val = overload::StrVal($true);
$false_val = overload::StrVal($false);
$bool_vals = {$true_val => 1, $false_val => 1};
}
-# use XXX;
sub true() { $true }
sub false() { $false }
sub boolean($) {
@@ -51,6 +59,25 @@
(overload::StrVal($_[0]) eq $false_val) ? true : false;
}
+# Methods
+sub is_true {
+ return isTrue($_[0]);
+}
+sub is_false {
+ return isFalse($_[0]);
+}
+
+# For autobox
+sub SCALAR::boolean {
+ return boolean($_[0]);
+}
+sub SCALAR::is_true {
+ return isTrue(boolean($_[0]));
+}
+sub SCALAR::is_false {
+ return isFalse(boolean($_[0]));
+}
+
1;
=encoding utf8
@@ -65,6 +92,15 @@
do &always if true;
do &never if false;
+
+ do &maybe if boolean($value)->is_true;
+
+With autobox:
+
+ use autobox;
+ use boolean;
+
+ do &maybe if $value->is_true;
and:
@@ -94,15 +130,6 @@
This module provides basic Boolean support, by defining two special
objects: C<true> and C<false>.
-=head1 IMPLEMENTATION NOTE
-
-Version 0.20 is a complete rewrite from version 0.12. The old version
-used XS and had some fundamental flaws. The new version is pure Perl and
-is more correct. The new version depends on overload.pm to make the
-true and false objects return 1 and 0 respectively.
-
-The "null" support found in 0.12 was also removed as superfluous.
-
=head1 RATIONALE
When sharing data between programming languages, it is important to
@@ -133,6 +160,11 @@
Perl process at any time. You can check to see whether the value is the
"false" object with the isFalse function described below.
+=item boolean($scalar)
+
+Casts the scalar value to a boolean value. If C<$scalar> is true, it
+returns C<boolean::true>, otherwise it returns C<boolean::false>.
+
=item isTrue($scalar)
Returns C<boolean::true> if the scalar passed to it is the
@@ -151,9 +183,45 @@
=back
+=head1 METHODS
+
+Since true and false return objects, you can call methods on them.
+
+=over
+
+=item $boolean->is_true
+
+Same as isTrue($boolean).
+
+=item $boolean->is_false
+
+Same as isFalse($boolean).
+
+=back
+
+=head2 autobox Methods
+
+If you use C<boolean> with C<autobox> you can call the following methods on any scalar:
+
+=over
+
+=item $scalar->boolean
+
+Same as boolean($scalar).
+
+=item $scalar->is_true
+
+Same as isTrue(boolean($scalar)).
+
+=item $scalar->is_false
+
+Same as isFalse(boolean($scalar)).
+
+=back
+
=head1 EXPORTABLES
-By default this module exports the C<true> and C<false> functions.
+By default this module exports the C<true>, C<false> and C<boolean> functions.
The module also defines these export tags:
@@ -161,7 +229,7 @@
=item :all
-Exports C<true>, C<false>, C<isTrue>, C<isFalse>, C<isBoolean>
+Exports C<true>, C<false>, C<boolean>, C<isTrue>, C<isFalse>, C<isBoolean>
=item :test
@@ -175,7 +243,7 @@
=head1 COPYRIGHT
-Copyright (c) 2007, 2008, 2010. Ingy döt Net.
+Copyright (c) 2007, 2008, 2010, 2011. Ingy döt Net.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Added: branches/upstream/libboolean-perl/current/t/autobox.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/t/autobox.t?rev=67403&op=file
==============================================================================
--- branches/upstream/libboolean-perl/current/t/autobox.t (added)
+++ branches/upstream/libboolean-perl/current/t/autobox.t Fri Jan 14 20:43:01 2011
@@ -1,0 +1,16 @@
+use Test::More;
+
+BEGIN {
+ plan skip_all => "Test requires autobox" unless eval {require autobox};
+}
+
+use boolean;
+plan tests => 4;
+
+{
+ use autobox;
+ ok 1->boolean, "1->boolean is true";
+ ok not(0->boolean), "0->boolean is false";
+ ok 1.1->is_true, "1.1->is_true";
+ ok 0.0->is_false, "0.0->is_false";
+}
Modified: branches/upstream/libboolean-perl/current/t/boolean.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libboolean-perl/current/t/boolean.t?rev=67403&op=diff
==============================================================================
--- branches/upstream/libboolean-perl/current/t/boolean.t (original)
+++ branches/upstream/libboolean-perl/current/t/boolean.t Fri Jan 14 20:43:01 2011
@@ -1,4 +1,4 @@
-use Test::More tests => 55;
+use Test::More tests => 61;
use strict;
use lib 'lib';
@@ -108,7 +108,15 @@
eval 'true(())'; ok $@, "Can't pass values to true/false";
eval 'false(undef)'; ok $@, "Can't pass values to true/false";
-# my $c = true;
-# $$c = 0;
-# ok $c ? 1 : 0, "true is imutable";
+# Check that true is immutable
+SKIP: {
+ skip "Need Readonly to make truth immutable", 4 if !eval { require Readonly };
+ for my $bool (true, false) {
+ my $truthiness = !!$bool;
+ ok !eval { $$bool = 0; 1 }, "truth is forever";
+ is $bool, $truthiness, "imutable";
+ }
+}
+ok true->is_true, "true is_true";
+ok false->is_false, "true is_true";
More information about the Pkg-perl-cvs-commits
mailing list