Wiki/Plugin/Function/GoogleVideo.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 4 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 100% 57 / 57 CC 4 SCAR 5.5
CC
4
Cov
100%
prepare_args
3.0
prepare_value
2.0
BEGIN
1.0
CRAP 1.7
« Wiki/Plugin/Function/Size.pm ↑ Summary Wiki/Plugin/Function/Jimakuin.pm »
1 package Text::Livedoor::Wiki::Plugin::Function::GoogleVideo;
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use base qw/Text::Livedoor::Wiki::Plugin::Function/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Text::Livedoor::Wiki::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 __PACKAGE__->function_name('googlevideo');
7 11 __PACKAGE__->operation_regexp(q{(docid=\d+|^\d+$)});
8  
9 # what's is difference between google video and youtube.
10 21 ▶sub prepare_args {
Subroutine prepare_args: called CC=3 SCAR=11.0
Pod documented
11 21 my $class= shift;
12 21 my $args = shift;
13  
14 # no argument
15 21 ▶ die 'no arg' unless scalar @$args;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$args 2 19 21
16  
17 19 my ( $docid ) = $args->[0] =~ /(docid=-?\d+|^-?\d+$)/;
18 # no doc id
19 19 ▶ die 'no docid' unless $docid;
Branch: 1 branch
BranchTrueFalseTotal
unless $docid 3 16 19
20  
21 # do not need it
22 16 $docid =~ s/docid=//;
23  
24 # ok
25 16 return { docid => $docid } ;
26 }
27 16 ▶sub prepare_value {
Subroutine prepare_value: called CC=2 SCAR=6.9
Pod documented
28 16 my $class = shift;
29 16 my $value = shift;
30 16 my $width = 340;
31 16 my $height = 280;
32  
33 # do not need space
34 16 ▶ $value ||= '';
Condition100%2/2
$value ||= ""
l!l
79
MC/DC100%1/1
$value ||= ""
$value
Truth table100%2/2
A
A= $value
Aresult
11
00
35 16 $value =~ s/\s//g;
36 16 ($width , $height )
37 = Text::Livedoor::Wiki::Utils::get_width_height( $value , { width => $width , height => $height }) ;
38  
39 16 return { width => $width , height => $height };
40 }
41  
42 15 ▶sub process {
Subroutine process: called CC=1 SCAR=0.0
Pod documented
43 15 my ( $class, $inline , $data ) = @_;
44 15 my $docid = $data->{args}{docid};
45 15 my $width = $data->{value}{width};
46 15 my $height= $data->{value}{height};
47  
48 15 my $html = <<"END_GOOGLEVIDEO_TMPL";
49 <div class="link_googlevideo">
50 <object width="$width" height="$height">
51 <param name="movie" value="http://video.google.com/googleplayer.swf?docId=$docid">
52 </param><param name="wmode" value="transparent"></param>
53 <embed src="http://video.google.com/googleplayer.swf?docId=$docid"
54 type="application/x-shockwave-flash"
55 style="width:${width}px; height:${height}dpx;" id="VideoPlayback" flashvars="" wmode="opaque">
56 <param name="wmode" value="opaque" />
57 </embed></object>
58 </div>
59 END_GOOGLEVIDEO_TMPL
60  
61 15 $html =~ s/\n$//;
62 15 return $html;
63 }
64  
65 1 ▶sub process_mobile { '' }
Subroutine process_mobile: called CC=1 SCAR=0.0
Pod documented
66  
67 11 1;
68  
69 =head1 NAME
70  
71 Text::Livedoor::Wiki::Plugin::Function::GoogleVideo - Google Video Function Plugin
72  
73 =head1 DESCRIPTION
74  
75 let's watch google video.
76  
77 =head1 SYNOPSIS
78  
79 &googlevideo(http://video.google.co.jp/videoplay?docid=-694264032177935779&ei=sh8VSsrpFpTewgP-sb1x&q=livedoor+viedo.google)
80 &googlevideo(-694264032177935779)
81 &googlevideo(-694264032177935779){99,88}
82 &googlevideo(-694264032177935779){,99}
83 &googlevideo(-694264032177935779){99}
84 &googlevideo(-694264032177935779){99,}
85  
86 =head1 FUNCTION
87  
88 =head2 prepare_args
89  
90 =head2 prepare_value
91  
92 =head2 process
93  
94 =head2 process_mobile
95  
96 =head1 AUTHOR
97  
98 polocky
99  
100 =cut
« Wiki/Plugin/Function/Size.pm ↑ Summary Wiki/Plugin/Function/Jimakuin.pm »