class IronMunger::Monger {
- use MooseX::Types::Moose qw(ArrayRef);
+ use MooseX::Types::Moose qw(ArrayRef Str);
use IronMunger::Calculate qw(:all);
use aliased 'IronMunger::Post';
use signatures;
+ has name => (is => 'ro', isa => Str, required => 0, predicate => 'has_name');
+ has nick => (is => 'ro', isa => Str, required => 0, predicate => 'has_nick');
+
has posts => (
is => 'ro', isa => ArrayRef[Post], required => 1,
default => sub { [] },
use IronMunger::CSVUtils qw(:all);
use aliased 'IronMunger::Post';
+ use aliased 'IronMunger::Monger';
use IO::All;
use Text::CSV_XS;
}
method _expand_monger (IO::All::File $file) {
- my ($name, $nick) = name_and_nick_from_filename($file->name);
+ my ($name, $nick) = filename_to_name_and_nick(($file->splitpath)[-1]);
Monger->new(
(defined $name ? (name => $name) : ()),
(defined $nick ? (nick => $nick) : ()),
}
}
+my $jdv = $loader->_expand_monger($jdv_file);
+
+is($jdv->name, 'Justin DeVuyst', 'Name correct');
+ok(!$jdv->has_nick, 'No nickname');
+cmp_ok(@{$jdv->posts}, '==', 2, '2 posts loaded');
+
+my @mongers = sort { $a->name cmp $b->name } $loader->mongers;
+
+cmp_ok(scalar(@mongers), '==', 2, '2 mongers loaded');
+
+foreach my $i (0, 1) {
+ is($mongers[$i]->name, $names[$i], $names[$i].' loaded');
+}