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             package Code::TidyAll::Result;
2              
3 27     27   204 use strict;
  27         62  
  27         849  
4 27     27   315 use warnings;
  27         58  
  27         735  
5              
6 27     27   148 use Specio::Declare;
  27         59  
  27         209  
7 27     27   5470 use Specio::Library::Builtins;
  27         245  
  27         222  
8 27     27   257609 use Specio::Library::Path::Tiny;
  27         67  
  27         210  
9 27     27   380117 use Specio::Library::String;
  27         62  
  27         186  
10              
11 27     27   60015 use Moo;
  27         66  
  27         223  
12              
13             our $VERSION = '0.83';
14              
15             has error => (
16             is => 'ro',
17             isa => t('NonEmptyStr'),
18             );
19              
20             has new_contents => (
21             is => 'ro',
22             isa => t('Str'),
23             );
24              
25             has orig_contents => (
26             is => 'ro',
27             isa => t('Str'),
28             );
29              
30             has path => (
31             is => 'ro',
32             isa => t('Path'),
33             );
34              
35             has state => (
36             is => 'ro',
37             isa => enum( values => [qw( cached checked error no_match tidied)] ),
38             );
39              
40 63     63 1 401 sub ok { return $_[0]->state ne 'error' }
41              
42             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