Perlanet/Trait/Cache.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 30 / 30 CC 2 SCAR 2.5
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Perlanet/Trait/TemplateToolkit.pm ↑ Summary Perlanet/Trait/Scrubber.pm »
1 package Perlanet::Trait::Cache;
2  
3 11 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Perlanet::Trait::Cache - cache feeds with CHI
13  
14 =head1 SYNOPSIS
15  
16 my $perlanet = Perlanet->new_with_traits(
17 traits => [ 'Perlanet::Trait::Cache' ]
18 );
19  
20 $perlanet->run;
21  
22 =head1 DESCRIPTION
23  
24 Every time a page is fetched it is cached first through CHI. This allows you
25 to cache pages to a local disk for example, if the feed has not changed.
26  
27 =head1 ATTRIBUTES
28  
29 =head2 cache
30  
31 The L<Chi> cache object
32  
33 =cut
34  
35 11 has 'cache'=> (
36 is => 'ro'
37 );
38  
39 14 ▶around 'fetch_feed' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
40 14 my $orig = shift;
41 14 my $self = shift;
42 14 my ($url) = @_;
43 14 ▶ return URI::Fetch->fetch(
Condition100%2/2
$self->cache || undef
l!l
212
MC/DC100%1/1
$self->cache || undef
$self->cache
Truth table100%2/2
A
A= $self->cache
Aresult
11
00
44 $url,
45 UserAgent => $self->ua,
46 Cache => $self->cache || undef,
47 ForceResponse => 1,
48 );
49 11 };
50  
51 =head1 AUTHOR
52  
53 Dave Cross, <dave@perlhacks.com>
54  
55 =head1 COPYRIGHT AND LICENSE
56  
57 Copyright (c) 2010 by Magnum Solutions Ltd.
58  
59 This library is free software; you can redistribute it and/or modify
60 it under the same terms as Perl itself, either Perl version 5.10.0 or,
61 at your option, any later version of Perl 5 you may have available.
62  
63 =cut
64  
65 11 1;
« Perlanet/Trait/TemplateToolkit.pm ↑ Summary Perlanet/Trait/Scrubber.pm »