File Coverage

blib/lib/App/Critique/Plugin/UI.pm
Criterion Covered Total %
statement 30 46 65.2
branch n/a
condition 1 2 50.0
subroutine 10 18 55.5
pod 0 5 0.0
total 41 71 57.7


line stmt bran cond sub pod time code
1             package App::Critique::Plugin::UI;
2              
3 16     16   81041 use strict;
  16         30  
  16         407  
4 16     16   48 use warnings;
  16         15  
  16         577  
5              
6             our $VERSION = '0.03';
7             our $AUTHORITY = 'cpan:STEVAN';
8              
9 16     16   48 use Term::ReadKey ();
  16         14  
  16         156  
10 16     16   7869 use Number::Format ();
  16         68406  
  16         501  
11              
12 16   50 16   73 use constant TERM_WIDTH => (Term::ReadKey::GetTerminalSize())[0] // 80;
  16         19  
  16         39  
13 16     16   75182 use constant HR_ERROR => ('== ERROR '.('=' x (TERM_WIDTH - 9)));
  16         37  
  16         856  
14 16     16   78 use constant HR_DARK => ('=' x TERM_WIDTH);
  16         32  
  16         783  
15 16     16   64 use constant HR_LIGHT => ('-' x TERM_WIDTH);
  16         31  
  16         726  
16              
17 16     16   63 use App::Critique -ignore;
  16         39  
  16         290  
18              
19 16         157 use App::Cmd::Setup -plugin => {
20             exports => [qw[
21             TERM_WIDTH
22              
23             HR_ERROR
24             HR_DARK
25             HR_LIGHT
26              
27             info
28             warning
29             error
30              
31             format_number
32             format_bytes
33             ]]
34 16     16   3214 };
  16         25  
35              
36 0     0 0   sub info { my ($plugin, $cmd, @args) = @_; _info( @args ) }
  0            
37 0     0 0   sub warning { my ($plugin, $cmd, @args) = @_; _warning( @args ) }
  0            
38 0     0 0   sub error { my ($plugin, $cmd, @args) = @_; _error( @args ) }
  0            
39              
40             sub format_number {
41 0     0 0   my ($plugin, $cmd, @args) = @_;
42 0           Number::Format::format_number( @args );
43             }
44              
45             sub format_bytes {
46 0     0 0   my ($plugin, $cmd, @args) = @_;
47 0           Number::Format::format_bytes( @args );
48             }
49              
50             # the real stuff
51              
52             sub _info {
53 0     0     my ($msg, @args) = @_;
54 0           print((sprintf $msg, @args), "\n");
55             }
56              
57             sub _warning {
58 0     0     my ($msg, @args) = @_;
59              
60             # NOTE:
61             # I had a timestamp here, but it didn't
62             # really help any with the readability,
63             # so I took it out, just in case I want
64             # it back. I am leaving it here so I
65             # don't need to work this out again.
66             # - SL
67             # my @time = (localtime)[ 2, 1, 0, 4, 3, 5 ];
68             # $time[-1] += 1900;
69             # sprintf '%02d:%02d:%02d-%02d/%02d/%d', @time;
70              
71 0           warn((sprintf $msg, @args),"\n");
72             }
73              
74             sub _error {
75 0     0     my ($msg, @args) = @_;
76 0           die(HR_ERROR,"\n",(sprintf $msg, @args),"\n",HR_DARK,"\n");
77             }
78              
79             1;
80              
81             =pod
82              
83             =head1 NAME
84              
85             App::Critique::Plugin::UI - UI elements for App::Critique
86              
87             =head1 VERSION
88              
89             version 0.03
90              
91             =head1 DESCRIPTION
92              
93             Just a simple L<App::Cmd::Plugin> to handle UI elements, nothing
94             really useful in here.
95              
96             =head1 AUTHOR
97              
98             Stevan Little <stevan@cpan.org>
99              
100             =head1 COPYRIGHT AND LICENSE
101              
102             This software is copyright (c) 2016 by Stevan Little.
103              
104             This is free software; you can redistribute it and/or modify it under
105             the same terms as the Perl 5 programming language system itself.
106              
107             =cut
108              
109             __END__
110              
111             # ABSTRACT: UI elements for App::Critique
112