| 1 | package Pod::POM::View::Trac; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||
| 4 | 1 | our $INDENT = 4; | |||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | ▶ | use Text::Wrap; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | ▶ | use base 'Pod::POM::View::Text'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | #--------------------------------------------------------------------------- | ||||||||||||||||||||
| 13 | # Public Methods | ||||||||||||||||||||
| 14 | #--------------------------------------------------------------------------- | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | ▶ | sub view_head1 { | ||||||||||||||||||
|
Subroutine
view_head1: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 17 | 0 | my ($self, $head1) = @_; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | my $title = $head1->title->present($self); | |||||||||||||||||||
| 20 | 0 | my $output = "= $title =\n\n" . $head1->content->present($self); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | return $output; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub view_head2 { | ||||||||||||||||||
|
Subroutine
view_head2: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 27 | 0 | my ($self, $head2) = @_; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | my $title = $head2->title->present($self); | |||||||||||||||||||
| 30 | 0 | my $output = "== $title ==\n\n" . $head2->content->present($self); | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | return $output; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub view_head3 { | ||||||||||||||||||
|
Subroutine
view_head3: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 37 | 0 | my ($self, $head3) = @_; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | my $title = $head3->title->present($self); | |||||||||||||||||||
| 40 | 0 | my $output = "=== $title ===\n\n" . $head3->content->present($self); | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | return $output; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | sub view_head4 { | ||||||||||||||||||
|
Subroutine
view_head4: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 47 | 0 | my ($self, $head4) = @_; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 0 | my $title = $head4->title->present($self); | |||||||||||||||||||
| 50 | 0 | my $output = "==== $title ====\n\n" . $head4->content->present($self); | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | return $output; | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | #------------------------------------------------------------------------ | ||||||||||||||||||||
| 57 | # view_over($self, $over) | ||||||||||||||||||||
| 58 | # | ||||||||||||||||||||
| 59 | # Present an =over block - this is a blockquote if there are no =items | ||||||||||||||||||||
| 60 | # within the block. | ||||||||||||||||||||
| 61 | #------------------------------------------------------------------------ | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 0 | ▶ | sub view_over { | ||||||||||||||||||
|
Subroutine
view_over: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 64 | 0 | my ($self, $over) = @_; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | ▶ | if (@{$over->item}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | return $over->content->present($self); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | my $indent = ref $self ? \$self->{INDENT} : \$INDENT; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | 0 | my $pad = ' ' x $$indent; | |||||||||||||||||||
| 74 | 0 | my $text = $over->content->present($self); | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | local $Text::Wrap::unexpand = 0; | |||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 0 | my $content = wrap($pad, $pad, $text) . "\n\n"; | |||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 0 | return $content; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | ▶ | sub view_item { | ||||||||||||||||||
|
Subroutine
view_item: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 87 | 0 | my ($self, $item) = @_; | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | my $title = $item->title->present($self); | |||||||||||||||||||
| 90 | 0 | my $text = $item->content->present($self); | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 0 | ▶ | my $indent = ref $self ? \$self->{INDENT} : \$INDENT; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 93 | 0 | my $pad = ' ' x $$indent; | |||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 0 | local $Text::Wrap::unexpand = 0; | |||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 0 | my $content = wrap($pad, $pad, $text) . "\n"; | |||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | return "$title\n\n$content"; | |||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | 0 | ▶ | sub view_for { | ||||||||||||||||||
|
Subroutine
view_for: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 104 | 0 | my ($self, $for) = @_; | |||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | ▶ | return '' unless $for->format() =~ /\btrac\b/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 107 | 0 | return $for->text() . "\n\n"; | |||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | } | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | 0 | ▶ | sub view_begin { | ||||||||||||||||||
|
Subroutine
view_begin: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 112 | 0 | my ($self, $begin) = @_; | |||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 0 | ▶ | return '' unless $begin->format() =~ /\btrac\b/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 115 | 0 | return $begin->content->present($self); | |||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 0 | ▶ | sub view_textblock { | ||||||||||||||||||
|
Subroutine
view_textblock: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 120 | 0 | my ($self, $text) = @_; | |||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 0 | $text =~ s/\s+/ /mg; | |||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 0 | my $pad = ''; | |||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | local $Text::Wrap::unexpand = 0; | |||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 0 | return wrap($pad, $pad, $text) . "\n\n"; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | } | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 0 | ▶ | sub view_verbatim { | ||||||||||||||||||
|
Subroutine
view_verbatim: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 133 | 0 | my ($self, $text) = @_; | |||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | 0 | return "{{{\n$text\n}}}\n"; | |||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | } | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | 0 | ▶ | sub view_seq_bold { | ||||||||||||||||||
|
Subroutine
view_seq_bold: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 140 | 0 | my ($self, $text) = @_; | |||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | 0 | return "'''$text'''"; | |||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | } | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | 0 | ▶ | sub view_seq_italic { | ||||||||||||||||||
|
Subroutine
view_seq_italic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 147 | 0 | my ($self, $text) = @_; | |||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | 0 | return "''$text''"; | |||||||||||||||||||
| 150 | |||||||||||||||||||||
| 151 | } | ||||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | 0 | ▶ | sub view_seq_code { | ||||||||||||||||||
|
Subroutine
view_seq_code: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 154 | 0 | my ($self, $text) = @_; | |||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | 0 | my $output = "`$text`"; | |||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | 0 | return $output; | |||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | } | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | 0 | ▶ | sub view_seq_file { | ||||||||||||||||||
|
Subroutine
view_seq_file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 163 | 0 | my ($self, $text) = @_; | |||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | 0 | return "source:$text"; | |||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | } | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | 1 | my $entities = { | |||||||||||||||||||
| 170 | gt => '>', | ||||||||||||||||||||
| 171 | lt => '<', | ||||||||||||||||||||
| 172 | amp => '&', | ||||||||||||||||||||
| 173 | quot => '"', | ||||||||||||||||||||
| 174 | }; | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | 0 | ▶ | sub view_seq_entity { | ||||||||||||||||||
|
Subroutine
view_seq_entity: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 177 | 0 | my ($self, $entity) = @_; | |||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | 0 | ▶ | return $entities->{ $entity } || $entity; | ||||||||||||||||||
|
Condition0%0/3
$entities->{$entity} || $entity
MC/DC0%0/2
$entities->{$entity} || $entity
$entities->{$entity}
$entity
Truth table0%0/3
A || B
A= $entities->{$entity}B= $entity
| |||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | } | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | 0 | ▶ | sub view_seq_index { | ||||||||||||||||||
|
Subroutine
view_seq_index: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | 0 | return ''; | |||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | } | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | 0 | ▶ | sub view_seq_link { | ||||||||||||||||||
|
Subroutine
view_seq_link: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 190 | 0 | my ($self, $link) = @_; | |||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | # full-blown URL's are emitted as-is | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | 0 | ▶ | if ($link =~ /^\w+:\/\// ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | # check to see if there is title | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | 0 | ▶ | if (my ($text, $name) = $link =~ m/^(.*)\|(.*)/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | 0 | return "[$name $text]"; | |||||||||||||||||||
| 201 | |||||||||||||||||||||
| 202 | } | ||||||||||||||||||||
| 203 | |||||||||||||||||||||
| 204 | 0 | return $link; | |||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | } | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | # links to other modules are parsed out | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | 0 | ▶ | if (my ($text, $name) = $link =~ m/^(.*)\|(.*)/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | 0 | ▶ | if ($name =~ /::/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | # make it wiki CamelCase link | ||||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | 0 | my @parts = split('::', $name); | |||||||||||||||||||
| 217 | 0 | @parts = map {lc $_ } @parts; | |||||||||||||||||||
| 218 | 0 | @parts = map {ucfirst $_} @parts; | |||||||||||||||||||
| 219 | |||||||||||||||||||||
| 220 | 0 | $name = join('', @parts); | |||||||||||||||||||
| 221 | |||||||||||||||||||||
| 222 | } | ||||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | 0 | return "[wiki:$name $text]"; | |||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | } | ||||||||||||||||||||
| 227 | |||||||||||||||||||||
| 228 | # otherwise return it verbatim | ||||||||||||||||||||
| 229 | |||||||||||||||||||||
| 230 | 0 | return "[wiki:$link]"; | |||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | } | ||||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | 1 | 1; | |||||||||||||||||||
| 235 | |||||||||||||||||||||
| 236 | __END__ | ||||||||||||||||||||