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 7     7   167352 use strict;
  7         15  
  7         200  
4 7     7   36 use warnings;
  7         12  
  7         175  
5              
6 7     7   2734 use Moose;
  7         2569452  
  7         54  
7 7     7   55094 use namespace::autoclean;
  7         42024  
  7         44  
8              
9 7     7   439 use Carp;
  7         16  
  7         435  
10 7     7   2842 use YAML 'LoadFile';
  7         37206  
  7         1356  
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             use Perlanet::Simple;
30              
31             my $perlanet = Perlanet::Simple->new_with_config(
32             configfile => 'perlanet.yaml'
33             );
34             $perlanet->run;
35              
36             =head1 DESCRIPTION
37              
38             L<Perlanet> provides the driving force behind all Perlanet applications,
39             but it doesn't do a whole lot, which means you would normally have to write
40             the functionality you require. However, in the motive of simplicity,
41             Perlanet::Simple glues enough stuff together to allow you to get a very quick
42             planet working out of the box.
43              
44             Perlanet::Simple takes the standard Perlanet module, and adds support for
45             caching, OPML feed generation, and L<Template> rendering support. It will
46             also attempt to clean each post using both L<HTML::Scrubber> and L<HTML::Tidy>.
47              
48             =head2 Configuration
49              
50             Perlanet::Simple uses L<Perlanet::Trait::YAMLConfig> to allow you to specify
51             configuration through a file.
52              
53             =cut
54              
55             around '_build_ua' => sub {
56             my $orig = shift;
57             my $self = shift;
58             my $ua = $self->$orig;
59             $ua->agent($self->agent) if $self->agent;
60             return $ua;
61             };
62              
63             =head2 clean_html
64              
65             Some custom cleaning code to remove a nasty piece of BlogSpot HTML
66             (and still running all other cleaning traits)
67              
68             =cut
69              
70             around clean_html => sub {
71             my $orig = shift;
72             my ($self, $html) = @_;
73              
74             # hack to remove a particularly nasty piece of blogspot HTML
75             $html = $self->$orig($html);
76             $html =~ s|<div align="justify"></div>||g;
77              
78             return $html;
79             };
80              
81             1;