[Bps-public-commit] App-Changeloggr branch, master, updated. e7b40dcf95bbd0d9f0f9ef6e9995daa8acb73e12

Alex M Vandiver alexmv at bestpractical.com
Tue Mar 31 14:27:50 EDT 2009


The branch, master has been updated
       via  e7b40dcf95bbd0d9f0f9ef6e9995daa8acb73e12 (commit)
      from  056a3da109b67b4d25318d0afbad04851bf9bfc1 (commit)

Summary of changes:
 lib/App/Changeloggr/LogFormat/Subversion.pm    |   64 ++++++++++++++++++++
 lib/App/Changeloggr/LogFormat/SubversionXML.pm |   75 ++++++++++++++++++++++++
 2 files changed, 139 insertions(+), 0 deletions(-)
 create mode 100644 lib/App/Changeloggr/LogFormat/Subversion.pm
 create mode 100644 lib/App/Changeloggr/LogFormat/SubversionXML.pm

- Log -----------------------------------------------------------------
commit e7b40dcf95bbd0d9f0f9ef6e9995daa8acb73e12
Author: Alex Vandiver <alexmv at mit.edu>
Date:   Tue Mar 31 14:26:59 2009 -0400

    Add Subversion and SubversionXML backend parsers

diff --git a/lib/App/Changeloggr/LogFormat/Subversion.pm b/lib/App/Changeloggr/LogFormat/Subversion.pm
new file mode 100644
index 0000000..0ab48f0
--- /dev/null
+++ b/lib/App/Changeloggr/LogFormat/Subversion.pm
@@ -0,0 +1,64 @@
+package App::Changeloggr::LogFormat::Subversion;
+use base qw/App::Changeloggr::LogFormat/;
+use strict;
+use warnings;
+
+use DateTime::Format::Strptime;
+use constant DATE_PARSER => DateTime::Format::Strptime->new(
+    pattern => '%F %T %z',
+);
+
+sub matches {
+    my $self = shift;
+    my %args = @_;
+
+    return $args{text} =~ /\A-{72}\r?\nr\d+ \| \S+ \| \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \S+ \(.*?\) \| \d+ lines?/;
+}
+
+sub next_match {
+    my $self = shift;
+
+    $self->{text} =~ s{
+        \A
+        (
+            ^ -{72} \r? \n
+            (r.*?) \s+ \|
+            \s+ (.*?) \s+ \|
+            \s+ (\d{4}-\d{2}-\d{2} \s+ \d{2}:\d{2}:\d{2}\s+\S+) \s+ \(.*?\) \s+ \|
+            \s+ \d+ \s+ lines? \r? \n \r? \n
+            ( .*? )
+        )
+        (?=
+            ^ -{72} \r? \n
+        )
+    }{}xms or return;
+
+    my %fields;
+    $fields{raw} = $1;
+    $fields{identifier} = $2;
+    $fields{author} = $3;
+    $fields{date} = DATE_PARSER->parse_datetime($4);
+    $fields{message} = $5;
+
+    return \%fields;
+}
+
+=begin svn-sample
+
+------------------------------------------------------------------------
+r18997 | ruz | 2009-03-31 10:32:02 -0400 (Tue, 31 Mar 2009) | 1 line
+
+* after load check if we actually loaded the user
+------------------------------------------------------------------------
+r18996 | ruz | 2009-03-31 06:51:57 -0400 (Tue, 31 Mar 2009) | 1 line
+
+* more principal_id -> principal
+------------------------------------------------------------------------
+r18995 | acme | 2009-03-31 05:41:05 -0400 (Tue, 31 Mar 2009) | 2 lines
+
+Remove sunnavy's use lib
+
+------------------------------------------------------------------------
+=cut
+
+1;
diff --git a/lib/App/Changeloggr/LogFormat/SubversionXML.pm b/lib/App/Changeloggr/LogFormat/SubversionXML.pm
new file mode 100644
index 0000000..41e4929
--- /dev/null
+++ b/lib/App/Changeloggr/LogFormat/SubversionXML.pm
@@ -0,0 +1,75 @@
+package App::Changeloggr::LogFormat::SubversionXML;
+use base qw/App::Changeloggr::LogFormat/;
+use strict;
+use warnings;
+
+use XML::Simple;
+use DateTime::Format::Strptime;
+use constant DATE_PARSER => DateTime::Format::Strptime->new(
+    pattern => '%FT%T',
+);
+
+sub matches {
+    my $self = shift;
+    my %args = @_;
+
+    return $args{text} =~ /\A<\?xml\s+version="1.0"\?>\s+<log>\s+<logentry\s+revision="?\d+"?>/;
+}
+
+sub next_match {
+    my $self = shift;
+
+    unless ( $self->{log_entries} ) {
+        my $data = XMLin( $self->{text}, ForceArray => ["logentry"] );
+        $self->{log_entries} = [map {
+            {
+                identifier => "r" . $_->{revision},
+                author     => $_->{author},
+                date       => DATE_PARSER->parse_datetime( $_->{date} ),
+                message    => $_->{msg},
+                raw        => XMLout($_, NoAttr => 1), # Rather a hack
+            };
+        } @{ $data->{logentry} }];
+    }
+
+    return shift @{ $self->{log_entries} };
+}
+
+=begin svn-sample
+<?xml version="1.0"?>
+<log>
+<logentry
+   revision="5662">
+<author>glasser</author>
+<date>2006-07-27T18:26:08.845218Z</date>
+<msg>XML::WBXML actually works on Perl 5.6.0; requirement change requested by aaron at freebsd.org.</msg>
+</logentry>
+<logentry
+   revision="3645">
+<author>glasser</author>
+<date>2005-08-12T03:04:20.416142Z</date>
+<msg>Thingy</msg>
+</logentry>
+<logentry
+   revision="3644">
+<author>glasser</author>
+<date>2005-08-12T02:44:08.798828Z</date>
+<msg>Moose</msg>
+</logentry>
+<logentry
+   revision="3643">
+<author>glasser</author>
+<date>2005-08-12T01:35:10.934580Z</date>
+<msg>Woo</msg>
+</logentry>
+<logentry
+   revision="3642">
+<author>glasser</author>
+<date>2005-08-12T00:18:18.113445Z</date>
+<msg>start XML::WBXML project</msg>
+</logentry>
+</log>
+
+=cut
+
+1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list