Knit/Document.pm

filter: Statementstmt 96.9% 63 / 65 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.4% 19 / 21 Podpod 80.0% 4 / 5 totaltotal 90.7% 88 / 97 CC 5 SCAR 6.7
CC
5
Cov
92%
__ANON__
6.0
_build_content
6.0
__ANON__
2.0
CRAP 2.0
« use.pl ↑ Summary Knit/Plugin/Authors.pm »
1 package Pod::Knit::Document;
2 13 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTACT: a Pod::Knit document
4 13 $Pod::Knit::Document::VERSION = '0.0.1';
5 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 ▶use Log::Any '$log', prefix => 'PKnit::Doc: ';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use XML::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use XML::WriterX::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 13 ▶use List::Util qw/ reduce /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 13 ▶use Pod::Knit;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 13 ▶use Pod::Knit::PodParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 13 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 13 with 'Pod::Knit::Output::Pod';
21  
22 13 ▶use MooseX::MungeHas { has_ro => [ 'is_ro' ] };
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 13 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26  
27  
28  
29  
30  
31  
32 13 has_ro knit => (
33 predicate => 1,
34 );
35  
36  
37 has_ro plugins => (
38 lazy => 1,
39 traits => [ 'Array' ],
40 13 ▶ default => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
41 13 my $self = shift;
42 13 ▶ $self->has_knit ? $self->knit->plugins : [];
Branch: 1 branch
BranchTrueFalseTotal
$self->has_knit ? : 6 7 13
43 },
44 13 handles => { all_plugins => 'elements' },
45 );
46  
47  
48 13 has_ro file => (
49 predicate => 'has_file',
50 );
51  
52  
53 0 ▶has_ro content => sub {
Subroutine _build_content: not called CC=2 SCAR=17.9
Subroutine __ANON__: not called CC=2 SCAR=17.9
54 0 ▶ $_[0]->has_file and path( $_[0]->file )->slurp;
Branch: 2 branches
BranchTrueFalseTotal
$_[0]->has_file and path($_[0]->file)->slurp 0 0 0
$_[0]->has_file and path($_[0]->file)->slurp 0 0 0
55 13 };
56  
57  
58  
59 13 ▶sub podparser {
Subroutine podparser: called CC=2 SCAR=6.9
Pod documented
60 13 my $self = shift;
61
62 13 my $parser = Pod::Knit::PodParser->new;
63 13 $_->setup_podparser($parser) for grep { $_->can('setup_podparser') }
64 $self->all_plugins;
65 13 return $parser;
66 }
67  
68  
69 has xml_pod => (
70 is => 'rw',
71 lazy => 1,
72 13 ▶ default => sub($self) {
Subroutine __ANON__: called CC=1 SCAR=0.0
73 13 my $parser = $self->podparser;
74  
75 13 return $parser->parse($self->content)
76 =~ s/(?<=<)(\w+)/\L$1/gr
77 =~ s/(?<=<\/)(\w+)/\L$1/gr;
78 }
79 13 );
80  
81  
82 12 ▶sub clone {
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
83 12 my $self = shift;
84  
85 __PACKAGE__->new(
86 plugins => [],
87 12 map { $_ => $self-> $_ } qw/ content xml_pod knit file /
88 );
89 }
90  
91  
92  
93 2 ▶sub as_code ($self ) {
Subroutine as_code: called CC=1 SCAR=0.0
Pod documented
94 return join "\n", grep {
95 2 not /^=/../^=cut/
96 } split "\n", $self->content;
97 }
98  
99  
100 1 ▶sub as_string ($self) {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
101 1 return join "\n\n__END__\n\n", $self->as_code, $self->as_pod;
102 }
103  
104  
105 9 ▶sub xml_write($self,@data) {
Subroutine xml_write: called CC=1 SCAR=0.0
Pod undocumented
106 9 my $writer = XML::Writer->new( OUTPUT => 'self' );
107 9 $writer->produce(@data);
108 9 $writer->to_string;
109 }
110  
111 13 1;
112  
113 __END__
« use.pl ↑ Summary Knit/Plugin/Authors.pm »