blib/lib/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 0.0% 0 / 9 totaltotal 26.0% 26 / 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
« Build ↑ Summary blib/lib/QuadPres/Exception.pm »
1 package QuadPres::Config;
2 1 $QuadPres::Config::VERSION = '0.28.2';
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 {
16 0 ▶ my $self = shift;
Subroutine _init: not called CC=3 SCAR=24.8
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 {
38 0 ▶ my $self = shift;
Subroutine _get_raw_val: not called CC=1 SCAR=6.9
39 0 return $self->cfg->val(@_);
40 }
41  
42 sub _get_tt_driver
43 {
44 0 ▶ return Template->new( {} );
Subroutine _get_tt_driver: not called CC=1 SCAR=6.9
45 }
46  
47 sub _get_tt_vars
48 {
49 0 ▶ my $vars = { 'ENV' => \%ENV, };
Subroutine _get_tt_vars: not called CC=1 SCAR=6.9
50  
51 0 return $vars;
52 }
53  
54 sub _get_tt_val
55 {
56 0 ▶ my ( $self, $section, $key, $value ) = @_;
Subroutine _get_tt_val: not called CC=2 SCAR=17.9
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 {
74 0 ▶ my $self = shift;
Subroutine get_val: not called CC=2 SCAR=17.9
Pod undocumented
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 {
91 0 ▶ my $self = shift;
Subroutine get_server_dest_dir: not called CC=1 SCAR=6.9
Pod undocumented
92  
93 0 return $self->get_val( "quadpres", "server_dest_dir" );
94 }
95  
96 sub get_setgid_group
97 {
98 0 ▶ my $self = shift;
Subroutine get_setgid_group: not called CC=1 SCAR=6.9
Pod undocumented
99  
100 0 return $self->get_val( "quadpres", "setgid_group" );
101 }
102  
103 sub get_upload_path
104 {
105 0 ▶ my $self = shift;
Subroutine get_upload_path: not called CC=1 SCAR=6.9
Pod undocumented
106  
107 0 return $self->get_val( "upload", "upload_path" );
108 }
109  
110 sub get_upload_util
111 {
112 0 ▶ my $self = shift;
Subroutine get_upload_util: not called CC=1 SCAR=6.9
Pod undocumented
113  
114 0 return $self->get_val( "upload", "util" );
115 }
116  
117 sub get_upload_cmdline
118 {
119 0 ▶ my $self = shift;
Subroutine get_upload_cmdline: not called CC=1 SCAR=6.9
Pod undocumented
120  
121 0 return $self->get_val( "upload", "cmdline" );
122 }
123  
124 sub get_version_control
125 {
126 0 ▶ my $self = shift;
Subroutine get_version_control: not called CC=1 SCAR=6.9
Pod undocumented
127  
128 0 return $self->get_val( "quadpres", "version_control" );
129 }
130  
131 sub get_hard_disk_dest_dir
132 {
133 0 ▶ my $self = shift;
Subroutine get_hard_disk_dest_dir: not called CC=1 SCAR=6.9
Pod undocumented
134  
135 0 return $self->get_val( "hard-disk", "dest_dir" );
136 }
137  
138 sub get_src_archive_path
139 {
140 0 ▶ my $self = shift;
Subroutine get_src_archive_path: not called CC=1 SCAR=6.9
Pod undocumented
141  
142 0 return $self->get_val( "quadpres", "src_archive" );
143 }
144  
145 1 1;
146  
147 __END__
148  
149 =pod
150  
151 =encoding UTF-8
152  
153 =head1 VERSION
154  
155 version 0.28.2
156  
157 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
158  
159 =head1 SUPPORT
160  
161 =head2 Websites
162  
163 The following websites have more information about this module, and may be of help to you. As always,
164 in addition to those websites please use your favorite search engine to discover more resources.
165  
166 =over 4
167  
168 =item *
169  
170 MetaCPAN
171  
172 A modern, open-source CPAN search engine, useful to view POD in HTML format.
173  
174 L<https://metacpan.org/release/QuadPres>
175  
176 =item *
177  
178 RT: CPAN's Bug Tracker
179  
180 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
181  
182 L<https://rt.cpan.org/Public/Dist/Display.html?Name=QuadPres>
183  
184 =item *
185  
186 CPANTS
187  
188 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
189  
190 L<http://cpants.cpanauthors.org/dist/QuadPres>
191  
192 =item *
193  
194 CPAN Testers
195  
196 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
197  
198 L<http://www.cpantesters.org/distro/Q/QuadPres>
199  
200 =item *
201  
202 CPAN Testers Matrix
203  
204 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
205  
206 L<http://matrix.cpantesters.org/?dist=QuadPres>
207  
208 =item *
209  
210 CPAN Testers Dependencies
211  
212 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
213  
214 L<http://deps.cpantesters.org/?module=QuadPres>
215  
216 =back
217  
218 =head2 Bugs / Feature Requests
219  
220 Please report any bugs or feature requests by email to C<bug-quadpres at rt.cpan.org>, or through
221 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=QuadPres>. You will be automatically notified of any
222 progress on the request by the system.
223  
224 =head2 Source Code
225  
226 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
227 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
228 from your repository :)
229  
230 L<https://github.com/shlomif/quad-pres>
231  
232 git clone https://github.com/shlomif/quad-pres.git
233  
234 =head1 AUTHOR
235  
236 Shlomi Fish <shlomif@cpan.org>
237  
238 =head1 BUGS
239  
240 Please report any bugs or feature requests on the bugtracker website
241 L<https://github.com/shlomif/quad-pres/issues>
242  
243 When submitting a bug or request, please include a test-file or a
244 patch to an existing test-file that illustrates the bug or desired
245 feature.
246  
247 =head1 COPYRIGHT AND LICENSE
248  
249 This software is Copyright (c) 2019 by Shlomi Fish.
250  
251 This is free software, licensed under:
252  
253 The MIT (X11) License
254  
255 =cut
« Build ↑ Summary blib/lib/QuadPres/Exception.pm »