File Coverage

blib/lib/Code/TidyAll/Plugin/GenericTransformer.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Code::TidyAll::Plugin::GenericTransformer;
2              
3 1     1   548 use strict;
  1         3  
  1         64  
4 1     1   8 use warnings;
  1         2  
  1         31  
5              
6 1     1   8 use Moo;
  1         2  
  1         9  
7              
8             extends 'Code::TidyAll::Plugin';
9              
10             with 'Code::TidyAll::Role::GenericExecutable';
11              
12             our $VERSION = '0.83';
13              
14             sub transform_file {
15 5     5 1 14 my $self = shift;
16 5         10 my $file = shift;
17              
18 5         24 my $output = $self->_run_generic_executable_or_die($file);
19 4         105 $file->spew_raw($output);
20              
21 4         4729 return;
22             }
23              
24             1;
25              
26             # ABSTRACT: A plugin to run any executable as a transformer
27              
28             __END__
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             Code::TidyAll::Plugin::GenericTransformer - A plugin to run any executable as a transformer
37              
38             =head1 VERSION
39              
40             version 0.83
41              
42             =head1 SYNOPSIS
43              
44             # In your tidyall config
45             [GenericTransformer / JSONOrderedTidy]
46             cmd = json-ordered-tidy
47             argv = -stdout
48             ok_exit_codes = 0 1
49              
50             =head1 DESCRIPTION
51              
52             This plugin allows you to define any executable as a transformer.
53              
54             =head1 CONFIGURATION
55              
56             This plugin accepts the following configuration options:
57              
58             =head2 cmd
59              
60             This is the command to be run. This is required.
61              
62             =head2 argv
63              
64             This is a string containing additional arguments to be passed to the command.
65             These arguments will always be passed.
66              
67             =head2 file_flag
68              
69             This is the flag used to tell the command what file to operate on, if it has
70             one.
71              
72             By default, the file is simply passed as the last argument. However, many
73             commands will want this passed with a flag like C<-f>, C<--file>, or
74             C<--input>.
75              
76             =head2 ok_exit_codes
77              
78             By default, any exit code other than C<0> is considered an exception. However,
79             many commands use their exit code to indicate that there was a validation issue
80             as opposed to an exception.
81              
82             You can specify multiple exit codes either by listing C<ok_exit_codes> multiple
83             times or as a space-separate list.
84              
85             =head1 SUPPORT
86              
87             Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
88              
89             =head1 SOURCE
90              
91             The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
92              
93             =head1 AUTHORS
94              
95             =over 4
96              
97             =item *
98              
99             Jonathan Swartz <swartz@pobox.com>
100              
101             =item *
102              
103             Dave Rolsky <autarch@urth.org>
104              
105             =back
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
110              
111             This is free software; you can redistribute it and/or modify it under
112             the same terms as the Perl 5 programming language system itself.
113              
114             The full text of the license can be found in the
115             F<LICENSE> file included with this distribution.
116              
117             =cut