File Coverage

blib/lib/Siffra/Base.pm
Criterion Covered Total %
statement 63 83 75.9
branch 3 12 25.0
condition 3 8 37.5
subroutine 18 21 85.7
pod 1 1 100.0
total 88 125 70.4


line stmt bran cond sub pod time code
1             package Siffra::Base;
2              
3 1     1   55150 use 5.014;
  1         3  
4 1     1   4 use strict;
  1         2  
  1         18  
5 1     1   5 use warnings;
  1         1  
  1         22  
6 1     1   5 use Carp;
  1         1  
  1         63  
7 1     1   482 use utf8;
  1         11  
  1         4  
8 1     1   502 use Data::Dumper;
  1         5557  
  1         65  
9 1     1   392 use DDP;
  1         33010  
  1         10  
10 1     1   456 use Log::Any qw($log);
  1         8364  
  1         5  
11 1     1   1693 use Scalar::Util qw(blessed);
  1         3  
  1         64  
12             $Carp::Verbose = 1;
13              
14             $| = 1; #autoflush
15              
16             use constant {
17             FALSE => 0,
18             TRUE => 1,
19 1   50     75 DEBUG => $ENV{ DEBUG } // 0,
20 1     1   22 };
  1         2  
21              
22             BEGIN
23             {
24 1     1   6 use Exporter ();
  1         2  
  1         18  
25 1     1   4 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
  1         2  
  1         119  
26 1     1   3 $VERSION = '0.08';
27 1         13 @ISA = qw(Exporter);
28              
29             #Give a hoot don't pollute, do not export more than needed by default
30 1         3 @EXPORT = qw();
31 1         1 @EXPORT_OK = qw();
32 1         251 %EXPORT_TAGS = ();
33             } ## end BEGIN
34              
35             BEGIN
36             {
37 1     1   18 binmode( STDOUT, ":encoding(UTF-8)" );
  1     1   10  
  1         2  
  1         7  
38 1         9308 binmode( STDERR, ":encoding(UTF-8)" );
39              
40             $SIG{ __DIE__ } = sub {
41 1         4 $log->debug( 'Entrando em __DIE__', { package => __PACKAGE__ } );
42 1 50       6 if ( $^S )
43             {
44 1         4 $log->debug( 'Entrando em __DIE__ eval {}', { package => __PACKAGE__ } );
45              
46             # We're in an eval {} and don't want log
47             # this message but catch it later
48 1         24 return;
49             } ## end if ( $^S )
50              
51 0         0 ( my $message = $_[ 0 ] ) =~ s/\n|\r//g;
52 0         0 $log->fatal( $message, { package => __PACKAGE__ } );
53              
54 0         0 die Dumper @_; # Now terminate really
55 1         42 };
56              
57             $SIG{ __WARN__ } = sub {
58 0         0 state $count = 0;
59 0         0 ( my $message = $_[ 0 ] ) =~ s/\n|\r//g;
60 0 0       0 if ( $log )
61             {
62 0         0 $log->warn( $message, { package => __PACKAGE__, count => $count++, global_phase => ${^GLOBAL_PHASE} } );
63             }
64 1         390 };
65             } ## end BEGIN
66              
67             =head2 C<new()>
68              
69             Usage : $self->block_new_method() within text_pm_file()
70             Purpose : Build 'new()' method as part of a pm file
71             Returns : String holding sub new.
72             Argument : $module: pointer to the module being built
73             (as there can be more than one module built by EU::MM);
74             for the primary module it is a pointer to $self
75             Throws : n/a
76             Comment : This method is a likely candidate for alteration in a subclass,
77             e.g., pass a single hash-ref to new() instead of a list of
78             parameters.
79              
80             =cut
81              
82             sub new
83             {
84 1     1 1 85 $log->debug( "new", { progname => $0, pid => $$, perl_version => $], package => __PACKAGE__ } );
85 1         6 my ( $class, %parameters ) = @_;
86              
87 1         3 my $self = {};
88              
89 1   33     6 $self = bless( $self, ref( $class ) || $class );
90              
91 1         3 return $self;
92             } ## end sub new
93              
94             sub _initialize()
95             {
96 0     0   0 $log->debug( "_initialize", { package => __PACKAGE__ } );
97 0         0 my ( $self, %parameters ) = @_;
98             }
99              
100             sub _finalize()
101             {
102 0     0   0 $log->debug( "_finalize", { package => __PACKAGE__ } );
103 0         0 my ( $self, %parameters ) = @_;
104             }
105              
106             sub END
107             {
108 1     1   115 $log->debug( "END", { package => __PACKAGE__ } );
109 1         4 eval { $log->{ adapter }->{ dispatcher }->{ outputs }->{ Email }->flush; };
  1         59  
110             }
111              
112             sub DESTROY
113             {
114 1     1   524 my ( $self, %parameters ) = @_;
115              
116 1 50       5 if ( ${^GLOBAL_PHASE} eq 'DESTRUCT' )
117             {
118 0         0 eval { $log->{ adapter }->{ dispatcher }->{ outputs }->{ Email }->flush; };
  0         0  
119 0         0 return;
120             }
121              
122 1 50 33     10 if ( blessed( $self ) && $self->isa( __PACKAGE__ ) )
123             {
124 1         7 $log->debug( "DESTROY", { package => __PACKAGE__, GLOBAL_PHASE => ${^GLOBAL_PHASE}, blessed => TRUE } );
125             }
126             else
127             {
128             # TODO
129             }
130             } ## end sub DESTROY
131              
132             =head2 C<AUTOLOAD>
133             =cut
134              
135             sub AUTOLOAD
136             {
137 0     0     my ( $self, @parameters ) = @_;
138 0           our $AUTOLOAD;
139 0 0         return if ( $AUTOLOAD =~ /DESTROY/ );
140              
141             # Remove qualifier from original method name...
142 0           my $called = $AUTOLOAD =~ s/.*:://r;
143              
144             # Is there an attribute of that name?
145 0 0         die "No such attribute ****[ $called ]****" unless exists $self->{ $called };
146              
147             # If so, return it...
148 0           return $self->{ $called };
149             } ## end sub AUTOLOAD
150              
151             #################### main pod documentation begin ###################
152             ## Below is the stub of documentation for your module.
153             ## You better edit it!
154              
155             =encoding UTF-8
156              
157              
158             =head1 NAME
159              
160             Siffra::Base - Siffra Base Module
161              
162             =head1 SYNOPSIS
163              
164             use Siffra::Base;
165             blah blah blah
166              
167              
168             =head1 DESCRIPTION
169              
170             Stub documentation for this module was created by ExtUtils::ModuleMaker.
171             It looks like the author of the extension was negligent enough
172             to leave the stub unedited.
173              
174             Blah blah blah.
175              
176              
177             =head1 USAGE
178              
179              
180              
181             =head1 BUGS
182              
183              
184              
185             =head1 SUPPORT
186              
187              
188              
189             =head1 AUTHOR
190              
191             Luiz Benevenuto
192             CPAN ID: LUIZBENE
193             Siffra TI
194             luiz@siffra.com.br
195             https://siffra.com.br
196              
197             =head1 COPYRIGHT
198              
199             This program is free software; you can redistribute
200             it and/or modify it under the same terms as Perl itself.
201              
202             The full text of the license can be found in the
203             LICENSE file included with this module.
204              
205              
206             =head1 SEE ALSO
207              
208             perl(1).
209              
210             =cut
211              
212             #################### main pod documentation end ###################
213              
214             1;
215              
216             # The preceding line will help the module return a true value
217