Stats/Config.pm

filter: Statementstmt 16.6% 7 / 42 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 20.0% 2 / 10 Podpod 0.0% 0 / 1 totaltotal 12.8% 9 / 70 CC 9 SCAR 32.0
CC
9
Cov
12%
_parse_args
56.0
_parse_config
12.0
new
2.0
CRAP 24.6
« Stats.pm ↑ Summary Stats/Record.pm »
1 package Mail::Stats::Config;
2  
3 1 ▶use AppConfig qw(:argcount);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
7 0 my $class = shift;
8
9 0 my $cfg = shift;
10 0 my $this = {
11 raw_cfg => $cfg,
12 message => "%% count %% new messages in %% mbox %%\n",
13 };
14
15 # Now we set up the sort routines
16 0 bless $this, $class;
17  
18 0 $this->_parse_config();
19
20 0 $this->_parse_args();
21  
22 0 return $this;
23 }
24  
25 0 ▶sub _parse_args {
Subroutine _parse_args: not called CC=7 SCAR=40.3
26 0 my $this = shift;
27
28 # First set sorts
29
30 0 my $sort = $this->{raw_cfg}->{s}; # default just in case
31  
32 0 ▶ if($sort eq 'A') {
Branch: 4 branches
BranchTrueFalseTotal
if ($sort eq 'A') { } 0 0 0
elsif ($sort eq 'N') { } 0 0 0
elsif ($sort eq 'n') { } 0 0 0
elsif ($sort eq 'a') { } 0 0 0
33 0 ▶ $this->{sort} = sub {$Mail::Stats::b cmp $Mail::Stats::a};
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 } elsif($sort eq 'N') {
35 0 ▶ $this->{sort} = sub {my $hash = shift; $hash->{$Mail::Stats::b}->num_unread() <=> $hash->{$Mail::Stats::a}->num_unread()};
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 } elsif($sort eq 'n') {
37 0 ▶ $this->{sort} = sub {my $hash = shift; $hash->{$Mail::Stats::a}->num_unread() <=> $hash->{$Mail::Stats::b}->num_unread()};
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 } elsif($sort eq 'a') { # defaults to 'a'
39 0 ▶ $this->{sort} = sub {$Mail::Stats::a cmp $Mail::Stats::b};
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 }
41
42 0 ▶ if($this->{raw_cfg}->{m}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"raw_cfg"}{"m"}) 0 0 0
43 0 $this->{mboxen} = [split(/:/,$this->{raw_cfg}->{m})];
44 }
45 0 ▶ $this->{showall} = 1 if $this->{raw_cfg}->{a};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"raw_cfg"}{"a"} 0 0 0
46
47 }
48  
49 0 ▶sub _parse_config {
Subroutine _parse_config: not called CC=3 SCAR=24.8
50 0 my $this = shift;
51
52 my $config = AppConfig->new(
53 {
54 CASE => 0,
55 CREATE => 1,
56 0 ▶ ERROR => sub {return},
Subroutine __ANON__: not called CC=1 SCAR=6.9
57 0 GLOBAL => {
58 ARGCOUNT => ARGCOUNT_ONE,
59 }
60 }
61 );
62 0 $config->define("mailbox" => {ARGCOUNT => ARGCOUNT_LIST});
63
64 0 ▶ my $cfgfile = $this->{raw_cfg}->{c} || "$ENV{HOME}/.countmailrc";
Condition0%0/2
$this->{'raw_cfg'}{'c'} || "$ENV{'HOME'}/.countmailrc"
l!l
00
MC/DC0%0/1
$this->{'raw_cfg'}{'c'} || "$ENV{'HOME'}/.countmailrc"
$this->{'raw_cfg'}{'c'}
Truth table0%0/2
A
A= $this->{'raw_cfg'}{'c'}
Aresult
11
00
65 0 $config->file($cfgfile);
66
67 0 $this->{mboxen} = $config->mailbox;
68 0 ▶ if($config->message()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->message) 0 0 0
69 0 my $temp = $config->message();
70 # do some quick fix ups so you can put tabs or newlines in
71 # the message format
72 0 $temp =~ s/\\n/\n/;
73 0 $temp =~ s/\\t/\t/;
74 0 $this->{message} = $temp;
75 }
76
77
78 }
79  
80  
81 1 1;
82  
83  
« Stats.pm ↑ Summary Stats/Record.pm »