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   9 use utf8;
  3         3  
  3         12  
21 3     3   84 use v5.12;
  3         8  
22 3     3   7 use strict;
  3         3  
  3         47  
23 3     3   10 use warnings;
  3         5  
  3         68  
24 3     3   7 use open qw(:std :utf8);
  3         3  
  3         32  
25              
26 3     3   234 use Text::Frundis::Object qw(@Arg);
  3         3  
  3         203  
27 3     3   9 use Text::Frundis::Processing;
  3         7  
  3         544  
28              
29             our @Arg;
30              
31             sub _compile_perl_code { # [[[
32 63     63   49 my $self = shift;
33 63         74 my ($macro, $text, $type) = @_;
34 63 100       92 my $key = $type eq "macro" ? "macros" : "filters";
35 63         50 local $@;
36             {
37 63         43 local $SIG{'__WARN__'} = sub {
38 0     0   0 Text::Frundis::Processing::diag_error("perl_eval:$type:$_[0]");
39 63         328 };
40 63     1   6363 $self->{$key}{$macro}{code} = eval qq(sub { $text });
  1     1   7  
  1     1   2  
  1     1   7  
  1     1   403  
  1     1   171  
  1     1   20  
  1     1   5  
  1         1  
  1         4  
  1         86  
  1         1  
  1         16  
  1         5  
  1         1  
  1         4  
  1         86  
  1         2  
  1         17  
  1         4  
  1         2  
  1         3  
  1         86  
  1         2  
  1         16  
41             }
42 63 50       267 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