File Coverage

blib/lib/GitHub/MergeVelocity/Repository/Statistics.pm
Criterion Covered Total %
statement 16 16 100.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 23 27 85.1


line stmt bran cond sub pod time code
1              
2             use Moo;
3 3     3   133026  
  3         9942  
  3         16  
4             our $VERSION = '0.000009';
5              
6             use Math::Round qw( nearest round );
7 3     3   2401 use Types::Standard qw( Bool Int );
  3         1004  
  3         204  
8 3     3   524  
  3         64188  
  3         28  
9             has average_velocity => (
10             is => 'ro',
11             isa => Int,
12             lazy => 1,
13             default => sub {
14             my $self = shift;
15             return $self->pull_request_count
16             ? round( $self->total_velocity / $self->pull_request_count )
17             : 0;
18             },
19             );
20              
21             has [ 'closed', 'open', 'merged', ] => (
22             is => 'ro',
23             isa => Int,
24             default => 0,
25             );
26              
27             has [ 'closed_age', 'open_age', 'merged_age' ] => (
28             is => 'ro',
29             isa => Int,
30             default => 0,
31             );
32              
33             has pull_request_count => (
34             is => 'ro',
35             isa => Int,
36             lazy => 1,
37             default => sub {
38             my $self = shift;
39             return $self->closed + $self->open + $self->merged;
40             },
41             );
42              
43             has total_velocity => (
44             is => 'ro',
45             isa => Int,
46             required => 1,
47             );
48              
49             my $self = shift;
50             my $state = shift;
51 3     3 0 10908  
52 3         8 my $method = $state . '_age';
53             return $self->$method
54 3         7 ? round( $self->$method / $self->$state )
55 3 50       27 : 0;
56             }
57              
58             my $self = shift;
59             my $state = shift;
60             return $self->pull_request_count
61 6     6 0 6635 ? nearest( 0.01, $self->$state / $self->pull_request_count )
62 6         12 : 0;
63 6 50       110 }
64              
65             1;
66              
67             =pod
68              
69             =encoding UTF-8
70              
71             =head1 NAME
72              
73             GitHub::MergeVelocity::Repository::Statistics - Pull request statistics for a given repository
74              
75             =head1 VERSION
76              
77             version 0.000009
78              
79             =head1 AUTHOR
80              
81             Olaf Alders <olaf@wundercounter.com>
82              
83             =head1 COPYRIGHT AND LICENSE
84              
85             This software is copyright (c) 2015 by Olaf Alders.
86              
87             This is free software; you can redistribute it and/or modify it under
88             the same terms as the Perl 5 programming language system itself.
89              
90             =cut
91              
92              
93             # ABSTRACT: Pull request statistics for a given repository