blib/lib/Pinto/Util.pm

filter: Statementstmt 74.6% 144 / 193 Branchbran 46.1% 36 / 78 Conditioncond 48.1% 13 / 27 MC/DCmcdc 23.0% 3 / 13 Subroutinesub 83.0% 44 / 53 Podpod 91.4% 32 / 35 totaltotal 68.1% 272 / 399 CC 49 SCAR 15.3
CC
49
Cov
65%
truncate_text
20.0
current_username
13.1
body_text
12.0
CRAP 4.6
« blib/lib/Pinto/Action/Delete.pm ↑ Summary blib/lib/Pinto/Server/Responder/File.pm »
1 # ABSTRACT: Static utility functions for Pinto
2  
3 package Pinto::Util;
4  
5 149 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 149 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 149 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 149 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 149 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 149 ▶use URI::file;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 149 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 149 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 149 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 149 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 149 ▶use Digest::MD5;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 149 ▶use Digest::SHA;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 149 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 149 ▶use UUID::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 149 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 149 ▶use Pinto::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 149 ▶use Pinto::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 149 ▶use Pinto::Types qw(DiffStyle);
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 #-------------------------------------------------------------------------------
27  
28 149 our $VERSION = '0.14'; # VERSION
29  
30 #-------------------------------------------------------------------------------
31  
32 149 Readonly our @EXPORT_OK => qw(
33 author_dir
34 body_text
35 current_author_id
36 current_utc_time
37 current_time_offset
38 current_username
39 debug
40 decamelize
41 default_diff_style
42 indent_text
43 interpolate
44 is_blank
45 is_not_blank
46 is_interactive
47 is_remote_repo
48 is_system_prop
49 isa_perl
50 itis
51 make_uri
52 md5
53 mksymlink
54 mtime
55 parse_dist_path
56 mask_uri_passwords
57 sha256
58 tempdir
59 title_text
60 throw
61 trim_text
62 truncate_text
63 user_palette
64 uuid
65 whine
66 );
67  
68 149 Readonly our %EXPORT_TAGS => ( all => \@EXPORT_OK );
69  
70 #-------------------------------------------------------------------------------
71  
72  
73 141 ▶sub throw {
Subroutine throw: called CC=2 SCAR=7.0
Pod documented
74 141 my ($error) = @_;
75  
76 # Rethrowing...
77 141 ▶ $error->throw if itis( $error, 'Pinto::Exception' );
Branch: 1 branch
BranchTrueFalseTotal
if itis($error, "Pinto::Exception") 20 121 141
78  
79 121 require Pinto::Exception;
80 121 Pinto::Exception->throw( message => "$error" );
81  
82 0 return; # Should never get here
83 }
84  
85 #-------------------------------------------------------------------------------
86  
87  
88 3499 ▶sub debug {
Subroutine debug: called CC=3 SCAR=18.7
Pod documented
89 3499 my ($it) = @_;
90  
91 # TODO: Use Carp instead?
92  
93 3499 ▶ return 1 if not $ENV{PINTO_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"PINTO_DEBUG"} 3499 0 3499
94  
95 0 ▶ $it = $it->() if ref $it eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $it eq "CODE" 0 0 0
96 0 my ( $file, $line ) = (caller)[ 1, 2 ];
97 0 print {*STDERR} "$it in $file at line $line\n";
98  
99 0 return 1;
100 }
101  
102 #-------------------------------------------------------------------------------
103  
104  
105 4 ▶sub whine {
Subroutine whine: called CC=2 SCAR=7.6
Pod documented
106 4 my ($message) = @_;
107  
108 4 ▶ if ( $ENV{DEBUG} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"DEBUG"}) 0 4 4
109 0 Carp::cluck($message);
110 0 return 1;
111 }
112  
113 4 chomp $message;
114 4 warn $message . "\n";
115  
116 4 return 1;
117 }
118  
119 #-------------------------------------------------------------------------------
120  
121  
122 45 ▶sub author_dir { ## no critic (ArgUnpacking)
Subroutine author_dir: called CC=1 SCAR=0.0
Pod documented
123 45 my $author = uc pop;
124 45 my @base = @_;
125  
126 45 return dir( @base, substr( $author, 0, 1 ), substr( $author, 0, 2 ), $author );
127 }
128  
129 #-------------------------------------------------------------------------------
130  
131  
132 934 ▶sub itis {
Subroutine itis: called CC=3 SCAR=11.0
Pod documented
133 934 my ( $var, $class ) = @_;
134  
135 934 ▶ return ref $var && Scalar::Util::blessed($var) && $var->isa($class);
Condition83%5/6
ref $var && builtin::blessed($var) && $var->isa($class)
!ll&&!rl&&r
58581268
ref $var and builtin::blessed($var)
!ll&&!rl&&r
5850349
MC/DC66%2/3
ref $var && builtin::blessed($var) && $var->isa($class)
ref $var builtin::blessed($var) $var->isa($class)
Truth table75%3/4
A and B && C
A= ref $varB= builtin::blessed($var)C= $var->isa($class)
ABCresult
0XX0
10X0
1100
1111
136 }
137  
138 #-------------------------------------------------------------------------------
139  
140  
141 1 ▶sub parse_dist_path {
Subroutine parse_dist_path: called CC=2 SCAR=7.1
Pod documented
142 1 my ($path) = @_;
143  
144 # eg: /yadda/authors/id/A/AU/AUTHOR/subdir1/subdir2/Foo-1.0.tar.gz
145 # or: A/AU/AUTHOR/subdir/Foo-1.0.tar.gz
146  
147 1 ▶ if ( $path =~ s{^ (?:.*/authors/id/)? (.*) $}{$1}mx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ s[^ (?:.*/authors/id/)? (.*) $][$1]mx) 1 0 1
148  
149 # $path = 'A/AU/AUTHOR/subdir/Foo-1.0.tar.gz'
150 1 my @path_parts = split m{ / }mx, $path;
151 1 my $author = $path_parts[2]; # AUTHOR
152 1 my $archive = $path_parts[-1]; # Foo-1.0.tar.gz
153 1 return ( $author, $archive );
154 }
155  
156 0 throw "Unable to parse path: $path";
157 }
158  
159 #-------------------------------------------------------------------------------
160  
161  
162 0 ▶sub isa_perl {
Subroutine isa_perl: not called CC=1 SCAR=6.9
Pod documented
163 0 my ($path_or_uri) = @_;
164  
165 0 return $path_or_uri =~ m{ / perl-[\d.]+ \.tar \.(?: gz|bz2 ) $ }mx;
166 }
167  
168 #-------------------------------------------------------------------------------
169  
170  
171 59 ▶sub mtime {
Subroutine mtime: called CC=3 SCAR=11.4
Pod documented
172 59 my ($file) = @_;
173  
174 59 ▶ throw 'Must supply a file' if not $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 59 59
175 59 ▶ throw "$file does not exist" if not -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 59 59
176  
177 59 return ( stat $file )[9];
178 }
179  
180 #-------------------------------------------------------------------------------
181  
182  
183 59 ▶sub md5 {
Subroutine md5: called CC=3 SCAR=11.2
Pod documented
184 59 my ($file) = @_;
185  
186 59 ▶ throw 'Must supply a file' if not $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 59 59
187 59 ▶ throw "$file does not exist" if not -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 59 59
188  
189 59 my $fh = $file->openr();
190 59 my $md5 = Digest::MD5->new->addfile($fh)->hexdigest();
191  
192 59 return $md5;
193 }
194  
195 #-------------------------------------------------------------------------------
196  
197  
198 179 ▶sub sha256 {
Subroutine sha256: called CC=3 SCAR=11.2
Pod documented
199 179 my ($file) = @_;
200  
201 179 ▶ throw 'Must supply a file' if not $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 179 179
202 179 ▶ throw "$file does not exist" if not -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 179 179
203  
204 179 my $fh = $file->openr();
205 179 my $sha256 = Digest::SHA->new(256)->addfile($fh)->hexdigest();
206  
207 179 return $sha256;
208 }
209  
210 #-------------------------------------------------------------------------------
211  
212  
213 179 ▶sub validate_property_name {
Subroutine validate_property_name: called CC=2 SCAR=6.9
Pod documented
214 179 my ($prop_name) = @_;
215  
216 179 ▶ throw "Invalid property name $prop_name" if $prop_name !~ $PINTO_PROPERTY_NAME_REGEX;
Branch: 1 branch
BranchTrueFalseTotal
unless $prop_name =~ /$Pinto::Util::PINTO_PROPERTY_NAME_REGEX/ 1 178 179
217  
218 178 return $prop_name;
219 }
220  
221 #-------------------------------------------------------------------------------
222  
223  
224 0 ▶sub validate_stack_name {
Subroutine validate_stack_name: not called CC=2 SCAR=17.9
Pod documented
225 0 my ($stack_name) = @_;
226  
227 0 ▶ throw "Invalid stack name $stack_name" if $stack_name !~ $PINTO_STACK_NAME_REGEX;
Branch: 1 branch
BranchTrueFalseTotal
unless $stack_name =~ /$Pinto::Util::PINTO_STACK_NAME_REGEX/ 0 0 0
228  
229 0 return $stack_name;
230 }
231  
232 #-------------------------------------------------------------------------------
233  
234  
235 191 ▶sub current_utc_time {
Subroutine current_utc_time: called CC=2 SCAR=6.9
Pod documented
236  
237 ## no critic qw(PackageVars)
238 191 ▶ return $Pinto::Globals::current_utc_time
Branch: 1 branch
BranchTrueFalseTotal
if defined $Pinto::Globals::current_utc_time 4 187 191
239 if defined $Pinto::Globals::current_utc_time;
240  
241 187 return time;
242 }
243  
244 #-------------------------------------------------------------------------------
245  
246  
247 54 ▶sub current_time_offset {
Subroutine current_time_offset: called CC=2 SCAR=7.0
Pod documented
248  
249 ## no critic qw(PackageVars)
250 54 ▶ return $Pinto::Globals::current_time_offset
Branch: 1 branch
BranchTrueFalseTotal
if defined $Pinto::Globals::current_time_offset 1 53 54
251 if defined $Pinto::Globals::current_time_offset;
252  
253 53 my $now = current_utc_time;
254 53 my $time = DateTime->from_epoch( epoch => $now, time_zone => 'local' );
255  
256 0 return $time->offset;
257 }
258  
259 #-------------------------------------------------------------------------------
260  
261  
262 51 ▶sub current_username {
Subroutine current_username: called CC=7 SCAR=25.7
Pod documented
263  
264 ## no critic qw(PackageVars)
265 51 ▶ return $Pinto::Globals::current_username
Branch: 1 branch
BranchTrueFalseTotal
if defined $Pinto::Globals::current_username 41 10 51
266 if defined $Pinto::Globals::current_username;
267  
268 10 ▶ my $username = $ENV{PINTO_USERNAME} || $ENV{USER} || $ENV{LOGIN} || $ENV{USERNAME} || $ENV{LOGNAME};
Condition33%4/12
$ENV{'PINTO_USERNAME'} || $ENV{'USER'} || $ENV{'LOGIN'} || $ENV{'USERNAME'} || $ENV{'LOGNAME'}
l!l&&r!l&&!r
0010
$ENV{"PINTO_USERNAME"} or $ENV{"USER"} or $ENV{"LOGIN"} or $ENV{"USERNAME"}
l!l&&r!l&&!r
0010
$ENV{"PINTO_USERNAME"} or $ENV{"USER"} or $ENV{"LOGIN"}
l!l&&r!l&&!r
0010
$ENV{"PINTO_USERNAME"} or $ENV{"USER"}
l!l&&r!l&&!r
0010
MC/DC0%0/5
$ENV{'PINTO_USERNAME'} || $ENV{'USER'} || $ENV{'LOGIN'} || $ENV{'USERNAME'} || $ENV{'LOGNAME'}
$ENV{"PINTO_USERNAME"} $ENV{"USER"} $ENV{"LOGIN"} $ENV{"USERNAME"} $ENV{'LOGNAME'}
Truth table16%1/6
A or B or C or D || E
A= $ENV{"PINTO_USERNAME"}B= $ENV{"USER"}C= $ENV{"LOGIN"}D= $ENV{"USERNAME"}E= $ENV{'LOGNAME'}
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
269  
270 10 ▶ throw "Unable to determine your username. Set PINTO_USERNAME." if not $username;
Branch: 1 branch
BranchTrueFalseTotal
unless $username 10 0 10
271  
272 0 return $username;
273 }
274  
275 #-------------------------------------------------------------------------------
276  
277  
278 21 ▶sub current_author_id {
Subroutine current_author_id: called CC=3 SCAR=20.3
Pod documented
279  
280 ## no critic qw(PackageVars)
281 21 ▶ return $Pinto::Globals::current_author_id
Branch: 1 branch
BranchTrueFalseTotal
if defined $Pinto::Globals::current_author_id 21 0 21
282 if defined $Pinto::Globals::current_author_id;
283  
284 0 my $author_id = $ENV{PINTO_AUTHOR_ID};
285 0 ▶ return uc $author_id if $author_id;
Branch: 1 branch
BranchTrueFalseTotal
if $author_id 0 0 0
286  
287 0 my $username = current_username;
288 0 $username =~ s/[^a-zA-Z0-9]//g;
289  
290 0 return uc $username;
291 }
292  
293 #-------------------------------------------------------------------------------
294  
295  
296 35 ▶sub is_interactive {
Subroutine is_interactive: called CC=2 SCAR=9.2
Pod documented
297  
298 ## no critic qw(PackageVars)
299 35 ▶ return $Pinto::Globals::is_interactive
Branch: 1 branch
BranchTrueFalseTotal
if defined $Pinto::Globals::is_interactive 35 0 35
300 if defined $Pinto::Globals::is_interactive;
301  
302 0 return -t STDOUT;
303 }
304  
305 #-------------------------------------------------------------------------------
306  
307  
308 0 ▶sub interpolate {
Subroutine interpolate: not called CC=1 SCAR=6.9
Pod documented
309 0 my $string = shift;
310  
311 0 return eval qq{"$string"}; ## no critic qw(Eval)
312 }
313  
314 #-------------------------------------------------------------------------------
315  
316  
317 46 ▶sub trim_text {
Subroutine trim_text: called CC=1 SCAR=0.0
Pod documented
318 46 my $string = shift;
319  
320 46 $string =~ s/^ \s+ //x;
321 46 $string =~ s/ \s+ $//x;
322  
323 46 return $string;
324 }
325  
326 #-------------------------------------------------------------------------------
327  
328  
329 0 ▶sub title_text {
Subroutine title_text: not called CC=2 SCAR=17.9
Pod documented
330 0 my $string = shift;
331  
332 0 my $nl = index $string, "\n";
333 0 ▶ return $nl < 0 ? $string : substr $string, 0, $nl;
Branch: 1 branch
BranchTrueFalseTotal
$nl < 0 ? : 0 0 0
334 }
335  
336 #-------------------------------------------------------------------------------
337  
338  
339 0 ▶sub body_text {
Subroutine body_text: not called CC=3 SCAR=24.8
Pod documented
340 0 my $string = shift;
341  
342 0 my $nl = index $string, "\n";
343 0 ▶ return '' if $nl < 0 or $nl == length $string;
Branch: 1 branch
BranchTrueFalseTotal
if $nl < 0 or $nl == length $string 0 0 0
Condition0%0/3
$nl < 0 or $nl == length $string
l!l&&r!l&&!r
000
MC/DC0%0/2
$nl < 0 or $nl == length $string
$nl < 0 $nl == length $string
Truth table0%0/3
A or B
A= $nl < 0B= $nl == length $string
ABresult
1X1
011
000
344 0 return substr $string, $nl + 1;
345 }
346  
347 #-------------------------------------------------------------------------------
348  
349  
350 0 ▶sub truncate_text {
Subroutine truncate_text: not called CC=4 SCAR=30.0
Pod documented
351 0 my ( $string, $max_length, $elipses ) = @_;
352  
353 0 ▶ return $string if not $max_length;
Branch: 1 branch
BranchTrueFalseTotal
unless $max_length 0 0 0
354 0 ▶ return $string if length $string <= $max_length;
Branch: 1 branch
BranchTrueFalseTotal
if length $string <= $max_length 0 0 0
355  
356 0 ▶ $elipses = '...' if not defined $elipses;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $elipses 0 0 0
357  
358 0 my $truncated = substr $string, 0, $max_length;
359  
360 0 return $truncated . $elipses;
361 }
362  
363 #-------------------------------------------------------------------------------
364  
365  
366 434 ▶sub decamelize {
Subroutine decamelize: called CC=2 SCAR=7.0
Pod documented
367 434 my $string = shift;
368  
369 434 ▶ return if not defined $string;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string 0 434 434
370  
371 434 $string =~ s/ ([a-z]) ([A-Z]) /$1_$2/xg;
372  
373 434 return lc $string;
374 }
375  
376 #-------------------------------------------------------------------------------
377  
378  
379 3 ▶sub indent_text {
Subroutine indent_text: called CC=3 SCAR=11.2
Pod documented
380 3 my ( $string, $spaces ) = @_;
381  
382 3 ▶ return $string if not $spaces;
Branch: 1 branch
BranchTrueFalseTotal
unless $spaces 0 3 3
383 3 ▶ return $string if not $string;
Branch: 1 branch
BranchTrueFalseTotal
unless $string 0 3 3
384  
385 3 my $indent = ' ' x $spaces;
386 3 $string =~ s/^ /$indent/xmg;
387  
388 3 return $string;
389 }
390  
391 #-------------------------------------------------------------------------------
392  
393  
394 164 ▶sub mksymlink {
Subroutine mksymlink: called CC=2 SCAR=7.0
Pod documented
395 164 my ( $from, $to ) = @_;
396  
397 # TODO: Try to add Win32 support here, somehow.
398 164 debug "Linking $to to $from";
399 164 ▶ symlink $to, $from or throw "symlink to $to from $from failed: $!";
Branch: 1 branch
BranchTrueFalseTotal
symlink $to, $from or throw("symlink to $to from $from failed: $!") 164 0 164
400  
401 164 return 1;
402 }
403  
404 #-------------------------------------------------------------------------------
405  
406  
407 0 ▶sub is_system_prop {
Subroutine is_system_prop: not called CC=2 SCAR=17.9
Pod documented
408 0 my $string = shift;
409  
410 0 ▶ return 0 if not $string;
Branch: 1 branch
BranchTrueFalseTotal
unless $string 0 0 0
411 0 return $string =~ m/^ pinto- /x;
412 }
413  
414 #-------------------------------------------------------------------------------
415  
416  
417 66 ▶sub uuid {
Subroutine uuid: called CC=1 SCAR=0.0
Pod documented
418 66 return UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_V4);
419 }
420  
421 #-------------------------------------------------------------------------------
422  
423  
424 6 ▶sub user_palette {
Subroutine user_palette: called CC=4 SCAR=14.1
Pod documented
425 my $palette = $ENV{PINTO_PALETTE}
426 6 ▶ || $ENV{PINTO_COLORS} || $ENV{PINTO_COLOURS}; # For backcompat
Condition66%4/6
$ENV{'PINTO_PALETTE'} || $ENV{'PINTO_COLORS'} || $ENV{'PINTO_COLOURS'}
l!l&&r!l&&!r
105
$ENV{"PINTO_PALETTE"} or $ENV{"PINTO_COLORS"}
l!l&&r!l&&!r
105
MC/DC33%1/3
$ENV{'PINTO_PALETTE'} || $ENV{'PINTO_COLORS'} || $ENV{'PINTO_COLOURS'}
$ENV{"PINTO_PALETTE"} $ENV{"PINTO_COLORS"} $ENV{'PINTO_COLOURS'}
Truth table50%2/4
A or B || C
A= $ENV{"PINTO_PALETTE"}B= $ENV{"PINTO_COLORS"}C= $ENV{'PINTO_COLOURS'}
ABCresult
1XX1
01X1
0011
0000
427  
428 6 ▶ return $PINTO_DEFAULT_PALETTE if not $palette;
Branch: 1 branch
BranchTrueFalseTotal
unless $palette 5 1 6
429  
430 1 return [ split m/\s* , \s*/x, $palette ];
431 }
432  
433 #-------------------------------------------------------------------------------
434  
435  
436 24 ▶sub is_blank {
Subroutine is_blank: called CC=3 SCAR=12.5
Pod documented
437 24 my ($string) = @_;
438  
439 24 ▶ return 1 if not $string;
Branch: 1 branch
BranchTrueFalseTotal
unless $string 0 24 24
440 24 ▶ return 0 if $string =~ m/ \S /x;
Branch: 1 branch
BranchTrueFalseTotal
if $string =~ / \S /x 24 0 24
441 0 return 1;
442 }
443  
444 #-------------------------------------------------------------------------------
445  
446  
447 24 ▶sub is_not_blank {
Subroutine is_not_blank: called CC=1 SCAR=0.0
Pod documented
448 24 my ($string) = @_;
449  
450 24 return !is_blank($string);
451 }
452  
453 #-------------------------------------------------------------------------------
454  
455  
456 0 ▶sub mask_uri_passwords {
Subroutine mask_uri_passwords: not called CC=1 SCAR=6.9
Pod documented
457 0 my ($uri) = @_;
458  
459 0 $uri =~ s{ (https?://[^:/@]+ :) [^@/]+@}{$1*password*@}gx;
460  
461 0 return $uri;
462 }
463  
464 #-------------------------------------------------------------------------------
465  
466  
467 0 ▶sub is_remote_repo {
Subroutine is_remote_repo: not called CC=2 SCAR=17.9
Pod documented
468 0 my ($uri) = @_;
469  
470 0 ▶ return if not $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri 0 0 0
471 0 return $uri =~ m{^https?://}x;
472 }
473  
474 #-------------------------------------------------------------------------------
475  
476 72 ▶sub tempdir {
Subroutine tempdir: called CC=1 SCAR=0.0
Pod undocumented
477  
478 72 return Path::Class::dir(File::Temp::tempdir(CLEANUP => 1));
479 }
480  
481  
482 #-------------------------------------------------------------------------------
483  
484  
485 8 ▶sub default_diff_style {
Subroutine default_diff_style: called CC=3 SCAR=11.0
Pod undocumented
486  
487 8 ▶ if (my $style = $ENV{PINTO_DIFF_STYLE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $style = $ENV{"PINTO_DIFF_STYLE"}) 7 1 8
488  
489 7 ▶ throw "PINTO_DIFF_STYLE ($style) is invalid. Must be one of (@PINTO_DIFF_STYLES)"
Branch: 1 branch
BranchTrueFalseTotal
unless DiffStyle()->check($style) 0 7 7
490 unless DiffStyle->check($style);
491  
492 7 return $style;
493 }
494  
495 1 return $PINTO_DIFF_STYLE_CONCISE;
496 }
497  
498 #-------------------------------------------------------------------------------
499  
500 60 ▶sub make_uri {
Subroutine make_uri: called CC=4 SCAR=17.1
Pod undocumented
501 60 my ($it) = @_;
502  
503 60 ▶ return $it
Branch: 1 branch
BranchTrueFalseTotal
if itis($it, "URI") 1 59 60
504 if itis( $it, 'URI' );
505  
506 59 ▶ return URI::file->new( $it->absolute )
Branch: 1 branch
BranchTrueFalseTotal
if itis($it, "Path::Class::File") 59 0 59
507 if itis( $it, 'Path::Class::File' );
508  
509 0 ▶ return URI::file->new( file($it)->absolute )
Branch: 1 branch
BranchTrueFalseTotal
if -e $it 0 0 0
510 if -e $it;
511  
512 0 return URI->new($it);
513 }
514  
515 #-------------------------------------------------------------------------------
516 149 1;
517  
518 __END__
« blib/lib/Pinto/Action/Delete.pm ↑ Summary blib/lib/Pinto/Server/Responder/File.pm »