[Nagiosplug-checkins] Nagios-Plugin/lib/Nagios/Plugin ExitResult.pm, NONE, 1.1

Gavin Carr gonzai at users.sourceforge.net
Mon Sep 11 03:59:45 CEST 2006

Update of /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv18169

Added Files:
Log Message:
Add missing Nagios::Plugin::ExitResult class.

--- NEW FILE: ExitResult.pm ---
# Tiny helper class to return both output and return_code when testing

package Nagios::Plugin::ExitResult;

use strict;

# Stringify to message
use overload '""' => sub { shift->{message} };

# Constructor
sub new { 
    my $class = shift;
    return bless { return_code => $_[0], message => $_[1] }, $class;

# Accessors
sub message { shift->{message} }
sub return_code { shift->{return_code} }
sub code { shift->{return_code} }



=head1 NAME

Nagios::Plugin::ExitResult - Helper class for returning both output and 
return codes when testing.


    use Test::More;
    use Nagios::Plugin::Base;

    # In a test file somewhere

    # Later ...
    $e = nagios_exit( CRITICAL, 'aiiii ...' );
    print $e->message;
    print $e->return_code;
    # NP::ExitResult also stringifies to the message output
    like(nagios_exit( WARNING, 'foobar'), qr/^foo/, 'matches!');


Nagios::Plugin::ExitResult is a tiny helper class intended for use 
when testing other Nagios::Plugin modules. A Nagios::Plugin::ExitResult 
object is returned by nagios_exit() and friends when 
Nagios::Plugin::Base::_fake_exit has been set, instead of doing a 
conventional print + exit.

=head1 AUTHOR

Gavin Carr , E<lt>gavin at openfusion.com.auE<gt>


Copyright (C) 2006 by Nagios Plugin Development Team

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.


More information about the Commits mailing list