lib/PXML/Tags.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 38 / 38 CC 3 SCAR 3.4
CC
3
Cov
100%
import
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.4
« lib/FP/Docstring/t.pm ↑ Summary lib/Chj/noTEST.pm »
1 #
2 # Copyright (c) 2013-2019 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::Tags
13  
14 =head1 SYNOPSIS
15  
16 1 ▶ use PXML::Tags qw(records
Subroutine BEGIN: called CC=1 SCAR=0.0
17 protocol-version
18 1 record);
19 my $xml = RECORDS(PROTOCOL_VERSION("1.0"),
20 RECORD("Hi"), RECORD("there!"));
21 is ref($xml), "PXML::Element";
22 is $xml->string, '<records><protocol-version>1.0</protocol-version><record>Hi</record><record>there!</record></records>';
23  
24 =head1 DESCRIPTION
25  
26 Creates tag wrappers that return PXML elements. The names of the
27 wrappers are all uppercase, and "-" is replaced with "_".
28  
29 =head1 NOTE
30  
31 This is alpha software! Read the status section in the package README
32 or on the L<website|http://functional-perl.org/>.
33  
34 =cut
35  
36 package PXML::Tags;
37  
38 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 4 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 4 ▶use PXML::Element;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 11 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
45 11 my $caller = caller;
46 11 for my $name (@_) {
47 35 my $fname = uc $name;
48 35 $fname =~ s/-/_/sg;
49 35 my $fqname = "${caller}::$fname";
50 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
51 37 ▶ *$fqname = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
52 37 ▶ my $atts = ref($_[0]) eq "HASH" ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 3 34 37
53 37 PXML::Element->new($name, $atts, [@_]);
54 35 };
55 }
56 1
57 11 }
58  
59 4 1
« lib/FP/Docstring/t.pm ↑ Summary lib/Chj/noTEST.pm »