Skip to content

Commit

Permalink
removed the save_report sub
Browse files Browse the repository at this point in the history
  • Loading branch information
apocalypse committed Nov 25, 2009
1 parent a3ccf41 commit 5345384
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
37 changes: 14 additions & 23 deletions lib/Test/Reporter/POEGateway.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ sub spawn {

# setup the path to store reports
if ( ! exists $opt{'reports'} or ! defined $opt{'reports'} ) {
my $path = File::Spec->catdir( $ENV{HOME}, 'cpan_reports' );
if ( DEBUG ) {
warn 'Using default REPORTS = "$ENV{HOME}/cpan_reports"';
warn "Using default REPORTS = '$path'";
}

# Set the default
$opt{'reports'} = File::Spec->catdir( $ENV{HOME}, 'cpan_reports' );
$opt{'reports'} = $path;
}

# validate the report path
Expand Down Expand Up @@ -204,8 +205,17 @@ sub got_req : State {

# not a malformed request...
if ( ! defined $response->code ) {
# store the request somewhere
save_report( $form, $request, $response );
# add some misc info
$form->{'_sender'} = $response->connection->remote_ip;
$form->{'via'} .= ', via ' . __PACKAGE__ . ' ' . $VERSION;

# calculate the filename
my $filename = File::Spec->catfile( $_[HEAP]->{'REPORTS'}, time() . '.' . sha1_hex( $form->{'report'} ) );
DumpFile( $filename, $form );

if ( DEBUG ) {
warn "Saved $form->{subject} report to $filename";
}

# Do our stuff to HTTP::Response
$response->code( 200 );
Expand All @@ -218,25 +228,6 @@ sub got_req : State {
return;
}

# does the brunt work of saving posted reports
sub save_report {
my( $form, $request, $response ) = @_;

# add some misc info
$form->{'_sender'} = $response->connection->remote_ip;
$form->{'via'} .= ', via ' . __PACKAGE__ . ' ' . $VERSION;

# calculate the filename
my $filename = time() . '.' . sha1_hex( $form->{'report'} );
DumpFile( File::Spec->catfile( $_[HEAP]->{'REPORTS'}, $filename ), $form );

if ( DEBUG ) {
warn "Saved $form->{subject} report to $filename";
}

return;
}

1;
__END__
Expand Down
6 changes: 5 additions & 1 deletion lib/Test/Reporter/POEGateway/Mailer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sub spawn {
if ( ! exists $opt{'reports'} or ! defined $opt{'reports'} ) {
my $path = File::Spec->catdir( $ENV{HOME}, 'cpan_reports' );
if ( DEBUG ) {
warn 'Using default REPORTS = "$path"';
warn "Using default REPORTS = '$path'";
}

# Set the default
Expand Down Expand Up @@ -396,6 +396,10 @@ sub Got_STDOUT {
# The data!
my $data = $_[ARG0];

if ( DEBUG ) {
warn __PACKAGE__ . ": got stdout '$data'";
}

# We should get: "OK $file" or "NOK $error"
if ( $data =~ /^OK\s+(.+)$/ ) {
my $file = $1;
Expand Down

0 comments on commit 5345384

Please sign in to comment.