line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zeal::Feed; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
15512
|
use 5.014000; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
4
|
use re '/s'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.000_003'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
427
|
use parent qw/Class::Accessor::Fast/; |
|
1
|
|
|
|
|
250
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw/version/); |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
2723
|
use Cwd qw/getcwd/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
69
|
|
14
|
1
|
|
|
1
|
|
556
|
use File::Spec::Functions qw/catfile rel2abs/; |
|
1
|
|
|
|
|
626
|
|
|
1
|
|
|
|
|
58
|
|
15
|
1
|
|
|
1
|
|
644
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
53953
|
|
|
1
|
|
|
|
|
55
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
945
|
use Archive::Tar; |
|
1
|
|
|
|
|
123108
|
|
|
1
|
|
|
|
|
91
|
|
18
|
1
|
|
|
1
|
|
772
|
use File::Slurp qw/read_file/; |
|
1
|
|
|
|
|
3904
|
|
|
1
|
|
|
|
|
89
|
|
19
|
1
|
|
|
1
|
|
595
|
use File::Which; |
|
1
|
|
|
|
|
899
|
|
|
1
|
|
|
|
|
54
|
|
20
|
1
|
|
|
1
|
|
227
|
use XML::Rules; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
|
|
|
|
|
|
my ($class, $url) = @_; |
24
|
|
|
|
|
|
|
$class->new_from_content(HTTP::Tiny->new->get($url)->{content}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new_from_file { |
28
|
|
|
|
|
|
|
my ($class, $file) = @_; |
29
|
|
|
|
|
|
|
$class->new_from_content(scalar read_file $file); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new_from_content { |
33
|
|
|
|
|
|
|
my ($class, $xml) = @_; |
34
|
|
|
|
|
|
|
my ($version, @urls) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $self = XML::Rules->parse( |
37
|
|
|
|
|
|
|
rules => { |
38
|
|
|
|
|
|
|
_default => 'content', |
39
|
|
|
|
|
|
|
entry => 'pass', |
40
|
|
|
|
|
|
|
url => 'content array', |
41
|
|
|
|
|
|
|
'other-versions' => undef, |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
stripspaces => 3|4, |
44
|
|
|
|
|
|
|
)->($xml); |
45
|
|
|
|
|
|
|
bless $self, $class |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub urls { |
49
|
|
|
|
|
|
|
my ($self) = @_; |
50
|
|
|
|
|
|
|
@{$self->{url}} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub url { |
54
|
|
|
|
|
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
my @urls = $self->urls; |
56
|
|
|
|
|
|
|
$urls[int rand @urls] |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _unpack_tar_to_dir { |
60
|
|
|
|
|
|
|
my ($file, $dir) = @_; |
61
|
|
|
|
|
|
|
my $tar = which 'tar' or which 'gtar'; |
62
|
|
|
|
|
|
|
if ($tar && !$ENV{ZEAL_USE_INTERNAL_TAR}) { |
63
|
|
|
|
|
|
|
my $arg = '-xf'; |
64
|
|
|
|
|
|
|
$arg = '-xzf' if $file =~ /[.]t?gz$/; |
65
|
|
|
|
|
|
|
$arg = '-xjf' if $file =~ /[.]bz2$/; |
66
|
|
|
|
|
|
|
system $tar, -C => $dir, $arg => $file |
67
|
|
|
|
|
|
|
} else { |
68
|
|
|
|
|
|
|
$file = rel2abs $file; |
69
|
|
|
|
|
|
|
my $oldwd = getcwd; |
70
|
|
|
|
|
|
|
chdir $dir; |
71
|
|
|
|
|
|
|
Archive::Tar->extract_archive($file); |
72
|
|
|
|
|
|
|
chdir $oldwd; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub download { |
77
|
|
|
|
|
|
|
my ($self, $path) = @_; |
78
|
|
|
|
|
|
|
my ($name) = $self->url =~ /([^\/])+$/; |
79
|
|
|
|
|
|
|
my $file = catfile $path, $name; |
80
|
|
|
|
|
|
|
HTTP::Tiny->new->mirror($self->url, $file); |
81
|
|
|
|
|
|
|
_unpack_tar_to_dir $file, $path; |
82
|
|
|
|
|
|
|
unlink $file; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__END__ |