line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ************************************************************************* |
2
|
|
|
|
|
|
|
# Copyright (c) 2014-2016, SUSE LLC |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
7
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions are met: |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice, |
10
|
|
|
|
|
|
|
# this list of conditions and the following disclaimer. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright |
13
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the |
14
|
|
|
|
|
|
|
# documentation and/or other materials provided with the distribution. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# 3. Neither the name of SUSE LLC nor the names of its contributors may be |
17
|
|
|
|
|
|
|
# used to endorse or promote products derived from this software without |
18
|
|
|
|
|
|
|
# specific prior written permission. |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
21
|
|
|
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
22
|
|
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
23
|
|
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
24
|
|
|
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25
|
|
|
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26
|
|
|
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27
|
|
|
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28
|
|
|
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29
|
|
|
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30
|
|
|
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE. |
31
|
|
|
|
|
|
|
# ************************************************************************* |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use 5.012; |
35
|
22
|
|
|
22
|
|
404
|
use strict; |
|
22
|
|
|
|
|
66
|
|
36
|
22
|
|
|
22
|
|
109
|
use warnings; |
|
22
|
|
|
|
|
40
|
|
|
22
|
|
|
|
|
442
|
|
37
|
22
|
|
|
22
|
|
94
|
|
|
22
|
|
|
|
|
41
|
|
|
22
|
|
|
|
|
630
|
|
38
|
|
|
|
|
|
|
use App::CELL qw( $log ); |
39
|
22
|
|
|
22
|
|
132
|
use File::Spec; |
|
22
|
|
|
|
|
46
|
|
|
22
|
|
|
|
|
1654
|
|
40
|
22
|
|
|
22
|
|
143
|
use JSON; |
|
22
|
|
|
|
|
55
|
|
|
22
|
|
|
|
|
643
|
|
41
|
22
|
|
|
22
|
|
108
|
use Params::Validate qw( :all ); |
|
22
|
|
|
|
|
58
|
|
|
22
|
|
|
|
|
221
|
|
42
|
22
|
|
|
22
|
|
2480
|
use Pod::Simple::HTML; |
|
22
|
|
|
|
|
45
|
|
|
22
|
|
|
|
|
3344
|
|
43
|
22
|
|
|
22
|
|
10881
|
use Pod::Simple::Text; |
|
22
|
|
|
|
|
781928
|
|
|
22
|
|
|
|
|
775
|
|
44
|
22
|
|
|
22
|
|
9167
|
|
|
22
|
|
|
|
|
95740
|
|
|
22
|
|
|
|
|
1270
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $JSON = JSON->new->allow_nonref->convert_blessed->utf8->pretty; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Web::MREST::Util - Miscellaneous utilities |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Miscellaneous utilities |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 EXPORTS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This module provides the following exports: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item C<$JSON> (singleton) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item C<pod_to_html> (function) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item C<pod_to_text> (function) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
use Exporter qw( import ); |
82
|
22
|
|
|
22
|
|
150
|
our @EXPORT_OK = qw( |
|
22
|
|
|
|
|
50
|
|
|
22
|
|
|
|
|
4496
|
|
83
|
|
|
|
|
|
|
$JSON |
84
|
|
|
|
|
|
|
pod_to_html |
85
|
|
|
|
|
|
|
pod_to_text |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 FUNCTIONS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 pod_to_html |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Every L<Web::MREST> resource definition includes a 'documentation' |
97
|
|
|
|
|
|
|
property containing a POD string. Our 'docu/html' resource converts this |
98
|
|
|
|
|
|
|
POD string into HTML with a little help from this routine. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my ( $pod_str ) = @_; |
103
|
|
|
|
|
|
|
$log->debug( "Entering " . __PACKAGE__ . "::pod_to_html" ); |
104
|
1
|
|
|
1
|
1
|
15
|
|
105
|
1
|
|
|
|
|
8
|
#$log->debug( "pod_to_html before: $pod_str" ); |
106
|
|
|
|
|
|
|
my $p = Pod::Simple::HTML->new; |
107
|
|
|
|
|
|
|
$p->output_string(\my $html_str); |
108
|
1
|
|
|
|
|
177
|
$p->parse_string_document($pod_str); |
109
|
1
|
|
|
|
|
405
|
|
110
|
1
|
|
|
|
|
884
|
# now $html_str contains a full-blown HTML file, of which only one part is |
111
|
|
|
|
|
|
|
# of interest to us. That part starts with the line <!-- start doc --> and |
112
|
|
|
|
|
|
|
# ends with <!-- end doc --> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$html_str =~ s/.*<!-- start doc -->//s; |
115
|
|
|
|
|
|
|
$html_str =~ s/<!-- end doc -->.*//s; |
116
|
1
|
|
|
|
|
1631
|
|
117
|
1
|
|
|
|
|
4
|
$log->debug( "pod_to_html after: $html_str" ); |
118
|
|
|
|
|
|
|
return $html_str; |
119
|
1
|
|
|
|
|
8
|
} |
120
|
1
|
|
|
|
|
221
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 pod_to_text |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Convert POD string into text |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my $pod_str = shift; |
129
|
|
|
|
|
|
|
$log->debug( "Entering " . __PACKAGE__ . "::pod_to_text" ); |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
0
|
1
|
|
my $p = Pod::Simple::Text->new; |
132
|
0
|
|
|
|
|
|
$p->output_string(\my $text_str); |
133
|
|
|
|
|
|
|
$p->parse_string_document($pod_str); |
134
|
0
|
|
|
|
|
|
return $text_str; |
135
|
0
|
|
|
|
|
|
} |
136
|
0
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |