blib/lib/WWW/PlantUML.pm

filter: Statementstmt 100% 28 / 28 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 83.3% 40 / 48 SCAR 14.0
CC
4
Cov
86%
new
3.6
fetch_url
2.0
BEGIN
1.0
CRAP 4.0
↑ Summary
1 package WWW::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 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use UML::PlantUML::Encoder qw(encode_p);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 WWW::PlantUML - a simple Perl remote client interface to a plantuml server.
13  
14 =head1 VERSION
15  
16 Version 0.01
17  
18 =cut
19  
20 2 our $VERSION = '0.01';
21 2 our $URL = 'http://www.plantuml.com/plantuml';
22  
23 =head1 SYNOPSIS
24  
25 use WWW::PlantUML;
26  
27 my $puml = WWW::PlantUML->new;
28 my $url = $puml->fetch_url(qq{
29 Alice -> Bob : hello
30 }, 'png');
31  
32 print $url;
33 # prints http://www.plantuml.com/plantuml/png/69NZKb1moazIqBLJSCp9J4vLi5B8ICt9oUS204a_1dy0
34  
35 =head1 DESCRIPTION
36  
37 Plantuml is a library for generating UML diagrams from a simple text markup language.
38  
39 This is a simple Perl remote client interface to a plantuml server using the same custom encoding used by most other plantuml clients. Perl was missing from the list.
40  
41 There are other plantuml Perl libraries, like PlantUML::ClassDiagram::Parse, they provide only parsing capabilities for Class Diagrams. In contrast WWW::PlantUML module provides accessing any UML Diagram Type in various formats supported by any plantUML server via HTTP Protocol.
42  
43 This client defaults to the public plantuml server, but can be used against any server.
44  
45 =head1 SUBROUTINES/METHODS
46  
47 =head2 new
48  
49 Constructor.
50  
51 Can be optionally passed a URL to the PlantUML Server.
52  
53 Defaults to http://www.plantuml.com/plantuml
54  
55 =cut
56  
57 sub new {
58 1 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=12.7
Pod documented
59 1 my $url = shift;
60 my %args = (
61 1 ▶ 'baseurl' => $url || $ENV{PLANTUML_BASE_URL} || $URL,
Condition33%2/6
$url || $ENV{'PLANTUML_BASE_URL'} || $WWW::PlantUML::URL
l!l&&r!l&&!r
100
$url or $ENV{"PLANTUML_BASE_URL"}
l!l&&r!l&&!r
010
MC/DC0%0/3
$url || $ENV{'PLANTUML_BASE_URL'} || $WWW::PlantUML::URL
$url $ENV{"PLANTUML_BASE_URL"} $WWW::PlantUML::URL
Truth table25%1/4
A or B || C
A= $urlB= $ENV{"PLANTUML_BASE_URL"}C= $WWW::PlantUML::URL
ABCresult
1XX1
01X1
0011
0000
62 'contexts' => ( 'png', 'svg', 'txt' ),
63 @_,
64 );
65  
66 1 return bless {%args}, $class;
67 }
68  
69 =head2 fetch_url
70  
71 First parameter is PlantUML Syntax as a String.
72  
73 Optionally second parameter is the format of the generated diagram as a String.
74  
75 Default is Text Format.
76  
77 =cut
78  
79 sub fetch_url {
80 1 ▶ my $self = shift;
Subroutine fetch_url: called CC=2 SCAR=7.0
Pod documented
81 1 my $base = $self->{'baseurl'};
82  
83 #my $path = $self->{'infopath'};
84 #my ( $type, $code ) = $self->_parse_args(@_);
85 1 my $code = shift;
86 1 my $type = shift;
87  
88 1 my $ncoded = encode_p($code);
89 1 ▶ my $url = defined $type ? "$base/$type/$ncoded" : "$base/txt/$ncoded";
Branch: 1 branch
BranchTrueFalseTotal
defined $type ? : 1 0 1
90 1 return $url;
91 }
92  
93 =head1 AUTHOR
94  
95 Rangana Sudesha Withanage, C<< <rwi at cpan.org> >>
96  
97 =head1 BUGS
98  
99 Please report any bugs or feature requests to C<bug-www-plantuml at rt.cpan.org>, or through
100 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-PlantUML>. I will be notified, and then you'll
101 automatically be notified of progress on your bug as I make changes.
102  
103  
104 =head1 SUPPORT
105  
106 You can find documentation for this module with the perldoc command.
107  
108 perldoc WWW::PlantUML
109  
110  
111 You can also look for information at:
112  
113 =over 4
114  
115 =item * RT: CPAN's request tracker (report bugs here)
116  
117 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-PlantUML>
118  
119 =item * AnnoCPAN: Annotated CPAN documentation
120  
121 L<http://annocpan.org/dist/WWW-PlantUML>
122  
123 =item * CPAN Ratings
124  
125 L<https://cpanratings.perl.org/d/WWW-PlantUML>
126  
127 =item * Search CPAN
128  
129 L<https://metacpan.org/release/WWW-PlantUML>
130  
131 =back
132  
133  
134 =head1 ACKNOWLEDGEMENTS
135  
136  
137 =head1 LICENSE AND COPYRIGHT
138  
139 This software is copyright (c) 2019 by Rangana Sudesha Withanage.
140  
141 This is free software; you can redistribute it and/or modify it under
142 the same terms as the Perl 5 programming language system itself.
143  
144  
145 =cut
146  
147 2 1; # End of WWW::PlantUML
↑ Summary