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   2727145 use warnings;
  27         195  
  27         734  
4 27     27   153  
  27         51  
  27         650  
5             use File::Spec;
6 27     27   124 use Path::Tiny 0.098 qw(tempdir);
  27         43  
  27         736  
7 27     27   9116  
  27         133674  
  27         1416  
8             use Exporter qw(import);
9 27     27   171  
  27         69  
  27         1694  
10             our $VERSION = '0.82';
11              
12             our @EXPORT_OK = qw(tempdir_simple);
13              
14             use constant IS_WIN32 => $^O eq 'MSWin32';
15 27     27   168  
  27         60  
  27         4143  
16             my $template = shift || 'Code-TidyAll-XXXX';
17              
18 60   50 60 0 9063919 my %args = (
19             TEMPLATE => $template,
20 60         287 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         99 $args{DIR} = Win32::GetLongPathName( File::Spec->tmpdir );
32             }
33              
34             return tempdir(
35             { realpath => 1 },
36 60         452 %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.82
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