File Coverage

blib/lib/Acme/Oppai.pm
Criterion Covered Total %
statement 21 75 28.0
branch 0 26 0.0
condition n/a
subroutine 7 16 43.7
pod 3 8 37.5
total 31 125 24.8


line stmt bran cond sub pod time code
1             package Acme::Oppai;
2              
3 1     1   23420 use strict;
  1         2  
  1         36  
4 1     1   5 use warnings;
  1         2  
  1         28  
5 1     1   1019 use utf8;
  1         15  
  1         5  
6              
7 1     1   2645 use Encode;
  1         13826  
  1         133  
8 1     1   968 use Encode::Guess;
  1         7552  
  1         8  
9 1     1   297 use Scalar::Util qw(blessed);
  1         3  
  1         547  
10              
11             our $VERSION = '0.03';
12              
13             our %BASIC_AA = (
14             oppai => sub {
15             my $word = shift;
16             return <
17               _  ∩
18             ( ゜∀゜)彡 $word
19              ⊂彡
20             OPPAI
21             },
22             oppai_up => sub {
23             my $word = shift;
24             return <
25               _  ∩
26             ( ゜∀゜)彡 $word
27              
28             OPPAI
29             },
30             oppai_down => sub {
31             my $word = shift;
32             return <
33              
34             ( ゜∀゜)彡 $word
35              ⊂彡
36             OPPAI
37             },
38              
39             Oppai => sub {
40             my $word = shift;
41             return <
42                 _  ∩
43               ( ゜∀゜)彡 $word
44               (  ⊂彡
45                |   | 
46                し ⌒J
47             OPPAI
48             },
49             Oppai_up => sub {
50             my $word = shift;
51             return <
52                 _  ∩
53               ( ゜∀゜)彡 $word
54               (    | 
55                |   | 
56                し ⌒J
57             OPPAI
58             },
59             Oppai_down => sub {
60             my $word = shift;
61             return <
62                 _  
63               ( ゜∀゜)  $word
64               (  ⊂彡
65                |   | 
66                し ⌒J
67             OPPAI
68             },
69             );
70              
71             our %BASIC_WORD = (
72             oppai => 'おっぱい!おっぱい!',
73             oppai_up => 'おっぱい!',
74             oppai_down => 'おっぱい!',
75              
76             Oppai => 'おっぱい!おっぱい!',
77             Oppai_up => 'おっぱい!',
78             Oppai_down => 'おっぱい!',
79             );
80              
81             use overload q("") => sub {
82 0     0     my $self = shift;
83 0           my $oppai = ${ $self->[0] };
  0            
84              
85 0 0         if ($self->[1]->{use_utf8}) {
86 0 0         utf8::decode($oppai) unless utf8::is_utf8($oppai);
87             } else {
88 0 0         utf8::encode($oppai) if utf8::is_utf8($oppai);
89             }
90 0           $self->clear;
91 0           $oppai;
92 1     1   2769 };
  1         1415  
  1         12  
93              
94             sub new {
95 0     0 0   my $class = shift;
96 0           my %opt = @_;
97              
98 0           my $str = '';
99 0           my $self = [
100             \$str,
101             \%opt,
102             ];
103 0           $self = bless $self, $class;
104              
105 0           $self->clear;
106 0           $self;
107             }
108              
109             sub clear {
110 0     0 0   my $self = shift;
111 0           my $str = '';
112 0           $self->[0] = \$str;
113 0           $self->[2] = 0;
114 0           $self->[3] = [];
115             }
116              
117             sub gen_word {
118 0     0 0   my ($self, $type, $word) = @_;
119              
120 0 0         return $BASIC_WORD{$type} unless $word;
121 0 0         return $word if utf8::is_utf8($word);
122 0           my $enc = guess_encoding($word, qw(euc-jp shiftjis 7bit-jis utf8));
123 0 0         return $word unless ref($enc);
124 0           $enc->decode($word);
125             }
126              
127             sub gen {
128 0     0 0   my ($self, $type, $word) = @_;
129 0           $BASIC_AA{$type}($word);
130             }
131              
132             sub base {
133 0     0 0   my $proto = shift;
134 0 0         my $self = blessed($proto) ? $proto : $proto->new;
135 0           my $type = shift;
136              
137 0 0         if ($self->[1]->{default}) {
138 0 0         $type .= "_$1" if $self->[1]->{default} =~ /^(up|down)$/;
139             } else {
140 0 0         if ($self->[2] eq 1) {
141 0           ${ $self->[0] } = $self->gen($self->[3]->[0]->{type} . '_up', $self->[3]->[0]->{word});
  0            
142             }
143 0           $self->[2]++;
144 0 0         if ($self->[2] ne 1) {
145 0 0         if ($self->[2] % 2) {
146 0           $type .= "_up";
147             } else {
148 0           $type .= "_down";
149             }
150             }
151             }
152              
153 0           my $word = $self->gen_word($type, @_);
154 0 0         utf8::decode($word) unless utf8::is_utf8($word);
155 0           push @{ $self->[3] }, {type => $type, word => $word};
  0            
156 0           ${ $self->[0] } .= $self->gen($type, $word);
  0            
157 0           $self;
158             }
159              
160 0     0 1   sub oppai { shift->base('oppai', @_) }
161 0     0 1   sub Oppai { shift->base('Oppai', @_) }
162              
163             sub massage {
164 0     0 1   my $self = shift;
165 0           ${ $self->[0] } .=<
  0            
166                 _  ∩
167               ( ゜∀゜)彡 おっぱい!おっぱい!
168               (  ⊂彡
169                |   | 
170                し ⌒J
171             OPPAI
172 0           $self;
173             }
174              
175             1;
176             __END__