This is an automated email from the git hooks/post-receive script. intrigeri pushed a commit to tag debian_version_0_8-1 in repository libparse-debianchangelog-perl.
commit 3834307563d9e60c586e9f2c2436605ffa1d67bd Author: Frank Lichtenheld <fr...@lichtenheld.de> Date: Mon Oct 3 12:14:00 2005 +0000 Merge 0.8 to MAIN --- lib/Parse/DebianChangelog.pm | 84 +++++++++++++++++++++++++++++++++++++++++++- t/Parse-DebianChangelog.t | 18 +++++++++- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/lib/Parse/DebianChangelog.pm b/lib/Parse/DebianChangelog.pm index 8f109e4..1d4c2bb 100644 --- a/lib/Parse/DebianChangelog.pm +++ b/lib/Parse/DebianChangelog.pm @@ -71,6 +71,12 @@ Similar to the C<dpkg> format, but the requested entries are returned as one stanza each, i.e. they are not merged. This is probably the format to use if you want a machine-usable representation of the changelog. +=item xml + +Just a simple XML dump of the changelog data. Without any schema or +DTD currenlty, just some made up XML. The actual format might still +change. Comments and Improvements welcome. + =item html The changelog is converted to a somewhat nice looking HTML file with @@ -97,7 +103,7 @@ use Parse::DebianChangelog::Util qw( :all ); use Parse::DebianChangelog::Entry; our $CLASSNAME = 'Parse::DebianChangelog'; -our $VERSION = 0.7; +our $VERSION = 0.8; =pod @@ -673,6 +679,81 @@ sub __version2id { =pod +=head3 xml + +(and B<xml_str>) + +C<xml> converts the changelog to some free-form (i.e. there is neither +a DTD or a schema for it) XML. + +The method C<xml_str> is an alias for C<xml>. + +Both methods support the common output options described in +section L<"COMMON OUTPUT OPTIONS"> and additionally the following +configuration options (as usual to give +in a hash reference as parameter to the method call): + +=over 4 + +=item outfile + +directly write the output to the file specified + +=back + +=cut + +sub xml { + my ($self, $config) = @_; + + $self->{config}{XML} = $config if $config; + $config = $self->{config}{XML} || {}; + $config->{all} = 1 unless exists $config->{all}; + my $data = $self->_data_range( $config ) or return undef; + my %out_data; + $out_data{Entry} = []; + + require XML::Simple; + import XML::Simple qw( :strict ); + + foreach my $entry (@$data) { + my %f; + foreach my $field (qw( Urgency Source Version + Distribution Closes )) { + $f{$field} = $entry->{$field}; + } + foreach my $field (qw( Maintainer Changes )) { + $f{$field} = [ $entry->{$field} ]; + } + + $f{Urgency} .= $entry->{Urgency_Comment}; + $f{Date} = { timestamp => $entry->{Timestamp}, + content => $entry->{Date} }; + push @{$out_data{Entry}}, \%f; + } + + my $xml_str; + my %xml_opts = ( SuppressEmpty => 1, KeyAttr => {}, + RootName => 'Changelog' ); + $xml_str = XMLout( \%out_data, %xml_opts ); + if ($config->{outfile}) { + open my $fh, '>', $config->{outfile} or return undef; + flock $fh, LOCK_EX or return undef; + + print $fh $xml_str; + + close $fh or return undef; + } + + return $xml_str; +} + +sub xml_str { + return xml(@_); +} + +=pod + =head3 html (and B<html_str>) @@ -748,6 +829,7 @@ sub html { if $config->{print_style}; my $cgi = new CGI; + $cgi->autoEscape(0); my %navigation; my $last_year; diff --git a/t/Parse-DebianChangelog.t b/t/Parse-DebianChangelog.t index 4d691ac..04607f8 100644 --- a/t/Parse-DebianChangelog.t +++ b/t/Parse-DebianChangelog.t @@ -10,10 +10,11 @@ use strict; use warnings; use File::Basename; +use XML::Simple; BEGIN { my $no_examples = 2; - my $no_tests = $no_examples * 11 + 6; + my $no_tests = $no_examples * 13 + 7; require Test::More; import Test::More tests => $no_tests, ; @@ -83,6 +84,13 @@ foreach my $file (qw(Changes t/examples/shadow)) { ok( 1 ); + if ($file eq 'Changes') { + my $v = $data[0]->Version; + $v =~ s/[a-z]$//; + is( $v, $Parse::DebianChangelog::VERSION, + 'version numbers in module and Changes match' ); + } + my $oldest_version = $data[-1]->Version; $str = $changes->dpkg_str({ since => $oldest_version }); @@ -98,5 +106,13 @@ foreach my $file (qw(Changes t/examples/shadow)) { ok( 1 ); + $str = $changes->xml( { outfile => "t/$basename.xml.tmp" }); + + ok( XMLin($str, ForceArray => {}, + KeyAttr => {} ), "can read in the result of XMLout" ); + ok( (-s "t/$basename.xml.tmp") == length($str) ); + + unlink( "t/$basename.xml.tmp" ); + } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libparse-debianchangelog-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits