Wiki/Plugin/Function/Fukidashi.pm

filter: Statementstmt 100% 50 / 50 Branchbran 100% 14 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 100% 76 / 76 CC 8 SCAR 11.8
CC
8
Cov
100%
prepare_args
6.0
process
2.0
process_mobile
2.0
CRAP 3.3
« Wiki/Inline.pm ↑ Summary Wiki/Plugin/Inline/Function.pm »
1 package Text::Livedoor::Wiki::Plugin::Function::Fukidashi;
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  
7 11 __PACKAGE__->function_name('fukidashi');
8  
9 16 ▶sub prepare_args {
Subroutine prepare_args: called CC=6 SCAR=17.9
Pod documented
10 16 my $class= shift;
11 16 my $args = shift;
12 16 my $image_url = '';
13 16 my $location = 'left';
14  
15 16 ▶ my $icon = scalar @$args ? $args->[0] : '' ;
Branch: 1 branch
BranchTrueFalseTotal
scalar @$args ? : 12 4 16
16 16 my $type = '';
17 # livedoor icon
18 16 ▶ if( $icon =~ /^[a-zA-Z0-9_]+$/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($icon =~ /^[a-zA-Z0-9_]+$/) { } 8 8 16
elsif (Text::Livedoor::Wiki::Utils::is_image_url($icon)) { } 3 5 8
19 8 $type = 'livedoor_id';
20 # image
21 }elsif( Text::Livedoor::Wiki::Utils::is_image_url( $icon ) ){
22 3 $type = 'image';
23 # default
24 }else {
25 5 $type = 'image';
26 5 $icon = $class->default_icon;
27 }
28  
29 # potision
30 16 ▶ if( scalar @$args == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$args == 2) 5 11 16
31 5 my $loc = $args->[1] ;
32 5 ▶ $location = $loc if $loc eq 'right';
Branch: 1 branch
BranchTrueFalseTotal
if $loc eq "right" 3 2 5
33 }
34  
35 # return result
36 16 return { type => $type, icon => $icon , location => $location }
37  
38 }
39  
40 13 ▶sub process {
Subroutine process: called CC=2 SCAR=6.9
Pod documented
41 13 my ( $class, $inline , $data ) = @_;
42 13 my $value = $inline->parse($data->{value} );
43 13 my $icon = $data->{args}{icon};
44 13 my $location = $data->{args}{location};
45 13 my $type = $data->{args}{type};
46  
47 13 ▶ if( $type eq 'livedoor_id' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'livedoor_id') { } 7 6 13
48 7 $icon = qq|<a target="_blank" title="$icon" href="http://profile.livedoor.com/$icon/"><img src="http://image.profile.livedoor.jp/icon/${icon}_60.gif" /></a>|;
49 }else {
50 6 $icon = qq|<img src="$icon" />|;
51 }
52  
53 13 return qq|<div class="BOX-balloon BOX-balloon-$location">\n<div class="BOX-balloon-image">$icon</div><div class="BOX-balloon-text"><div class="balloon-top"><div class="balloon-top-inner"></div></div><div class="balloon-body"><div class="balloon-body-inner"><div class="balloon-body-inner2">$value</div></div></div>\n<div class="balloon-bottom"><div class="balloon-bottom-inner"></div></div>\n</div><!-- /BOX-balloon-text -->\n</div><!-- /BOX-balloon -->\n|;
54 }
55  
56 5 ▶sub default_icon {
Subroutine default_icon: called CC=1 SCAR=0.0
Pod documented
57 5 my $class = shift;
58 5 my $default_icon_url = $class->opts->{storage} . '/images/function/fukidashi/icon_guest.gif';
59 5 return $default_icon_url;
60 }
61  
62 3 ▶sub process_mobile {
Subroutine process_mobile: called CC=2 SCAR=6.9
Pod documented
63 3 my ( $class, $inline , $data ) = @_;
64 3 my $value = $inline->parse($data->{value} );
65 3 my $icon = $data->{args}{icon};
66 3 my $location = $data->{args}{location};
67 3 my $type = $data->{args}{type};
68  
69 3 ▶ if( $type eq 'livedoor_id' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'livedoor_id') { } 1 2 3
70 1 $icon = qq|<a target="_blank" title="$icon" href="http://profile.livedoor.com/$icon/"><img src="http://image.profile.livedoor.jp/icon/${icon}_16.gif" /></a>|;
71 }
72 else {
73 2 $icon = qq|<img width="16" height="16"src="$icon">|;
74 }
75  
76 3 return $icon . $value ;
77 }
78  
79 11 1;
80  
81 =head1 NAME
82  
83 Text::Livedoor::Wiki::Plugin::Function::Fukidashi - Fukidashi Function Plugin
84  
85 =head1 DESCRIPTION
86  
87 Everybody likes a good looking Fukidashi.
88  
89 =head1 SYNOPSIS
90  
91 &fukidashi(polocky){i am polocky}
92 &fukidashi(polocky,right){i am polocky}
93 &fukidashi(polocky,left){i am polocky}
94 &fukidashi(,right){i am polocky}
95 &fukidashi(){i am polocky}
96 &fukidashi(http://image.livedoor.com/img/top/10/logo.gif){i am polocky}
97  
98 =head1 CSS
99  
100 DOCUMENT ME
101  
102 =head1 FUNCTION
103  
104 =head2 prepare_args
105  
106 =head2 process
107  
108 =head2 default_icon
109  
110 =head2 process_mobile
111  
112 =head1 AUTHOR
113  
114 polocky
115  
116 =cut
« Wiki/Inline.pm ↑ Summary Wiki/Plugin/Inline/Function.pm »