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   3200693 use strict;
  27         204  
  27         820  
4 27     27   150 use warnings;
  27         60  
  27         749  
5              
6 27     27   145 use File::Spec;
  27         63  
  27         773  
7 27     27   11254 use Path::Tiny 0.098 qw(tempdir);
  27         173330  
  27         1792  
8              
9 27     27   218 use Exporter qw(import);
  27         61  
  27         1979  
10              
11             our $VERSION = '0.83';
12              
13             our @EXPORT_OK = qw(tempdir_simple);
14              
15 27     27   203 use constant IS_WIN32 => $^O eq 'MSWin32';
  27         66  
  27         4893  
16              
17             sub tempdir_simple {
18 61   50 61 0 10869597 my $template = shift || 'Code-TidyAll-XXXX';
19              
20 61         424 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 61         131 if (IS_WIN32) {
32             require Win32;
33             $args{DIR} = Win32::GetLongPathName( File::Spec->tmpdir );
34             }
35              
36 61         552 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.83
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 - 2022 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