lib/Mite/App/Command/exec.pm

filter: Statementstmt 40.3% 23 / 57 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 34.9% 29 / 83 CC 10 SCAR 42.4
CC
10
Cov
32%
execute
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 69.1
« lib/Mite/Signature.pm.mite.pm ↑ Summary lib/Mite/Project.pm.mite.pm »
1 24 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Mite::App::Command::exec;
6 24 ▶use Mite::Miteception -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 24 extends qw(Mite::App::Command);
8  
9 24 our $AUTHORITY = 'cpan:TOBYINK';
10 24 our $VERSION = '0.013000';
11  
12 24 ▶sub abstract {
Subroutine abstract: called CC=1 SCAR=0.0
Pod undocumented
13 24 return "Compile the project in memory and run a script.";
14 }
15  
16 24 ▶around _build_kingpin_command => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 24 my ( $next, $self, @args ) = @_;
18  
19 24 my $command = $self->$next( @args );
20 24 $command->flag( 'oneliner', 'Script is a oneliner, not a filename.' )->short( 'e' )->bool;
21 24 $command->arg( 'script', 'Script to run.' )->file;
22 24 $command->arg( 'args', 'Arguments to pass to script.' )->string_list;
23  
24 24 return $command;
25 24 };
26  
27 0 ▶sub execute {
Subroutine execute: not called CC=10 SCAR=47.0
Pod undocumented
28 0 my $self = shift;
29  
30 0 ▶ return 0 if $self->should_exit_quietly;
Branch: 1 branch
BranchTrueFalseTotal
if $self->should_exit_quietly 0 0 0
31  
32 0 my $oneliner = $self->kingpin_command->flags->get( 'oneliner' )->value;
33 0 my $script = $self->kingpin_command->args->get( 'script' )->value;
34 0 my $args = $self->kingpin_command->args->get( 'args' )->value;
35  
36 0 ▶ unless ( defined $script ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $script) 0 0 0
37 0 printf STDERR "%s: error: expected oneliner or script, try --help\n",
38 $self->kingpin_command->parent->name;
39 0 return 1;
40 }
41  
42 0 my $project = $self->project;
43 0 $project->load_directory;
44  
45 0 for my $source ( values %{ $project->sources } ) {
46 0 local $@;
47 0 ▶ eval( $source->compile ) or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval $source->compile or die $@ 0 0 0
48 }
49  
50 {
51 0 ▶ local @ARGV = @{ $args || [] };
Condition0%0/2
$args || []
l!l
00
MC/DC0%0/1
$args || []
$args
Truth table0%0/2
A
A= $args
Aresult
11
00
52 0 ▶ if ( $oneliner ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oneliner) { } 0 0 0
53 0 local $@;
54 0 my $r = eval "$script; 1";
55 0 ▶ if ( $r ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r) { } 0 0 0
56 0 return 0;
57 }
58 else {
59 0 warn "$@\n";
60 0 return 1;
61 }
62 }
63 else {
64 0 ▶ if ( not $script->exists ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($script->exists) 0 0 0
65 0 printf STDERR "%s: error: %s does not exist, try --help\n",
66 $self->kingpin_command->parent->name, $script;
67 0 return 1;
68 }
69 0 local $@;
70 0 do $script;
71 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
72 0 warn "$@\n";
73 0 return 1;
74 }
75 0 return 0;
76 }
77 }
78  
79 0 return 0;
80 }
81  
82 24 1;
« lib/Mite/Signature.pm.mite.pm ↑ Summary lib/Mite/Project.pm.mite.pm »