File Coverage

blib/lib/ProgressMonitor/Null.pm
Criterion Covered Total %
statement 24 30 80.0
branch 0 2 0.0
condition n/a
subroutine 8 10 80.0
pod n/a
total 32 42 76.1


line stmt bran cond sub pod time code
1             package ProgressMonitor::Null;
2            
3 1     1   2078 use warnings;
  1         2  
  1         34  
4 1     1   5 use strict;
  1         3  
  1         77  
5            
6             require ProgressMonitor if 0;
7            
8             use classes
9 1         12 extends => 'ProgressMonitor',
10             new => 'new',
11             methods => {
12             begin => 'EMPTY',
13             end => 'EMPTY',
14             isCanceled => 'EMPTY',
15             prepare => 'EMPTY',
16             setCanceled => 'EMPTY',
17             setMessage => 'EMPTY',
18             setErrorMessage => 'EMPTY',
19             tick => 'EMPTY',
20             subMonitor => 'subMonitor',
21             },
22             class_attrs_pr => [ 'instance' ],
23 1     1   5 ;
  1         2  
24            
25             sub new
26             {
27 0     0     my $class = shift;
28 0           my $cfg = shift;
29            
30 1     1   1013 no strict 'refs';
  1         3  
  1         161  
31 0 0         unless ($$CLASS_ATTR_instance)
32             {
33             # don't pass any cfg; just discard it
34             #
35 0           $$CLASS_ATTR_instance = classes::new_only($class);
36             }
37            
38 0           return $$CLASS_ATTR_instance;
39             }
40            
41             sub subMonitor
42             {
43 1     1   7 no strict 'refs';
  1         3  
  1         82  
44 0     0     return $$CLASS_ATTR_instance;
45             }
46            
47             ###
48            
49             package ProgressMonitor::NullConfiguration;
50            
51 1     1   6 use strict;
  1         2  
  1         25  
52 1     1   5 use warnings;
  1         2  
  1         37  
53            
54             use classes
55 1         5 extends => 'ProgressMonitor::AbstractConfiguration',
56 1     1   5 ;
  1         1  
57            
58             ############################
59            
60             =head1 NAME
61            
62             ProgressMonitor::Null - a monitor implementation which doesn't render anything.
63             Useful if a receiver insists on a monitor impl to talk to.
64            
65             =head1 SYNOPSIS
66            
67             ...
68             $someObj->someLongRunningMethod(ProgressMonitor::Null->new);
69             ...
70            
71             ####
72            
73             useful pattern inside a method that takes a monitor instance
74             but can accept undef for it:
75            
76             someMethod
77             {
78             my $monitor = shift;
79            
80             monitor = ProgressMonitor::Null->new unless $monitor;
81            
82             ...
83             #now the rest of the code is guaranteed a monitor
84             ...
85             }
86            
87             =head1 DESCRIPTION
88            
89             This is a 'null' implementation of the ProgressMonitor interface. It will simply
90             ignore to render anything, thus it's a good dropin for a method that requires
91             a monitor instance but you don't wish anything shown.
92            
93             Inherits from AbstractStatefulMonitor.
94            
95             =head1 AUTHOR
96            
97             Kenneth Olwing, C<< >>
98            
99             =head1 BUGS
100            
101             I wouldn't be surprised! If you can come up with a minimal test that shows the
102             problem I might be able to take a look. Even better, send me a patch.
103            
104             Please report any bugs or feature requests to
105             C, or through the web interface at
106             L.
107             I will be notified, and then you'll automatically be notified of progress on
108             your bug as I make changes.
109            
110             =head1 SUPPORT
111            
112             You can find general documentation for this module with the perldoc command:
113            
114             perldoc ProgressMonitor
115            
116             =head1 ACKNOWLEDGEMENTS
117            
118             Thanks to my family. I'm deeply grateful for you!
119            
120             =head1 COPYRIGHT & LICENSE
121            
122             Copyright 2006,2007 Kenneth Olwing, all rights reserved.
123            
124             This program is free software; you can redistribute it and/or modify it
125             under the same terms as Perl itself.
126            
127             =cut
128            
129             1; # End of ProgressMonitor::Null