lib/PXML.pm

filter: Statementstmt 100% 43 / 43 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 3 totaltotal 91.9% 57 / 62 CC 2 SCAR 1.4
CC
2
Cov
98%
is_pxmlflush
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/FP/BigInt.pm ↑ Summary lib/FP/Path/t.pm »
1 #
2 # Copyright (c) 2015-2020 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 PXML - functional XML handling, general functions
13  
14 =head1 SYNOPSIS
15  
16 1 ▶ use PXML qw(is_pxml_element);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use PXML::XHTML qw(P);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 ok is_pxml_element P();
20 is P("Hi <there>")->string, '<p>Hi &lt;there&gt;</p>';
21  
22 1 ▶ use PXML ":all";
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 is(pxmlbody("foo")->string, "foo");
25  
26  
27 =head1 DESCRIPTION
28  
29 General Functions for the PXML libraries.
30  
31 =head1 SEE ALSO
32  
33 L<PXML::Element>, L<PXML::Tags>, L<PXML::SVG>, L<PXML::XHTML>,
34 L<PXML::HTML5>, L<PXML::Util>, L<PXML::Serialize>, L<PXML::Preserialize>,
35 L<http://functional-perl/>
36  
37 =head1 NOTE
38  
39 This is alpha software! Read the status section in the package README
40 or on the L<website|http://functional-perl.org/>.
41  
42 =cut
43  
44 package PXML;
45 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 7 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
48 7 ▶use Exporter "import";
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 7 our @EXPORT = qw(is_pxml_element);
51 7 our @EXPORT_OK = qw(pxmlbody pxmlflush is_pxmlflush);
52 7 our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]);
53  
54 7 ▶use PXML::Element;
Subroutine BEGIN: called CC=1 SCAR=0.0
55  
56 7 ▶use FP::Predicates 'instance_of';
Subroutine BEGIN: called CC=1 SCAR=0.0
57 7 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 sub is_pxml_element;
60 7 *is_pxml_element = instance_of("PXML::Element");
61  
62 {
63  
64 7 package PXML::Body;
65  
66 # hacky?.
67 7 *string = \&PXML::Element::string;
68 }
69  
70 9 ▶sub pxmlbody {
Subroutine pxmlbody: called CC=1 SCAR=0.0
Pod undocumented
71 9 bless [@_], "PXML::Body"
72 }
73  
74 7 my $flush = bless [], "PXML::Flush";
75  
76 1 ▶sub pxmlflush {
Subroutine pxmlflush: called CC=1 SCAR=0.0
Pod undocumented
77 1 $flush
78 }
79  
80 31 ▶sub is_pxmlflush {
Subroutine is_pxmlflush: called CC=2 SCAR=7.1
Pod undocumented
81 31 my ($v) = @_;
82 31 ▶ blessed($v) // return;
Condition50%1/2
builtin::blessed($v) // (return)
l!l
310
MC/DC0%0/1
builtin::blessed($v) // (return)
builtin::blessed($v)
Truth table50%1/2
A
A= builtin::blessed($v)
Aresult
11
00
83 31 $v->isa("PXML::Flush")
84 }
85  
86 # XX make this cleaner:
87 # - make PXML::Body and PXML::Element inherit both from a base class
88 # - move `string` there (and perhaps all of serialization)
89 # - automatically use PXML::Body for bodies? (now that I moved away
90 # from requiring bodies to be arrays, though?)
91  
92 7 1
« lib/FP/BigInt.pm ↑ Summary lib/FP/Path/t.pm »