line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Jugem::API; |
2
|
2
|
|
|
2
|
|
29973
|
use 5.008005; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
79
|
|
3
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
23
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
55
|
|
5
|
2
|
|
|
2
|
|
890
|
use utf8; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
8
|
|
6
|
2
|
|
|
2
|
|
1756
|
use Mouse; |
|
2
|
|
|
|
|
68063
|
|
|
2
|
|
|
|
|
11
|
|
7
|
2
|
|
|
2
|
|
2658
|
use Furl; |
|
2
|
|
|
|
|
72393
|
|
|
2
|
|
|
|
|
75
|
|
8
|
2
|
|
|
2
|
|
1618
|
use JSON; |
|
2
|
|
|
|
|
14678
|
|
|
2
|
|
|
|
|
17
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
408
|
use constant BASE_URL => 'http://api.jugemkey.jp/api/horoscope/free/'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
554
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'date' => (is => 'rw',isa => 'Str'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has furl => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => 'Furl', |
19
|
|
|
|
|
|
|
lazy_build => 1 |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _build_furl{ |
23
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
24
|
1
|
|
|
|
|
10
|
return Furl->new( |
25
|
|
|
|
|
|
|
agent => 'WWW::Jugem::API(Perl)', |
26
|
|
|
|
|
|
|
timeout => 20, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %star_chart = ( |
31
|
|
|
|
|
|
|
'牡羊座' => 0, |
32
|
|
|
|
|
|
|
'牡牛座' => 1, |
33
|
|
|
|
|
|
|
'双子座' => 2, |
34
|
|
|
|
|
|
|
'蟹座' => 3, |
35
|
|
|
|
|
|
|
'獅子座' => 4, |
36
|
|
|
|
|
|
|
'乙女座' => 5, |
37
|
|
|
|
|
|
|
'天秤座' => 6, |
38
|
|
|
|
|
|
|
'蠍座' => 7, |
39
|
|
|
|
|
|
|
'射手座' => 8, |
40
|
|
|
|
|
|
|
'山羊座' => 9, |
41
|
|
|
|
|
|
|
'水瓶座' => 10, |
42
|
|
|
|
|
|
|
'魚座' => 11 |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub fetch{ |
46
|
1
|
|
|
1
|
0
|
147
|
my ($self,$star) = @_; |
47
|
1
|
|
|
|
|
5
|
my $date = $self->date; |
48
|
1
|
|
|
|
|
4
|
my $url = BASE_URL.$date; |
49
|
1
|
|
|
|
|
10
|
my $response = $self->furl->get($url); |
50
|
1
|
|
|
|
|
818208
|
my $content = JSON::decode_json($response->content); |
51
|
1
|
|
|
|
|
193
|
return $content->{horoscope}->{$date}->[$star_chart{$star}]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |