r63612 - in /trunk/libhash-flatten-perl: Changes META.yml README debian/changelog debian/control debian/copyright debian/libhash-flatten-perl.docs debian/rules debian/source/ debian/source/format lib/Hash/Flatten.pm t/hash_flatten.t

ansgar at users.alioth.debian.org ansgar at users.alioth.debian.org
Mon Oct 11 14:25:57 UTC 2010


Author: ansgar
Date: Mon Oct 11 14:25:01 2010
New Revision: 63612

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63612
Log:
* New upstream release.
* Use tiny debian/rules.
* Use source format 3.0 (quilt).
* debian/copyright: Formatting changes; refer to "Debian systems" instead of
  "Debian GNU/Linux systems"; refer to /usr/share/common-licenses/GPL-1.
* Bump Standards-Version to 3.9.1.
* Add myself to Uploaders.

Added:
    trunk/libhash-flatten-perl/debian/source/
    trunk/libhash-flatten-perl/debian/source/format
Removed:
    trunk/libhash-flatten-perl/debian/libhash-flatten-perl.docs
Modified:
    trunk/libhash-flatten-perl/Changes
    trunk/libhash-flatten-perl/META.yml
    trunk/libhash-flatten-perl/README
    trunk/libhash-flatten-perl/debian/changelog
    trunk/libhash-flatten-perl/debian/control
    trunk/libhash-flatten-perl/debian/copyright
    trunk/libhash-flatten-perl/debian/rules
    trunk/libhash-flatten-perl/lib/Hash/Flatten.pm
    trunk/libhash-flatten-perl/t/hash_flatten.t

Modified: trunk/libhash-flatten-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/Changes?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/Changes (original)
+++ trunk/libhash-flatten-perl/Changes Mon Oct 11 14:25:01 2010
@@ -1,3 +1,9 @@
+Thu Sep 23 09:52:13 2010 - 1.19
+    * Fix handling of 0 and '' key values (thanks to Fabrice Dulaunoy)
+    * Update docs to reflect behaviour: EscapeSequence=undef
+      doesn't work, you need to use the DisableEscapes Option
+      (thanks to Fischer Ronald)
+
 Tue Apr 11 14:44:55 2006 - 1.16
     * modified default escape sequence handling (bug fix)
     * unit tests now change into t/ directory correctly under windows environment

Modified: trunk/libhash-flatten-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/META.yml?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/META.yml (original)
+++ trunk/libhash-flatten-perl/META.yml Mon Oct 11 14:25:01 2010
@@ -1,12 +1,23 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Hash-Flatten
-version:      1.16
-version_from: lib/Hash/Flatten.pm
-installdirs:  site
+--- #YAML:1.0
+name:               Hash-Flatten
+version:            1.19
+abstract:           flatten/unflatten complex data hashes
+author:
+    - British Broadcasting Corporation
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
 requires:
-    Log::Trace:                    0
-    Test::Assertions:              0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+    Log::Trace:        0
+    Test::Assertions:  0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.56
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: trunk/libhash-flatten-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/README?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/README (original)
+++ trunk/libhash-flatten-perl/README Mon Oct 11 14:25:01 2010
@@ -1,4 +1,4 @@
-Hash::Flatten v1.16
+Hash::Flatten v1.19
 
 (c) BBC 2004. This program is free software; you can redistribute it and/or
 modify it under the GNU GPL.

Modified: trunk/libhash-flatten-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/debian/changelog?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/debian/changelog (original)
+++ trunk/libhash-flatten-perl/debian/changelog Mon Oct 11 14:25:01 2010
@@ -1,4 +1,4 @@
-libhash-flatten-perl (1.16-3) UNRELEASED; urgency=low
+libhash-flatten-perl (1.19-1) unstable; urgency=low
 
   [ Nathan Handler ]
   * debian/watch: Update to ignore development releases.
@@ -8,7 +8,16 @@
     perl (>= 5.6.0-{12,16}) with an unversioned dependency on perl (as
     permitted by Debian Policy 3.8.3).
 
- -- Nathan Handler <nhandler at ubuntu.com>  Sat, 06 Jun 2009 01:34:23 +0000
+  [ Ansgar Burchardt ]
+  * New upstream release.
+  * Use tiny debian/rules.
+  * Use source format 3.0 (quilt).
+  * debian/copyright: Formatting changes; refer to "Debian systems" instead of
+    "Debian GNU/Linux systems"; refer to /usr/share/common-licenses/GPL-1.
+  * Bump Standards-Version to 3.9.1.
+  * Add myself to Uploaders.
+
+ -- Ansgar Burchardt <ansgar at debian.org>  Mon, 11 Oct 2010 16:23:06 +0200
 
 libhash-flatten-perl (1.16-2) unstable; urgency=low
 

Modified: trunk/libhash-flatten-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/debian/control?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/debian/control (original)
+++ trunk/libhash-flatten-perl/debian/control Mon Oct 11 14:25:01 2010
@@ -4,8 +4,9 @@
 Build-Depends: debhelper (>= 7)
 Build-Depends-Indep: perl, libtest-assertions-perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Krzysztof Krzyżaniak (eloy) <eloy at debian.org>
-Standards-Version: 3.8.1
+Uploaders: Krzysztof Krzyżaniak (eloy) <eloy at debian.org>,
+ Ansgar Burchardt <ansgar at debian.org>
+Standards-Version: 3.9.1
 Homepage: http://search.cpan.org/dist/Hash-Flatten/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libhash-flatten-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libhash-flatten-perl/

Modified: trunk/libhash-flatten-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/debian/copyright?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/debian/copyright (original)
+++ trunk/libhash-flatten-perl/debian/copyright Mon Oct 11 14:25:01 2010
@@ -1,8 +1,7 @@
-Format-Specification:
-    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: John Alden amp P Kent <cpan _at_ bbc _dot_ co _dot_ uk>
-Upstream-Source: http://search.cpan.org/dist/Hash-Flatten/
-Upstream-Name: Hash-Flatten
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
+Maintainer: John Alden & P Kent <cpan _at_ bbc _dot_ co _dot_ uk>
+Source: http://search.cpan.org/dist/Hash-Flatten/
+Name: Hash-Flatten
 
 Files: *
 Copyright: © 2005 by BBC
@@ -10,26 +9,29 @@
 
 Files: debian/*
 Copyright: © 2009, Krzysztof Krzyżaniak (eloy) <eloy at debian.org>
-License: GPL-2+ | Artistic | GPL-1+
+License: Artistic or GPL-1+
 
 License: GPL-2+
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; version 2 dated June, 1991, or (at your
-    option) any later version.
-    On Debian GNU/Linux systems, the complete text of version 2 of the GNU
-    General Public License can be found in `/usr/share/common-licenses/GPL-2'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 dated June, 1991, or (at your
+ option) any later version.
+ .
+ On Debian systems, the complete text of version 2 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-2'.
 
 License: Artistic
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the Artistic License, which comes with Perl.
-    On Debian GNU/Linux systems, the complete text of the Artistic License
-    can be found in `/usr/share/common-licenses/Artistic'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Artistic License, which comes with Perl.
+ .
+ On Debian systems, the complete text of the Artistic License can be
+ found in `/usr/share/common-licenses/Artistic'.
 
 License: GPL-1+
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 1, or (at your option)
-    any later version.
-    On Debian GNU/Linux systems, the complete text of the GNU General
-    Public License can be found in `/usr/share/common-licenses/GPL'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ .
+ On Debian systems, the complete text of version 1 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-1'.

Modified: trunk/libhash-flatten-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/debian/rules?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/debian/rules (original)
+++ trunk/libhash-flatten-perl/debian/rules Mon Oct 11 14:25:01 2010
@@ -1,23 +1,4 @@
 #!/usr/bin/make -f
 
-build: build-stamp
-build-stamp:
-	dh build
-	touch $@
-
-clean:
+%:
 	dh $@
-
-install: install-stamp
-install-stamp: build-stamp
-	dh install
-	touch $@
-
-binary-arch:
-
-binary-indep: install
-	dh $@
-
-binary: binary-arch binary-indep
-
-.PHONY: binary binary-arch binary-indep install clean build

Added: trunk/libhash-flatten-perl/debian/source/format
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/debian/source/format?rev=63612&op=file
==============================================================================
--- trunk/libhash-flatten-perl/debian/source/format (added)
+++ trunk/libhash-flatten-perl/debian/source/format Mon Oct 11 14:25:01 2010
@@ -1,0 +1,1 @@
+3.0 (quilt)

Modified: trunk/libhash-flatten-perl/lib/Hash/Flatten.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/lib/Hash/Flatten.pm?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/lib/Hash/Flatten.pm (original)
+++ trunk/libhash-flatten-perl/lib/Hash/Flatten.pm Mon Oct 11 14:25:01 2010
@@ -2,7 +2,7 @@
 # Purpose : Flatten/Unflatten nested data structures to/from key-value form
 # Author  : John Alden
 # Created : Feb 2002
-# CVS     : $Id: Flatten.pm,v 1.16 2006/04/10 08:47:03 mattheww Exp $
+# CVS     : $Id: Flatten.pm,v 1.19 2009/05/09 12:42:02 jamiel Exp $
 ###############################################################################
 
 package Hash::Flatten;
@@ -15,7 +15,7 @@
 @ISA = qw(Exporter);
 @EXPORT_OK = qw(flatten unflatten);
 %EXPORT_TAGS = ('all' => \@EXPORT_OK);
-$VERSION = ('$Revision: 1.16 $' =~ /([\d\.]+)/)[0];
+$VERSION = ('$Revision: 1.19 $' =~ /([\d\.]+)/)[0];
 
 use constant DEFAULT_HASH_DELIM => '.';
 use constant DEFAULT_ARRAY_DELIM => ':';
@@ -37,6 +37,7 @@
 	$self->{HashDelimiter} ||= DEFAULT_HASH_DELIM;
 	$self->{ArrayDelimiter} ||= DEFAULT_ARRAY_DELIM;
 	$self->{EscapeSequence} = "\\" unless(defined $self->{EscapeSequence} && length($self->{EscapeSequence}) > 0);
+	$self->{EscapeSequence} = undef if($self->{DisableEscapes});
 	
 	#Sanity check: delimiters don't contain escape sequence
 	croak("Hash delimiter cannot contain escape sequence") if($self->{HashDelimiter} =~ /\Q$self->{EscapeSequence}\E/);
@@ -93,7 +94,7 @@
 		my $value = $hashref->{$key};
 		my @levels = split(/$regexp/, $key);
 		
-		my $finalkey = $self->_unescape(pop(@levels), $self->{EscapeSequence});
+		my $finalkey = $self->_unescape((scalar(@levels) % 2 ? pop(@levels) : ''), $self->{EscapeSequence});
 		my $ptr = \%expanded;
 		while (@levels >= 2)
 		{
@@ -210,7 +211,7 @@
 		TRACE("_flatten_hash_level: flattening: $k");
 		my $v = $hashref->{$k};
 		$k = $self->_escape($k, $self->{EscapeSequence}, [values %$delim]);
-		my $flatkey = ($prefix? $prefix.$delim->{'HASH'}.$k : $k);		
+		my $flatkey = (defined($prefix) ? $prefix.$delim->{'HASH'}.$k : $k);
 		push @flat, $self->_flatten($flatkey, $v, $delim);
 	}
 	return @flat;
@@ -228,7 +229,7 @@
 	my @flat;
 	foreach my $ind (0 .. $#$arrayref)
 	{
-		my $flatkey = ($prefix? $prefix.$delim->{'ARRAY'}.$ind : $ind);
+		my $flatkey = (defined($prefix) ? $prefix.$delim->{'ARRAY'}.$ind : $ind);
 		my $v = $arrayref->[$ind];
 		push @flat, $self->_flatten($flatkey, $v, $delim);
 	}
@@ -413,9 +414,15 @@
 =item EscapeSequence
 
 This is the character or sequence of characters that will be used to escape the hash and array delimiters.
-If this is set to undef, no escaping will be done.  The default escape sequence is a backslash.
-The escaping strategy is to place the escape sequence in front of delimiter sequences; the escape
-sequence itself is escaped by replacing it with two instances.
+The default escape sequence is '\\'. The escaping strategy is to place the escape sequence in front of 
+delimiter sequences; the escape sequence itself is escaped by replacing it with two instances.
+
+=item DisableEscapes
+
+Stop the escaping from happening.  No escape sequences will be added to flattened output, nor interpreted on the way back.
+
+B<WARNING:> If your structure has keys that contain the delimiter characters, it will not be possible to unflatten the 
+structure correctly.
 
 =back
 
@@ -430,10 +437,6 @@
 C<'foo' =E<gt> $foo>.
 You can override this behaviour using the OnRefScalar and OnRefRef constructor option.
 
-If you set EscapeSequence to undef, unflatten() will produce incorrect results
-if your hash keys contain the delimiter strings, and your hash key will be split up.
-Either set the delimiter strings appropriately to allow for this, or define an EscapeSequence.
-
 Recursive structures are detected and cause a fatal error.
 
 =head1 SEE ALSO
@@ -459,7 +462,7 @@
 
 =head1 VERSION
 
-$Id: Flatten.pm,v 1.16 2006/04/10 08:47:03 mattheww Exp $
+$Id: Flatten.pm,v 1.19 2009/05/09 12:42:02 jamiel Exp $
 
 =head1 AUTHOR
 

Modified: trunk/libhash-flatten-perl/t/hash_flatten.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhash-flatten-perl/t/hash_flatten.t?rev=63612&op=diff
==============================================================================
--- trunk/libhash-flatten-perl/t/hash_flatten.t (original)
+++ trunk/libhash-flatten-perl/t/hash_flatten.t Mon Oct 11 14:25:01 2010
@@ -4,7 +4,7 @@
 # Purpose : Unit test for Hash::Flatten
 # Author  : John Alden
 # Created : Feb 2002
-# CVS     : $Header: /home/cvs/software/cvsroot/hash_flatten/t/hash_flatten.t,v 1.19 2006/04/11 13:43:30 mattheww Exp $
+# CVS     : $Header: /home/cvs/software/cvsroot/hash_flatten/t/hash_flatten.t,v 1.21 2009/05/09 12:42:02 jamiel Exp $
 ###############################################################################
 # -t : trace
 # -T : deep trace into modules
@@ -68,6 +68,47 @@
 my $unflat = Hash::Flatten::unflatten($flat);
 DUMP($unflat);
 ASSERT EQUAL($unflat, $data), 'nested hashes unflattened';
+
+#############################################################
+#
+# Nested hashes with weird values
+#
+#############################################################
+
+my $data =
+{
+	'x' => 1,
+	'0' => {
+		'1' => 2,
+		'' => {
+			'' => 3,
+			'q' => 4
+		},
+	},
+	'a' => [1,2,3],
+	'' => [4,5,6],
+};
+
+my $flat_data = {
+	'x' => 1,
+	'0.1' => 2,
+	'0..' => 3,
+	'0..q' => 4,
+	'a:0' => 1,
+	'a:1' => 2,
+	'a:2' => 3,
+	':0' => 4,
+	':1' => 5,
+	':2' => 6,
+};
+
+my $flat = Hash::Flatten::flatten($data);
+DUMP($flat);
+ASSERT EQUAL($flat, $flat_data), 'nested hashes with weird values';
+
+my $unflat = Hash::Flatten::unflatten($flat);
+DUMP($unflat);
+ASSERT EQUAL($unflat, $data), 'nested hashes with weird values unflattened';
 
 #############################################################
 #
@@ -430,7 +471,29 @@
 	'a:1' => 2
 }), "warn mode works as expected");
 
-# check to ensure passing an undefined escape sequence doesn't die!
-my $escape_seq;
-my $o = Hash::Flatten->new({EscapeSequence => $escape_seq});
-ASSERT($o,"setting an undefined escape sequence didn't cause an error.");
+$rv = Hash::Flatten::flatten({a=>"m:o.o", "o:i.n:k" => {a=>1}},{EscapeSequence => "#", DisableEscapes => 0});
+DUMP($rv);
+ASSERT(
+	EQUAL($rv,{a => 'm:o.o','o#:i#.n#:k.a' => 1}),
+	"Escapes on, returned escaped hash"
+);    
+$rv = Hash::Flatten::unflatten({a => 'm:o.o','o#:i#.n#:k.a' => 1},{EscapeSequence => "#", DisableEscapes => 0});
+DUMP($rv);
+ASSERT(
+	EQUAL($rv,{a=>"m:o.o", "o:i.n:k" => {a=>1}}),
+	"Escapes on, unescaped hash correctly"
+);    
+
+$rv = Hash::Flatten::flatten({a=>"m:o.o", "o:i.n:k" => {a=>1}},{EscapeSequence => "#", DisableEscapes => 1});
+DUMP($rv);
+ASSERT(
+	EQUAL($rv,{a => 'm:o.o','o:i.n:k.a' => 1}),
+	"Escapes off, returned nonsense"
+);    
+$rv = Hash::Flatten::unflatten({a => 'm:o.o','o#:i#.n#:k.a' => 1},{EscapeSequence => "#", DisableEscapes => 1});
+DUMP($rv);
+ASSERT(
+	EQUAL($rv,{a => 'm:o.o','o#' => [{'n#' => [{a => 1}]}]}),
+	"Escapes off, didn't unescape hash"
+);    
+




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