File Coverage

blib/lib/Code/TidyAll/Util.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition 1 2 50.0
subroutine 7 7 100.0
pod 0 1 0.0
total 30 32 93.7


line stmt bran cond sub pod time code
1              
2             use strict;
3 27     27   2798993 use warnings;
  27         196  
  27         782  
4 27     27   127  
  27         57  
  27         689  
5             use File::Spec;
6 27     27   128 use Path::Tiny 0.098 qw(tempdir);
  27         55  
  27         652  
7 27     27   9392  
  27         139058  
  27         1605  
8             use Exporter qw(import);
9 27     27   193  
  27         72  
  27         1656  
10             our $VERSION = '0.81';
11              
12             our @EXPORT_OK = qw(tempdir_simple);
13              
14             use constant IS_WIN32 => $^O eq 'MSWin32';
15 27     27   177  
  27         58  
  27         4161  
16             my $template = shift || 'Code-TidyAll-XXXX';
17              
18 60   50 60 0 9396445 my %args = (
19             TEMPLATE => $template,
20 60         331 CLEANUP => 1
21             );
22              
23             # On Windows the default tmpdir is under C:\Users\<Current User>. If the
24             # current user name is long or has spaces, then you get a short name like
25             # LONGUS~1. But lots of other code, particularly in the tests, will end up
26             # seeing long path names. This makes comparing paths to see if one path is
27             # under the tempdir fail, because the long name and short name don't
28             # compare as equal.
29             if (IS_WIN32) {
30             require Win32;
31 60         114 $args{DIR} = Win32::GetLongPathName( File::Spec->tmpdir );
32             }
33              
34             return tempdir(
35             { realpath => 1 },
36 60         466 %args,
37             );
38             }
39              
40             1;
41              
42             # ABSTRACT: Utility functions for internal use by Code::TidyAll
43              
44              
45             =pod
46              
47             =encoding UTF-8
48              
49             =head1 NAME
50              
51             Code::TidyAll::Util - Utility functions for internal use by Code::TidyAll
52              
53             =head1 VERSION
54              
55             version 0.81
56              
57             =head1 SUPPORT
58              
59             Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
60              
61             =head1 SOURCE
62              
63             The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
64              
65             =head1 AUTHORS
66              
67             =over 4
68              
69             =item *
70              
71             Jonathan Swartz <swartz@pobox.com>
72              
73             =item *
74              
75             Dave Rolsky <autarch@urth.org>
76              
77             =back
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             The full text of the license can be found in the
87             F<LICENSE> file included with this distribution.
88              
89             =cut