/[Frey]/trunk/lib/Frey/Mirror.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/Mirror.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 303 - (show annotations)
Wed Nov 5 12:31:12 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 750 byte(s)
mirror web content locally
1 package Frey::Mirror;
2 use Moose;
3
4 =head1 DESCRIPTION
5
6 Mirror content from web and store it locally
7
8 =head1 SYNOPSYS
9
10 my $content = Frey::Mirror->new( uri => 'http://www.example.com' )->content;
11
12 =cut
13
14 use Frey::Types;
15 use LWP::Simple;
16 use File::Slurp;
17
18 with 'Frey::Path';
19
20 has uri => (
21 is => 'rw',
22 isa => 'Uri', coerce => 1,
23 required => 1,
24 default => 'https://blog.rot13.org/index.xml',
25 );
26
27 has content => (
28 is => 'ro',
29 required => 1,
30 lazy => 1,
31 default => sub {
32 my ($self) = @_;
33 my $path = 'var/mirror/' . $self->uri->host . '/' . $self->uri->path;
34 if ( ! -e $path ) {
35 $self->mkbasepath( $path );
36 mirror( $self->uri, $path );
37 warn "mirror ", $self->uri, " -> $path ", -s $path, " bytes";
38 }
39 read_file( $path );
40 },
41 );
42
43 1;

  ViewVC Help
Powered by ViewVC 1.1.26