« blib/lib/Code/TidyAll/CacheModel/Shared.pm
↑ Summary
blib/lib/Code/TidyAll/Plugin/GenericValidator.pm »
| 1 | package Code::TidyAll::Plugin::GenericTransformer; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | extends 'Code::TidyAll::Plugin'; | |
| 9 | |||
| 10 | 1 | with 'Code::TidyAll::Role::GenericExecutable'; | |
| 11 | |||
| 12 | 1 | our $VERSION = '0.83'; | |
| 13 | |||
| 14 | sub transform_file { | ||
| 15 | 5 | ▶ | my $self = shift; |
|
Subroutine
transform_file: called CC=1 SCAR=0.0
Pod
documented
| |||
| 16 | 5 | my $file = shift; | |
| 17 | |||
| 18 | 5 | my $output = $self->_run_generic_executable_or_die($file); | |
| 19 | 4 | $file->spew_raw($output); | |
| 20 | |||
| 21 | 4 | return; | |
| 22 | } | ||
| 23 | |||
| 24 | 1 | 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 | ||