| 1 | package App::VTide::Command::Grep; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # Created on: 2016-02-05 10:11:54 | ||||||||||||||||||||||||||||
| 4 | # Create by: Ivan Wills | ||||||||||||||||||||||||||||
| 5 | # $Id$ | ||||||||||||||||||||||||||||
| 6 | # $Revision$, $HeadURL$, $Date$ | ||||||||||||||||||||||||||||
| 7 | # $Revision$, $Source$, $Date$ | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use English qw/ -no_match_vars /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | extends 'App::VTide::Command::Run'; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | our $VERSION = version->new('1.0.6'); | |||||||||||||||||||||||||||
| 18 | 1 | our $NAME = 'grep'; | |||||||||||||||||||||||||||
| 19 | 1 | our $OPTIONS = [ 'test|T!', 'verbose|v+', ]; | |||||||||||||||||||||||||||
| 20 | 1 | our $LOCAL = 1; | |||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub details_sub { return ( $NAME, $OPTIONS, $LOCAL ) } | ||||||||||||||||||||||||||
|
Subroutine
details_sub: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | my ($name) = $self->env; | |||||||||||||||||||||||||||
| 27 | 0 | my $cmd = $self->options->files->[0]; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | my $params = $self->params($cmd); | |||||||||||||||||||||||||||
| 30 | 0 | my ( @files, @grep, $start ); | |||||||||||||||||||||||||||
| 31 | 0 | $start = 1; | |||||||||||||||||||||||||||
| 32 | 0 | for my $file ( @{ $self->options->files } ) { | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ( $file eq '--' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 34 | 0 | $start = 0; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | elsif ($start) { | ||||||||||||||||||||||||||||
| 37 | 0 | push @files, $file; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||
| 40 | 0 | push @grep, $file; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | $params->{editor}{command} = []; | |||||||||||||||||||||||||||
| 45 | 0 | $params->{edit} = \@files; | |||||||||||||||||||||||||||
| 46 | 0 | my @cmd = $self->command($params); | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ( $params->{env} && ref $params->{env} eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$params->{"env"} and ref $params->{"env"} eq "HASH"
MC/DC0%0/2
$params->{"env"} and ref $params->{"env"} eq "HASH"
$params->{"env"}
ref $params->{"env"} eq "HASH"
Truth table0%0/3
A and B
A= $params->{"env"}B= ref $params->{"env"} eq "HASH"
| |||||||||||||||||||||||||||||
| 49 | 0 | for my $env ( keys %{ $params->{env} } ) { | |||||||||||||||||||||||||||
| 50 | 0 | my $orig = $ENV{$env}; | |||||||||||||||||||||||||||
| 51 | 0 | $ENV{$env} = $params->{env}{$env}; | |||||||||||||||||||||||||||
| 52 | 0 | $ENV{$env} =~ s/[\$]$env/$orig/xms; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | $self->load_env( $params->{env} ); | |||||||||||||||||||||||||||
| 57 | 0 | $self->hooks->run( 'grepping', \@cmd ); | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | $self->runit( ( $params->{grep} || 'grep' ), @grep, @cmd ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$params->{'grep'} || 'grep'
MC/DC0%0/1
$params->{'grep'} || 'grep'
$params->{'grep'}
Truth table0%0/2
A
A= $params->{'grep'}
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | return; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub auto_complete { | ||||||||||||||||||||||||||
|
Subroutine
auto_complete: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | my $env = $self->options->files->[-1]; | |||||||||||||||||||||||||||
| 67 | 0 | my @files = sort keys %{ $self->config->get->{editor}{files} }; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | eval { | ||||||||||||||||||||||||||||
| 70 | 0 | my $helper = $self->config->get->{editor}{helper_autocomplete}; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($helper) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $helper = eval $helper; ## no critic | |||||||||||||||||||||||||||
| 73 | 0 | push @files, $helper->(); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | 1; | |||||||||||||||||||||||||||
| 76 | 0 | ▶ | } or do { warn $@ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | print join ' ', grep { $env ne 'grep' ? /^$env/xms : 1 } @files; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | return; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 1 | 1; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | __END__ | ||||||||||||||||||||||||||||