File Coverage

blib/lib/Term/Twiddle/Quiet.pm
Criterion Covered Total %
statement 23 23 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 32 33 96.9


line stmt bran cond sub pod time code
1             #
2             # This file is part of Term-Twiddle-Quiet
3             #
4             # This software is copyright (c) 2010 by Jerome Quelin.
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9 1     1   14619 use 5.008;
  1         5  
  1         50  
10 1     1   6 use strict;
  1         3  
  1         34  
11 1     1   6 use warnings;
  1         2  
  1         81  
12              
13             package Term::Twiddle::Quiet;
14             our $VERSION = '1.100110';
15             # ABSTRACT: Twiddles a thingy while-u-wait if run interactively
16              
17 1     1   5 use IO::Interactive qw{ is_interactive };
  1         2  
  1         7  
18 1     1   1041 use Term::Twiddle;
  1         5618  
  1         34  
19 1     1   86255 use Test::MockObject;
  1         45802  
  1         8  
20              
21              
22             # -- public methods
23              
24              
25             sub new {
26 1     1 1 59 my $class = shift;
27              
28             # interactive: return the real object
29 1 50       5 return Term::Twiddle->new(@_) if is_interactive;
30              
31             # not interactive: let's mock it
32 1         20 my $mock = Test::MockObject->new;
33 1         15 $mock->set_true($_) for qw{
34             start stop thingy rate probability random stream
35             type width delay
36             };
37 1         302 return $mock;
38             }
39              
40             1;
41              
42              
43             =pod
44              
45             =head1 NAME
46              
47             Term::Twiddle::Quiet - Twiddles a thingy while-u-wait if run interactively
48              
49             =head1 VERSION
50              
51             version 1.100110
52              
53             =head1 SYNOPSIS
54              
55             use Term::Twiddle::Quiet;
56             my $tw = Term::Twiddle::Quiet->new( \%params );
57             $tw->start;
58             # do some stuff taking a long time in here
59             $tw->stop;
60              
61             =head1 DESCRIPTION
62              
63             L is a nice module for showing spinning thingies on the
64             terminal while waiting for an action to complete.
65              
66             L acts very much like that module when it is run
67             interactively. However, when it isn't run interactively (for example, as
68             a cron job) then it does not show the twiddle.
69              
70             Other than this difference, it really act as a L with all
71             its options, methods and restrictions (of course, it supports the same
72             API) - cf its documentation for more information.
73              
74             =head1 METHODS
75              
76             =head2 my $tw = Term::Twiddle::Quiet->new( \%params );
77              
78             Create and return twiddle. The twiddle will do nothing when activated if
79             the program is ran non-interactively, otherwise it'll return a plain
80             L object.
81              
82             =head1 AUTHOR
83              
84             Jerome Quelin
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             This software is copyright (c) 2010 by Jerome Quelin.
89              
90             This is free software; you can redistribute it and/or modify it under
91             the same terms as the Perl 5 programming language system itself.
92              
93             =cut
94              
95              
96             __END__