File Coverage

blib/lib/Perlanet/Simple.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Perlanet::Simple;
2              
3 6     6   571015 use strict;
  6         11  
  6         150  
4 6     6   24 use warnings;
  6         8  
  6         287  
5              
6 6     6   1634 use Moose;
  6         1378910  
  6         49  
7 6     6   36501 use namespace::autoclean;
  6         104203  
  6         44  
8              
9 6     6   293 use Carp;
  6         74  
  6         298  
10 6     6   1596 use YAML 'LoadFile';
  6         25380  
  6         1102  
11              
12             extends 'Perlanet';
13             with qw(
14             Perlanet::Trait::Cache
15             Perlanet::Trait::OPML
16             Perlanet::Trait::Scrubber
17             Perlanet::Trait::Tidy
18             Perlanet::Trait::YAMLConfig
19             Perlanet::Trait::TemplateToolkit
20             Perlanet::Trait::FeedFile
21             );
22              
23             =head1 NAME
24            
25             Perlanet::Simple - a DWIM Perlanet
26            
27             =head1 SYNOPSIS
28            
29             my $perlanet = Perlanet::Simple->new_with_config('perlanet.yaml')
30             $perlanet->run;
31            
32             =head1 DESCRIPTION
33            
34             L<Perlanet> provides the driving force behind all Perlanet applications,
35             but it doesn't do a whole lot, which means you would normally have to write
36             the functionality you require. However, in the motive of simplicity,
37             Perlanet::Simple glues enough stuff together to allow you to get a very quick
38             planet working out of the box.
39            
40             Perlanet::Simple takes the standard Perlanet module, and adds support for
41             caching, OPML feed generation, and L<Template> rendering support. It will
42             also attempt to clean each post using both L<HTML::Scrubber> and L<HTML::Tidy>.
43            
44             =head2 Configuration
45            
46             Perlanet::Simple uses L<Perlanet::Trait::YAMLConfig> to allow you to specify
47             configuration through a file.
48            
49             =cut
50              
51             around '_build_ua' => sub {
52               my $orig = shift;
53               my $self = shift;
54               my $ua = $self->$orig;
55               $ua->agent($self->agent) if $self->agent;
56               return $ua;
57             };
58              
59             =head2 clean_html
60            
61             Some custom cleaning code to remove a nasty piece of BlogSpot HTML
62             (and still running all other cleaning traits)
63            
64             =cut
65              
66             around clean_html => sub {
67               my $orig = shift;
68               my ($self, $html) = @_;
69              
70             # hack to remove a particularly nasty piece of blogspot HTML
71               $html = $self->$orig($html);
72               $html =~ s|<div align="justify"></div>||g;
73              
74               return $html;
75             };
76              
77             1;
78