lib/Mite/App.pm

filter: Statementstmt 94.3% 50 / 53 Branchbran 66.6% 4 / 6 Conditioncond 75.0% 3 / 4 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 91.6% 11 / 12 Podpod 0.0% 0 / 3 totaltotal 86.2% 69 / 80 CC 8 SCAR 9.1
CC
8
Cov
90%
run
5.1
__ANON__
2.3
BUILD
2.0
CRAP 2.5
« lib/Mite/Class.pm ↑ Summary lib/Mite/Config.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;
6 24 ▶use Mite::Miteception -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 24 our $AUTHORITY = 'cpan:TOBYINK';
9 24 our $VERSION = '0.013000';
10  
11 use Module::Pluggable
12 24 ▶ search_path => [ 'Mite::App::Command' ],
Subroutine BEGIN: called CC=1 SCAR=0.2
13 sub_name => '_plugins',
14 require => true,
15 inner => false,
16 200 ▶ on_require_error => sub {
Subroutine __ANON__: called CC=2 SCAR=8.1
17 200 my ( $plugin, $err ) = @_;
18 200 ▶ return if $plugin =~ /.mite$/;
Branch: 1 branch
BranchTrueFalseTotal
if $plugin =~ /.mite$/ 200 0 200
19 0 croak $err;
20 24 };
21  
22 24 has commands => (
23 is => ro,
24 isa => HashRef[Object],
25 default => \ '{}',
26 );
27  
28 24 has kingpin => (
29 is => lazy,
30 isa => Object,
31 handles => {
32 _parse_argv => 'parse',
33 },
34 );
35  
36 24 has project => (
37 is => lazy,
38 isa => MiteProject,
39 handles => [ 'config' ],
40 );
41  
42 24 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
43 24 my $self = shift;
44 24 for my $plugin ( $self->_plugins ) {
45 120 $plugin->new( app => $self );
46 }
47 }
48  
49 0 ▶sub _default_command {
Subroutine _default_command: not called CC=1 SCAR=6.9
50 0 return 'compile';
51 }
52  
53 24 ▶sub _build_kingpin {
Subroutine _build_kingpin: called CC=1 SCAR=0.0
54 24 require Getopt::Kingpin;
55  
56 24 my $kingpin = Getopt::Kingpin->new;
57 24 $kingpin->flags->get( 'help' )->short( 'h' );
58 24 $kingpin->flag( 'verbose', 'Verbose mode.' )->short( 'v' )->bool;
59 24 $kingpin->flag( 'search-mite-dir', 'Only look for .mite/ in the current directory.' )->bool->default( true );
60 24 $kingpin->flag( 'exit-if-no-mite-dir', 'Exit quietly if .mite/ cannot be found.' )->bool->default( false );
61 24 $kingpin->flag( 'set', 'Set config option.' )->string_hash;
62  
63 24 return $kingpin;
64 }
65  
66 22 ▶sub _build_project {
Subroutine _build_project: called CC=1 SCAR=0.0
67 22 require Mite::Project;
68 22 return Mite::Project->default;
69 }
70  
71 68 ▶sub get_flag_value {
Subroutine get_flag_value: called CC=2 SCAR=6.9
Pod undocumented
72 68 my ( $self, $flag ) = @_;
73 68 my $got = $self->kingpin->flags->get( $flag );
74 68 ▶ $got ? $got->value : undef;
Branch: 1 branch
BranchTrueFalseTotal
$got ? : 23 45 68
75 }
76  
77 24 ▶sub run {
Subroutine run: called CC=5 SCAR=16.3
Pod undocumented
78 24 my ( $class, $argv ) = @_;
79  
80 24 my $self = $class->new;
81 24 ▶ my $parsed = $self->_parse_argv( $argv || [ @ARGV ] );
Condition100%2/2
$argv || [@ARGV]
l!l
168
MC/DC100%1/1
$argv || [@ARGV]
$argv
Truth table100%2/2
A
A= $argv
Aresult
11
00
82  
83 22 $self->project->debug( $self->get_flag_value( 'verbose' ) );
84 22 $self->config->search_for_mite_dir( $self->get_flag_value( 'search-mite-dir' ) );
85  
86 {
87 22 my $set_flag = $self->kingpin->flags->get( 'set' );
88 22 ▶ my %set = %{ $set_flag->value || {} };
Condition50%1/2
$set_flag->value || {}
l!l
220
MC/DC0%0/1
$set_flag->value || {}
$set_flag->value
Truth table50%1/2
A
A= $set_flag->value
Aresult
11
00
89 22 for my $opt ( keys %set ) {
90 0 $self->config->data->{$opt} = $set{$opt};
91 }
92 }
93  
94 my $command = $parsed->isa( 'Getopt::Kingpin::Command' )
95 ? $self->commands->{ $parsed->name }
96 22 ▶ : $self->commands->{ $self->_default_command };
Branch: 1 branch
BranchTrueFalseTotal
$parsed->isa('Getopt::Kingpin::Command') ? : 22 0 22
97  
98 22 return $command->execute;
99 }
100  
101 24 1;
« lib/Mite/Class.pm ↑ Summary lib/Mite/Config.pm »