File Coverage

blib/lib/WWW/Shopify/Liquid/Tag.pm
Criterion Covered Total %
statement 28 41 68.2
branch 3 10 30.0
condition 1 6 16.6
subroutine 9 16 56.2
pod 0 8 0.0
total 41 81 50.6


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3 21     21   164 use strict;
  21         37  
  21         732  
4 21     21   104 use warnings;
  21         34  
  21         712  
5              
6             package WWW::Shopify::Liquid::Tag;
7 21     21   98 use base 'WWW::Shopify::Liquid::Element';
  21         33  
  21         12973  
8              
9 0     0 0 0 sub inner_tags { return (); }
10 368 50   368 0 659 sub name { my $package = ref($_[0]) ? ref($_[0]) : $_[0]; die unless $package =~ m/::(\w+)$/; my $name = lc($1); $name =~ s/([A-Z])/_$1/g; return $name; }
  368 50       2835  
  368         697  
  368         507  
  368         1091  
11             sub new {
12 0     0 0 0 my ($package, $line, $tag, $arguments, $contents) = @_;
13 0         0 my $self = { line => $line, core => $tag, arguments => $arguments, contents => $contents };
14 0         0 return bless $self, $package;
15             }
16 230     230 0 560 sub is_free { return 0; }
17 184     184 0 746 sub is_enclosing { return 0; }
18 0     0 0 0 sub min_arguments { return 0; }
19 0     0 0 0 sub max_arguments { return undef; }
20              
21 0     0 0 0 sub tokens { return ($_[0], map { $_->tokens } grep { defined $_ } (@{$_[0]->{arguments}}, $_[0]->{contents})) }
  0         0  
  0         0  
  0         0  
22              
23             package WWW::Shopify::Liquid::Tag::Output;
24 21     21   128 use base 'WWW::Shopify::Liquid::Tag::Free';
  21         32  
  21         9431  
25 0 0   0   0 sub abstract { my $package = ref($_[0]) ? ref($_[0]) : $_[0]; return ($package eq __PACKAGE__); }
  0         0  
26              
27 0     0   0 sub max_arguments { return 1; }
28              
29             sub new {
30 63     63   119 my ($package, $line, $arguments) = @_;
31 63         199 my $self = { arguments => $arguments, line => $line };
32 63         488 return bless $self, $package;
33             }
34             sub process {
35 8     8   14 my ($self, $hash, $action) = @_;
36 8 50       9 return '' unless int(@{$self->{arguments}}) > 0;
  8         29  
37 8         38 my $result = $self->{arguments}->[0]->$action($hash);
38 8 0 0     23 return '' if ref($result) && (ref($result) eq "ARRAY" || ref($result) eq "HASH");
      33        
39 8         19 return $result;
40             }
41              
42             1;