File Coverage

blib/lib/Code/TidyAll/Role/GenericExecutable.pm
Criterion Covered Total %
statement 30 30 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 40 41 97.5


line stmt bran cond sub pod time code
1              
2             use strict;
3 2     2   878 use warnings;
  2         4  
  2         76  
4 2     2   12  
  2         4  
  2         64  
5             use IPC::Run3 qw(run3);
6 2     2   10 use Specio::Library::Builtins;
  2         4  
  2         101  
7 2     2   11 use Specio::Library::String;
  2         3  
  2         23  
8 2     2   16089 use Text::ParseWords qw(shellwords);
  2         5  
  2         21  
9 2     2   4558 use Try::Tiny;
  2         2363  
  2         103  
10 2     2   13  
  2         4  
  2         89  
11             use Moo::Role;
12 2     2   19  
  2         4  
  2         14  
13             with 'Code::TidyAll::Role::RunsCommand';
14              
15             our $VERSION = '0.81';
16              
17             has 'cmd' => (
18             is => 'ro',
19             required => 1,
20             );
21              
22             has file_flag => (
23             is => 'ro',
24             isa => t('NonEmptyStr'),
25             predicate => '_has_file_flag',
26             );
27              
28             my $self = shift;
29             my $file = shift;
30 9     9   22  
31 9         48 my @argv;
32             push @argv, $self->file_flag if $self->_has_file_flag;
33 9         17 push @argv, $file;
34 9 50       42  
35 9         24 return $self->_run_or_die(@argv);
36             }
37 9         52  
38             1;
39              
40             # ABSTRACT: A role for plugins which allow you to use any executable as a transformer or validator
41              
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Code::TidyAll::Role::GenericExecutable - A role for plugins which allow you to use any executable as a transformer or validator
50              
51             =head1 VERSION
52              
53             version 0.81
54              
55             =head1 SYNOPSIS
56              
57             package Whatever;
58             use Moo;
59             with 'Code::TidyAll::Role::GenericExecutable';
60              
61             =head1 DESCRIPTION
62              
63             This role exists for the benefit of the
64             L<Code::TidyAll::Plugin::GenericTransformer> and
65             L<Code::TidyAll::Plugin::GenericValidator> plugin classes.
66              
67             =head1 ATTRIBUTES
68              
69             =over
70              
71             =item cmd
72              
73             This attribute is require for any class which consumes this role.
74              
75             =item file_flag
76              
77             If this is set then this flag is used to indicate the file passed to the
78             command, for example something like C<-f>, C<--file>, or C<--input>. By
79             default, the file is simply passed as the last argument to the command.
80              
81             =back
82              
83             =head1 SUPPORT
84              
85             Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
86              
87             =head1 SOURCE
88              
89             The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
90              
91             =head1 AUTHORS
92              
93             =over 4
94              
95             =item *
96              
97             Jonathan Swartz <swartz@pobox.com>
98              
99             =item *
100              
101             Dave Rolsky <autarch@urth.org>
102              
103             =back
104              
105             =head1 COPYRIGHT AND LICENSE
106              
107             This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
108              
109             This is free software; you can redistribute it and/or modify it under
110             the same terms as the Perl 5 programming language system itself.
111              
112             The full text of the license can be found in the
113             F<LICENSE> file included with this distribution.
114              
115             =cut