| 1 | package Code::TidyAll::Role::Tempdir; | ||
| 2 | |||
| 3 | 35 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 35 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 35 | ▶ | use Path::Tiny qw(tempdir); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 35 | ▶ | use Specio::Library::Builtins; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 35 | ▶ | use Specio::Library::Path::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 35 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 35 | our $VERSION = '0.83'; | |
| 13 | |||
| 14 | 35 | has _tempdir => ( | |
| 15 | is => 'ro', | ||
| 16 | isa => t('Dir'), | ||
| 17 | lazy => 1, | ||
| 18 | builder => 1, | ||
| 19 | ); | ||
| 20 | |||
| 21 | 35 | has no_cleanup => ( | |
| 22 | is => 'ro', | ||
| 23 | isa => t('Bool'), | ||
| 24 | default => 0, | ||
| 25 | ); | ||
| 26 | |||
| 27 | sub _build__tempdir { | ||
| 28 | 22 | ▶ | my ($self) = @_; |
|
Subroutine
_build__tempdir: called CC=1 SCAR=0.0
| |||
| 29 | 22 | return tempdir( | |
| 30 | 'Code-TidyAll-XXXX', | ||
| 31 | CLEANUP => !$self->no_cleanup, | ||
| 32 | ); | ||
| 33 | } | ||
| 34 | |||
| 35 | 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 | ||