line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::256locksMaker; |
2
|
1
|
|
|
1
|
|
780
|
use 5.008005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
4
|
1
|
|
|
1
|
|
15
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
7
|
|
|
|
|
|
|
our $ENDPOINT_URL = 'http://maker-256locks.herokuapp.com/name'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
11443
|
use URI; |
|
1
|
|
|
|
|
6141
|
|
|
1
|
|
|
|
|
29
|
|
10
|
1
|
|
|
1
|
|
814
|
use Furl; |
|
1
|
|
|
|
|
29709
|
|
|
1
|
|
|
|
|
31
|
|
11
|
1
|
|
|
1
|
|
1405
|
use Imager; |
|
1
|
|
|
|
|
48004
|
|
|
1
|
|
|
|
|
8
|
|
12
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
13
|
1
|
|
|
|
|
11
|
new => 1, |
14
|
|
|
|
|
|
|
ro => [qw[image_url tweet_link image]], |
15
|
1
|
|
|
1
|
|
66
|
); |
|
1
|
|
|
|
|
2
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $furl = Furl->new(agent => __PACKAGE__.'/'.$VERSION); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub make { |
20
|
0
|
|
|
0
|
0
|
|
my ($class, $str) = @_; |
21
|
0
|
|
|
|
|
|
my $uri = URI->new($ENDPOINT_URL); |
22
|
0
|
|
|
|
|
|
$uri->query_form(name => $str); |
23
|
0
|
|
|
|
|
|
my $res = $furl->get($uri->as_string); |
24
|
0
|
0
|
|
|
|
|
unless ($res->is_success) { |
25
|
0
|
|
|
|
|
|
warn sprintf('remote server(%s) said : %s', $uri->host, $res->status_line); |
26
|
0
|
|
|
|
|
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
0
|
|
|
|
|
|
my $image_url = $class->get_image_url($res->content); |
29
|
0
|
|
|
|
|
|
my $tweet_link = $class->get_tweet_link($res->content); |
30
|
0
|
|
|
|
|
|
my $image = do{ |
31
|
0
|
|
|
|
|
|
my $r = $furl->get($image_url); |
32
|
0
|
0
|
|
|
|
|
$r->is_success ? Imager->new(data => $r->content) : undef; |
33
|
|
|
|
|
|
|
}; |
34
|
0
|
|
|
|
|
|
return $class->new( |
35
|
|
|
|
|
|
|
image_url => $image_url, |
36
|
|
|
|
|
|
|
tweet_link => $tweet_link, |
37
|
|
|
|
|
|
|
image => $image, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_image_url { |
42
|
0
|
|
|
0
|
0
|
|
my ($class, $content) = @_; |
43
|
0
|
|
|
|
|
|
my ($url) = $content =~ /<\/div>/; |
44
|
0
|
|
|
|
|
|
return $url; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_tweet_link { |
48
|
0
|
|
|
0
|
0
|
|
my ($class, $content) = @_; |
49
|
0
|
|
|
|
|
|
my ($url) = $content =~ / |
50
|
0
|
|
|
|
|
|
return $url; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |