App/Simple.pm

filter: Statementstmt 96.5% 56 / 58 Branchbran 60.0% 6 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 13 / 13 Podpod 50.0% 1 / 2 totaltotal 82.6% 81 / 98 CC 9 SCAR 17.2
CC
9
Cov
86%
new_with_options
11.7
BEGIN
1.0
BEGIN
1.0
CRAP 5.6
« App/Meta/Role/Class/Simple.pm ↑ Summary App/Plugin/Man.pm »
1 # ============================================================================«
2 package MooseX::App::Simple;
3 # ============================================================================«
4  
5 6 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 our $AUTHORITY = 'cpan:MAROS';
11 6 our $VERSION = '1.42';
12  
13 6 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use MooseX::App::Exporter qw(app_usage app_description app_base app_fuzzy app_strict app_prefer_commandline app_permute option parameter command_short_description command_long_description command_usage command_strict);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use MooseX::App::Meta::Role::Attribute::Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶use MooseX::App::Message::Envelope;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 6 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 6 my ($IMPORT,$UNIMPORT,$INIT_META) = Moose::Exporter->build_import_methods(
20 with_meta => [ qw(app_usage app_description app_base app_fuzzy app_strict app_permute option parameter command_short_description command_long_description command_usage command_strict) ],
21 also => [ 'Moose' ],
22 as_is => [ 'new_with_options' ],
23 install => [ 'unimport', 'init_meta' ],
24 );
25  
26 6 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
27 6 my ( $class, @plugins ) = @_;
28  
29 # Get caller
30 6 my ($caller_class) = caller();
31  
32 # Process plugins
33 6 MooseX::App::Exporter->process_plugins($caller_class,@plugins);
34  
35 # Call Moose-Exporter generated importer
36 6 return $class->$IMPORT( { into => $caller_class } );
37 }
38  
39 6 ▶sub init_meta {
Subroutine init_meta: called CC=1 SCAR=0.0
Pod undocumented
40 6 my ($class,%args) = @_;
41  
42 # Get required roles and metaroles
43 6 $args{roles} = ['MooseX::App::Role::Base' ];
44 $args{metaroles} = {
45 6 class => [
46 'MooseX::App::Meta::Role::Class::Base',
47 'MooseX::App::Meta::Role::Class::Simple',
48 'MooseX::App::Meta::Role::Class::Documentation'
49 ],
50 attribute => [
51 'MooseX::App::Meta::Role::Attribute::Option'
52 ],
53 };
54 6 my $meta = MooseX::App::Exporter->process_init_meta(%args);
55  
56 # Register only one command
57 6 $meta->app_commands({ 'self' => $args{for_class} });
58  
59 6 return $meta;
60 }
61  
62 14 ▶sub new_with_options {
Subroutine new_with_options: called CC=9 SCAR=24.6
Pod documented
63 14 my ($class,@args) = @_;
64  
65 # Sanity check
66 14 ▶ Moose->throw_error('new_with_options is a class method')
Branch: 1 branch
BranchTrueFalseTotal
if not defined $class or builtin::blessed($class) 0 14 14
Condition33%1/3
not defined $class or builtin::blessed($class)
l!l&&r!l&&!r
0014
MC/DC0%0/2
not defined $class or builtin::blessed($class)
not defined $class builtin::blessed($class)
Truth table33%1/3
not(A) or B
A= not defined $classB= builtin::blessed($class)
ABresult
1X1
011
000
67 if ! defined $class || blessed($class);
68  
69 14 my %args;
70 14 ▶ if (scalar @args == 1
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @args == 1 and ref $args[0] eq 'HASH') { } 1 13 14
elsif (scalar @args % 2 == 0) { } 13 0 13
Condition66%2/3
scalar @args == 1 and ref $args[0] eq "HASH"
!ll&&!rl&&r
1301
MC/DC50%1/2
scalar @args == 1 and ref $args[0] eq "HASH"
scalar @args == 1 ref $args[0] eq "HASH"
Truth table66%2/3
A and B
A= scalar @args == 1B= ref $args[0] eq "HASH"
ABresult
0X0
100
111
71 && ref($args[0]) eq 'HASH' ) {
72 1 %args = %{$args[0]};
73 } elsif (scalar @args % 2 == 0) {
74 13 %args = @args;
75 } else {
76 0 Moose->throw_error('new_with_command got invalid extra arguments');
77 }
78  
79 $class->meta->command_check()
80 14 ▶ if $ENV{APP_DEVELOPER} || $ENV{HARNESS_ACTIVE};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"APP_DEVELOPER"} or $ENV{"HARNESS_ACTIVE"} 14 0 14
Condition33%1/3
$ENV{"APP_DEVELOPER"} or $ENV{"HARNESS_ACTIVE"}
l!l&&r!l&&!r
0140
MC/DC0%0/2
$ENV{"APP_DEVELOPER"} or $ENV{"HARNESS_ACTIVE"}
$ENV{"APP_DEVELOPER"} $ENV{"HARNESS_ACTIVE"}
Truth table33%1/3
A or B
A= $ENV{"APP_DEVELOPER"}B= $ENV{"HARNESS_ACTIVE"}
ABresult
1X1
011
000
81  
82 # Get ARGV
83 13 my $argv = delete $args{ARGV};
84 13 my $parsed_argv;
85 13 ▶ if (defined $argv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv) { } 0 13 13
86 0 $parsed_argv = MooseX::App::ParsedArgv->new( argv => $argv );
87 } else {
88 13 $parsed_argv = MooseX::App::ParsedArgv->instance();
89 }
90  
91 13 return $class->initialize_command_class($class,%args);
92 }
93  
94 6 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 6 1;
96  
97 __END__
« App/Meta/Role/Class/Simple.pm ↑ Summary App/Plugin/Man.pm »