| 1 | package Store::Digest::Stats; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use Store::Digest::Types qw(DateTimeType NonNegativeInt); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | Store::Digest::Stats - Statistical report about data usage in the store | ||
| 15 | |||
| 16 | =head1 VERSION | ||
| 17 | |||
| 18 | Version 0.01 | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | 1 | our $VERSION = '0.01'; | |
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | my $store = Store::Digest->new; | ||
| 27 | |||
| 28 | my $stats = $store->stats; | ||
| 29 | |||
| 30 | =head1 METHODS | ||
| 31 | |||
| 32 | =head2 bytes | ||
| 33 | |||
| 34 | Returns the total number of bytes of I<payload> stored. | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | 1 | has bytes => ( | |
| 39 | is => 'ro', | ||
| 40 | isa => NonNegativeInt, | ||
| 41 | ); | ||
| 42 | |||
| 43 | =head2 objects | ||
| 44 | |||
| 45 | Returns the total number of I<digests> in the database, including | ||
| 46 | those for which the payloads have been removed. | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | 1 | has objects => ( | |
| 51 | is => 'ro', | ||
| 52 | isa => NonNegativeInt, | ||
| 53 | ); | ||
| 54 | |||
| 55 | =head2 deleted | ||
| 56 | |||
| 57 | Returns the number of digests which have had their payloads removed. | ||
| 58 | |||
| 59 | =cut | ||
| 60 | |||
| 61 | 1 | has deleted => ( | |
| 62 | is => 'ro', | ||
| 63 | isa => NonNegativeInt, | ||
| 64 | ); | ||
| 65 | |||
| 66 | =head2 created | ||
| 67 | |||
| 68 | Returns the L<DateTime> the database was created. | ||
| 69 | |||
| 70 | =cut | ||
| 71 | |||
| 72 | 1 | has created => ( | |
| 73 | is => 'ro', | ||
| 74 | isa => DateTimeType, | ||
| 75 | ); | ||
| 76 | |||
| 77 | =head2 modified | ||
| 78 | |||
| 79 | Returns the L<DateTime> the database was last modified. | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | 1 | has modified => ( | |
| 84 | is => 'ro', | ||
| 85 | isa => DateTimeType, | ||
| 86 | ); | ||
| 87 | |||
| 88 | =head2 as_string | ||
| 89 | |||
| 90 | Returns the stats as a string. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | 0 | ▶ | sub as_string { |
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | 0 | my $self = shift; | |
| 96 | 0 | my $str = <<EOT; | |
| 97 | Digest store stats: | ||
| 98 | Created on: %-20s | ||
| 99 | Last Modified: %-20s | ||
| 100 | Bytes stored: %-20d | ||
| 101 | Objects stored: %-20d | ||
| 102 | Objects deleted: %-20d | ||
| 103 | EOT | ||
| 104 | |||
| 105 | return sprintf $str, | ||
| 106 | 0 | map { $self->$_ } qw(created modified bytes objects deleted); | |
| 107 | } | ||
| 108 | |||
| 109 | =head1 AUTHOR | ||
| 110 | |||
| 111 | Dorian Taylor, C<< <dorian at cpan.org> >> | ||
| 112 | |||
| 113 | =head1 LICENSE AND COPYRIGHT | ||
| 114 | |||
| 115 | Copyright 2012 Dorian Taylor. | ||
| 116 | |||
| 117 | Licensed under the Apache License, Version 2.0 (the "License"); you | ||
| 118 | may not use this file except in compliance with the License. You may | ||
| 119 | obtain a copy of the License at | ||
| 120 | L<http://www.apache.org/licenses/LICENSE-2.0>. | ||
| 121 | |||
| 122 | Unless required by applicable law or agreed to in writing, software | ||
| 123 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 124 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
| 125 | implied. See the License for the specific language governing | ||
| 126 | permissions and limitations under the License. | ||
| 127 | |||
| 128 | |||
| 129 | =cut | ||
| 130 | |||
| 131 | 1 | __PACKAGE__->meta->make_immutable; | |
| 132 | |||
| 133 | 1 | 1; # End of Store::Digest::Stats | |