Mason/OO.pm

filter: Statementstmt 61.4% 43 / 70 Branchbran 15.0% 3 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 12 / 15 Podpod 60.0% 3 / 5 totaltotal 55.4% 61 / 110 CC 14 SCAR 21.4
CC
14
Cov
51%
load_file
25.1
load_mason
12.2
import
4.2
CRAP 8.5
« Mason.pm ↑ Summary Mason/Base.pm »
1 package Inline::Mason::OO;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.02';
5  
6 1 ▶use AutoLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Inline::Mason::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our @EXPORT = qw(AUTOLOAD);
9 1 our @ISA = qw(Inline::Mason::Base AutoLoader);
10  
11  
12 1 ▶use Text::MicroMason qw(execute);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Inline::Files::Virtual;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our @files_to_load;
16 1 ▶sub to_load_files {
Subroutine to_load_files: called CC=1 SCAR=0.0
Pod undocumented
17 1 push @files_to_load, @_;
18 }
19  
20 1 ▶sub import {
Subroutine import: called CC=4 SCAR=14.3
21 1 shift;
22 1 my $no_autoload;
23 1 foreach my $arg (@_){
24 1 ▶ $no_autoload = 1 if($arg eq 'no_autoload');
Branch: 1 branch
BranchTrueFalseTotal
if $arg eq "no_autoload" 1 0 1
25 }
26 1 ▶ to_load_files((caller(0))[1]) unless $no_autoload;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_autoload 0 1 1
27 }
28  
29 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
30 1 my $pkg = shift;
31 1 my @file = @_;
32 1 my $self = bless {} => $pkg;
33 1 foreach my $f (grep{$_} @files_to_load, (caller(0))[1], @file){
34 1 $self->load_file($f);
35 }
36 0 $self;
37 }
38  
39  
40 0 ▶sub load_mason {
Subroutine load_mason: not called CC=4 SCAR=25.0
Pod documented
41 0 my $self = shift;
42 0 my %arg = @_;
43 0 my ($pkg) = (caller(0))[0];
44 1 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 0 ▶ while(my($marker, $content) = each %arg){
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %arg) 0 0 0
46 0 ▶ die err_taboo($marker) if $taboo_word{$marker};
Branch: 1 branch
BranchTrueFalseTotal
if $taboo_word{$marker} 0 0 0
47 0 ▶ $self->{template}{$marker} = $content if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
48 }
49 }
50  
51 1 ▶sub load_file {
Subroutine load_file: called CC=6 SCAR=32.2
Pod documented
52 1 my $self = shift;
53 1 my $filename = shift;
54  
55 1 ▶ my @virtual_filenames = vf_load($filename, $file_marker) or die;
Branch: 1 branch
BranchTrueFalseTotal
my(@virtual_filenames) = vf_load($filename, $Inline::Mason::OO::file_marker) or die 0 1 1
56 0 local $/;
57 0 foreach my $vfile (@virtual_filenames){
58 0 my $marker = vf_marker($vfile);
59 0 $marker =~ s/\n+//so;
60 0 $marker =~ s/^__(.+?)__/$1/so;
61 0 ▶ die err_taboo($marker) if $taboo_word{$marker};
Branch: 1 branch
BranchTrueFalseTotal
if $Inline::Mason::OO::taboo_word{$marker} 0 0 0
62 0 ▶ vf_open(my $F, $vfile) or die "$! ==> $marker";
Branch: 1 branch
BranchTrueFalseTotal
&vf_open(my $F, $vfile) or die "$! ==> $marker" 0 0 0
63 0 my $content = <$F>;
64 0 ▶ $self->load_mason($marker, $content) if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
65 0 vf_close $F;
66 }
67 }
68  
69 0 ▶sub generate {
Subroutine generate: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my $self = shift;
71 0 my $name = shift;
72 0 my %args = @_;
73 0 execute($template->{(caller(0))[0]}{$name}, %args);
74 }
75  
76 1 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
77 1 my $self = shift;
78 1 undef $self;
79 }
80  
81 0 ▶sub AUTOLOAD{
Subroutine AUTOLOAD: not called CC=2 SCAR=12.6
82 1 ▶ use vars '$AUTOLOAD';
Subroutine BEGIN: called CC=1 SCAR=0.0
83 0 $AUTOLOAD =~ /.+::(.+)/o;
84 0 my $self = shift;
85 0 my $pkg = (caller(0))[0];
86 0 ▶ if(defined $self->{template}{$1}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'template'}{$1}) { } 0 0 0
87 0 execute($self->{template}{$1}, @_);
88 }
89 else {
90 0 die "${pkg}::$1 does not exist.\n";
91 }
92 }
93  
94  
95 1 1;
96 __END__
« Mason.pm ↑ Summary Mason/Base.pm »