class IronMunger::StatsSaver {
use MooseX::Types::Path::Class qw(Dir);
+ use aliased 'IronMunger::Monger';
+ 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);
+ my @types = qw(male female);
+
method _image_symlink_target (Str $type, Str $level) {
$self->dir->subdir('badges')->subdir($type)->file("${level}.png");
}
$self->_image_symlink_from($user, $type),
$self->_image_symlink_target($type, $level),
);
+ my $dir = File::Spec->catpath((File::Spec->splitpath($target))[0,1]);
+ mkpath($dir);
symlink($target, $from)
or confess "Couldn't symlink ${from} to ${target}: $!";
return;
}
+
+ method _write_symlinks_for (IronMunger::Monger $monger) {
+ foreach my $type (@types) {
+ foreach my $name (map $monger->$_, qw(name nick)) {
+ $self->_write_image_symlink($name, $type, $monger->level);
+ }
+ }
+ }
+
+ method _write_summary_csv (ArrayRef[IronMunger::Monger] $mongers) {
+ }
+
+ method mongers (ArrayRef[IronMunger::Monger] $mongers) {
+ $self->_write_summary_csv($mongers);
+ $self->_write_symlinks_for($_) for @$mongers;
+ }
+
}
1;
use strict;
use warnings;
use Test::More qw(no_plan);
+use IO::All;
+use File::Temp qw(tempdir);
BEGIN { use_ok aliased => 'IronMunger::StatsSaver'; }
+BEGIN { use_ok aliased => 'IronMunger::Monger'; }
ok(
(my $saver = StatsSaver->new(dir => 'X')),
);
is(
- $saver->_image_symlink_from('mst', 'female',), 'X/mybadge/female/mst.png',
+ $saver->_image_symlink_from('mst', 'female'), 'X/mybadge/female/mst.png',
'Symlink from ok',
);
+
+my $monger = Monger->new(
+ nick => 'mst',
+ posts => []
+);
+
+is($monger->level, 'paper', 'mst sucks');
+
+my $dir = tempdir(CLEANUP => 1);
+
+$saver = StatsSaver->new(dir => $dir);
+
+$saver->_write_symlinks_for($monger);
+
+my @links = sort map $_->readlink, grep -l, io($dir)->all_files;
+
+warn join("\n", @links);