| 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.85'; | |||||||||
| 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 | 9 | ▶ | sub _run_generic_executable_or_die { | ||||||||
|
Subroutine
_run_generic_executable_or_die: called CC=2 SCAR=7.0
| |||||||||||
| 30 | 9 | my $self = shift; | |||||||||
| 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
| |||||||||||
| 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__ | ||||||||||