File Coverage

blib/lib/Pipe/Tube/Map.pm
Criterion Covered Total %
statement 21 22 95.4
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 28 32 87.5


line stmt bran cond sub pod time code
1             package Pipe::Tube::Map;
2 1     1   6 use strict;
  1         2  
  1         39  
3 1     1   6 use warnings;
  1         2  
  1         23  
4 1     1   15 use 5.006;
  1         3  
5              
6 1     1   5 use base 'Pipe::Tube';
  1         2  
  1         295  
7              
8             our $VERSION = '0.06';
9              
10             sub init {
11 3     3 0 7 my ($self, $expr) = @_;
12 3         12 $self->logger("Receiving the map expression: $expr");
13 3         6 $self->{expr} = $expr;
14 3         7 return $self;
15             }
16              
17             sub run {
18 16     16 0 31 my ($self, @input) = @_;
19              
20 16         44 $self->logger("The map expression: $self->{expr}");
21 16 50       33 if ("Regexp" eq ref $self->{expr}) {
22 0         0 return map /$self->{expr}/, @input;
23             } else {
24 16         22 my $sub = $self->{expr};
25 16         28 return map { $sub->($_) } @input;
  15         37  
26             }
27             }
28              
29             1;
30