r61339 - in /branches/upstream/libhash-moreutils-perl: ./ current/ current/lib/ current/lib/Hash/ current/t/
emhn-guest at users.alioth.debian.org
emhn-guest at users.alioth.debian.org
Sat Aug 7 01:07:33 UTC 2010
Author: emhn-guest
Date: Sat Aug 7 01:07:20 2010
New Revision: 61339
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=61339
Log:
[svn-inject] Installing original source of libhash-moreutils-perl (0.02)
Added:
branches/upstream/libhash-moreutils-perl/
branches/upstream/libhash-moreutils-perl/current/
branches/upstream/libhash-moreutils-perl/current/Build.PL
branches/upstream/libhash-moreutils-perl/current/Changes
branches/upstream/libhash-moreutils-perl/current/MANIFEST
branches/upstream/libhash-moreutils-perl/current/MANIFEST.SKIP
branches/upstream/libhash-moreutils-perl/current/META.yml
branches/upstream/libhash-moreutils-perl/current/Makefile.PL
branches/upstream/libhash-moreutils-perl/current/README
branches/upstream/libhash-moreutils-perl/current/lib/
branches/upstream/libhash-moreutils-perl/current/lib/Hash/
branches/upstream/libhash-moreutils-perl/current/lib/Hash/MoreUtils.pm
branches/upstream/libhash-moreutils-perl/current/t/
branches/upstream/libhash-moreutils-perl/current/t/00-load.t
branches/upstream/libhash-moreutils-perl/current/t/01-hash.t
branches/upstream/libhash-moreutils-perl/current/t/manifest.t
branches/upstream/libhash-moreutils-perl/current/t/pod-coverage.t
branches/upstream/libhash-moreutils-perl/current/t/pod.t
Added: branches/upstream/libhash-moreutils-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/Build.PL?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/Build.PL (added)
+++ branches/upstream/libhash-moreutils-perl/current/Build.PL Sat Aug 7 01:07:20 2010
@@ -1,0 +1,17 @@
+use strict;
+use warnings;
+use Module::Build;
+
+my $builder = Module::Build->new(
+ module_name => 'Hash::MoreUtils',
+ license => 'perl',
+ dist_author => q{Hans Dieter Pearcey <hdp at cpan.org>},
+ dist_version_from => 'lib/Hash/MoreUtils.pm',
+ build_requires => {
+ 'Test::More' => 0,
+ },
+ add_to_cleanup => [ 'Hash-MoreUtils-*' ],
+ create_makefile_pl => 'traditional',
+);
+
+$builder->create_build_script();
Added: branches/upstream/libhash-moreutils-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/Changes?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/Changes (added)
+++ branches/upstream/libhash-moreutils-perl/current/Changes Sat Aug 7 01:07:20 2010
@@ -1,0 +1,13 @@
+Revision history for Hash-MoreUtils
+
+0.02 2010-04-28
+ - Taking maintainership (Jens Rehsack)
+ - Implement optimized versions for slice, slice_exists and
+ slice_def
+ - Add test for each function to work proper with default keys
+ - Add safe_reverse as wished in RT#48403 (Ed Davis)
+ - Add test for hashsort
+
+0.01 Date/time
+ First version, released on an unsuspecting world.
+
Added: branches/upstream/libhash-moreutils-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/MANIFEST?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/MANIFEST (added)
+++ branches/upstream/libhash-moreutils-perl/current/MANIFEST Sat Aug 7 01:07:20 2010
@@ -1,0 +1,13 @@
+Build.PL
+Changes
+lib/Hash/MoreUtils.pm
+Makefile.PL
+MANIFEST
+MANIFEST.SKIP
+META.yml Module meta-data (added by MakeMaker)
+README
+t/00-load.t
+t/01-hash.t
+t/manifest.t
+t/pod-coverage.t
+t/pod.t
Added: branches/upstream/libhash-moreutils-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/MANIFEST.SKIP?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libhash-moreutils-perl/current/MANIFEST.SKIP Sat Aug 7 01:07:20 2010
@@ -1,0 +1,16 @@
+\B\.svn\b
+\.[Bb][Aa][Kk]$
+\.orig$
+\.rej$
+\.old$
+\..*sw[po]
+.*~
+Makefile$
+\.project
+\bblib\b
+pm_to_blib
+.*\.csv
+^MYMETA.yml$
+^_build/.*
+^Build$
+^Hash-MoreUtils-.*
Added: branches/upstream/libhash-moreutils-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/META.yml?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/META.yml (added)
+++ branches/upstream/libhash-moreutils-perl/current/META.yml Sat Aug 7 01:07:20 2010
@@ -1,0 +1,21 @@
+---
+abstract: 'Provide the stuff missing in Hash::Util'
+author:
+ - 'Hans Dieter Pearcey <hdp at cpan.org>'
+build_requires:
+ Test::More: 0
+configure_requires:
+ Module::Build: 0.36
+generated_by: 'Module::Build version 0.3603'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
+name: Hash-MoreUtils
+provides:
+ Hash::MoreUtils:
+ file: lib/Hash/MoreUtils.pm
+ version: 0.02
+resources:
+ license: http://dev.perl.org/licenses/
+version: 0.02
Added: branches/upstream/libhash-moreutils-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/Makefile.PL?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/Makefile.PL (added)
+++ branches/upstream/libhash-moreutils-perl/current/Makefile.PL Sat Aug 7 01:07:20 2010
@@ -1,0 +1,14 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.3603
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+ 'NAME' => 'Hash::MoreUtils',
+ 'VERSION_FROM' => 'lib/Hash/MoreUtils.pm',
+ 'PREREQ_PM' => {
+ 'Test::More' => 0
+ },
+ 'INSTALLDIRS' => 'site',
+ 'EXE_FILES' => [],
+ 'PL_FILES' => {}
+ )
+;
Added: branches/upstream/libhash-moreutils-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/README?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/README (added)
+++ branches/upstream/libhash-moreutils-perl/current/README Sat Aug 7 01:07:20 2010
@@ -1,0 +1,29 @@
+Hash-MoreUtils
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the README
+file from a module distribution so that people browsing the archive
+can use it get an idea of the modules uses. It is usually a good idea
+to provide version information here so that people can decide whether
+fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2005 Hans Dieter Pearcey
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
Added: branches/upstream/libhash-moreutils-perl/current/lib/Hash/MoreUtils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/lib/Hash/MoreUtils.pm?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/lib/Hash/MoreUtils.pm (added)
+++ branches/upstream/libhash-moreutils-perl/current/lib/Hash/MoreUtils.pm Sat Aug 7 01:07:20 2010
@@ -1,0 +1,257 @@
+package Hash::MoreUtils;
+
+use strict;
+use warnings;
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
+use Scalar::Util qw(blessed);
+
+require Exporter;
+
+ at ISA = qw(Exporter);
+
+%EXPORT_TAGS = (
+ all => [
+ qw(slice slice_def slice_exists slice_grep
+ hashsort safe_reverse
+ )
+ ],
+);
+
+ at EXPORT_OK = ( @{ $EXPORT_TAGS{all} } );
+
+$VERSION = '0.02';
+
+=head1 NAME
+
+Hash::MoreUtils - Provide the stuff missing in Hash::Util
+
+=head1 SYNOPSIS
+
+ use Hash::MoreUtils qw(slice slice_def slice_exists slice_grep
+ hashsort
+ );
+
+=head1 DESCRIPTION
+
+Similar to C<< List::MoreUtils >>, C<< Hash::MoreUtils >>
+contains trivial but commonly-used functionality for hashes.
+
+=head1 FUNCTIONS
+
+=head2 C<slice> HASHREF[, LIST]
+
+Returns a hash containing the (key, value) pair for every
+key in LIST.
+
+=head2 C<slice_def> HASHREF[, LIST]
+
+As C<slice>, but only includes keys whose values are
+defined.
+
+=head2 C<slice_exists> HASHREF[, LIST]
+
+As C<slice> but only includes keys which exist in the
+hashref.
+
+=head2 C<slice_grep> BLOCK, HASHREF[, LIST]
+
+As C<slice>, with an arbitrary condition.
+
+Unlike C<grep>, the condition is not given aliases to
+elements of anything. Instead, C<< %_ >> is set to the
+contents of the hashref, to avoid accidentally
+auto-vivifying when checking keys or values. Also,
+'uninitialized' warnings are turned off in the enclosing
+scope.
+
+=cut
+
+sub slice_grep (&@);
+
+sub slice
+{
+ my ( $href, @list ) = @_;
+ if( @list )
+ {
+ return map { $_ => $href->{$_} } @list;
+ }
+ %{$href};
+}
+
+sub slice_exists
+{
+ my ( $href, @list ) = @_;
+ if( @list )
+ {
+ return map { $_ => $href->{$_} } grep {exists( $href->{$_} ) } @list;
+ }
+ %{$href};
+}
+
+sub slice_def
+{
+ my ( $href, @list ) = @_;
+ @list = keys %{$href} unless @list;
+ return map { $_ => $href->{$_} } grep { defined( $href->{$_} ) } @list;
+}
+
+sub slice_grep (&@)
+{
+ my ( $code, $hash, @keys ) = @_;
+ local %_ = %{$hash};
+ @keys = keys %_ unless @keys;
+ no warnings 'uninitialized';
+ return map { ( $_ => $_{$_} ) } grep { $code->($_) } @keys;
+}
+
+=head2 C<hashsort> [BLOCK,] HASHREF
+
+ my @array_of_pairs = hashsort \%hash;
+ my @pairs_by_length = hashsort sub { length($a) <=> length($b) }, \%hash;
+
+Returns the (key, value) pairs of the hash, sorted by some
+property of the keys. By default (if no sort block given), sorts the
+keys with C<cmp>.
+
+I'm not convinced this is useful yet. If you can think of
+some way it could be more so, please let me know.
+
+=cut
+
+sub hashsort
+{
+ my ( $code, $hash ) = @_;
+ unless ($hash)
+ {
+ $hash = $code;
+ $code = sub { $a cmp $b };
+ }
+ return map { ( $_ => $hash->{$_} ) } sort { $code->() } keys %$hash;
+}
+
+=head2 C<safe_reverse> [BLOCK,] HASHREF
+
+ my %dup_rev = safe_reverse \%hash
+
+ sub croak_dup {
+ my ($k, $v, $r) = @_;
+ exists( $r->{$v} ) and
+ croak "Cannot safe reverse: $v would be mapped to both $k and $r->{$v}";
+ $v;
+ };
+ my %easy_rev = save_reverse \&croak_dup, \%hash
+
+Returns safely reversed hash (value, key pairs of original hash). If no
+C<< BLOCK >> is given, following routine will be used:
+
+ sub merge_dup {
+ my ($k, $v, $r) = @_;
+ return exists( $r->{$v} )
+ ? ( ref($r->{$v}) ? [ @{$r->{$v}}, $k ] : [ $r->{$v}, $k ] )
+ : $k;
+ };
+
+The C<BLOCK> will be called with 3 arguments:
+
+=over 8
+
+=item C<key>
+
+The key from the C<< ( key, value ) >> pair in the original hash
+
+=item C<value>
+
+The value from the C<< ( key, value ) >> pair in the original hash
+
+=item C<ref-hash>
+
+Reference to the reversed hash (read-only)
+
+=back
+
+The C<BLOCK> is expected to return the value which will used
+for the resulting hash.
+
+=cut
+
+sub safe_reverse
+{
+ my ( $code, $hash ) = @_;
+ unless ($hash)
+ {
+ $hash = $code;
+ $code = sub {
+ my ($k, $v, $r) = @_;
+ return exists( $r->{$v} )
+ ? ( ref($r->{$v}) ? [ @{$r->{$v}}, $k ] : [ $r->{$v}, $k ] )
+ : $k;
+ };
+ }
+
+ my %reverse;
+ while( my ( $key, $val ) = each %{$hash} )
+ {
+ $reverse{$val} = &{$code}( $key, $val, \%reverse );
+ }
+ return %reverse;
+}
+
+1;
+
+=head1 AUTHOR
+
+Hans Dieter Pearcey, C<< <hdp at cpan.org> >>
+Jens Rehsack, C<< <rehsack at cpan.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-hash-moreutils at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hash-MoreUtils>.
+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 Hash::MoreUtils
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Hash-MoreUtils>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Hash-MoreUtils>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Hash-MoreUtils>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Hash-MoreUtils/>
+
+=back
+
+=head1 ACKNOWLEDGEMENTS
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2005 Hans Dieter Pearcey, all rights reserved.
+Copyright 2010 Jens Rehsack
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+
+=cut
+
+1; # End of Hash::MoreUtils
Added: branches/upstream/libhash-moreutils-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/t/00-load.t?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/t/00-load.t (added)
+++ branches/upstream/libhash-moreutils-perl/current/t/00-load.t Sat Aug 7 01:07:20 2010
@@ -1,0 +1,9 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'Hash::MoreUtils' );
+}
+
+diag( "Testing Hash::MoreUtils $Hash::MoreUtils::VERSION, Perl $], $^X" );
Added: branches/upstream/libhash-moreutils-perl/current/t/01-hash.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/t/01-hash.t?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/t/01-hash.t (added)
+++ branches/upstream/libhash-moreutils-perl/current/t/01-hash.t Sat Aug 7 01:07:20 2010
@@ -1,0 +1,88 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 14;
+use Hash::MoreUtils qw(:all);
+
+my %h = (a => 1,
+ b => 2,
+ c => undef);
+
+is_deeply(
+ { slice(\%h, qw(a)) },
+ { a => 1 },
+ "simple slice",
+);
+
+is_deeply(
+ { slice(\%h, qw(a d)) },
+ { a => 1, d => undef },
+ "slice to nonexistent",
+);
+
+is_deeply(
+ { slice(\%h) },
+ { a => 1, b => 2, c => undef },
+ "slice with default keys",
+);
+
+is_deeply(
+ { slice_def(\%h, qw(a c d)) },
+ { a => 1 },
+ "slice_def undef + nonexistent",
+);
+ok(!exists $h{d}, "slice_def didn't autovivify d");
+
+is_deeply(
+ { slice_exists(\%h, qw(a c d)) },
+ { a => 1, c => undef },
+ "slice_exists nonexistent",
+);
+ok(!exists $h{d}, "slice_exists didn't autovivify d");
+
+is_deeply(
+ { slice_exists(\%h) },
+ { a => 1, b => 2, c => undef },
+ "slice_exists with default keys",
+);
+
+is_deeply(
+ { slice_def \%h },
+ { a => 1, b => 2 },
+ "slice_def with default keys",
+);
+
+is_deeply(
+ { slice_grep { $_ gt 'a' } \%h },
+ { b => 2, c => undef },
+ "slice_grep on keys",
+);
+
+is_deeply(
+ { slice_grep { $_{$_} && $_{$_} > 1 } \%h },
+ { b => 2 },
+ "slice_grep on values",
+);
+
+is_deeply(
+ [ hashsort \%h ],
+ [ 'a', 1, 'b', 2, 'c', undef ],
+ "hashsort with default function",
+);
+
+my %he = slice_def(\%h);
+is_deeply(
+ { safe_reverse(\%he), },
+ { 2 => 'b', 1 => 'a' },
+ "safe revert with unique values and default function",
+);
+
+%he = ( a => 1, b => 1 );
+my %hec = safe_reverse(\%he);
+is_deeply(
+ [ keys %hec, sort @{$hec{1}} ],
+ [ 1, qw(a b) ],
+ "safe revert with duplicate values and default function",
+);
Added: branches/upstream/libhash-moreutils-perl/current/t/manifest.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/t/manifest.t?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/t/manifest.t (added)
+++ branches/upstream/libhash-moreutils-perl/current/t/manifest.t Sat Aug 7 01:07:20 2010
@@ -1,0 +1,13 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+unless ( $ENV{RELEASE_TESTING} ) {
+ plan( skip_all => "Author tests not required for installation" );
+}
+
+eval "use Test::CheckManifest 0.9";
+plan skip_all => "Test::CheckManifest 0.9 required" if $@;
+ok_manifest();
Added: branches/upstream/libhash-moreutils-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/t/pod-coverage.t?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libhash-moreutils-perl/current/t/pod-coverage.t Sat Aug 7 01:07:20 2010
@@ -1,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();
Added: branches/upstream/libhash-moreutils-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhash-moreutils-perl/current/t/pod.t?rev=61339&op=file
==============================================================================
--- branches/upstream/libhash-moreutils-perl/current/t/pod.t (added)
+++ branches/upstream/libhash-moreutils-perl/current/t/pod.t Sat Aug 7 01:07:20 2010
@@ -1,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();
More information about the Pkg-perl-cvs-commits
mailing list