blib/lib/QuadPres/FS.pm

filter: Statementstmt 30.4% 14 / 46 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 100% 3 / 3 totaltotal 29.1% 21 / 72 CC 7 SCAR 25.5
CC
7
Cov
24%
set_group
30.0
my_chown
6.0
make_dest_dir
6.0
CRAP 12.9
« blib/lib/QuadPres.pm ↑ Summary Build »
1 package QuadPres::FS;
2 1 $QuadPres::FS::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 __PACKAGE__->mk_acc_ref( [qw( gid group )] );
10  
11 sub _init
12 {
13 0 ▶ my $self = shift;
Subroutine _init: not called CC=1 SCAR=6.9
14  
15 0 my %args = @_;
16  
17 0 my $group;
18  
19 0 $group = $args{group};
20 0 $self->set_group($group);
21  
22 # Set the umask to ensure that other users which are a member of $group
23 # can write to the files and directories generated by the program.
24 0 umask(0002);
25  
26 0 return 0;
27 }
28  
29 sub set_group
30 {
31 0 ▶ my $self = shift;
Subroutine set_group: not called CC=5 SCAR=34.0
Pod documented
32  
33 0 my $group = shift;
34  
35 0 $self->group($group);
36  
37 0 my $gid;
38  
39 # Check if the group is not empty.
40 0 ▶ if ( defined($group) && ( $group !~ /^\s*$/ ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group and not $group =~ /^\s*$/u) 0 0 0
Condition0%0/3
defined $group and not $group =~ /^\s*$/u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $group and not $group =~ /^\s*$/u
defined $group not $group =~ /^\s*$/u
Truth table0%0/3
A and not(B)
A= defined $groupB= not $group =~ /^\s*$/u
ABresult
0X0
100
111
41 {
42 0 ▶ if ( $group =~ /^\d+$/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($group =~ /^\d+$/u) { } 0 0 0
43 {
44 0 $gid = $group;
45 }
46 else
47 {
48 0 my @group_info = getgrnam($group);
49 0 ▶ if (@group_info)
Branch: 1 branch
BranchTrueFalseTotal
if (@group_info) 0 0 0
50 {
51 0 $gid = $group_info[2];
52 }
53 }
54  
55 0 $self->gid($gid);
56 }
57  
58 0 return 0;
59 }
60  
61 sub my_chown
62 {
63 0 ▶ my $self = shift;
Subroutine my_chown: not called CC=2 SCAR=17.9
Pod documented
64  
65 0 my $path = shift;
66  
67 0 ▶ if ( !defined( $self->gid ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->gid) 0 0 0
68 {
69 0 return;
70 }
71  
72 0 chown( -1, $self->gid, $path );
73  
74 0 return;
75 }
76  
77 sub make_dest_dir
78 {
79 0 ▶ my $self = shift;
Subroutine make_dest_dir: not called CC=2 SCAR=17.9
Pod documented
80  
81 0 my $dest_dir = shift;
82  
83 # Check if the destination directory exists and if not -
84 # create it.
85 0 ▶ if ( !-e $dest_dir )
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $dest_dir) 0 0 0
86 {
87 0 mkdir($dest_dir);
88  
89 # Make it belong to the common group
90 0 $self->my_chown($dest_dir);
91  
92 # Make it a SGID directory
93 # This means that subsequent files will belong to its group.
94 # And that subsequent directories inside will also be SGID.
95 0 chmod( 02775, $dest_dir );
96 }
97  
98 0 return;
99 }
100  
101 1 1;
102  
103 __END__
104  
105 =pod
106  
107 =encoding UTF-8
108  
109 =head1 NAME
110  
111 QuadPres::FS - filesystem utils
112  
113 =head1 VERSION
114  
115 version 0.28.4
116  
117 =head1 SYNOPSIS
118  
119 =head1 DESCRIPTION
120  
121 =head1 METHODS
122  
123 =head2 gid
124  
125 =head2 group
126  
127 =head2 make_dest_dir($dest_dir)
128  
129 =head2 my_chown($dest_dir)
130  
131 =head2 set_group
132  
133 =head2
134  
135 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
136  
137 =head1 SUPPORT
138  
139 =head2 Websites
140  
141 The following websites have more information about this module, and may be of help to you. As always,
142 in addition to those websites please use your favorite search engine to discover more resources.
143  
144 =over 4
145  
146 =item *
147  
148 MetaCPAN
149  
150 A modern, open-source CPAN search engine, useful to view POD in HTML format.
151  
152 L<https://metacpan.org/release/QuadPres>
153  
154 =item *
155  
156 RT: CPAN's Bug Tracker
157  
158 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
159  
160 L<https://rt.cpan.org/Public/Dist/Display.html?Name=QuadPres>
161  
162 =item *
163  
164 CPANTS
165  
166 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
167  
168 L<http://cpants.cpanauthors.org/dist/QuadPres>
169  
170 =item *
171  
172 CPAN Testers
173  
174 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
175  
176 L<http://www.cpantesters.org/distro/Q/QuadPres>
177  
178 =item *
179  
180 CPAN Testers Matrix
181  
182 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
183  
184 L<http://matrix.cpantesters.org/?dist=QuadPres>
185  
186 =item *
187  
188 CPAN Testers Dependencies
189  
190 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
191  
192 L<http://deps.cpantesters.org/?module=QuadPres>
193  
194 =back
195  
196 =head2 Bugs / Feature Requests
197  
198 Please report any bugs or feature requests by email to C<bug-quadpres at rt.cpan.org>, or through
199 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=QuadPres>. You will be automatically notified of any
200 progress on the request by the system.
201  
202 =head2 Source Code
203  
204 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
205 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
206 from your repository :)
207  
208 L<https://github.com/shlomif/quad-pres>
209  
210 git clone https://github.com/shlomif/quad-pres.git
211  
212 =head1 AUTHOR
213  
214 Shlomi Fish <shlomif@cpan.org>
215  
216 =head1 BUGS
217  
218 Please report any bugs or feature requests on the bugtracker website
219 L<https://github.com/shlomif/quad-pres/issues>
220  
221 When submitting a bug or request, please include a test-file or a
222 patch to an existing test-file that illustrates the bug or desired
223 feature.
224  
225 =head1 COPYRIGHT AND LICENSE
226  
227 This software is Copyright (c) 2019 by Shlomi Fish.
228  
229 This is free software, licensed under:
230  
231 The MIT (X11) License
232  
233 =cut
« blib/lib/QuadPres.pm ↑ Summary Build »