/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (hide annotations)
Tue Jun 30 15:10:55 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 796 byte(s)
make classes immutable and remove moose droppings to make Perl::Critic::Moose happy
1 dpavlin 303 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 => 'http://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 dpavlin 1133 __PACKAGE__->meta->make_immutable;
44     no Moose;
45    
46 dpavlin 303 1;

  ViewVC Help
Powered by ViewVC 1.1.26