From: Matt S Trout Date: Fri, 22 May 2009 14:58:25 +0000 (+0100) Subject: clean up and get the integration code to make a first run X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4142f6a9a081cfd6821656cbaf6d3fc5d201802a;p=engit%2FIron-Munger.git clean up and get the integration code to make a first run --- diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..e1d2560 --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +Options +Indexes diff --git a/lib/IronMunger.pm b/lib/IronMunger.pm index a56545c..5b11d17 100644 --- a/lib/IronMunger.pm +++ b/lib/IronMunger.pm @@ -4,14 +4,12 @@ class IronMunger { our $VERSION = '0.001000'; - use aliased 'IronMunger::Monger'; use aliased 'IronMunger::PlaggerLoader'; use aliased 'IronMunger::StatsSaver'; + use aliased 'IronMunger::Monger'; use MooseX::Types::Moose qw(HashRef ClassName Str); - use namespace::autoclean; - has mongers => ( is => 'ro', isa => HashRef[Monger], required => 1, default => sub { {} }, @@ -21,12 +19,16 @@ class IronMunger { my $loader = PlaggerLoader->new(dir => $dir); my $munger = $class->new; $munger->mongers->{$_->full_name} - = $_ for @{$loader->mongers}; + = $_ for $loader->mongers; + return $munger; } method save_monger_stats (Str $dir) { my $saver = StatsSaver->new(dir => $dir); - $saver->mongers([ sort $_->full_name, values %{$self->mongers} ]); + $saver->mongers([ + sort { $a->full_name cmp $b->full_name } + values %{$self->mongers} + ]); } } diff --git a/lib/IronMunger/Monger.pm b/lib/IronMunger/Monger.pm index 5b844b7..e047a11 100644 --- a/lib/IronMunger/Monger.pm +++ b/lib/IronMunger/Monger.pm @@ -10,6 +10,10 @@ class IronMunger::Monger { has name => (is => 'ro', isa => Str, required => 0, predicate => 'has_name'); has nick => (is => 'ro', isa => Str, required => 0, predicate => 'has_nick'); + method full_name () { + join(' aka ',$self->name||'nameless',$self->nick||'anoncow'); + } + has posts => ( is => 'ro', isa => ArrayRef[Post], required => 1, default => sub { [] }, diff --git a/lib/IronMunger/StatsSaver.pm b/lib/IronMunger/StatsSaver.pm index 304539f..be4156d 100644 --- a/lib/IronMunger/StatsSaver.pm +++ b/lib/IronMunger/StatsSaver.pm @@ -7,7 +7,6 @@ class IronMunger::StatsSaver { use IO::All; use File::Path qw(mkpath); use Text::CSV_XS; - use namespace::autoclean; has dir => (is => 'ro', isa => Dir, required => 1, coerce => 1); diff --git a/t/iron_munger.t b/t/iron_munger.t new file mode 100644 index 0000000..d5257b5 --- /dev/null +++ b/t/iron_munger.t @@ -0,0 +1,12 @@ +use strict; +use warnings; +use Test::More qw(no_plan); +use File::Temp 'tempdir'; + +BEGIN { + use_ok "IronMunger"; +} + +my $munger = IronMunger->load_from_plagger('t/csv'); + +$munger->save_monger_stats('whut');