1# -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2# vim: ts=4 sts=4 sw=4:
3package CPAN::Distrostatus;
4use overload '""' => "as_string",
5    fallback => 1;
6use vars qw($something_has_failed_at);
7use vars qw(
8            $VERSION
9);
10$VERSION = "5.5";
11
12
13sub new {
14    my($class,$arg) = @_;
15    my $failed = substr($arg,0,2) eq "NO";
16    if ($failed) {
17        $something_has_failed_at = $CPAN::CurrentCommandId;
18    }
19    bless {
20           TEXT => $arg,
21           FAILED => $failed,
22           COMMANDID => $CPAN::CurrentCommandId,
23           TIME => time,
24          }, $class;
25}
26sub something_has_just_failed () {
27    defined $something_has_failed_at &&
28        $something_has_failed_at == $CPAN::CurrentCommandId;
29}
30sub commandid { shift->{COMMANDID} }
31sub failed { shift->{FAILED} }
32sub text {
33    my($self,$set) = @_;
34    if (defined $set) {
35        $self->{TEXT} = $set;
36    }
37    $self->{TEXT};
38}
39sub as_string {
40    my($self) = @_;
41    $self->text;
42}
43
44
451;
46