| 1 | package App::ManiacDownloader::_BytesDownloaded; | ||||||||||
| 2 | 3 | $App::ManiacDownloader::_BytesDownloaded::VERSION = '0.0.13'; | |||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use MooX qw/late/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use List::Util qw/min/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | has [ '_bytes_dled', '_bytes_dled_last_timer' ] => | ||||||||||
| 11 | 0 | ▶ | ( isa => 'Int', is => 'rw', default => sub { return 0; } ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 12 | |||||||||||
| 13 | has '_stale_checkpoints_count' => ( | ||||||||||
| 14 | isa => 'Int', | ||||||||||
| 15 | is => 'rw', | ||||||||||
| 16 | 0 | ▶ | default => sub { return 0; } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 17 | 3 | ); | |||||||||
| 18 | |||||||||||
| 19 | sub _add | ||||||||||
| 20 | 0 | ▶ | { | ||||||||
|
Subroutine
_add: not called CC=1 SCAR=6.9
| |||||||||||
| 21 | 0 | my ( $self, $num_written ) = @_; | |||||||||
| 22 | |||||||||||
| 23 | 0 | $self->_bytes_dled( $self->_bytes_dled + $num_written, ); | |||||||||
| 24 | |||||||||||
| 25 | 0 | return; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub _total_downloaded | ||||||||||
| 29 | 0 | ▶ | { | ||||||||
|
Subroutine
_total_downloaded: not called CC=1 SCAR=6.9
| |||||||||||
| 30 | 0 | my ($self) = @_; | |||||||||
| 31 | |||||||||||
| 32 | 0 | return $self->_bytes_dled; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub _were_stale_checkpoints_exceeded | ||||||||||
| 36 | 0 | ▶ | { | ||||||||
|
Subroutine
_were_stale_checkpoints_exceeded: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | 0 | my ( $self, $MAX_COUNT ) = @_; | |||||||||
| 38 | |||||||||||
| 39 | 0 | return ( $self->_stale_checkpoints_count >= $MAX_COUNT ); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub _flush_and_report | ||||||||||
| 43 | 0 | ▶ | { | ||||||||
|
Subroutine
_flush_and_report: not called CC=2 SCAR=17.9
| |||||||||||
| 44 | 0 | my $self = shift; | |||||||||
| 45 | |||||||||||
| 46 | 0 | my $difference = $self->_bytes_dled - $self->_bytes_dled_last_timer; | |||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | if ( $difference > 0 ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | { | ||||||||||
| 50 | 0 | $self->_stale_checkpoints_count(0); | |||||||||
| 51 | } | ||||||||||
| 52 | else | ||||||||||
| 53 | { | ||||||||||
| 54 | 0 | $self->_stale_checkpoints_count( $self->_stale_checkpoints_count + 1 ); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | $self->_bytes_dled_last_timer( $self->_bytes_dled ); | |||||||||
| 58 | |||||||||||
| 59 | 0 | return ( $difference, $self->_bytes_dled ); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | sub _my_init | ||||||||||
| 63 | 0 | ▶ | { | ||||||||
|
Subroutine
_my_init: not called CC=1 SCAR=6.9
| |||||||||||
| 64 | 0 | my ( $self, $num_bytes ) = @_; | |||||||||
| 65 | |||||||||||
| 66 | 0 | $self->_bytes_dled($num_bytes); | |||||||||
| 67 | 0 | $self->_bytes_dled_last_timer($num_bytes); | |||||||||
| 68 | |||||||||||
| 69 | 0 | return; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 3 | 1; | |||||||||
| 73 | |||||||||||
| 74 | __END__ | ||||||||||