blib/lib/Pinto/Statistics.pm

filter: Statementstmt 45.7% 16 / 35 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 26.6% 4 / 15 Podpod 0.0% 0 / 6 totaltotal 32.7% 20 / 61 CC 2 SCAR 8.1
CC
2
Cov
42%
to_string
6.0
total_distributions
2.0
stack_distributions
2.0
CRAP 2.2
« blib/lib/Pinto/IndexWriter.pm ↑ Summary blib/lib/Pinto/Action/Roots.pm »
1 # ABSTRACT: Report statistics about a Pinto repository
2  
3 package Pinto::Statistics;
4  
5 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use String::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #------------------------------------------------------------------------------
12  
13 2 our $VERSION = '0.14'; # VERSION
14  
15 #------------------------------------------------------------------------------
16  
17 2 has stack => (
18 is => 'ro',
19 isa => 'Pinto::Schema::Result::Stack',
20 required => 1,
21 );
22  
23 #------------------------------------------------------------------------------
24  
25 0 ▶sub total_distributions {
Subroutine total_distributions: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my ($self) = @_;
27  
28 0 return $self->stack->repo->distribution_count;
29 }
30  
31 #------------------------------------------------------------------------------
32  
33 0 ▶sub stack_distributions {
Subroutine stack_distributions: not called CC=1 SCAR=6.9
Pod undocumented
34 0 my ($self) = @_;
35  
36 0 return $self->stack->distribution_count;
37 }
38  
39 #------------------------------------------------------------------------------
40  
41 0 ▶sub total_packages {
Subroutine total_packages: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my ($self) = @_;
43  
44 0 return $self->stack->repo->package_count;
45 }
46  
47 #------------------------------------------------------------------------------
48  
49 0 ▶sub stack_packages {
Subroutine stack_packages: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my ($self) = @_;
51  
52 0 return $self->stack->package_count;
53 }
54  
55 #------------------------------------------------------------------------------
56  
57 # TODO: Other statistics to consider...
58 #
59 # foreign packages (total/indexed)
60 # local packages (total/indexed)
61 # foreign dists (total/indexed)
62 # local dists (total/indexed)
63 # avg pkgs per dist
64 # avg # pkg revisions
65 # authors
66 # most prolific author
67 # N most recently added dist
68  
69 #------------------------------------------------------------------------------
70  
71 0 ▶sub to_string {
Subroutine to_string: not called CC=2 SCAR=17.9
Pod undocumented
72 0 my ( $self, $format ) = @_;
73  
74 my %fspec = (
75 0 ▶ 'D' => sub { $self->total_distributions },
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 0 ▶ 'd' => sub { $self->stack_distributions },
Subroutine __ANON__: not called CC=1 SCAR=6.9
77 0 ▶ 'k' => sub { $self->stack },
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 0 ▶ 'P' => sub { $self->total_packages },
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 0 ▶ 'p' => sub { $self->stack_packages },
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 0 );
81  
82 0 ▶ $format ||= $self->default_format();
Condition0%0/3
$format ||= $self->default_format
l!l&&r!l&&!r
000
MC/DC0%0/2
$format ||= $self->default_format
$format $self->default_format
Truth table0%0/3
A ||= B
A= $formatB= $self->default_format
ABresult
1X1
011
000
83 0 return String::Format::stringf( $format, %fspec );
84 }
85  
86 #------------------------------------------------------------------------------
87  
88 0 ▶sub default_format {
Subroutine default_format: not called CC=1 SCAR=6.9
Pod undocumented
89 0 my ($self) = @_;
90  
91 0 return <<'END_FORMAT';
92  
93 STATISTICS FOR THE "%k" STACK
94 -------------------------------------
95  
96 Stack Total
97 ----------------------
98 Packages %10p %10P
99 Distributions %10d %10D
100 END_FORMAT
101  
102 }
103  
104 #------------------------------------------------------------------------------
105  
106 2 __PACKAGE__->meta->make_immutable;
107  
108 #------------------------------------------------------------------------------
109 2 1;
110  
111 __END__
« blib/lib/Pinto/IndexWriter.pm ↑ Summary blib/lib/Pinto/Action/Roots.pm »