File Coverage

blib/lib/Sledge/Utils.pm
Criterion Covered Total %
statement 26 27 96.3
branch 3 4 75.0
condition 5 9 55.5
subroutine 7 7 100.0
pod 2 2 100.0
total 43 49 87.7


line stmt bran cond sub pod time code
1             package Sledge::Utils;
2 3     3   1451 use strict;
  3         8  
  3         91  
3 3     3   14 use warnings;
  3         6  
  3         107  
4             our $VERSION = '0.04';
5 3     3   15 use Carp;
  3         4  
  3         238  
6 3     3   2797 use String::CamelCase ();
  3         515  
  3         55  
7              
8 3     3   79 use 5.008001;
  3         15  
  3         729  
9              
10             sub class2prefix {
11 5     5 1 22 my $class = shift;
12              
13 5   33     26 my $proto = ref $class || $class;
14 5 50       28 if ($proto =~ /.+::Pages::(.+)/) {
15 5 100 100     29 if ($1 eq 'Index' || $1 eq 'Root') {
16 2         8 return '/';
17             }
18             else {
19 3         12 return '/' . join('/', map { String::CamelCase::decamelize($_) } split /::/, $1);
  5         64  
20             }
21             }
22 0         0 croak "$class does not match";
23             }
24              
25             sub class2appclass {
26 3     3 1 15 my $class = shift;
27              
28 3   33     24 my $proto = ref $class || $class;
29 3         17 $proto =~ s/::Pages.*$//;
30 3         12 return $proto;
31             }
32              
33             1;
34             __END__