File Coverage

blib/lib/CGI/Lazy/CSS.pm
Criterion Covered Total %
statement 9 28 32.1
branch 0 2 0.0
condition n/a
subroutine 3 7 42.8
pod 5 5 100.0
total 17 42 40.4


line stmt bran cond sub pod time code
1             package CGI::Lazy::CSS;
2              
3 1     1   1251 use strict;
  1         2  
  1         32  
4              
5 1     1   5 use CGI::Lazy::Globals;
  1         2  
  1         426  
6              
7             #-------------------------------------------------------------------------------------------------
8             sub dir {
9 0     0 1 0 my $self = shift;
10              
11 0         0 return $self->{_dir};
12             }
13              
14             #----------------------------------------------------------------------------------------
15             sub file {
16 0     0 1 0 my $self = shift;
17 0         0 my $file = shift;
18              
19 0         0 my $dir = $self->dir;
20              
21 0         0 return "$dir/$file";
22             }
23              
24             #----------------------------------------------------------------------------------------
25             sub load {
26 0     0 1 0 my $self = shift;
27 0         0 my $file = shift;
28            
29 0         0 my $dir = $self->dir;
30 0         0 $dir =~ s/^\///; #strip a leading slash so we don't double it
31 0         0 my $docroot = $ENV{DOCUMENT_ROOT};
32 0         0 $docroot =~ s/\/$//; #strip the trailing slash so we don't double it
33              
34 0 0       0 open IF, "< $docroot/$dir/$file" or $self->q->errorHandler->couldntOpenCssFile($docroot, $dir, $file, $!);
35              
36 0         0 my $script;
37              
38 0         0 $script .= $_ while ;
39              
40 0         0 close IF;
41              
42 0         0 return $self->q->csswrap($script);
43              
44             }
45              
46             #-------------------------------------------------------------------------------------------------
47             sub new {
48 1     1 1 3 my $class = shift;
49 1         2 my $q = shift;
50              
51 1         5 return bless {
52             _q => $q,
53             _dir => $q->config->cssDir,
54            
55             }, $class;
56             }
57              
58             #-------------------------------------------------------------------------------------------------
59             sub q {
60 0     0 1   my $self = shift;
61              
62 0           return $self->{_q};
63             }
64              
65             1
66              
67             __END__