File Coverage

blib/lib/Code/TidyAll/Result.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 31 31 100.0


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