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