From: Matt S Trout Date: Sun, 5 Jul 2009 15:12:55 +0000 (+0100) Subject: add debug code X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c5a24bc1a473894c9cf7e105d8b6f3c7a7835e2e;p=engit%2FIron-Munger.git add debug code --- diff --git a/lib/IronMunger.pm b/lib/IronMunger.pm index 5b11d17..d5c3bc6 100644 --- a/lib/IronMunger.pm +++ b/lib/IronMunger.pm @@ -23,6 +23,13 @@ class IronMunger { return $munger; } + method debug_dump () { + join("\n", map { + "Monger: ".$_->full_name."\n" + .$_->debug_dump + } map $self->mongers->{$_}, sort keys %{$self->mongers}); + } + method save_monger_stats (Str $dir) { my $saver = StatsSaver->new(dir => $dir); $saver->mongers([ diff --git a/lib/IronMunger/Monger.pm b/lib/IronMunger/Monger.pm index e047a11..aa63b7f 100644 --- a/lib/IronMunger/Monger.pm +++ b/lib/IronMunger/Monger.pm @@ -33,6 +33,18 @@ class IronMunger::Monger { is => 'ro', lazy => 1, default => sub ($self) { level_for_post_count($self->post_count) } ); + + method debug_dump () { + join("\n", + (map join(': ', $_, $self->$_), + qw(full_name post_count days_left level)), + 'Posts:', + join('', + map { my $x = $_->debug_dump; $x =~ s/^/ /m; $x; } @{$self->posts} + ), + '' + ); + } } 1; diff --git a/lib/IronMunger/Post.pm b/lib/IronMunger/Post.pm index aca135f..5d62b55 100644 --- a/lib/IronMunger/Post.pm +++ b/lib/IronMunger/Post.pm @@ -8,6 +8,10 @@ class IronMunger::Post { has at => (isa => DateTime, is => 'ro', required => 1, coerce => 1); has url => (isa => Str, is => 'ro', required => 1); + + method debug_dump () { + join("\n", (map join(': ', $_, $self->$_), qw(at url)), ''); + } } 1;