File Coverage

blib/lib/Code/TidyAll/Role/Tempdir.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 27 27 100.0


line stmt bran cond sub pod time code
1              
2             use strict;
3 27     27   18214 use warnings;
  27         65  
  27         775  
4 27     27   131  
  27         55  
  27         824  
5             use Path::Tiny qw(tempdir);
6 27     27   141 use Specio::Library::Builtins;
  27         54  
  27         1290  
7 27     27   146 use Specio::Library::Path::Tiny;
  27         67  
  27         254  
8 27     27   215096  
  27         70  
  27         231  
9             use Moo::Role;
10 27     27   719488  
  27         62  
  27         262  
11             our $VERSION = '0.81';
12              
13             has _tempdir => (
14             is => 'ro',
15             isa => t('Dir'),
16             lazy => 1,
17             builder => 1,
18             );
19              
20             has no_cleanup => (
21             is => 'ro',
22             isa => t('Bool'),
23             default => 0,
24             );
25              
26             my ($self) = @_;
27             return tempdir(
28 21     21   332 'Code-TidyAll-XXXX',
29 21         131 CLEANUP => !$self->no_cleanup,
30             );
31             }
32              
33             1;
34              
35             # ABSTRACT: Provides a _tempdir attribute for Code::TidyAll classes
36              
37              
38             =pod
39              
40             =encoding UTF-8
41              
42             =head1 NAME
43              
44             Code::TidyAll::Role::Tempdir - Provides a _tempdir attribute for Code::TidyAll classes
45              
46             =head1 VERSION
47              
48             version 0.81
49              
50             =head1 SYNOPSIS
51              
52             package Whatever;
53             use Moo;
54             with 'Code::TidyAll::Role::Tempdir';
55              
56             =head1 DESCRIPTION
57              
58             A role to add tempdir attributes to classes.
59              
60             =head1 ATTRIBUTES
61              
62             =over
63              
64             =item _tempdir
65              
66             The temp directory. Lazily constructed if not passed
67              
68             =item no_cleanup
69              
70             A boolean indicating if the temp directory created by the C<_tempdir> builder
71             should not automatically clean up after itself
72              
73             =back
74              
75             =head1 SUPPORT
76              
77             Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
78              
79             =head1 SOURCE
80              
81             The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
82              
83             =head1 AUTHORS
84              
85             =over 4
86              
87             =item *
88              
89             Jonathan Swartz <swartz@pobox.com>
90              
91             =item *
92              
93             Dave Rolsky <autarch@urth.org>
94              
95             =back
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
100              
101             This is free software; you can redistribute it and/or modify it under
102             the same terms as the Perl 5 programming language system itself.
103              
104             The full text of the license can be found in the
105             F<LICENSE> file included with this distribution.
106              
107             =cut