File Coverage

blib/lib/Pipe/Tube/Split.pm
Criterion Covered Total %
statement 21 22 95.4
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 30 34 88.2


line stmt bran cond sub pod time code
1             package Pipe::Tube::Split;
2 1     1   7 use strict;
  1         1  
  1         30  
3 1     1   5 use warnings;
  1         2  
  1         22  
4 1     1   14 use 5.006;
  1         4  
5              
6 1     1   6 use base 'Pipe::Tube';
  1         2  
  1         301  
7              
8             our $VERSION = '0.06';
9              
10             sub init {
11 3     3 0 4 my ($self, $expr) = @_;
12 3         13 $self->logger("Receiving the split expression: $expr");
13 3 100       11 if ("Regexp" eq ref $expr) {
    50          
14 1         7 $self->{expr} = $expr;
15             } elsif (not ref $expr) {
16 2         27 $self->{expr} = qr/\Q$expr/;
17             } else {
18 0         0 die "Unrecognized type of parameter for split\n";
19             }
20 3         9 return $self;
21             }
22              
23             sub run {
24 12     12 0 21 my ($self, @input) = @_;
25              
26 12         33 $self->logger("The grep expression: $self->{expr}");
27 12         22 return map { [ split /$self->{expr}/, $_ ] } @input;
  6         47  
28             }
29              
30             1;
31