Permalink
Browse files

Merge branch 'master' of github.com:davorg/perlanet

  • Loading branch information...
2 parents dcc001b + c2c791b commit f3520a3e23f0584d07ef0fba29f61258e0f75d45 @davorg committed Jul 23, 2011
Showing with 12 additions and 8 deletions.
  1. +1 −1 lib/Perlanet.pm
  2. +10 −6 lib/Perlanet/Trait/OPML.pm
  3. +1 −1 t/01_basic.t
View
@@ -18,7 +18,7 @@ use XML::Feed;
use vars qw{$VERSION};
BEGIN {
- $VERSION = '0.53';
+ $VERSION = '0.54';
}
with 'MooseX::Traits';
View
@@ -6,7 +6,7 @@ use warnings;
use Moose::Role;
use namespace::autoclean;
-use Carp qw( croak );
+use Carp qw( carp );
use POSIX qw(setlocale LC_ALL);
=head1 NAME
@@ -35,8 +35,9 @@ An L<XML::OPML::SimpleGen> object to generate the XML for the OPML file
has 'opml_generator' => (
is => 'rw',
- isa => 'XML::OPML::SimpleGen',
- lazy_build => 1
+ isa => 'Maybe[XML::OPML::SimpleGen]',
+ lazy_build => 1,
+ predicate => 'has_opml'
);
sub _build_opml_generator {
@@ -45,8 +46,10 @@ sub _build_opml_generator {
eval { require XML::OPML::SimpleGen; };
if ($@) {
- croak 'You need to install XML::OPML::SimpleGen to enable OPML ' .
+ carp 'You need to install XML::OPML::SimpleGen to enable OPML ' .
'support';
+ $self->opml(undef);
+ return;
}
my $loc = setlocale(LC_ALL, 'C');
@@ -67,9 +70,8 @@ Where to save the OPML feed when it has been created
=cut
has 'opml' => (
- isa => 'Str',
+ isa => 'Maybe[Str]',
is => 'rw',
- predicate => 'has_opml'
);
=head1 METHODS
@@ -85,6 +87,8 @@ each author into the OPML file and saves it to disk.
sub update_opml {
my ($self, @feeds) = @_;
+ return unless $self->has_opml;
+
foreach my $f (@feeds) {
$self->opml_generator->insert_outline(
title => $f->title,
View
@@ -24,7 +24,7 @@ $p->run;
ok(-e $p->feed->{file}, 'Feed created');
ok(-e $p->page->{file}, 'Page created');
SKIP: {
- skip 'XML::OPML::SimpleGen not installed', 1 unless $p->opml;
+ skip 'XML::OPML::SimpleGen not installed', 1 unless $p->has_opml;
ok(-e $p->opml, 'OPML created');
}

0 comments on commit f3520a3

Please sign in to comment.