Catmandu/Fix/add_to_exporter.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 41 / 41 CC 2 SCAR 2.0
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Catmandu/Fix/Condition/all_match.pm ↑ Summary Catmandu/Fix/copy_field.pm »
1 package Catmandu::Fix::add_to_exporter;
2  
3 3 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 our $VERSION = '1.2025';
6  
7 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 has path => (fix_arg => 1);
13 3 has exporter_name => (fix_arg => 1);
14 3 has exporter_args => (fix_opt => 'collect');
15 3 has exporter => (is => 'lazy', init_arg => undef);
16  
17 3 with 'Catmandu::Fix::Builder';
18  
19 3 ▶sub _build_exporter {
Subroutine _build_exporter: called CC=1 SCAR=0.0
20 3 my ($self) = @_;
21 Catmandu->exporter(
22 $self->exporter_name,
23 3 %{$self->exporter_args},
24 autocommit => 1
25 );
26 }
27  
28 3 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
29 3 my ($self) = @_;
30 3 my $exporter = $self->exporter;
31 3 my $getter = as_path($self->path)->getter;
32 3 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
33 3 my $data = $_[0];
34 3 my $vals = $getter->($data);
35 3 $exporter->add($_) for @$vals;
36 3 $data;
37 3 };
38 }
39  
40 3 1;
41  
42 __END__
« Catmandu/Fix/Condition/all_match.pm ↑ Summary Catmandu/Fix/copy_field.pm »