| 1 | # | ||||||||||
| 2 | # Copyright (c) 2002 Paul Winkeler. All Rights Reserved. | ||||||||||
| 3 | # This program is free software; you may redistribute it and/or modify it under | ||||||||||
| 4 | # the same terms as Perl itself. | ||||||||||
| 5 | # | ||||||||||
| 6 | package NBU::Retention; | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | $VERSION = do { my @r=(q$Revision: 1.7 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; | |||||||||
| 16 | 1 | @ISA = qw(); | |||||||||
| 17 | 1 | @EXPORT = qw(); | |||||||||
| 18 | 1 | @EXPORT_OK = qw(); | |||||||||
| 19 | 1 | %EXPORT_TAGS = qw(); | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 1 | my $retained; | |||||||||
| 23 | my %retentionLevels; | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 26 | 0 | my $proto = shift; | |||||||||
| 27 | 0 | my $retention = { | |||||||||
| 28 | }; | ||||||||||
| 29 | |||||||||||
| 30 | 0 | bless $retention, $proto; | |||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | my $level = $retention->{LEVEL} = shift; | |||||||||
| 34 | 0 | $retention->{PERIOD} = shift; | |||||||||
| 35 | 0 | $retention->{DESCRIPTION} = shift; | |||||||||
| 36 | |||||||||||
| 37 | 0 | $retentionLevels{$level} = $retention; | |||||||||
| 38 | } | ||||||||||
| 39 | 0 | return $retention; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub populate { | ||||||||
|
Subroutine
populate: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 43 | 0 | my $proto = shift; | |||||||||
| 44 | |||||||||||
| 45 | 0 | my @masters = NBU->masters; my $master = $masters[0]; | |||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | die "Could not open retention pipe\n" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | unless my $pipe = NBU->cmd("bpretlevel -M ".$master->name." -l |"); | ||||||||||
| 49 | 0 | ▶ | while (<$pipe>) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | chop; s/[\s]*$//; | |||||||||
| 51 | 0 | my ($level, $period, $description) = split(/[\s]+/, $_, 3); | |||||||||
| 52 | 0 | $proto->new($level, $period, $description); | |||||||||
| 53 | 0 | chop; | |||||||||
| 54 | } | ||||||||||
| 55 | 0 | close($pipe); | |||||||||
| 56 | 0 | $retained = 1; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | sub byLevel { | ||||||||
|
Subroutine
byLevel: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 60 | 0 | my $proto = shift; | |||||||||
| 61 | 0 | my $level = shift; | |||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | $proto->populate if (!$retained); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | return $retentionLevels{$level}; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | sub period { | ||||||||
|
Subroutine
period: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 68 | 0 | my $self = shift; | |||||||||
| 69 | |||||||||||
| 70 | 0 | return $self->{PERIOD}; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub level { | ||||||||
|
Subroutine
level: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 74 | 0 | my $self = shift; | |||||||||
| 75 | |||||||||||
| 76 | 0 | return $self->{LEVEL}; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | sub description { | ||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 80 | 0 | my $self = shift; | |||||||||
| 81 | |||||||||||
| 82 | 0 | return $self->{DESCRIPTION}; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 0 | ▶ | sub list { | ||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 86 | 0 | my $proto = shift; | |||||||||
| 87 | |||||||||||
| 88 | 0 | ▶ | $proto->populate if (!$retained); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | 0 | return (values %retentionLevels); | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 1 | 1; | |||||||||
| 93 | |||||||||||
| 94 | __END__ | ||||||||||