lib/MojoMojo/Formatter/GoogleCalendar.pm

filter: Statementstmt 82.6% 19 / 23 Branchbran 12.5% 1 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 2 / 2 totaltotal 69.4% 25 / 36 CC 6 SCAR 19.5
CC
6
Cov
65%
format_content
9.1
BEGIN
1.0
format_content_order
1.0
CRAP 7.0
« lib/MojoMojo/Controller/Comment.pm ↑ Summary lib/MojoMojo/Formatter/DocBook.pm »
1 package MojoMojo::Formatter::GoogleCalendar;
2  
3 #use strict;
4 26 ▶use parent 'MojoMojo::Formatter';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 #my $dependencies_installed = !$@;
7 #sub module_loaded { $dependencies_installed }
8  
9 26 our $VERSION = '0.1';
10  
11 =head1 NAME
12  
13 MojoMojo::Formatter::GoogleCalendar - Embed Google Calendar
14  
15 =head1 DESCRIPTION
16  
17 Embed Goodle Calendar in wiki page {{gcal <url> <width>,<height> <alignment>}}.
18  
19 =head1 METHODS
20  
21 =head2 format_content_order
22  
23 Format order can be 1-99. The Google Calendar formatter runs on 20.
24  
25 =cut
26  
27 620 ▶sub format_content_order { 20 }
Subroutine format_content_order: called CC=1 SCAR=0.0
Pod documented
28  
29 =head2 format_content
30  
31 Calls the formatter. Takes a ref to the content as well as the
32 context object.
33  
34 =cut
35  
36 124 ▶sub format_content {
Subroutine format_content: called CC=6 SCAR=22.0
Pod documented
37 124 my ( $class, $content, $c ) = @_;
38 124 my ( $width, $height, $align );
39 124 my $default_width = 600;
40 124 my $default_height = 400;
41 124 my $default_alignment = 'center';
42 124 my %alignment_style = (
43 'center' => 'margin:auto;width:70%',
44 'right' => 'float:right;width:70%',
45 'left' => 'float:left;width:70%'
46 );
47 124 my @lines = split /\n/, $$content;
48 124 my $re = $class->gen_re(qr/gcal\s+(.*?)\s+(\d+),(\d+)\s+(\w+)/);
49 124 $$content = "";
50  
51 124 foreach my $line (@lines) {
52 730 ▶ if ( $line =~ m/$re/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /$re/) 0 730 730
53 0 ▶ !defined($2) ? $height = $default_height : $height = $2;
Branch: 1 branch
BranchTrueFalseTotal
!defined($2) ? : 0 0 0
54 0 ▶ !defined($3) ? $width = $default_width : $width = $3;
Branch: 1 branch
BranchTrueFalseTotal
!defined($3) ? : 0 0 0
55 !defined($4)
56 ? $align = $alignment_style{$default_alignment}
57 0 ▶ : $align = $alignment_style{$4};
Branch: 1 branch
BranchTrueFalseTotal
!defined($4) ? : 0 0 0
58 0 $line =
59 "<div style='$align;border:1'><iframe src='$1' height='$height' width='$width' style='border-width:0; margin-left:auto; margin-right:auto' frameborder='0' scrolling='no'></iframe></div>";
60 }
61 730 $$content .= $line . "\n";
62 }
63 124 return $content;
64  
65 }
66  
67 =head1 SEE ALSO
68  
69 L<MojoMojo>, L<Module::Pluggable::Ordered>, L<URI::Fetch>
70  
71 =head1 AUTHORS
72  
73 Jurnell Cockhren <jurnell.cockhren@vanderbilt.edu>
74  
75 =head1 LICENSE
76  
77 This library is free software. You can redistribute it and/or modify
78 it under the same terms as Perl itself.
79  
80 =cut
81  
82 26 1;
« lib/MojoMojo/Controller/Comment.pm ↑ Summary lib/MojoMojo/Formatter/DocBook.pm »