The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
This file was generated by Devel::Cover Version 1.26
Devel::Cover is copyright 2001-2012, Paul Johnson (paul@pjcj.net)
Devel::Cover is free. It is licensed under the same terms as Perl itself.
The latest version of Devel::Cover should be available from my homepage:
http://www.pjcj.net
-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <meta http-equiv="Content-Language" content="en-us"></meta>
    <link rel="stylesheet" type="text/css" href="cover.css"></link>
    <link rel="stylesheet" type="text/css" href="cover.css"></link>
    <title>File Coverage: lib/Yukki/Web/Plugin/Role/Formatter.pm</title>
</head>
<body>
<h1>File Coverage</h1>
<table>
<tr><td class="h" align="right">File:</td><td align="left">lib/Yukki/Web/Plugin/Role/Formatter.pm</td></tr>
<tr><td class="h" align="right">Coverage:</td><td align="left" class="c2">92.6%</td></tr>
</table>
<div><br/></div>
<table>
<tr><th>line</th><th>stmt</th><th>bran</th><th>cond</th><th>sub</th><th>pod</th><th>time</th><th>code</th></tr>
<tr><td class="h">1</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">package Yukki::Web::Plugin::Role::Formatter;</td></tr>
<tr><td class="h">2</td><td colspan="7"></td></tr><tr><td class="h">3</td><td><div class="c3">1</div><div class="c3">1</div></td><td></td><td></td><td><div class="c3"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--subroutine.html#L3">1</a></div></td><td></td><td><div>446</div><div>2</div></td><td class="s">use v5.24;</td></tr>
<tr><td class="h">4</td><td><div class="c3">1</div><div class="c3">1</div><div class="c3">1</div></td><td></td><td></td><td><div class="c3"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--subroutine.html#L4">1</a></div></td><td></td><td><div>3</div><div>2</div><div>7</div></td><td class="s">use utf8;</td></tr>
<tr><td class="h">5</td><td><div class="c3">1</div><div class="c3">1</div><div class="c3">1</div></td><td></td><td></td><td><div class="c3"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--subroutine.html#L5">1</a></div></td><td></td><td><div>14</div><div>1</div><div>6</div></td><td class="s">use Moo::Role;</td></tr>
<tr><td class="h">6</td><td colspan="7"></td></tr><tr><td class="h">7</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s"># ABSTRACT: interface for HTML formatters</td></tr>
<tr><td class="h">8</td><td colspan="7"></td></tr><tr><td class="h">9 - 76</td><td colspan="6"></td><td class="s"><pre>=head1 SYNOPSIS

&nbsp;&nbsp;package MyPlugins::SimpleText;
&nbsp;&nbsp;use 5.12.1;
&nbsp;&nbsp;use Moo;

&nbsp;&nbsp;use Types::Standard qw( HashRef Str );

&nbsp;&nbsp;extends &#39;Yukki::Web::Plugin&#39;;

&nbsp;&nbsp;has html_formatters =&gt; (
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; &#39;ro&#39;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; HashRef[Str],
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; sub { +{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#39;text/simple&#39; =&gt; &#39;format_simple&#39;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} },
&nbsp;&nbsp;);

&nbsp;&nbsp;with &#39;Yukki::Web::Plugin::Role::Formatter;

&nbsp;&nbsp;sub format_simple {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my ($self, $file) = @_;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $html = $file-&gt;fetch;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$html =~ s/$/&lt;br&gt;/g;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return [ { title =&gt; &#39;Simple&#39; }, $html ];
&nbsp;&nbsp;}

=head1 DESCRIPTION

This role defines the interface for file formatters. The first formatter matching the MIME type for a file will be used to format a page&#39;s contents as HTML.

=head1 REQUIRED METHODS

=head2 html_formatters

This must return a reference to a hash mapping MIME-types to method names.

The methods will be called with a hashref parameter containing the following:

=over

=item context

The current L&lt;Yukki::Web::Context&gt; object.

=item repository

The name of the repository this file is in.

=item page

The full path to the name of the file being formatted.

=item media_type

This is the media type that Yukki has detected for the file.

=item content

The body of the page as a string.

=back

The method should return an HTML document.

=cut</pre></td></tr>
<tr><td class="h">77</td><td colspan="7"></td></tr><tr><td class="h">78</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">requires qw( html_formatters );</td></tr>
<tr><td class="h">79</td><td colspan="7"></td></tr><tr><td class="h">80 - 88</td><td colspan="6"></td><td class="s"><pre>=head1 METHOD

=head2 has_format

&nbsp;&nbsp;my $yes_or_no = $formatter-&gt;has_format($media_type);

Returns true if this formatter plugin has a formatter for the named media type.

=cut</pre></td></tr>
<tr><td class="h">89</td><td colspan="7"></td></tr><tr><td class="h">90</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">sub has_format {</td></tr>
<tr><td class="h">91</td><td><div class="c3">2</div></td><td></td><td></td><td><div class="c3"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--subroutine.html#L91">2</a></div></td><td><div class="c3">1</div></td><td><div>3</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;my ($self, $media_type) = @_;</td></tr>
<tr><td class="h">92</td><td><div class="c3">2</div></td><td><div class="c0" title="-/F"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--branch.html#L92">50</a></div></td><td></td><td></td><td></td><td><div>15</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;return unless defined $media_type;</td></tr>
<tr><td class="h">93</td><td><div class="c3">2</div></td><td></td><td></td><td></td><td></td><td><div>12</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;return defined $self-&gt;html_formatters-&gt;{$media_type};</td></tr>
<tr><td class="h">94</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">}</td></tr>
<tr><td class="h">95</td><td colspan="7"></td></tr><tr><td class="h">96 - 109</td><td colspan="6"></td><td class="s"><pre>=head2 format

&nbsp;&nbsp;my $html = $self-&gt;format({
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;context&nbsp;&nbsp;&nbsp;&nbsp;=&gt; $ctx,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repository =&gt; $repository,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&gt; $full_path,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;media_type =&gt; $media_type,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content&nbsp;&nbsp;&nbsp;&nbsp;=&gt; $content,
&nbsp;&nbsp;});

Renders the text as HTML. If this plugin cannot format this media type, it
returns C&lt;undef&gt;.

=cut</pre></td></tr>
<tr><td class="h">110</td><td colspan="7"></td></tr><tr><td class="h">111</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">sub format {</td></tr>
<tr><td class="h">112</td><td><div class="c3">1</div></td><td></td><td></td><td><div class="c3"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--subroutine.html#L112">1</a></div></td><td><div class="c3">1</div></td><td><div>2</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;my ($self, $params) = @_;</td></tr>
<tr><td class="h">113</td><td colspan="7"></td></tr><tr><td class="h">114</td><td><div class="c3">1</div></td><td></td><td></td><td></td><td></td><td><div>4</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;my $media_type = $params-&gt;{file}-&gt;media_type;</td></tr>
<tr><td class="h">115</td><td><div class="c3">1</div></td><td><div class="c0" title="-/F"><a href="lib-Yukki-Web-Plugin-Role-Formatter-pm--branch.html#L115">50</a></div></td><td></td><td></td><td></td><td><div>97</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;return unless $self-&gt;has_format($media_type);</td></tr>
<tr><td class="h">116</td><td colspan="7"></td></tr><tr><td class="h">117</td><td><div class="c3">1</div></td><td></td><td></td><td></td><td></td><td><div>2</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;my $format = $self-&gt;html_formatters-&gt;{$media_type};</td></tr>
<tr><td class="h">118</td><td><div class="c3">1</div></td><td></td><td></td><td></td><td></td><td><div>3</div></td><td class="s">&nbsp;&nbsp;&nbsp;&nbsp;return $self-&gt;$format($params);</td></tr>
<tr><td class="h">119</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">}</td></tr>
<tr><td class="h">120</td><td colspan="7"></td></tr><tr><td class="h">121</td><td></td><td></td><td></td><td></td><td></td><td></td><td class="s">1;</td></tr>
</table>
</body>
</html>