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 35     35   27980 use strict;
  35         102  
  35         1658  
4 35     35   237 use warnings;
  35         77  
  35         2823  
5              
6 35     35   648 use Path::Tiny qw(tempdir);
  35         243  
  35         3399  
7 35     35   386 use Specio::Library::Builtins;
  35         84  
  35         556  
8 35     35   370729 use Specio::Library::Path::Tiny;
  35         93  
  35         485  
9              
10 35     35   583229 use Moo::Role;
  35         658  
  35         528  
11              
12             our $VERSION = '0.85';
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   395 my ($self) = @_;
29 22         174 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.85
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 - 2025 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