[Bps-public-commit] App-Changeloggr branch, master, updated. 89735cfb0dcabdf33bd902efde85cb77d886edc3
Alex M Vandiver
alexmv at bestpractical.com
Wed Apr 1 14:06:35 EDT 2009
The branch, master has been updated
via 89735cfb0dcabdf33bd902efde85cb77d886edc3 (commit)
via 544e671e9d45d1b0cb8a58cb9763ee9e44e89e0c (commit)
from 6e3ca74f78b11bca5287b7fbc5433980573c0a85 (commit)
Summary of changes:
lib/App/Changeloggr.pm | 4 +-
lib/App/Changeloggr/Action/AddChanges.pm | 2 +-
lib/App/Changeloggr/Dispatcher.pm | 6 +++
.../Changeloggr/{LogFormat.pm => InputFormat.pm} | 4 +-
.../Changeloggr/{LogFormat => InputFormat}/Git.pm | 6 ++--
.../{LogFormat => InputFormat}/Subversion.pm | 4 +-
.../{LogFormat => InputFormat}/SubversionXML.pm | 4 +-
lib/App/Changeloggr/Model/ChangeCollection.pm | 4 +-
lib/App/Changeloggr/Model/Changelog.pm | 18 +++-------
lib/App/Changeloggr/OutputFormat.pm | 13 +++++++
lib/App/Changeloggr/OutputFormat/Jifty.pm | 26 ++++++++++++++
lib/App/Changeloggr/OutputFormat/Perl.pm | 37 ++++++++++++++++++++
lib/App/Changeloggr/View.pm | 6 ++--
13 files changed, 104 insertions(+), 30 deletions(-)
rename lib/App/Changeloggr/{LogFormat.pm => InputFormat.pm} (87%)
rename lib/App/Changeloggr/{LogFormat => InputFormat}/Git.pm (95%)
rename lib/App/Changeloggr/{LogFormat => InputFormat}/Subversion.pm (94%)
rename lib/App/Changeloggr/{LogFormat => InputFormat}/SubversionXML.pm (94%)
create mode 100644 lib/App/Changeloggr/OutputFormat.pm
create mode 100644 lib/App/Changeloggr/OutputFormat/Jifty.pm
create mode 100644 lib/App/Changeloggr/OutputFormat/Perl.pm
- Log -----------------------------------------------------------------
commit 544e671e9d45d1b0cb8a58cb9763ee9e44e89e0c
Author: Alex Vandiver <alexmv at mit.edu>
Date: Wed Apr 1 13:21:57 2009 -0400
LogFormat -> InputFormat in preperation for having OutputFormat
diff --git a/lib/App/Changeloggr.pm b/lib/App/Changeloggr.pm
index fd60632..f436699 100644
--- a/lib/App/Changeloggr.pm
+++ b/lib/App/Changeloggr.pm
@@ -2,14 +2,14 @@ package App::Changeloggr;
use strict;
use warnings;
-use App::Changeloggr::LogFormat;
+use App::Changeloggr::InputFormat;
sub start {
my $class = shift;
# Find all log format parsers
Jifty::Module::Pluggable->import(
- search_path => 'App::Changeloggr::LogFormat',
+ search_path => 'App::Changeloggr::InputFormat',
require => 1,
inner => 0,
sub_name => 'log_formats',
diff --git a/lib/App/Changeloggr/Action/AddChanges.pm b/lib/App/Changeloggr/Action/AddChanges.pm
index 7782f6f..7b1a04f 100644
--- a/lib/App/Changeloggr/Action/AddChanges.pm
+++ b/lib/App/Changeloggr/Action/AddChanges.pm
@@ -18,7 +18,7 @@ use Jifty::Action schema {
sub take_action {
my $self = shift;
- my $parser = App::Changeloggr::LogFormat->new( file => $self->argument_value('changes') );
+ my $parser = App::Changeloggr::InputFormat->new( file => $self->argument_value('changes') );
$self->argument_value( changes => undef );
unless ($parser) {
return $self->validation_error( changes => "That doesn't look like a log format we recognize." );
diff --git a/lib/App/Changeloggr/LogFormat.pm b/lib/App/Changeloggr/InputFormat.pm
similarity index 87%
rename from lib/App/Changeloggr/LogFormat.pm
rename to lib/App/Changeloggr/InputFormat.pm
index 7c03a25..3a97077 100644
--- a/lib/App/Changeloggr/LogFormat.pm
+++ b/lib/App/Changeloggr/InputFormat.pm
@@ -1,4 +1,4 @@
-package App::Changeloggr::LogFormat;
+package App::Changeloggr::InputFormat;
use strict;
use warnings;
@@ -16,7 +16,7 @@ sub new {
return unless $args{text} =~ /\S/;
- if ($class eq "App::Changeloggr::LogFormat") {
+ if ($class eq __PACKAGE__) {
for my $format (App::Changeloggr->log_formats) {
return $format->new( %args ) if $format->matches( %args );
}
diff --git a/lib/App/Changeloggr/LogFormat/Git.pm b/lib/App/Changeloggr/InputFormat/Git.pm
similarity index 95%
rename from lib/App/Changeloggr/LogFormat/Git.pm
rename to lib/App/Changeloggr/InputFormat/Git.pm
index 1b5ab14..05d68b1 100644
--- a/lib/App/Changeloggr/LogFormat/Git.pm
+++ b/lib/App/Changeloggr/InputFormat/Git.pm
@@ -1,5 +1,5 @@
-package App::Changeloggr::LogFormat::Git;
-use base qw/App::Changeloggr::LogFormat/;
+package App::Changeloggr::InputFormat::Git;
+use base qw/App::Changeloggr::InputFormat/;
use strict;
use warnings;
@@ -14,7 +14,7 @@ sub matches {
return $args{text} =~ /^commit \w+\r?\n/;
}
-
+
sub next_match {
my $self = shift;
diff --git a/lib/App/Changeloggr/LogFormat/Subversion.pm b/lib/App/Changeloggr/InputFormat/Subversion.pm
similarity index 94%
rename from lib/App/Changeloggr/LogFormat/Subversion.pm
rename to lib/App/Changeloggr/InputFormat/Subversion.pm
index 0ab48f0..8b7630f 100644
--- a/lib/App/Changeloggr/LogFormat/Subversion.pm
+++ b/lib/App/Changeloggr/InputFormat/Subversion.pm
@@ -1,5 +1,5 @@
-package App::Changeloggr::LogFormat::Subversion;
-use base qw/App::Changeloggr::LogFormat/;
+package App::Changeloggr::InputFormat::Subversion;
+use base qw/App::Changeloggr::InputFormat/;
use strict;
use warnings;
diff --git a/lib/App/Changeloggr/LogFormat/SubversionXML.pm b/lib/App/Changeloggr/InputFormat/SubversionXML.pm
similarity index 94%
rename from lib/App/Changeloggr/LogFormat/SubversionXML.pm
rename to lib/App/Changeloggr/InputFormat/SubversionXML.pm
index 41e4929..7f458f1 100644
--- a/lib/App/Changeloggr/LogFormat/SubversionXML.pm
+++ b/lib/App/Changeloggr/InputFormat/SubversionXML.pm
@@ -1,5 +1,5 @@
-package App::Changeloggr::LogFormat::SubversionXML;
-use base qw/App::Changeloggr::LogFormat/;
+package App::Changeloggr::InputFormat::SubversionXML;
+use base qw/App::Changeloggr::InputFormat/;
use strict;
use warnings;
diff --git a/lib/App/Changeloggr/Model/ChangeCollection.pm b/lib/App/Changeloggr/Model/ChangeCollection.pm
index 4ecc0de..6a5e3d9 100644
--- a/lib/App/Changeloggr/Model/ChangeCollection.pm
+++ b/lib/App/Changeloggr/Model/ChangeCollection.pm
@@ -13,14 +13,14 @@ sub create_from_text {
changelog => { isa => 'App::Changeloggr::Model::Changelog' },
});
- my $parser = App::Changeloggr::LogFormat->new( text => delete $args{text} );
+ my $parser = App::Changeloggr::InputFormat->new( text => delete $args{text} );
return $self->create_from_parser( %args, parser => $parser );
}
sub create_from_parser {
my $self = shift;
my %args = validate(@_, {
- parser => { isa => 'App::Changeloggr::LogFormat' },
+ parser => { isa => 'App::Changeloggr::InputFormat' },
changelog => { isa => 'App::Changeloggr::Model::Changelog' },
});
commit 89735cfb0dcabdf33bd902efde85cb77d886edc3
Author: Alex Vandiver <alexmv at mit.edu>
Date: Wed Apr 1 14:03:28 2009 -0400
Move to having OutputFormat classes, with only Perl and Jifty options for now
diff --git a/lib/App/Changeloggr/Dispatcher.pm b/lib/App/Changeloggr/Dispatcher.pm
index babdfa9..5becbac 100644
--- a/lib/App/Changeloggr/Dispatcher.pm
+++ b/lib/App/Changeloggr/Dispatcher.pm
@@ -24,6 +24,12 @@ on '/changelog/*/Changes' => run {
show '/changelog/download';
};
+on '/changelog/*/*/Changes' => run {
+ set name => $1;
+ set format => $2;
+ show '/changelog/download';
+};
+
on '/changelog/*/admin' => run {
my $uuid = $1;
set id => Changelog(admin_token => $uuid)->id;
diff --git a/lib/App/Changeloggr/Model/Changelog.pm b/lib/App/Changeloggr/Model/Changelog.pm
index 90c7786..54d5771 100644
--- a/lib/App/Changeloggr/Model/Changelog.pm
+++ b/lib/App/Changeloggr/Model/Changelog.pm
@@ -102,6 +102,10 @@ sub choose_change {
sub generate {
my $self = shift;
+ my $format = Jifty->app_class( OutputFormat => shift || "Jifty" );
+ Jifty::Util->require( $format )
+ or return "";
+
my $changes = $self->changes;
$changes->order_by(column => 'date');
my %categories;
@@ -114,19 +118,7 @@ sub generate {
}
}
- my $str = "Changelog for ". $self->name.", generated ".Jifty::DateTime->now."\n\n";
- for my $cat (sort keys %categories) {
- $str .= uc($cat) . "\n" . ("=" x length($cat)) . "\n";
- for my $change (@{$categories{$cat}}) {
- my $msg = " * " . $change->message;
- $msg =~ s/\n*\Z//;
- $msg =~ s/\n/\n /g;
- $msg =~ s/\n\s+\n/\n\n/g;
- $str .= $msg . "\n";
- }
- $str .= "\n";
- }
- return $str;
+ return $format->generate( changelog => $self, categories => \%categories );
}
1;
diff --git a/lib/App/Changeloggr/OutputFormat.pm b/lib/App/Changeloggr/OutputFormat.pm
new file mode 100644
index 0000000..f5fbdc2
--- /dev/null
+++ b/lib/App/Changeloggr/OutputFormat.pm
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+package App::Changeloggr::OutputFormat::Jifty;
+
+sub generate {
+ my $class = shift;
+ my($categories) = @_;
+ # ...
+ return "";
+}
+
+1;
diff --git a/lib/App/Changeloggr/OutputFormat/Jifty.pm b/lib/App/Changeloggr/OutputFormat/Jifty.pm
new file mode 100644
index 0000000..2ab0be4
--- /dev/null
+++ b/lib/App/Changeloggr/OutputFormat/Jifty.pm
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+
+package App::Changeloggr::OutputFormat::Jifty;
+use base qw/App::Changeloggr::OutputFormat/;
+
+sub generate {
+ my $class = shift;
+ my %args = @_;
+
+ my $str = "Changelog for ". $args{changelog}->name.", generated ".Jifty::DateTime->now."\n\n";
+ for my $cat (sort keys %{$args{categories}}) {
+ $str .= uc($cat) . "\n" . ("=" x length($cat)) . "\n";
+ for my $change (@{$args{categories}{$cat}}) {
+ my $msg = " * " . $change->message;
+ $msg =~ s/\n*\Z//;
+ $msg =~ s/\n/\n /g;
+ $msg =~ s/\n\s+\n/\n\n/g;
+ $str .= $msg . "\n";
+ }
+ $str .= "\n";
+ }
+ return $str;
+}
+
+1;
diff --git a/lib/App/Changeloggr/OutputFormat/Perl.pm b/lib/App/Changeloggr/OutputFormat/Perl.pm
new file mode 100644
index 0000000..c98b262
--- /dev/null
+++ b/lib/App/Changeloggr/OutputFormat/Perl.pm
@@ -0,0 +1,37 @@
+use strict;
+use warnings;
+
+package App::Changeloggr::OutputFormat::Perl;
+use base qw/App::Changeloggr::OutputFormat/;
+
+sub generate {
+ my $class = shift;
+ my %args = @_;
+
+ my $name = $args{changelog}->name;
+ my $version = $name =~ /(\d+\.(\d+)\.\d+)/ ? $1 : $name;
+ my $release = ($2 and $2 % 2) ? "development release" : "release";
+
+ my $str = <<EOT;
+=head1 NAME
+
+perldelta - what is new for $version
+
+=head1 DESCRIPTION
+
+This document describes differences between the __PREVIOUS__ and the $version
+$release.
+EOT
+
+ for my $cat (sort keys %{$args{categories}}) {
+ $str .= "\n=head1 $cat\n\n";
+ for my $change (@{$args{categories}{$cat}}) {
+ my($summary) = $change->message =~ /\A(.*)$/m;
+ $str .= "=head2 $summary\n\n" . $change->message . "\n";
+ }
+ }
+ $str .= "=cut\n\n";
+ return $str;
+}
+
+1;
diff --git a/lib/App/Changeloggr/View.pm b/lib/App/Changeloggr/View.pm
index 910c8ac..6a40b63 100644
--- a/lib/App/Changeloggr/View.pm
+++ b/lib/App/Changeloggr/View.pm
@@ -47,9 +47,9 @@ template '/changelog' => page {
};
template '/changelog/download' => sub {
- my $changelog = Changelog(name => get('name'));
- Jifty->handler->apache->header_out('Content-Type' => 'text/plain');
- outs_raw( $changelog->generate );
+ my $changelog = Changelog( name => get('name') );
+ Jifty->handler->apache->header_out( 'Content-Type' => 'text/plain' );
+ outs_raw( $changelog->generate( get('format') ) );
};
template '/vote-on-change' => sub {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list