Stenciller.pm

filter: Statementstmt 93.7% 15 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 2 totaltotal 83.3% 20 / 24 SCAR 0.0
CC
1
Cov
94%
meta
2.0
__ANON__
1.0
__ANON__
1.0
CRAP 1.0
« Stenciller/Standard.pm ↑ Summary Types/Stenciller.pm »
1 7 ▶use 5.14.0;
Subroutine __ANON__: called CC=1 SCAR=0.0
2 7 ▶use strict;
Subroutine __ANON__: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine __ANON__: called CC=1 SCAR=0.0
4  
5 7 ▶use Stenciller::Wrap;
Subroutine __ANON__: called CC=1 SCAR=0.0
6  
7 package Stenciller;
8  
9 7 our $VERSION = '0.1302'; # VERSION:
10 # PODCLASSNAME:
11 # ABSTRACT: Transforms a flat file format to different output
12  
13 sub new {
14 7 ▶ shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 7 Stenciller::Wrap->new(@_);
16 }
17 sub meta {
18 0 ▶ Stenciller::Wrap->meta;
Subroutine meta: not called CC=1 SCAR=6.9
Pod undocumented
19 }
20  
21 7 1;
22  
23 __END__
24  
25 =pod
26  
27 =encoding UTF-8
28  
29 =head1 NAME
30  
31 Stenciller - Transforms a flat file format to different output
32  
33  
34  
35 =begin HTML
36  
37 <p><img src="https://img.shields.io/badge/perl-5.14+-brightgreen.svg" alt="Requires Perl 5.14+" /> <a href="https://travis-ci.org/Csson/p5-Stenciller"><img src="https://api.travis-ci.org/Csson/p5-Stenciller.svg?branch=master" alt="Travis status" /></a></p>
38  
39 =end HTML
40  
41  
42 =begin markdown
43  
44 ![Requires Perl 5.14+](https://img.shields.io/badge/perl-5.14+-brightgreen.svg) [![Travis status](https://api.travis-ci.org/Csson/p5-Stenciller.svg?branch=master)](https://travis-ci.org/Csson/p5-Stenciller)
45  
46 =end markdown
47  
48 =head1 VERSION
49  
50 Version 0.1302, released 2015-11-28.
51  
52  
53  
54 =head1 SYNOPSIS
55  
56 use Stenciller;
57 my $stenciller = Stenciller->new(filepath => 't/corpus/test-1.stencil');
58 my $content = $stenciller->transform(plugin_name => 'ToUnparsedText');
59  
60 =head1 DESCRIPTION
61  
62 Stenciller reads a special fileformat and provides a way to convert the content into different types of output. For example, it can be used to create documentation and tests from the same source file.
63  
64 =head2 File format
65  
66 == stencil {} ==
67  
68 --input--
69  
70 --end input--
71  
72 --output--
73  
74 --end output--
75  
76 This is the basic layout. A stencil ends when a new stencil block is discovered (there is no set limit to the number of stencils in a file). The (optional) hash is for settings. Each stencil has five parts: C<before_input>, C<input>, C<between>, C<output> and C<after_output>. In addition to this
77 there is a header before the first stencil.
78  
79 =head1 ATTRIBUTES
80  
81  
82 =head2 filepath
83  
84 =begin HTML
85  
86 <table cellpadding="0" cellspacing="0">
87 <tr><td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;"><a href="https://metacpan.org/pod/Types::Path::Tiny#File">File</a>
88  
89 </td>
90 <td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;">required</td>
91 <td style="padding-left: 6px; padding-right: 6px; white-space: nowrap;">read-only</td></tr>
92 </table>
93  
94 <p>The textfile to parse.</p>
95  
96 =end HTML
97  
98 =head2 is_utf8
99  
100 =begin HTML
101  
102 <table cellpadding="0" cellspacing="0">
103 <tr><td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;"><a href="https://metacpan.org/pod/Types::Standard#Bool">Bool</a>
104  
105 </td>
106 <td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;">optional, default: <code>1</code>
107  
108 </td>
109 <td style="padding-left: 6px; padding-right: 6px; white-space: nowrap;">read-only</td></tr>
110 </table>
111  
112 <p>Determines how the stencil file is read.</p>
113  
114 =end HTML
115  
116 =head2 skip_if_input_empty
117  
118 =begin HTML
119  
120 <table cellpadding="0" cellspacing="0">
121 <tr><td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;"><a href="https://metacpan.org/pod/Types::Standard#Bool">Bool</a>
122  
123 </td>
124 <td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;">optional, default: <code>1</code>
125  
126 </td>
127 <td style="padding-left: 6px; padding-right: 6px; white-space: nowrap;">read-only</td></tr>
128 </table>
129  
130 <p>If a stencil has no input content, skip entire stencil.</p>
131  
132 =end HTML
133  
134 =head2 skip_if_output_empty
135  
136 =begin HTML
137  
138 <table cellpadding="0" cellspacing="0">
139 <tr><td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;"><a href="https://metacpan.org/pod/Types::Standard#Bool">Bool</a>
140  
141 </td>
142 <td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;">optional, default: <code>1</code>
143  
144 </td>
145 <td style="padding-left: 6px; padding-right: 6px; white-space: nowrap;">read-only</td></tr>
146 </table>
147  
148 <p>If a stencil has no output content, skip entire stencil.</p>
149  
150 =end HTML
151  
152 =head2 header_lines
153  
154 =begin HTML
155  
156 <table cellpadding="0" cellspacing="0">
157 <tr><td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;"><a href="https://metacpan.org/pod/Types::Standard#ArrayRef">ArrayRef</a> [ <a href="https://metacpan.org/pod/Types::Standard#Str">Str</a> ]</td>
158 <td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;">not in constructor</td>
159 <td style="padding-left: 6px; padding-right: 6px; white-space: nowrap;">read-only</td></tr>
160 </table>
161  
162 <p>After parsing, this contains all lines in the header.</p>
163  
164 =end HTML
165  
166 =head2 stencils
167  
168 =begin HTML
169  
170 <table cellpadding="0" cellspacing="0">
171 <tr><td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;"><a href="https://metacpan.org/pod/Types::Standard#ArrayRef">ArrayRef</a> [ <a href="https://metacpan.org/pod/Types::Stenciller#Stencil">Stencil</a> ]</td>
172 <td style="padding-right: 6px; padding-left: 6px; border-right: 1px solid #b8b8b8; white-space: nowrap;">not in constructor</td>
173 <td style="padding-left: 6px; padding-right: 6px; white-space: nowrap;">read-only</td></tr>
174 </table>
175  
176 <p>After parsing, this contains all parsed stencils.</p>
177  
178 =end HTML
179  
180 =head1 METHODS
181  
182  
183 =head2 transform
184  
185 =begin HTML
186  
187 <p></p>
188  
189 <!-- -->
190 <table style="margin-bottom: 10px; margin-left: 10px; border-collapse: bollapse;" cellpadding="0" cellspacing="0">
191  
192 <tr style="vertical-align: top;"><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8eee8;">Named parameters</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8eee8;">&#160;</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8eee8;">&#160;</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8eee8;">&#160;</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8eee8;">&#160;</td></tr>
193 <tr style="vertical-align: top;">
194 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;"><code>plugin_name =&gt; $value</code>
195  
196 </td>
197 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;"><a href="https://metacpan.org/pod/Types::Standard#Str">Str</a>
198  
199 </td>
200 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;">required</td>
201 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; border-bottom: 1px solid #eee;"></td>
202 <td style="padding: 3px 6px; vertical-align: top; border-bottom: 1px solid #eee;">Plugin to read contents with.</td>
203 </tr>
204 <tr style="vertical-align: top;">
205 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;"><code>constructor_args =&gt; $value</code>
206  
207 </td>
208 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;"><a href="https://metacpan.org/pod/Types::Standard#HashRef">HashRef</a>
209  
210 </td>
211 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;">optional, default <code>= { }</code>
212  
213 </td>
214 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; border-bottom: 1px solid #eee;"></td>
215 <td style="padding: 3px 6px; vertical-align: top; border-bottom: 1px solid #eee;">Constructor arguments for the plugin.</td>
216 </tr>
217 <tr style="vertical-align: top;">
218 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;"><code>transform_args =&gt; $value</code>
219  
220 </td>
221 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;"><a href="https://metacpan.org/pod/Types::Standard#HashRef">HashRef</a>
222  
223 </td>
224 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; padding: 3px 6px; border-bottom: 1px solid #eee;">optional, default <code>= { }</code>
225  
226 </td>
227 <td style="vertical-align: top; border-right: 1px solid #eee; white-space: nowrap; border-bottom: 1px solid #eee;"></td>
228 <td style="padding: 3px 6px; vertical-align: top; border-bottom: 1px solid #eee;">Settings for the specific transformation.</td>
229 </tr>
230 <tr style="vertical-align: top;"><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8e8ee;">Returns</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8e8ee;">&#160;</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8e8ee;">&#160;</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8e8ee;">&#160;</td><td style="text-align: left; color: #444; padding-left: 5px; font-weight: bold; background-color: #e8e8ee;">&#160;</td></tr>
231 <tr style="vertical-align: top;">
232 <td style="vertical-align: top; border-right: 1px solid #eee; padding: 3px 6px; border-bottom: 1px solid #eee;"><a href="https://metacpan.org/pod/Types::Standard#Str">Str</a>
233  
234 </td><td style="vertical-align: top; border-right: 1px solid #eee; padding: 3px 6px; border-bottom: 1px solid #eee;">&#160;</td><td style="vertical-align: top; border-right: 1px solid #eee; padding: 3px 6px; border-bottom: 1px solid #eee;">&#160;</td><td style="vertical-align: top; border-right: 1px solid #eee; padding: 3px 6px; border-bottom: 1px solid #eee;">&#160;</td>
235 <td style="padding: 3px 6px; vertical-align: top; border-bottom: 1px solid #eee;">The transformed content.</td>
236 </tr>
237 </table>
238  
239 =end HTML
240  
241 =head1 PLUGINS
242  
243 The actual transforming is done by plugins. There are two plugins bundled in this distribution:
244  
245 =over 4
246  
247 =item *
248  
249 L<Stenciller::Plugin::ToUnparsedText>
250  
251 =item *
252  
253 L<Stenciller::Plugin::ToHtmlPreBlock>
254  
255 =back
256  
257 Custom plugins should be in the L<Stenciller::Plugin> namespace and consume the L<Stenciller::Transformer> role.
258  
259 =head1 SOURCE
260  
261 L<https://github.com/Csson/p5-Stenciller>
262  
263 =head1 HOMEPAGE
264  
265 L<https://metacpan.org/release/Stenciller>
266  
267 =head1 AUTHOR
268  
269 Erik Carlsson <info@code301.com>
270  
271 =head1 COPYRIGHT AND LICENSE
272  
273 This software is copyright (c) 2015 by Erik Carlsson.
274  
275 This is free software; you can redistribute it and/or modify it under
276 the same terms as the Perl 5 programming language system itself.
277  
278 =cut
« Stenciller/Standard.pm ↑ Summary Types/Stenciller.pm »