File Coverage

blib/lib/App/PS1/Plugin/Face.pm
Criterion Covered Total %
statement 15 19 78.9
branch 0 4 0.0
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 21 30 70.0


line stmt bran cond sub pod time code
1             package App::PS1::Plugin::Face;
2              
3             # Created on: 2011-06-21 09:48:15
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   1014 use strict;
  1         3  
  1         30  
10 1     1   5 use warnings;
  1         2  
  1         25  
11 1     1   4 use Carp;
  1         2  
  1         54  
12 1     1   6 use Data::Dumper qw/Dumper/;
  1         2  
  1         52  
13 1     1   7 use English qw/ -no_match_vars /;
  1         3  
  1         5  
14              
15             our $VERSION = 0.08;
16              
17             sub face {
18 0     0 1   my ($self, $options) = @_;
19 0           my $exit_code = $self->exit;
20 0           my ($happy, $sad) = (qw/:-) :-(/);
21              
22 0 0         return ( 3, !$exit_code ? $self->colour('face_happy') . $happy : $exit_code ? $self->colour('face_sad') . $sad : $self->colour('red', 'red') . $sad );
    0          
23             }
24              
25             1;
26              
27             __END__
28              
29             =head1 NAME
30              
31             App::PS1::Plugin::Face - Adds an indicator of last programs success or failure to prompt
32              
33             =head1 VERSION
34              
35             This documentation refers to App::PS1::Plugin::Face version 0.08.
36              
37             =head1 SYNOPSIS
38              
39             use App::PS1::Plugin::Face;
40              
41             # Brief but working code example(s) here showing the most common usage(s)
42             # This section will be as far as many users bother reading, so make it as
43             # educational and exemplary as possible.
44              
45              
46             =head1 DESCRIPTION
47              
48             Adds a smiley face / sad face to indicate result of the previous command. That
49             is if the exit code of the last command is zero a happy face is shown but if
50             the exit code is non-zero a sad face is shown. Also if the exit code is less
51             than 3 the the colour is orange if greater than 3 it's red.
52              
53             =head1 SUBROUTINES/METHODS
54              
55             =head3 C<face ()>
56              
57             Happy face if last process returned without error sad otherwise.
58              
59             =head1 DIAGNOSTICS
60              
61             =head1 CONFIGURATION AND ENVIRONMENT
62              
63             =head1 DEPENDENCIES
64              
65             =head1 INCOMPATIBILITIES
66              
67             =head1 BUGS AND LIMITATIONS
68              
69             There are no known bugs in this module.
70              
71             Please report problems to Ivan Wills (ivan.wills@gmail.com).
72              
73             Patches are welcome.
74              
75             =head1 AUTHOR
76              
77             Ivan Wills - (ivan.wills@gmail.com)
78              
79             =head1 LICENSE AND COPYRIGHT
80              
81             Copyright (c) 2011 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW, Australia 2077)
82             All rights reserved.
83              
84             This module is free software; you can redistribute it and/or modify it under
85             the same terms as Perl itself. See L<perlartistic>. This program is
86             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
87             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
88             PARTICULAR PURPOSE.
89              
90             =cut