UnicornLogger/FromProfile.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran 50.0% 4 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 3 totaltotal 73.3% 33 / 45 CC 6 SCAR 9.8
CC
6
Cov
81%
get_profile
3.2
BUILDARGS
3.1
profiles
2.0
CRAP 2.7
« UnicornLogger.pm ↑ Summary
1 package DBIx::Class::UnicornLogger::FromProfile;
2 1 $DBIx::Class::UnicornLogger::FromProfile::VERSION = '0.001004';
3 # ABSTRACT: Define your UnicornLogger with a single string!
4  
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 extends 'DBIx::Class::UnicornLogger';
8  
9 2 ▶sub get_profile {
Subroutine get_profile: called CC=3 SCAR=11.6
Pod undocumented
10 2 my ($self, $profile_name) = @_;
11  
12 2 my $ret = {};
13 2 ▶ if ($profile_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($profile_name) 2 0 2
14 2 ▶ if (my $profile = $self->profiles->{$profile_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $profile = $self->profiles->{$profile_name}) { } 2 0 2
15 2 $ret = $profile
16 } else {
17 0 warn "no such profile: '$_[1]', using empty profile instead";
18 }
19 }
20 2 return $ret
21 }
22  
23 2 ▶sub profiles {
Subroutine profiles: called CC=2 SCAR=7.0
Pod undocumented
24 my @good_executing = (
25 executing =>
26 2 ▶ eval { require Term::ANSIColor } ? do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Term::ANSIColor } } ? : 2 0 2
27 2 my $c = \&Term::ANSIColor::color;
28 2 $c->('blink white on_black') . 'EXECUTING...' . $c->('reset');
29 } : 'EXECUTING...'
30 );
31 return {
32 2 console => {
33 tree => { profile => 'console' },
34 clear_line => "\r\x1b[J",
35 show_progress => 1,
36 @good_executing,
37 },
38 console_monochrome => {
39 tree => { profile => 'console_monochrome' },
40 clear_line => "\r\x1b[J",
41 show_progress => 1,
42 @good_executing,
43 },
44 plain => {
45 tree => { profile => 'console_monochrome' },
46 clear_line => "DONE\n",
47 show_progress => 1,
48 executing => 'EXECUTING...',
49 },
50 demo => {
51 tree => { profile => 'console' },
52 format => '[%d][%F:%L]%n%m',
53 clear_line => "DONE\n",
54 show_progress => 1,
55 executing => 'EXECUTING...',
56 },
57 }
58 }
59  
60 2 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=3 SCAR=11.4
Pod undocumented
61 2 my ($self, @rest) = @_;
62  
63 my %args = (
64 @rest == 1
65 0 ▶ ? %{$rest[0]}
Branch: 1 branch
BranchTrueFalseTotal
@rest == 1 ? : 0 2 2
66 : @rest
67 );
68  
69 2 my $profile = delete $args{unicorn_profile};
70 %args = (
71 2 ▶ %{$self->get_profile($ENV{DBIC_UNICORN_PROFILE} || $profile)},
Condition66%2/3
$ENV{'DBIC_UNICORN_PROFILE'} || $profile
l!l&&r!l&&!r
110
MC/DC0%0/2
$ENV{'DBIC_UNICORN_PROFILE'} || $profile
$ENV{'DBIC_UNICORN_PROFILE'} $profile
Truth table66%2/3
A || B
A= $ENV{'DBIC_UNICORN_PROFILE'}B= $profile
ABresult
1X1
011
000
72 %args,
73 );
74  
75 2 return $self->next::method(\%args)
76 }
77  
78 1 1;
79  
80 __END__
« UnicornLogger.pm ↑ Summary