sub _check_header {
my ($self, %params) = @_;
- return $self->header if $self->header;
+ my $header = $self->header;
- my $header = $self->_csv->getline($self->_io);
+ if (! $header) {
+ $header = $self->_csv->getline($self->_io);
- $self->_push_error([
- $self->_csv->error_input,
- $self->_csv->error_diag,
- 0,
- ]) unless $header;
+ $self->_push_error([
+ $self->_csv->error_input,
+ $self->_csv->error_diag,
+ 0,
+ ]) unless $header;
+ }
- $self->header([ map { lc } @{ $header } ]);
+ return unless $header;
+ return $self->header([ map { lc } @$header ]);
}
sub _parse_data {
-use Test::More tests => 37;
+use Test::More tests => 39;
use SL::Dispatcher;
use Data::Dumper;
use utf8;
$csv->parse;
is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'eol bug at the end of files';
+#####
+
+$csv = SL::Helper::Csv->new(
+ file => \"Description\nKaffee",
+ class => 'SL::DB::Part',
+);
+$csv->parse;
+is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'case insensitive header from csv works';
+
+#####
+
+$csv = SL::Helper::Csv->new(
+ file => \"Kaffee",
+ header => [ 'Description' ],
+ class => 'SL::DB::Part',
+);
+$csv->parse;
+is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'case insensitive header as param works';
+
# vim: ft=perl