];
}
+ method _csv_column_order () {
+ my $x;
+ return map +($_ => $x++), qw(author title url at);
+ }
+
method _expand_postspecs_from_file(IO::All::File $file) {
my $csv = Text::CSV_XS->new;
my $io = $file->open;
my @post_specs;
+ my %col_order = $self->_csv_column_order;
while (my $post_raw = $csv->getline($io)) {
my %post_spec;
- @post_spec{qw{url at}} = @{$post_raw}[1,2];
- push(@post_specs, %post_spec);
+ @post_spec{qw{url at}} = @{$post_raw}[@col_order{qw{url at}}];
+ push(@post_specs, \%post_spec);
}
return \@post_specs;
}
use strict;
use warnings;
use Test::More qw(no_plan);
-
+use IO::All;
BEGIN {
use_ok aliased => 'IronMunger::PlaggerLoader';
is($post->$key, $args{$key}, "Attribute ${key} ok");
}
}
+
+my @postspecs = map
+ +{
+ url => 'http://jdv79.blogspot.com/2009/05/testable-v007.html',
+ at => $_,
+ }, qw(2009-05-13T02:45:00 2009-05-14T16:00:00);
+
+my $specs = $loader->_expand_postspecs_from_file(
+ io('t/csv/my_Justin_DeVuyst.csv')
+ );
+
+is_deeply($specs, \@postspecs, 'Post specs from file ok');