blib/lib/Template/Plugin/Filter/PlantUML.pm

filter: Statementstmt 100% 30 / 30 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 95.3% 41 / 43 CC 2 SCAR 2.0
CC
2
Cov
97%
filter
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Template::Plugin::Filter::PlantUML;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 require Template::Plugin::Filter;
8 2 ▶use base qw(Template::Plugin::Filter);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use vars qw($VERSION $DYNAMIC $FILTER_NAME);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use WWW::PlantUML;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 =head1 NAME
14  
15 Template::Plugin::Filter::PlantUML - A template toolkit plugin filter for encoding and processing PlantUML Diagrams using a PlantUML Server.
16  
17 =head1 VERSION
18  
19 Version 0.01
20  
21 =cut
22  
23 2 our $VERSION = 0.01;
24 2 our $DYNAMIC = 1;
25 2 our $FILTER_NAME = 'plantuml';
26  
27 =head1 SYNOPSIS
28  
29 To use this plugin, you have to make sure that the Template Toolkit knows about its namespace.
30  
31 my $tt2 = Template->new({
32 PLUGIN_BASE => 'Template::Plugin::Filter::PlantUML',
33 });
34  
35 Then you C<USE> your plugin like below.
36  
37 [% USE Filter.PlantUML 'http://www.plantuml.com/plantuml' 'svg' -%]
38
39 [% url = FILTER plantuml %]
40 Bob -> Alice : hello
41 [% END %]
42
43 <img src="[% url %]" alt="[% url %]" />
44  
45 =head1 DESCRIPTION
46  
47 This is a trivial Template::Toolkit plugin filter to allow any template writer to embed PlantUML Diagram Syntax in Templates and have them encoded and processed via any PlantUML Server in any supported formats.
48  
49 It uses C<WWW:PlantUML> remote client under the hood.
50  
51 =head1 SUBROUTINES/METHODS
52  
53 =head2 init
54  
55 defines init() method.
56  
57 =cut
58  
59 sub init {
60 1 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod documented
61 1 $self->install_filter($FILTER_NAME);
62 1 return $self;
63 }
64  
65 =head2 filter
66  
67 defines filter() method.
68  
69 =cut
70  
71 sub filter {
72 1 ▶ my ( $self, $code, $args, $conf ) = @_;
Subroutine filter: called CC=2 SCAR=7.0
Pod documented
73  
74 1 $args = $self->merge_args($args);
75 1 $conf = $self->merge_config($conf);
76  
77 1 my $puml = WWW::PlantUML->new( @$args[0] );
78 1 ▶ return $puml->fetch_url( $code, @$args[1] || 'png' );
Condition50%1/2
@$args[1] || 'png'
l!l
01
MC/DC0%0/1
@$args[1] || 'png'
@$args[1]
Truth table50%1/2
A
A= @$args[1]
Aresult
11
00
79 }
80  
81 =head1 AUTHOR
82  
83 Rangana Sudesha Withanage, C<< <rwi at cpan.org> >>
84  
85 =head1 BUGS
86  
87 Please report any bugs or feature requests to C<bug-template-plugin-filter-plantuml at rt.cpan.org>, or through
88 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Plugin-Filter-PlantUML>. I will be notified, and then you'll
89 automatically be notified of progress on your bug as I make changes.
90  
91  
92 =head1 SUPPORT
93  
94 You can find documentation for this module with the perldoc command.
95  
96 perldoc Template::Plugin::Filter::PlantUML
97  
98  
99 You can also look for information at:
100  
101 =over 4
102  
103 =item * RT: CPAN's request tracker (report bugs here)
104  
105 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Plugin-Filter-PlantUML>
106  
107 =item * AnnoCPAN: Annotated CPAN documentation
108  
109 L<http://annocpan.org/dist/Template-Plugin-Filter-PlantUML>
110  
111 =item * CPAN Ratings
112  
113 L<https://cpanratings.perl.org/d/Template-Plugin-Filter-PlantUML>
114  
115 =item * Search CPAN
116  
117 L<https://metacpan.org/release/Template-Plugin-Filter-PlantUML>
118  
119 =back
120  
121  
122 =head1 ACKNOWLEDGEMENTS
123  
124  
125 =head1 LICENSE AND COPYRIGHT
126  
127 This software is copyright (c) 2019 by Rangana Sudesha Withanage.
128  
129 This is free software; you can redistribute it and/or modify it under
130 the same terms as the Perl 5 programming language system itself.
131  
132  
133 =cut
134  
135 2 1; # End of Template::Plugin::Filter::PlantUML
↑ Summary