| 1 | package Code::TidyAll::Result; | ||
| 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 Specio::Declare; |
|
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 | 35 | ▶ | use Specio::Library::String; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 35 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 35 | our $VERSION = '0.83'; | |
| 14 | |||
| 15 | 35 | has error => ( | |
| 16 | is => 'ro', | ||
| 17 | isa => t('NonEmptyStr'), | ||
| 18 | ); | ||
| 19 | |||
| 20 | 35 | has new_contents => ( | |
| 21 | is => 'ro', | ||
| 22 | isa => t('Str'), | ||
| 23 | ); | ||
| 24 | |||
| 25 | 35 | has orig_contents => ( | |
| 26 | is => 'ro', | ||
| 27 | isa => t('Str'), | ||
| 28 | ); | ||
| 29 | |||
| 30 | 35 | has path => ( | |
| 31 | is => 'ro', | ||
| 32 | isa => t('Path'), | ||
| 33 | ); | ||
| 34 | |||
| 35 | 35 | has state => ( | |
| 36 | is => 'ro', | ||
| 37 | isa => enum( values => [qw( cached checked error no_match tidied)] ), | ||
| 38 | ); | ||
| 39 | |||
| 40 | 93 | ▶ | sub ok { return $_[0]->state ne 'error' } |
|
Subroutine
ok: called CC=1 SCAR=0.0
Pod
documented
| |||
| 41 | |||
| 42 | 35 | 1; | |
| 43 | |||
| 44 | # ABSTRACT: Result returned from processing a file/source | ||
| 45 | |||
| 46 | __END__ | ||
| 47 | |||
| 48 | =pod | ||
| 49 | |||
| 50 | =encoding UTF-8 | ||
| 51 | |||
| 52 | =head1 NAME | ||
| 53 | |||
| 54 | Code::TidyAll::Result - Result returned from processing a file/source | ||
| 55 | |||
| 56 | =head1 VERSION | ||
| 57 | |||
| 58 | version 0.83 | ||
| 59 | |||
| 60 | =head1 SYNOPSIS | ||
| 61 | |||
| 62 | my $ct = Code::TidyAll->new(...); | ||
| 63 | my $result = $ct->process_file($file); | ||
| 64 | if ($result->error) { | ||
| 65 | ... | ||
| 66 | } | ||
| 67 | |||
| 68 | =head1 DESCRIPTION | ||
| 69 | |||
| 70 | Represents the result of C<< Code::TidyAll->process_file >> and C<< | ||
| 71 | Code::TidyAll->process_file >>. A list of these is returned from C< | ||
| 72 | Code::TidyAll->process_paths >>. | ||
| 73 | |||
| 74 | =head1 METHODS | ||
| 75 | |||
| 76 | This class provides the following methods: | ||
| 77 | |||
| 78 | =head2 $result->path | ||
| 79 | |||
| 80 | The path that was processed, relative to the root (e.g. "lib/Foo.pm") | ||
| 81 | |||
| 82 | =head2 $result->state | ||
| 83 | |||
| 84 | A string, one of | ||
| 85 | |||
| 86 | =over 4 | ||
| 87 | |||
| 88 | =item * C<no_match> - No plugins matched this file | ||
| 89 | |||
| 90 | =item * C<cached> - Cache hit (file had not changed since last processed) | ||
| 91 | |||
| 92 | =item * C<error> - An error occurred while applying one of the plugins | ||
| 93 | |||
| 94 | =item * C<checked> - File was successfully checked and did not change | ||
| 95 | |||
| 96 | =item * C<tidied> - File was successfully checked and changed | ||
| 97 | |||
| 98 | =back | ||
| 99 | |||
| 100 | =head2 $result->orig_contents | ||
| 101 | |||
| 102 | Contains the original contents if state is 'tidied' and with some errors (like | ||
| 103 | when a file needs tidying in check-only mode) | ||
| 104 | |||
| 105 | =head2 $result->new_contents | ||
| 106 | |||
| 107 | Contains the new contents if state is 'tidied' | ||
| 108 | |||
| 109 | =head2 $result->error | ||
| 110 | |||
| 111 | Contains the error message if state is 'error' | ||
| 112 | |||
| 113 | =head2 $result->ok | ||
| 114 | |||
| 115 | Returns true iff state is not 'error' | ||
| 116 | |||
| 117 | =head1 SUPPORT | ||
| 118 | |||
| 119 | Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>. | ||
| 120 | |||
| 121 | =head1 SOURCE | ||
| 122 | |||
| 123 | The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>. | ||
| 124 | |||
| 125 | =head1 AUTHORS | ||
| 126 | |||
| 127 | =over 4 | ||
| 128 | |||
| 129 | =item * | ||
| 130 | |||
| 131 | Jonathan Swartz <swartz@pobox.com> | ||
| 132 | |||
| 133 | =item * | ||
| 134 | |||
| 135 | Dave Rolsky <autarch@urth.org> | ||
| 136 | |||
| 137 | =back | ||
| 138 | |||
| 139 | =head1 COPYRIGHT AND LICENSE | ||
| 140 | |||
| 141 | This software is copyright (c) 2011 - 2022 by Jonathan Swartz. | ||
| 142 | |||
| 143 | This is free software; you can redistribute it and/or modify it under | ||
| 144 | the same terms as the Perl 5 programming language system itself. | ||
| 145 | |||
| 146 | The full text of the license can be found in the | ||
| 147 | F<LICENSE> file included with this distribution. | ||
| 148 | |||
| 149 | =cut | ||