QuadPres/Config.pm

filter: Statementstmt 32.2% 20 / 62 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 30.0% 6 / 20 Podpod 100% 9 / 9 totaltotal 35.0% 35 / 100 CC 5 SCAR 13.0
CC
5
Cov
29%
_init
12.0
_get_tt_val
6.0
get_val
6.0
CRAP 3.7
« QuadPres/FS.pm ↑ Summary QuadPres/Exception.pm »
1 package QuadPres::Config;
2 1 $QuadPres::Config::VERSION = '0.32.0';
3 1 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use parent 'QuadPres::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Config::IniFiles ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Template ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 __PACKAGE__->mk_acc_ref( [qw( base_path cfg )] );
13  
14 sub _init
15 0 ▶{
Subroutine _init: not called CC=3 SCAR=24.8
16 0 my $self = shift;
17  
18 0 my %args = @_;
19  
20 0 ▶ my $base_path = $args{path} || ".";
Condition0%0/2
$args{'path'} || '.'
l!l
00
MC/DC0%0/1
$args{'path'} || '.'
$args{'path'}
Truth table0%0/2
A
A= $args{'path'}
Aresult
11
00
21  
22 0 $self->base_path($base_path);
23  
24 0 my $cfg = Config::IniFiles->new( -file => "$base_path/quadpres.ini" );
25  
26 0 ▶ if ( !defined($cfg) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cfg) 0 0 0
27 {
28 0 die "Could not open the configuration file!";
29 }
30  
31 0 $self->cfg($cfg);
32  
33 0 return 0;
34 }
35  
36 sub _get_raw_val
37 0 ▶{
Subroutine _get_raw_val: not called CC=1 SCAR=6.9
38 0 my $self = shift;
39 0 return $self->cfg->val(@_);
40 }
41  
42 sub _get_tt_driver
43 0 ▶{
Subroutine _get_tt_driver: not called CC=1 SCAR=6.9
44 0 return Template->new( {} );
45 }
46  
47 sub _get_tt_vars
48 0 ▶{
Subroutine _get_tt_vars: not called CC=1 SCAR=6.9
49 0 my $vars = { 'ENV' => \%ENV, };
50  
51 0 return $vars;
52 }
53  
54 sub _get_tt_val
55 0 ▶{
Subroutine _get_tt_val: not called CC=2 SCAR=17.9
56 0 my ( $self, $section, $key, $value ) = @_;
57  
58 0 my $template = $self->_get_raw_val( $section, "tt_$key", $value );
59  
60 0 ▶ if ( !defined($template) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $template) 0 0 0
61 {
62 0 return;
63 }
64  
65 0 my $output = "";
66 0 $self->_get_tt_driver()
67 ->process( \$template, $self->_get_tt_vars(), \$output, );
68  
69 0 return $output;
70 }
71  
72 sub get_val
73 0 ▶{
Subroutine get_val: not called CC=2 SCAR=17.9
Pod documented
74 0 my $self = shift;
75  
76 # TODO : I'm assuming it's always scalar context here.
77 0 my $tt_value = $self->_get_tt_val(@_);
78  
79 0 ▶ if ( defined($tt_value) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tt_value) { } 0 0 0
80 {
81 0 return $tt_value;
82 }
83 else
84 {
85 0 return $self->_get_raw_val(@_);
86 }
87 }
88  
89 sub get_server_dest_dir
90 0 ▶{
Subroutine get_server_dest_dir: not called CC=1 SCAR=6.9
Pod documented
91 0 my $self = shift;
92  
93 0 return $self->get_val( "quadpres", "server_dest_dir" );
94 }
95  
96 sub get_setgid_group
97 0 ▶{
Subroutine get_setgid_group: not called CC=1 SCAR=6.9
Pod documented
98 0 my $self = shift;
99  
100 0 return $self->get_val( "quadpres", "setgid_group" );
101 }
102  
103 sub get_upload_path
104 0 ▶{
Subroutine get_upload_path: not called CC=1 SCAR=6.9
Pod documented
105 0 my $self = shift;
106  
107 0 return $self->get_val( "upload", "upload_path" );
108 }
109  
110 sub get_upload_util
111 0 ▶{
Subroutine get_upload_util: not called CC=1 SCAR=6.9
Pod documented
112 0 my $self = shift;
113  
114 0 return $self->get_val( "upload", "util" );
115 }
116  
117 sub get_upload_cmdline
118 0 ▶{
Subroutine get_upload_cmdline: not called CC=1 SCAR=6.9
Pod documented
119 0 my $self = shift;
120  
121 0 return $self->get_val( "upload", "cmdline" );
122 }
123  
124 sub get_version_control
125 0 ▶{
Subroutine get_version_control: not called CC=1 SCAR=6.9
Pod documented
126 0 my $self = shift;
127  
128 0 return $self->get_val( "quadpres", "version_control" );
129 }
130  
131 sub get_hard_disk_dest_dir
132 0 ▶{
Subroutine get_hard_disk_dest_dir: not called CC=1 SCAR=6.9
Pod documented
133 0 my $self = shift;
134  
135 0 return $self->get_val( "hard-disk", "dest_dir" );
136 }
137  
138 sub get_src_archive_path
139 0 ▶{
Subroutine get_src_archive_path: not called CC=1 SCAR=6.9
Pod documented
140 0 my $self = shift;
141  
142 0 return $self->get_val( "quadpres", "src_archive" );
143 }
144  
145 1 1;
146  
147 __END__
« QuadPres/FS.pm ↑ Summary QuadPres/Exception.pm »