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