r61865 - in /trunk/libxml-writer-perl: Changes META.yml Makefile.PL Writer.pm debian/changelog t/01_main.t
franck at users.alioth.debian.org
franck at users.alioth.debian.org
Sun Aug 22 14:32:30 UTC 2010
Author: franck
Date: Sun Aug 22 14:32:21 2010
New Revision: 61865
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=61865
Log:
Integrating new upstream release into trunk.
Modified:
trunk/libxml-writer-perl/Changes
trunk/libxml-writer-perl/META.yml
trunk/libxml-writer-perl/Makefile.PL
trunk/libxml-writer-perl/Writer.pm
trunk/libxml-writer-perl/debian/changelog
trunk/libxml-writer-perl/t/01_main.t
Modified: trunk/libxml-writer-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-writer-perl/Changes?rev=61865&op=diff
==============================================================================
--- trunk/libxml-writer-perl/Changes (original)
+++ trunk/libxml-writer-perl/Changes Sun Aug 22 14:32:21 2010
@@ -1,5 +1,10 @@
Revision history for Perl extension XML::Writer.
+0.612 Mon Aug 16 00:10:16 2010 +1000 <joe at kafsemo.org>
+ - Allow DATA_INDENT to specify arbitrary white space for
+ indentation. If it is numeric then use that many space
+ characters.
+
0.611 Thu Apr 22 13:09:12 BST 2010 <joe at kafsemo.org>
- Adopt rewritten license text to explicitly allow modification.
Modified: trunk/libxml-writer-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-writer-perl/META.yml?rev=61865&op=diff
==============================================================================
--- trunk/libxml-writer-perl/META.yml (original)
+++ trunk/libxml-writer-perl/META.yml Sun Aug 22 14:32:21 2010
@@ -3,7 +3,7 @@
version: 1.4
url: http://module-build.sourceforge.net/META-spec-v1.4.html
name: XML-Writer
-version: 0.611
+version: 0.612
abstract: Easily generate well-formed, namespace-aware XML.
author:
- David Megginson <david at megginson.com>
Modified: trunk/libxml-writer-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-writer-perl/Makefile.PL?rev=61865&op=diff
==============================================================================
--- trunk/libxml-writer-perl/Makefile.PL (original)
+++ trunk/libxml-writer-perl/Makefile.PL Sun Aug 22 14:32:21 2010
@@ -7,7 +7,7 @@
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'XML::Writer',
- 'VERSION' => '0.611',
+ 'VERSION' => '0.612',
# A manually-created META.yml has all the other metadata;
# we don't want it overwritten
Modified: trunk/libxml-writer-perl/Writer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-writer-perl/Writer.pm?rev=61865&op=diff
==============================================================================
--- trunk/libxml-writer-perl/Writer.pm (original)
+++ trunk/libxml-writer-perl/Writer.pm Sun Aug 22 14:32:21 2010
@@ -15,7 +15,7 @@
use vars qw($VERSION);
use Carp;
use IO::Handle;
-$VERSION = "0.611";
+$VERSION = "0.612";
@@ -49,7 +49,7 @@
my $unsafe = $params{UNSAFE};
my $newlines = $params{NEWLINES};
my $dataMode = $params{DATA_MODE};
- my $dataIndent = $params{DATA_INDENT} || 0;
+ my $dataIndent;
# If the NEWLINES parameter is specified,
# set the $nl variable appropriately
@@ -183,7 +183,7 @@
my $data = $_[0];
if ($dataMode && $elementLevel) {
$output->print("\n");
- $output->print(" " x ($elementLevel * $dataIndent));
+ $output->print($dataIndent x $elementLevel);
}
$output->print("<!-- $data -->");
if ($dataMode && $elementLevel) {
@@ -241,7 +241,7 @@
my $name = $_[0];
if ($dataMode && ($hasHeading || $elementLevel)) {
$output->print("\n");
- $output->print(" " x ($elementLevel * $dataIndent));
+ $output->print($dataIndent x $elementLevel);
}
$elementLevel++;
push @elementStack, $name;
@@ -282,7 +282,7 @@
my $name = $_[0];
if ($dataMode && ($hasHeading || $elementLevel)) {
$output->print("\n");
- $output->print(" " x ($elementLevel * $dataIndent));
+ $output->print($dataIndent x $elementLevel);
}
$output->print("<$name");
&{$showAttributes}(\@_);
@@ -320,7 +320,7 @@
$elementLevel--;
if ($dataMode && $hasElement) {
$output->print("\n");
- $output->print(" " x ($elementLevel * $dataIndent));
+ $output->print($dataIndent x $elementLevel);
}
$output->print("</$name$nl>");
if ($dataMode) {
@@ -495,12 +495,23 @@
};
$self->{'SETDATAINDENT'} = sub {
- $dataIndent = $_[0];
+ if ($_[0] =~ /^\s*$/) {
+ $dataIndent = $_[0];
+ } else {
+ $dataIndent = ' ' x $_[0];
+ }
};
$self->{'GETDATAINDENT'} = sub {
- return $dataIndent;
- };
+ if ($dataIndent =~ /^ *$/) {
+ return length($dataIndent);
+ } else {
+ return $dataIndent;
+ }
+ };
+
+ # Set the indent.
+ &{$self->{'SETDATAINDENT'}}($params{'DATA_INDENT'} || '');
# Set the output.
&{$self->{'SETOUTPUT'}}($params{'OUTPUT'});
@@ -1313,9 +1324,10 @@
=item DATA_INDENT
-A numeric value; if this parameter is present, it represents the
+A numeric value or white space; if this parameter is present, it represents the
indent step for elements in data mode (it will be ignored when not in
-data mode).
+data mode). If it is white space it will be repeated for each level of
+indentation.
=item ENCODING
@@ -1651,11 +1663,14 @@
=head1 COPYRIGHT AND LICENSE
-Copyright 1999, 2000 David Megginson E<lt>david at megginson.comE<gt>
-
-Copyright 2004, 2005 Joseph Walton E<lt>joe at kafsemo.orgE<gt>
-
-No warranty. Commercial and non-commercial use freely permitted.
+Copyright (c) 1999 by Megginson Technologies.
+
+Copyright (c) 2003 Ed Avis E<lt>ed at membled.comE<gt>
+
+Copyright (c) 2004-2010 Joseph Walton E<lt>joe at kafsemo.orgE<gt>
+
+Redistribution and use in source and compiled forms, with or without
+modification, are permitted under any circumstances. No warranty.
=head1 SEE ALSO
Modified: trunk/libxml-writer-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-writer-perl/debian/changelog?rev=61865&op=diff
==============================================================================
--- trunk/libxml-writer-perl/debian/changelog (original)
+++ trunk/libxml-writer-perl/debian/changelog Sun Aug 22 14:32:21 2010
@@ -1,3 +1,9 @@
+libxml-writer-perl (0.612-1) UNRELEASED; urgency=low
+
+ * New upstream release
+
+ -- Franck Joncourt <franck at debian.org> Sun, 22 Aug 2010 16:31:18 +0200
+
libxml-writer-perl (0.611-1) unstable; urgency=low
[ Brian Cassidy ]
Modified: trunk/libxml-writer-perl/t/01_main.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-writer-perl/t/01_main.t?rev=61865&op=diff
==============================================================================
--- trunk/libxml-writer-perl/t/01_main.t (original)
+++ trunk/libxml-writer-perl/t/01_main.t Sun Aug 22 14:32:21 2010
@@ -15,7 +15,7 @@
use Errno;
-use Test::More(tests => 225);
+use Test::More(tests => 236);
# Catch warnings
@@ -1891,6 +1891,89 @@
is ($w->getOutput(), $out, 'Changing output back should succeed');
};
+# Test changing numeric indentation
+TEST: {
+ initEnv();
+
+ is($w->getDataIndent(), 0, 'Indent should default to zero');
+
+ $w->setDataIndent(1);
+ is($w->getDataIndent(), 1, 'Indent should be as set');
+
+};
+
+# Generate a document with an indent of more than one
+TEST: {
+ initEnv(
+ DATA_MODE => 1,
+ DATA_INDENT => 2
+ );
+
+ $w->xmlDecl();
+ $w->startTag('doc');
+ $w->emptyTag('item');
+ $w->endTag('doc');
+ $w->end();
+ checkResult(<<"EOS", "Numeric indent should indicate the number of spaces");
+<?xml version="1.0"?>
+
+<doc>
+ <item />
+</doc>
+EOS
+};
+
+# Test getting and setting indentation as a whitespace string
+TEST: {
+ initEnv();
+
+ is($w->getDataIndent(), 0, 'Indent should be returned as the number of spaces');
+
+ $w->setDataIndent(' ');
+ is($w->getDataIndent(), 1, 'Indent should be returned as the number of spaces');
+
+ $w->setDataIndent(' ');
+ is($w->getDataIndent(), 2, 'Indent should be returned as the number of spaces');
+
+ $w->setDataIndent("\t");
+ is($w->getDataIndent(), "\t", 'Indent should be returned as a string when given as non-space whitespace');
+};
+
+# Generate a document with whitespace string indentation
+TEST: {
+ initEnv(
+ DATA_MODE => 1,
+ DATA_INDENT => ''
+ );
+
+ $w->xmlDecl();
+ $w->startTag('doc');
+ $w->emptyTag('item');
+ $w->setDataIndent(' ');
+ $w->emptyTag('item');
+ $w->setDataIndent("\t");
+ $w->emptyTag('item');
+ $w->endTag('doc');
+ $w->end();
+ checkResult(<<"EOS", "Numeric indent should indicate the number of spaces");
+<?xml version="1.0"?>
+
+<doc>
+<item />
+ <item />
+\t<item />
+</doc>
+EOS
+};
+
+# A non-whitespace, non-numeric indent should fall back to 0
+TEST: {
+ initEnv();
+
+ $w->setDataIndent('x');
+ is($w->getDataIndent(), 0, 'Non-numeric indent should fall back to zero');
+};
+
# Free test resources
$outputFile->close() or die "Unable to close temporary file: $!";
More information about the Pkg-perl-cvs-commits
mailing list