line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PAUSE::TimeMachine; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18909
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
30
|
use 5.008_005; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
624
|
use Pod::Usage (); |
|
1
|
|
|
|
|
53870
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
1094
|
use IPC::Run; |
|
1
|
|
|
|
|
38081
|
|
|
1
|
|
|
|
|
37
|
|
9
|
1
|
|
|
1
|
|
384
|
use Plack::Runner; |
|
1
|
|
|
|
|
5137
|
|
|
1
|
|
|
|
|
9
|
|
10
|
1
|
|
|
1
|
|
1608
|
use IO::Compress::Gzip (); |
|
1
|
|
|
|
|
26553
|
|
|
1
|
|
|
|
|
21
|
|
11
|
1
|
|
|
1
|
|
405
|
use File::pushd; |
|
1
|
|
|
|
|
8161
|
|
|
1
|
|
|
|
|
565
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $GIT_REPO = "git://github.com/batchpause/PAUSE-git"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
0
|
|
my($class, %args) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
0
|
|
|
|
$args{git_dir} ||= $ENV{"PAUSETM_GIT_DIR"} || "$ENV{HOME}/.pausetm/PAUSE-git"; |
|
|
|
0
|
|
|
|
|
19
|
0
|
|
|
|
|
|
bless { |
20
|
|
|
|
|
|
|
git_dir => $args{git_dir}, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub psgi_app { |
25
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return sub { |
28
|
0
|
|
|
0
|
|
|
my $env = shift; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if ($env->{PATH_INFO} eq '/') { |
31
|
0
|
|
|
|
|
|
return [200, ['Content-Type' => 'text/plain'], ["Access $env->{SCRIPT_NAME}/yyyy-mm-dd"]]; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $date = 'today'; |
35
|
0
|
0
|
|
|
|
|
if ($env->{PATH_INFO} =~ s!^/([^/]+)!!) { |
36
|
0
|
|
|
|
|
|
$date = $1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
if ($env->{PATH_INFO} eq '/modules/02packages.details.txt.gz') { |
40
|
0
|
|
|
|
|
|
chomp(my $rev = $self->git_capture('rev-list', '-1', "--before=$date", 'master')); |
41
|
0
|
|
|
|
|
|
my $text = $self->git_capture('show', "$rev:02packages.details.txt"); |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my($lastmod) = $text =~ m!^Last-Updated:\s*(.*)$!m; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
0
|
|
|
|
if ($env->{HTTP_IF_MODIFIED_SINCE} && $env->{HTTP_IF_MODIFIED_SINCE} eq $lastmod) { |
46
|
0
|
|
|
|
|
|
return [304, [], []]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
IO::Compress::Gzip::gzip \$text => \my $gztext; |
50
|
|
|
|
|
|
|
return [ |
51
|
0
|
|
|
|
|
|
200, |
52
|
|
|
|
|
|
|
[ |
53
|
|
|
|
|
|
|
'Content-Type' => 'application/x-gzip', |
54
|
|
|
|
|
|
|
'Content-Length' => length($gztext), |
55
|
|
|
|
|
|
|
'Last-Modified' => $lastmod, |
56
|
|
|
|
|
|
|
], |
57
|
|
|
|
|
|
|
[$gztext], |
58
|
|
|
|
|
|
|
]; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if ($env->{PATH_INFO} =~ m!authors/id/!) { |
62
|
0
|
|
|
|
|
|
return [301, ['Location' => "http://backpan.perl.org/$env->{PATH_INFO}"], []]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return [404, ['Content-Type' => 'text/plain'], ["Not Found"]]; |
66
|
0
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub git_dir { |
70
|
0
|
|
|
0
|
0
|
|
$_[0]->{git_dir}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub run { |
74
|
0
|
|
|
0
|
0
|
|
my($self, @args) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
0
|
|
|
|
my $cmd = shift @args || "help"; |
77
|
0
|
|
0
|
|
|
|
my $can = $self->can("cmd_$cmd") || $self->can("cmd_help"); |
78
|
0
|
|
|
|
|
|
$self->$can(@args); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub git_raw { |
82
|
0
|
|
|
0
|
0
|
|
my($self, @commands) = @_; |
83
|
0
|
|
|
|
|
|
IPC::Run::run ["git", @commands], \my $in, \*STDOUT; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub git_opts { |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
0
|
|
|
|
|
|
("--git-dir=" . $self->git_dir . "/.git", "--work-tree=."); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub git { |
92
|
0
|
|
|
0
|
0
|
|
my($self, @commands) = @_; |
93
|
0
|
|
|
|
|
|
IPC::Run::run ["git", $self->git_opts, @commands]; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub git_capture { |
97
|
0
|
|
|
0
|
0
|
|
my($self, @commands) = @_; |
98
|
0
|
|
|
|
|
|
IPC::Run::run ["git", $self->git_opts, @commands], \my $in, \my $out; |
99
|
0
|
|
|
|
|
|
$out; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub cmd_help { |
103
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
Pod::Usage::pod2usage(1); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub cmd_init { |
108
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
109
|
0
|
|
|
|
|
|
$self->git_raw('clone', $GIT_REPO, $self->git_dir); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub cmd_sync { |
113
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my $dir = pushd $self->git_dir; |
115
|
0
|
|
|
|
|
|
$self->git_raw('pull', 'origin', 'master'); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub cmd_cat { |
119
|
0
|
|
|
0
|
0
|
|
my($self, $date) = @_; |
120
|
0
|
|
|
|
|
|
chomp(my $rev = $self->git_capture('rev-list', '-1', "--before=$date", 'master')); |
121
|
0
|
|
|
|
|
|
$self->git('show', "$rev:02packages.details.txt"); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub cmd_server { |
125
|
0
|
|
|
0
|
0
|
|
my($self, @args) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $runner = Plack::Runner->new; |
128
|
0
|
|
|
|
|
|
$runner->parse_options(@args); |
129
|
0
|
|
|
|
|
|
$runner->run($self->psgi_app); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
133
|
|
|
|
|
|
|
__END__ |