File Coverage

lib/Text/Frundis/PerlEval.pm
Criterion Covered Total %
statement 52 54 96.3
branch 3 4 75.0
condition n/a
subroutine 16 17 94.1
pod n/a
total 71 75 94.6


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2             # Copyright (c) 2014, 2015 Yon
3             #
4             # Permission to use, copy, modify, and distribute this software for any
5             # purpose with or without fee is hereby granted, provided that the above
6             # copyright notice and this permission notice appear in all copies.
7             #
8             # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9             # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10             # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11             # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12             # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13             # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14             # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15             #
16             # Eval of perl code to compile new user defined macros
17             #
18             package Text::Frundis::PerlEval;
19              
20 3     3   15 use utf8;
  3         5  
  3         17  
21 3     3   94 use v5.12;
  3         9  
22 3     3   15 use strict;
  3         6  
  3         75  
23 3     3   14 use warnings;
  3         6  
  3         98  
24 3     3   14 use open qw(:std :utf8);
  3         10  
  3         56  
25              
26 3     3   310 use Text::Frundis::Object qw(@Arg);
  3         6  
  3         238  
27 3     3   15 use Text::Frundis::Processing;
  3         5  
  3         754  
28              
29             our @Arg;
30              
31             sub _compile_perl_code { # [[[
32 63     63   109 my $self = shift;
33 63         154 my ($macro, $text, $type) = @_;
34 63 100       217 my $key = $type eq "macro" ? "macros" : "filters";
35 63         102 local $@;
36             {
37 63         78 local $SIG{'__WARN__'} = sub {
38 0     0   0 Text::Frundis::Processing::diag_error("perl_eval:$type:$_[0]");
39 63         510 };
40 63     1   11165 $self->{$key}{$macro}{code} = eval qq(sub { $text });
  1     1   12  
  1     1   3  
  1     1   13  
  1     1   647  
  1     1   298  
  1     1   31  
  1     1   9  
  1         2  
  1         9  
  1         164  
  1         2  
  1         26  
  1         8  
  1         2  
  1         10  
  1         157  
  1         3  
  1         29  
  1         8  
  1         3  
  1         9  
  1         159  
  1         2  
  1         26  
41             }
42 63 50       449 if ($@) {
43 0         0 Text::Frundis::Processing::diag_fatal("perl_eval:$type:$@");
44             }
45             } # ]]]
46              
47             1;
48              
49             # vim:foldmarker=[[[,]]]:foldmethod=marker:sw=4:sts=4:expandtab