r6921 - in /branches/upstream/libhash-case-perl: ./ current/ current/lib/ current/lib/Hash/ current/lib/Hash/Case/ current/t/

azatoth-guest at users.alioth.debian.org azatoth-guest at users.alioth.debian.org
Sat Aug 18 17:12:14 UTC 2007


Author: azatoth-guest
Date: Sat Aug 18 17:12:13 2007
New Revision: 6921

URL: http://svn.debian.org/wsvn/?sc=1&rev=6921
Log:
[svn-inject] Installing original source of libhash-case-perl

Added:
    branches/upstream/libhash-case-perl/
    branches/upstream/libhash-case-perl/current/
    branches/upstream/libhash-case-perl/current/ChangeLog
    branches/upstream/libhash-case-perl/current/MANIFEST
    branches/upstream/libhash-case-perl/current/META.yml
    branches/upstream/libhash-case-perl/current/Makefile.PL
    branches/upstream/libhash-case-perl/current/README
    branches/upstream/libhash-case-perl/current/lib/
    branches/upstream/libhash-case-perl/current/lib/Hash/
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/
    branches/upstream/libhash-case-perl/current/lib/Hash/Case.pm
    branches/upstream/libhash-case-perl/current/lib/Hash/Case.pod
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pm
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pod
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pm
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pod
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pm
    branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pod
    branches/upstream/libhash-case-perl/current/lib/Hash/Makefile.PL
    branches/upstream/libhash-case-perl/current/t/
    branches/upstream/libhash-case-perl/current/t/10lower.t
    branches/upstream/libhash-case-perl/current/t/20upper.t
    branches/upstream/libhash-case-perl/current/t/30pres1.t
    branches/upstream/libhash-case-perl/current/t/31pres2.t
    branches/upstream/libhash-case-perl/current/t/pod.t

Added: branches/upstream/libhash-case-perl/current/ChangeLog
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/ChangeLog?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/ChangeLog (added)
+++ branches/upstream/libhash-case-perl/current/ChangeLog Sat Aug 18 17:12:13 2007
@@ -1,0 +1,46 @@
+
+version 1.004:
+
+	- fixed 2 typo's in POD (Thanks to CPANTS)
+
+	- add t/pod.t
+
+	- use oodist to create docs.
+
+version 1.003: Mon Oct 27 07:58:44 CET 2003
+
+	- Added methods addPairs() and addHashData() to initialize a
+	  hash with values.
+
+	- Use Test::More i.s.o. Test
+
+	- Move pm files to a new lib/ directory
+
+	- Copyrights also in 2003
+
+version 1.002: Fri Aug  2 16:48:23 CEST 2002
+
+	- Changed my e-mail address to mark at overmeer.net
+
+	- Added Hash::Case::init() as dummy.
+
+	- Some configuration problems fixed.
+
+	- An array passed as initializer for the hash was cleaned in
+	  the process, which is not nice, of course.
+	  Reported by [Jenda Krynicky]
+
+version 1.001: Sat Jun 15 13:29:55 CEST 2002
+
+	This code is fully tested, and too simple to be true, so I release
+	it without hesitation as stable.
+
+	- Initial implementation of Hash::Case
+
+	- Initial implementation of Hash::Case::Lower, tests in t/10lower.t
+
+	- Initial implementation of Hash::Case::Upper, tests in t/20upper.t
+
+	- Initial implementation of Hash::Case::Preserve, tests in t/30pres1.t
+
+	- Initial implementation of Hash::Case::Preserve, tests in t/31pres2.t

Added: branches/upstream/libhash-case-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/MANIFEST?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/MANIFEST (added)
+++ branches/upstream/libhash-case-perl/current/MANIFEST Sat Aug 18 17:12:13 2007
@@ -1,0 +1,19 @@
+ChangeLog
+MANIFEST
+META.yml                                 Module meta-data (added by MakeMaker)
+Makefile.PL
+README
+lib/Hash/Case.pm
+lib/Hash/Case.pod
+lib/Hash/Case/Lower.pm
+lib/Hash/Case/Lower.pod
+lib/Hash/Case/Preserve.pm
+lib/Hash/Case/Preserve.pod
+lib/Hash/Case/Upper.pm
+lib/Hash/Case/Upper.pod
+lib/Hash/Makefile.PL
+t/10lower.t
+t/20upper.t
+t/30pres1.t
+t/31pres2.t
+t/pod.t

Added: branches/upstream/libhash-case-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/META.yml?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/META.yml (added)
+++ branches/upstream/libhash-case-perl/current/META.yml Sat Aug 18 17:12:13 2007
@@ -1,0 +1,11 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Hash-Case
+version:      1.004
+version_from: 
+installdirs:  site
+requires:
+    Test::More:                    0.47
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

Added: branches/upstream/libhash-case-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/Makefile.PL?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/Makefile.PL (added)
+++ branches/upstream/libhash-case-perl/current/Makefile.PL Sat Aug 18 17:12:13 2007
@@ -1,0 +1,26 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile
+  ( NAME	 => 'Hash::Case'
+  , VERSION      => '1.004'
+  , PREREQ_PM    =>
+    { Test::More => 0.47
+    }
+  , AUTHOR       => 'Mark Overmeer'
+  , ABSTRACT     => 'Play trics with hash keys'
+  );
+
+sub MY::postamble { <<'__POSTAMBLE' }
+
+# for DIST
+RAWDIR          = ../public_html/hash-case/raw
+DISTDIR         = ../public_html/hash-case/source
+LICENSE         = artistic
+
+# for POD
+FIRST_YEAR      = 2002-2003,
+EMAIL           = perl at overmeer.net
+WEBSITE         = http://perl.overmeer.net/hash-case/
+
+__POSTAMBLE
+

Added: branches/upstream/libhash-case-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/README?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/README (added)
+++ branches/upstream/libhash-case-perl/current/README Sat Aug 18 17:12:13 2007
@@ -1,0 +1,24 @@
+=== README for Hash-Case version 1.004
+=   Generated on Fri Jun  8 14:46:12 2007 by OODoc 1.00
+
+There are various ways to install this module:
+
+ (1) if you have a command-line, you can do:
+       perl -MCPAN -e 'install <any package from this distribution>'
+
+ (2) if you use Windows, have a look at http://ppm.activestate.com/
+
+ (3) if you have downloaded this module manually (as root/administrator)
+       gzip -d Hash-Case-1.004.tar.gz
+       tar -xf Hash-Case-1.004.tar
+       cd Hash-Case-1.004
+       perl Makefile.PL
+       make          # optional
+       make test     # optional
+       make install
+
+For usage, see the included manual-pages.
+
+Please report problems to
+    http://rt.cpan.org/Dist/Display.html?Queue=Hash-Case
+

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case.pm?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case.pm (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case.pm Sat Aug 18 17:12:13 2007
@@ -1,0 +1,73 @@
+# Copyrights 2002-2003,-2007 by Mark Overmeer.
+#  For other contributors see ChangeLog.
+# See the manual pages for details on the licensing terms.
+# Pod stripped from pm file by OODoc 1.00.
+
+package Hash::Case;
+use vars '$VERSION';
+$VERSION = '1.004';
+
+use Tie::Hash;
+ at ISA = 'Tie::StdHash';
+
+use strict;
+use Carp;
+
+
+sub TIEHASH(@)
+{   my $class = shift;
+    my $to    = @_ % 2 ? shift : undef;
+    my %opts  = (@_, add => $to);
+    (bless {}, $class)->init( \%opts );
+}
+
+# Used for case-insensitive hashes which do not need more than
+# one hash.
+sub native_init($)
+{   my ($self, $args) = @_;
+    my $add = delete $args->{add};
+
+       if(!$add)               { ; }
+    elsif(ref $add eq 'ARRAY') { $self->addPairs(@$add) }
+    elsif(ref $add eq 'HASH')  { $self->addHashData($add)  }
+    else { croak "Cannot initialize the native hash this way." }
+
+    $self;
+}
+
+# Used for case-insensitive hashes which are implemented around
+# an existing hash.
+sub wrapper_init($)
+{   my ($self, $args) = @_;
+    my $add = delete $args->{add};
+
+       if(!$add)               { ; }
+    elsif(ref $add eq 'ARRAY') { $self->addPairs(@$add) }
+    elsif(ref $add eq 'HASH')  { $self->setHash($add)  }
+    else { croak "Cannot initialize a wrapping hash this way." }
+
+    $self;
+}
+
+
+sub addPairs(@)
+{   my $self = shift;
+    $self->STORE(shift, shift) while @_;
+    $self;
+}
+
+
+sub addHashData($)
+{   my ($self, $data) = @_;
+    while(my ($k, $v) = each %$data) { $self->STORE($k, $v) }
+    $self;
+}
+
+
+sub setHash($)
+{   my ($self, $hash) = @_;   # the native implementation is the default.
+    %$self = %$hash;
+    $self;
+}
+
+1;

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case.pod?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case.pod (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case.pod Sat Aug 18 17:12:13 2007
@@ -1,0 +1,122 @@
+=head1 NAME
+
+Hash::Case - base class for hashes with key-casing requirements
+
+=head1 INHERITANCE
+
+ Hash::Case
+   is a Tie::StdHash
+
+ Hash::Case is extended by
+   Hash::Case::Lower
+   Hash::Case::Preserve
+   Hash::Case::Upper
+
+=head1 SYNOPSIS
+
+ use Hash::Case::Lower;
+ tie my(%lchash), 'Hash::Case::Lower';
+ $lchash{StraNGeKeY} = 3;
+ print keys %lchash;  # strangekey
+
+=head1 DESCRIPTION
+
+Hash::Case is the base class for various classes which tie special
+treatment for the casing of keys.  Be aware of the differences in
+implementation: C<Lower> and C<Upper> are tied native hashes:
+these hashes have no need for hidden fields or other assisting
+data structured.  A case C<Preserve> hash will actually create
+three hashes.
+
+The following strategies are implemented:
+
+=over 4
+
+=item * Hash::Case::Lower (native hash)
+
+Keys are always considered lower case. The internals of this
+module translate any incoming key to lower case before it is used.
+
+=item * Hash::Case::Upper (native hash)
+
+Like the ::Lower, but then all keys are always translated into
+upper case.  This module can be of use for some databases, which
+do translate everything to capitals as well.  To avoid confusion,
+you may want to have you own internal Perl hash do this as well.
+
+=item * Hash::Case::Preserve
+
+The actual casing is ignored, but not forgotten.
+
+=back
+
+=head1 METHODS
+
+$obj-E<gt>B<addHashData>(HASH)
+
+=over 4
+
+Add the data of a hash (passed as reference) to the created tied hash.  The
+existing values in the hash remain, the keys are adapted to the needs of the
+the casing.
+
+=back
+
+$obj-E<gt>B<addPairs>(PAIRS)
+
+=over 4
+
+Specify an even length list of alternating key and value to be stored in
+the hash.
+
+=back
+
+$obj-E<gt>B<setHash>(HASH)
+
+=over 4
+
+The functionality differs for native and wrapper hashes.  For native
+hashes, this is the same as first clearing the hash, and then a call
+to addHashData.  Wrapper hashes will use the hash you specify here
+to store the data, and re-create the mapping hash.
+
+=back
+
+B<tie>(HASH, TIE, [VALUES,] OPTIONS)
+
+=over 4
+
+Tie the HASH with the TIE package which extends L<Hash::Case>.  The OPTIONS
+differ per implementation: read the manual page for the package you actually
+use.  The VALUES is a reference to an array containing key-value pairs,
+or a reference to a hash: they fill the initial hash.
+
+I<Example:> 
+
+ my %x;
+ tie %x, 'Hash::Case::Lower';
+ $x{Upper} = 3;
+ print keys %x;       # 'upper'
+
+ my @y = (ABC => 3, DeF => 4);
+ tie %x, 'Hash::Case::Lower', \@y;
+ print keys %x;       # 'abc' 'def'
+
+ my %z = (ABC => 3, DeF => 4);
+ tie %x, 'Hash::Case::Lower', \%z;
+
+=back
+
+=head1 SEE ALSO
+
+This module is part of Hash-Case distribution version 1.004,
+built on June 08, 2007. Website: F<http://perl.overmeer.net/hash-case/>
+
+=head1 LICENSE
+
+Copyrights 2002-2003,-2007 by Mark Overmeer. For other contributors see ChangeLog.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+See F<http://www.perl.com/perl/misc/Artistic.html>
+

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pm?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pm (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pm Sat Aug 18 17:12:13 2007
@@ -1,0 +1,30 @@
+# Copyrights 2002-2003,-2007 by Mark Overmeer.
+#  For other contributors see ChangeLog.
+# See the manual pages for details on the licensing terms.
+# Pod stripped from pm file by OODoc 1.00.
+package Hash::Case::Lower;
+use vars '$VERSION';
+$VERSION = '1.004';
+use base 'Hash::Case';
+
+use strict;
+use Carp;
+
+
+sub init($)
+{   my ($self, $args) = @_;
+
+    $self->SUPER::native_init($args);
+
+    croak "No options possible for ".__PACKAGE__
+        if keys %$args;
+
+    $self;
+}
+
+sub FETCH($)  { $_[0]->{lc $_[1]} }
+sub STORE($$) { $_[0]->{lc $_[1]} = $_[2] }
+sub EXISTS($) { exists $_[0]->{lc $_[1]} }
+sub DELETE($) { delete $_[0]->{lc $_[1]} }
+
+1;

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pod?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pod (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case/Lower.pod Sat Aug 18 17:12:13 2007
@@ -1,0 +1,71 @@
+=head1 NAME
+
+Hash::Case::Lower - hash with enforced lower cased keys
+
+=head1 INHERITANCE
+
+ Hash::Case::Lower
+   is a Hash::Case
+   is a Tie::StdHash
+
+=head1 SYNOPSIS
+
+ use Hash::Case::Lower;
+ tie my(%lchash), 'Hash::Case::Lower';
+ $lchash{StraNGeKeY} = 3;
+ print keys %lchash;  # strangekey
+
+=head1 DESCRIPTION
+
+Hash::Case::Lower extends Hash::Case, which lets you play various trics
+with hash keys.  See L<Hash::Case> for the other implementations.
+
+=head1 METHODS
+
+$obj-E<gt>B<addHashData>(HASH)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+$obj-E<gt>B<addPairs>(PAIRS)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+$obj-E<gt>B<setHash>(HASH)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+B<tie>(HASH, 'Hash::Case::Lower', [VALUES,] OPTIONS)
+
+=over 4
+
+Define HASH to have only lower cased keys.  The hash is
+initialized with the VALUES, specified as ref-array or
+ref-hash.  Currently, there are no OPTIONS defined.
+
+=back
+
+=head1 SEE ALSO
+
+This module is part of Hash-Case distribution version 1.004,
+built on June 08, 2007. Website: F<http://perl.overmeer.net/hash-case/>
+
+=head1 LICENSE
+
+Copyrights 2002-2003,-2007 by Mark Overmeer. For other contributors see ChangeLog.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+See F<http://www.perl.com/perl/misc/Artistic.html>
+

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pm?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pm (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pm Sat Aug 18 17:12:13 2007
@@ -1,0 +1,73 @@
+# Copyrights 2002-2003,-2007 by Mark Overmeer.
+#  For other contributors see ChangeLog.
+# See the manual pages for details on the licensing terms.
+# Pod stripped from pm file by OODoc 1.00.
+package Hash::Case::Preserve;
+use vars '$VERSION';
+$VERSION = '1.004';
+use base 'Hash::Case';
+
+use strict;
+use Carp;
+
+
+sub init($)
+{   my ($self, $args) = @_;
+
+    $self->{HCP_data} = {};
+    $self->{HCP_keys} = {};
+
+    my $keep = $args->{keep} || 'LAST';
+    if($keep eq 'LAST')     { $self->{HCP_update} = 1 }
+    elsif($keep eq 'FIRST') { $self->{HCP_update} = 0 }
+    else
+    {   croak "Use 'FIRST' or 'LAST' with the option keep.\n";
+    }
+
+    $self->SUPER::native_init($args);
+}
+
+# Maintain two hashes within this object: one to store the values, and
+# one to preserve the casing.  The main object also stores the options.
+# The data is kept under lower cased keys.
+
+sub FETCH($) { $_[0]->{HCP_data}{lc $_[1]} }
+
+sub STORE($$)
+{   my ($self, $key, $value) = @_;
+    my $lckey = lc $key;
+
+    $self->{HCP_keys}{$lckey} = $key
+        if $self->{HCP_update} || !exists $self->{HCP_keys}{$lckey};
+
+    $self->{HCP_data}{$lckey} = $value;
+}
+
+sub FIRSTKEY
+{   my $self = shift;
+    my $a = scalar keys %{$self->{HCP_keys}};
+    $self->NEXTKEY;
+}
+
+sub NEXTKEY($)
+{   my $self = shift;
+    if(my ($k, $v) = each %{$self->{HCP_keys}})
+    {    return wantarray ? ($v, $self->{HCP_data}{$k}) : $v;
+    }
+    else { return () }
+}
+
+sub EXISTS($) { exists $_[0]->{HCP_data}{lc $_[1]} }
+
+sub DELETE($)
+{   my $lckey = lc $_[1];
+    delete $_[0]->{HCP_keys}{$lckey};
+    delete $_[0]->{HCP_data}{$lckey};
+}
+
+sub CLEAR()
+{   %{$_[0]->{HCP_data}} = ();
+    %{$_[0]->{HCP_keys}} = ();
+}
+
+1;

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pod?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pod (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case/Preserve.pod Sat Aug 18 17:12:13 2007
@@ -1,0 +1,89 @@
+=head1 NAME
+
+Hash::Case::Preserve - hash with enforced lower cased keys
+
+=head1 INHERITANCE
+
+ Hash::Case::Preserve
+   is a Hash::Case
+   is a Tie::StdHash
+
+=head1 SYNOPSIS
+
+ use Hash::Case::Preserve;
+ tie my(%cphash), 'Hash::Case::Preserve';
+ $cphash{StraNGeKeY} = 3;
+ print keys %cphash;         # StraNGeKeY
+ print $cphash{strangekey};  # 3
+ print $cphash{STRANGEKEY};  # 3
+
+=head1 DESCRIPTION
+
+Hash::Case::Preserve extends Hash::Case, which lets you play various trics
+with hash keys.  See L<Hash::Case> for the other implementations.
+
+=head1 METHODS
+
+$obj-E<gt>B<addHashData>(HASH)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+$obj-E<gt>B<addPairs>(PAIRS)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+$obj-E<gt>B<setHash>(HASH)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+B<tie>(HASH, 'Hash::Case::Preserve', [VALUES,] OPTIONS)
+
+=over 4
+
+Define HASH to be case insensitive, but case preserving.
+The hash is initialized with the VALUES, specified as ref-array or
+ref-hash.
+
+OPTIONS is a list of key/value pairs, which specify how the hash
+must handle preservation.  Current options:
+
+ Option--Default
+ keep    <required>
+
+. keep => =E<gt> 'FIRST' | 'LAST'
+
+=over 4
+
+Which casing is the prefered casing?  The FIRST appearance or the LAST.
+Only stores will affect the casing, deletes will undo the definition.
+Defaults to LAST, which is slightly faster.
+
+=back
+
+=back
+
+=head1 SEE ALSO
+
+This module is part of Hash-Case distribution version 1.004,
+built on June 08, 2007. Website: F<http://perl.overmeer.net/hash-case/>
+
+=head1 LICENSE
+
+Copyrights 2002-2003,-2007 by Mark Overmeer. For other contributors see ChangeLog.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+See F<http://www.perl.com/perl/misc/Artistic.html>
+

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pm?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pm (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pm Sat Aug 18 17:12:13 2007
@@ -1,0 +1,31 @@
+# Copyrights 2002-2003,-2007 by Mark Overmeer.
+#  For other contributors see ChangeLog.
+# See the manual pages for details on the licensing terms.
+# Pod stripped from pm file by OODoc 1.00.
+
+package Hash::Case::Upper;
+use vars '$VERSION';
+$VERSION = '1.004';
+use base 'Hash::Case';
+
+use Carp;
+use strict;
+
+
+sub init($)
+{   my ($self, $args) = @_;
+
+    $self->SUPER::native_init($args);
+
+    croak "No options available for ".__PACKAGE__
+        if keys %$args;
+
+    $self;
+}
+
+sub FETCH($)  { $_[0]->{uc $_[1]} }
+sub STORE($$) { $_[0]->{uc $_[1]} = $_[2] }
+sub EXISTS($) { exists $_[0]->{uc $_[1]} }
+sub DELETE($) { delete $_[0]->{uc $_[1]} }
+
+1;

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pod
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pod?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pod (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Case/Upper.pod Sat Aug 18 17:12:13 2007
@@ -1,0 +1,71 @@
+=head1 NAME
+
+Hash::Case::Upper - native hash with enforced lower cased keys
+
+=head1 INHERITANCE
+
+ Hash::Case::Upper
+   is a Hash::Case
+   is a Tie::StdHash
+
+=head1 SYNOPSIS
+
+ use Hash::Case::Upper;
+ tie my(%uchash), 'Hash::Case::Upper';
+ $uchash{StraNGeKeY} = 3;
+ print keys %uchash;  # STRANGEKEY
+
+=head1 DESCRIPTION
+
+C<Hash::Case::Upper> extends L<Hash::Case|Hash::Case>, which lets you play various trics
+with hash keys.  See L<Hash::Case|Hash::Case> for the other implementations.
+
+=head1 METHODS
+
+$obj-E<gt>B<addHashData>(HASH)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+$obj-E<gt>B<addPairs>(PAIRS)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+$obj-E<gt>B<setHash>(HASH)
+
+=over 4
+
+See L<Hash::Case/"METHODS">
+
+=back
+
+B<tie>(HASH, 'Hash::Case::Upper', [VALUES,] OPTIONS)
+
+=over 4
+
+Define HASH to have only upper cased keys.  The hash is
+initialized with the VALUES, specified as ref-array or
+ref-hash.  Currently, there are no OPTIONS defined.
+
+=back
+
+=head1 SEE ALSO
+
+This module is part of Hash-Case distribution version 1.004,
+built on June 08, 2007. Website: F<http://perl.overmeer.net/hash-case/>
+
+=head1 LICENSE
+
+Copyrights 2002-2003,-2007 by Mark Overmeer. For other contributors see ChangeLog.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+See F<http://www.perl.com/perl/misc/Artistic.html>
+

Added: branches/upstream/libhash-case-perl/current/lib/Hash/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/lib/Hash/Makefile.PL?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/lib/Hash/Makefile.PL (added)
+++ branches/upstream/libhash-case-perl/current/lib/Hash/Makefile.PL Sat Aug 18 17:12:13 2007
@@ -1,0 +1,6 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile
+   ( NAME      => 'Hash::Case'
+   , PMLIBDIRS => [ qw/Case/ ]
+   );

Added: branches/upstream/libhash-case-perl/current/t/10lower.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/t/10lower.t?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/t/10lower.t (added)
+++ branches/upstream/libhash-case-perl/current/t/10lower.t Sat Aug 18 17:12:13 2007
@@ -1,0 +1,72 @@
+#!/usr/bin/perl -w
+
+# Test lower cased hash
+
+use strict;
+use Test::More;
+
+use lib qw/. t/;
+
+BEGIN {plan tests => 31}
+
+use Hash::Case::Lower;
+
+my %h;
+
+tie %h, 'Hash::Case::Lower';
+cmp_ok(keys %h, '==',  0);
+
+$h{abc} = 3;
+cmp_ok($h{abc}, '==',  3);
+cmp_ok($h{ABC}, '==',  3);
+cmp_ok($h{AbC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+my @h = keys %h;
+cmp_ok(@h, '==', 1);
+is($h[0], 'abc');
+
+$h{dEf} = 4;
+cmp_ok($h{def}, '==',  4);
+cmp_ok($h{dEf}, '==',  4);
+cmp_ok(keys %h, '==',  2);
+
+my (@k, @v);
+while(my ($k, $v) = each %h)
+{   push @k, $k;
+    push @v, $v;
+}
+
+cmp_ok(@k, '==', 2);
+ at k = sort @k;
+is($k[0], 'abc');
+is($k[1], 'def');
+
+ok(@v==2);
+ at v = sort {$a <=> $b} @v;
+cmp_ok($v[0], '==',  3);
+cmp_ok($v[1], '==',  4);
+
+ok(exists $h{ABC});
+cmp_ok(delete $h{ABC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+%h = ();
+cmp_ok(keys %h, '==',  0);
+ok(tied %h);
+
+my %a;
+tie %a, 'Hash::Case::Lower', [ AbC => 3, dEf => 4 ];
+ok(tied %a);
+cmp_ok(keys %a, '==', 2);
+ok(defined $a{abc});
+cmp_ok($a{ABC}, '==',  3);
+cmp_ok($a{DeF}, '==',  4);
+
+my %b;
+tie %b, 'Hash::Case::Lower', { AbC => 3, dEf => 4 };
+ok(tied %b);
+cmp_ok(keys %b, '==', 2);
+ok(defined $b{abc});
+cmp_ok($b{ABC}, '==',  3);
+cmp_ok($b{DeF}, '==',  4);

Added: branches/upstream/libhash-case-perl/current/t/20upper.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/t/20upper.t?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/t/20upper.t (added)
+++ branches/upstream/libhash-case-perl/current/t/20upper.t Sat Aug 18 17:12:13 2007
@@ -1,0 +1,72 @@
+#!/usr/bin/perl -w
+
+# Test upper cased hash
+
+use strict;
+use Test::More;
+
+use lib qw/. t/;
+
+BEGIN {plan tests => 31}
+
+use Hash::Case::Upper;
+
+my %h;
+
+tie %h, 'Hash::Case::Upper';
+cmp_ok(keys %h, '==',  0);
+
+$h{ABC} = 3;
+cmp_ok($h{ABC}, '==',  3);
+cmp_ok($h{abc}, '==',  3);
+cmp_ok($h{AbC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+my @h = keys %h;
+cmp_ok(@h, '==',  1);
+is($h[0], 'ABC');
+
+$h{dEf} = 4;
+cmp_ok($h{def}, '==',  4);
+cmp_ok($h{dEf}, '==',  4);
+cmp_ok(keys %h, '==',  2);
+
+my (@k, @v);
+while(my ($k, $v) = each %h)
+{   push @k, $k;
+    push @v, $v;
+}
+
+cmp_ok(@k, '==',  2);
+ at k = sort @k;
+is($k[0], 'ABC');
+is($k[1], 'DEF');
+
+cmp_ok(@v, '==',  2);
+ at v = sort {$a <=> $b} @v;
+cmp_ok($v[0], '==',  3);
+cmp_ok($v[1], '==',  4);
+
+ok(exists $h{ABC});
+cmp_ok(delete $h{ABC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+%h = ();
+cmp_ok(keys %h, '==',  0);
+ok(tied %h);
+
+my %a;
+tie %a, 'Hash::Case::Upper', [ AbC => 3, dEf => 4 ];
+ok(tied %a);
+cmp_ok(keys %a, '==',  2);
+ok(defined $a{abc});
+cmp_ok($a{ABC}, '==',  3);
+cmp_ok($a{DeF}, '==',  4);
+
+my %b;
+tie %b, 'Hash::Case::Upper', { AbC => 3, dEf => 4 };
+ok(tied %b);
+cmp_ok(keys %b, '==',  2);
+ok(defined $b{abc});
+cmp_ok($b{ABC}, '==',  3);
+cmp_ok($b{DeF}, '==',  4);

Added: branches/upstream/libhash-case-perl/current/t/30pres1.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/t/30pres1.t?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/t/30pres1.t (added)
+++ branches/upstream/libhash-case-perl/current/t/30pres1.t Sat Aug 18 17:12:13 2007
@@ -1,0 +1,82 @@
+#!/usr/bin/perl -w
+
+# Test case-preserving hash, where the last appearance is kept.
+
+use strict;
+use Test::More;
+
+use lib qw/. t/;
+
+BEGIN {plan tests => 37}
+
+use Hash::Case::Preserve;
+
+my %h;
+
+tie %h, 'Hash::Case::Preserve', keep => 'LAST';
+cmp_ok(keys %h, '==',  0);
+
+$h{ABC} = 3;
+cmp_ok($h{ABC}, '==',  3);
+cmp_ok($h{abc}, '==',  3);
+cmp_ok($h{AbC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+my @h = keys %h;
+cmp_ok(@h, '==',  1);
+is($h[0], 'ABC');   # last STORE
+
+$h{abc} = 6;
+cmp_ok(keys %h, '==',  1);
+cmp_ok($h{ABC}, '==',  6);
+is((keys %h)[0], 'abc');
+
+$h{ABC} = 3;
+cmp_ok(keys %h, '==',  1);
+cmp_ok($h{ABC}, '==',  3);
+is((keys %h)[0], 'ABC');
+
+$h{dEf} = 4;
+cmp_ok($h{def}, '==',  4);
+cmp_ok($h{dEf}, '==',  4);
+cmp_ok(keys %h, '==',  2);
+
+my (@k, @v);
+while(my ($k, $v) = each %h)
+{   push @k, $k;
+    push @v, $v;
+}
+
+cmp_ok(@k, '==',  2);
+ at k = sort @k;
+is($k[0], 'ABC');
+is($k[1], 'dEf');
+
+cmp_ok(@v, '==',  2);
+ at v = sort {$a <=> $b} @v;
+cmp_ok($v[0], '==',  3);
+cmp_ok($v[1], '==',  4);
+
+ok(exists $h{ABC});
+cmp_ok(delete $h{ABC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+%h = ();
+cmp_ok(keys %h, '==',  0);
+ok(tied %h);
+
+my %a;
+tie %a, 'Hash::Case::Preserve', [ AbC => 3, dEf => 4 ], keep => 'LAST';
+ok(tied %a);
+cmp_ok(keys %a, '==',  2);
+ok(defined $a{abc});
+cmp_ok($a{ABC}, '==',  3);
+cmp_ok($a{DeF}, '==',  4);
+
+my %b;
+tie %b, 'Hash::Case::Preserve', { AbC => 3, dEf => 4 }, keep => 'LAST';
+ok(tied %b);
+cmp_ok(keys %b, '==',  2);
+ok(defined $b{abc});
+cmp_ok($b{ABC}, '==',  3);
+cmp_ok($b{DeF}, '==',  4);

Added: branches/upstream/libhash-case-perl/current/t/31pres2.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/t/31pres2.t?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/t/31pres2.t (added)
+++ branches/upstream/libhash-case-perl/current/t/31pres2.t Sat Aug 18 17:12:13 2007
@@ -1,0 +1,82 @@
+#!/usr/bin/perl -w
+
+# Test case-preserving hash, where the first appearance is kept.
+
+use strict;
+use Test::More;
+
+use lib qw/. t/;
+
+BEGIN {plan tests => 37}
+
+use Hash::Case::Preserve;
+
+my %h;
+
+tie %h, 'Hash::Case::Preserve', keep => 'FIRST';
+cmp_ok(keys %h, '==',  0);
+
+$h{ABC} = 3;
+cmp_ok($h{ABC}, '==',  3);
+cmp_ok($h{abc}, '==',  3);
+cmp_ok($h{AbC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+my @h = keys %h;
+ok(@h==1);
+is($h[0], 'ABC');   # first STORE
+
+$h{abc} = 6;
+cmp_ok(keys %h, '==',  1);
+cmp_ok($h{ABC}, '==',  6);
+is((keys %h)[0], 'ABC');
+
+$h{ABC} = 3;
+cmp_ok(keys %h, '==',  1);
+cmp_ok($h{ABC}, '==',  3);
+is((keys %h)[0], 'ABC');
+
+$h{dEf} = 4;
+cmp_ok($h{def}, '==',  4);
+cmp_ok($h{dEf}, '==',  4);
+cmp_ok(keys %h, '==',  2);
+
+my (@k, @v);
+while(my ($k, $v) = each %h)
+{   push @k, $k;
+    push @v, $v;
+}
+
+cmp_ok(@k, '==',  2);
+ at k = sort @k;
+is($k[0], 'ABC');
+is($k[1], 'dEf');
+
+ok(@v==2);
+ at v = sort {$a <=> $b} @v;
+cmp_ok($v[0], '==',  3);
+cmp_ok($v[1], '==',  4);
+
+ok(exists $h{ABC});
+cmp_ok(delete $h{ABC}, '==',  3);
+cmp_ok(keys %h, '==',  1);
+
+%h = ();
+cmp_ok(keys %h, '==',  0);
+ok(tied %h);
+
+my %a;
+tie %a, 'Hash::Case::Preserve', [ AbC => 3, dEf => 4 ], keep => 'FIRST';
+ok(tied %a);
+cmp_ok(keys %a, '==',  2);
+ok(defined $a{abc});
+cmp_ok($a{ABC}, '==',  3);
+cmp_ok($a{DeF}, '==',  4);
+
+my %b;
+tie %b, 'Hash::Case::Preserve', { AbC => 3, dEf => 4 }, keep => 'FIRST';
+ok(tied %b);
+cmp_ok(keys %b, '==',  2);
+ok(defined $b{abc});
+cmp_ok($b{ABC}, '==',  3);
+cmp_ok($b{DeF}, '==',  4);

Added: branches/upstream/libhash-case-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/branches/upstream/libhash-case-perl/current/t/pod.t?rev=6921&op=file
==============================================================================
--- branches/upstream/libhash-case-perl/current/t/pod.t (added)
+++ branches/upstream/libhash-case-perl/current/t/pod.t Sat Aug 18 17:12:13 2007
@@ -1,0 +1,9 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Test::More;
+eval "use Test::Pod 1.00";
+
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();




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