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 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
« Build ↑ Summary blib/lib/QuadPres/Exception.pm »
1 package QuadPres::Config;
2 1 $QuadPres::Config::VERSION = '0.28.4';
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 documented
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 documented
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 documented
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 documented
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 documented
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 documented
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 documented
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 documented
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 documented
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 NAME
154  
155 =head1 VERSION
156  
157 version 0.28.4
158  
159 =head1 SYNOPSIS
160  
161 =head1 DESCRIPTION
162  
163 =head1 METHODS
164  
165 =head2 base_path
166  
167 =head2 cfg
168  
169 =head2 get_hard_disk_dest_dir
170  
171 =head2 get_server_dest_dir
172  
173 =head2 get_setgid_group
174  
175 =head2 get_src_archive_path
176  
177 =head2 get_upload_cmdline
178  
179 =head2 get_upload_path
180  
181 =head2 get_upload_util
182  
183 =head2 get_val
184  
185 =head2 get_version_control
186  
187 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
188  
189 =head1 SUPPORT
190  
191 =head2 Websites
192  
193 The following websites have more information about this module, and may be of help to you. As always,
194 in addition to those websites please use your favorite search engine to discover more resources.
195  
196 =over 4
197  
198 =item *
199  
200 MetaCPAN
201  
202 A modern, open-source CPAN search engine, useful to view POD in HTML format.
203  
204 L<https://metacpan.org/release/QuadPres>
205  
206 =item *
207  
208 RT: CPAN's Bug Tracker
209  
210 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
211  
212 L<https://rt.cpan.org/Public/Dist/Display.html?Name=QuadPres>
213  
214 =item *
215  
216 CPANTS
217  
218 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
219  
220 L<http://cpants.cpanauthors.org/dist/QuadPres>
221  
222 =item *
223  
224 CPAN Testers
225  
226 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
227  
228 L<http://www.cpantesters.org/distro/Q/QuadPres>
229  
230 =item *
231  
232 CPAN Testers Matrix
233  
234 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
235  
236 L<http://matrix.cpantesters.org/?dist=QuadPres>
237  
238 =item *
239  
240 CPAN Testers Dependencies
241  
242 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
243  
244 L<http://deps.cpantesters.org/?module=QuadPres>
245  
246 =back
247  
248 =head2 Bugs / Feature Requests
249  
250 Please report any bugs or feature requests by email to C<bug-quadpres at rt.cpan.org>, or through
251 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=QuadPres>. You will be automatically notified of any
252 progress on the request by the system.
253  
254 =head2 Source Code
255  
256 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
257 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
258 from your repository :)
259  
260 L<https://github.com/shlomif/quad-pres>
261  
262 git clone https://github.com/shlomif/quad-pres.git
263  
264 =head1 AUTHOR
265  
266 Shlomi Fish <shlomif@cpan.org>
267  
268 =head1 BUGS
269  
270 Please report any bugs or feature requests on the bugtracker website
271 L<https://github.com/shlomif/quad-pres/issues>
272  
273 When submitting a bug or request, please include a test-file or a
274 patch to an existing test-file that illustrates the bug or desired
275 feature.
276  
277 =head1 COPYRIGHT AND LICENSE
278  
279 This software is Copyright (c) 2019 by Shlomi Fish.
280  
281 This is free software, licensed under:
282  
283 The MIT (X11) License
284  
285 =cut
« Build ↑ Summary blib/lib/QuadPres/Exception.pm »