File Coverage

blib/lib/WWW/Shopify/Liquid/Filter/Truncatewords.pm
Criterion Covered Total %
statement 9 15 60.0
branch 0 4 0.0
condition 0 2 0.0
subroutine 3 6 50.0
pod 0 3 0.0
total 12 30 40.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2 37     37   14780 use strict;
  37         115  
  37         1102  
3 37     37   236 use warnings;
  37         108  
  37         1537  
4              
5 37     37   241 package WWW::Shopify::Liquid::Filter::Truncatewords; use base 'WWW::Shopify::Liquid::Filter';
  37         99  
  37         8852  
6 0     0 0   sub max_arguments { return 2; }
7 0     0 0   sub min_arguments { return 1; }
8             sub operate {
9 0     0 0   my ($self, $hash, $operand, $words, $addition) = @_;
10 0 0         my @words = split(/\s+/, defined $operand ? $operand : "");
11 0 0 0       return join(" ", grep { defined $_ } @words[0..(int($words || 0)-1)]) . (defined $addition ? $addition : "");
  0            
12             }
13              
14             1;