blib/lib/Code/TidyAll/Role/GenericExecutable.pm

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