File Coverage

blib/lib/TableDataRole/Source/CSVInDATA.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package TableDataRole::Source::CSVInDATA;
2              
3 8     8   363350 use 5.010001;
  8         36  
4 8     8   59 use strict;
  8         19  
  8         205  
5 8     8   38 use warnings;
  8         19  
  8         637  
6              
7 8     8   494 use Role::Tiny;
  8         5383  
  8         76  
8              
9             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10             our $DATE = '2024-05-14'; # DATE
11             our $DIST = 'TableDataRoles-Standard'; # DIST
12             our $VERSION = '0.025'; # VERSION
13              
14             with 'TableDataRole::Spec::Basic';
15             with 'TableDataRole::Source::CSVInFile';
16              
17             around new => sub {
18             my $orig = shift;
19             my ($class, %args) = @_;
20             die "Unknown argument(s): ". join(", ", sort keys %args)
21             if keys %args;
22              
23 8     8   3283 no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
  8         21  
  8         1664  
24             my $fh = \*{"$class\::DATA"};
25              
26             if (defined ${"$class\::_TableData_fhpos_data_begin_cache"}) {
27             seek $fh, ${"$class\::_TableData_fhpos_data_begin_cache"}, 0;
28             } else {
29             ${"$class\::_TableData_fhpos_data_begin_cache"} = tell $fh;
30             }
31              
32             my $obj = $orig->(@_, filehandle => $fh);
33             };
34              
35             1;
36             # ABSTRACT: Role to access table data from CSV in DATA section
37              
38             __END__