Skip to content

Commit

Permalink
Merge cab0098 into 635670a
Browse files Browse the repository at this point in the history
  • Loading branch information
goober99 committed Oct 5, 2018
2 parents 635670a + cab0098 commit 14ef0b9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Build.PL
Expand Up @@ -23,7 +23,7 @@ my $build = Module::Build
'XML::RSS' => '1.47',
'Test::More' => 0,
'Scalar::Util' => 0,
'perl' => '5.008001',
'perl' => '5.10.0',
},
build_requires => {
'URI' => 0,
Expand All @@ -44,6 +44,7 @@ my $build = Module::Build
'Minty Walker <mintywalker@gmail.com>',
'Karen Etheridge <ether@cpan.org>',
'Gerard Ribugent Navarro <ribugent@cpan.org>',
'Matthew D. Miller <matthew.miller@okbu.edu>',
],
},
);
Expand Down
5 changes: 3 additions & 2 deletions lib/XML/Feed.pm
@@ -1,6 +1,7 @@
package XML::Feed;
use strict;
use warnings;
use v5.10;

use base qw( Class::ErrorHandler );
use Feed::Find;
Expand All @@ -21,7 +22,7 @@ BEGIN {

sub new {
my $class = shift;
my $format = shift || 'Atom';
my $format = shift // 'Atom';
my $format_class = 'XML::Feed::Format::' . $format;
eval "use $format_class";
Carp::croak("Unsupported format $format: $@") if $@;
Expand Down Expand Up @@ -440,7 +441,7 @@ For reference, this cgi script will create valid, albeit nonsensical feeds
use XML::Feed;
my $cgi = CGI->new;
my @args = ( $cgi->param('format') || "Atom" );
my @args = ( $cgi->param('format') // "Atom" );
push @args, ( version => $cgi->param('version') ) if $cgi->param('version');
my $feed = XML::Feed->new(@args);
Expand Down
5 changes: 3 additions & 2 deletions lib/XML/Feed/Entry.pm
@@ -1,8 +1,9 @@
package XML::Feed::Entry;
use strict;
use warnings;
use v5.10;

our $VERSION = '0.53';
our $VERSION = '0.54';

use base qw( Class::ErrorHandler );

Expand All @@ -21,7 +22,7 @@ sub unwrap { $_[0]->{entry} }
sub new {
my $class = shift;
my($format) = @_;
$format ||= 'Atom';
$format //= 'Atom';
my $format_class = 'XML::Feed::Format::' . $format;
eval "use $format_class";
Carp::croak("Unsupported format $format: $@") if $@;
Expand Down
3 changes: 2 additions & 1 deletion lib/XML/Feed/Entry/Format/Atom.pm
@@ -1,6 +1,7 @@
package XML::Feed::Entry::Format::Atom;
use strict;
use warnings;
use v5.10;

our $VERSION = '0.54';

Expand Down Expand Up @@ -124,7 +125,7 @@ sub category {

my @category = ($entry->{entry}->can('categories')) ? $entry->{entry}->categories : $entry->{entry}->category;
my @return = @category
? (map { $_->label || $_->term } @category)
? (map { $_->label // $_->term } @category)
: $entry->{entry}->getlist($ns, 'subject');

return wantarray? @return : $return[0];
Expand Down
19 changes: 10 additions & 9 deletions lib/XML/Feed/Entry/Format/RSS.pm
@@ -1,6 +1,7 @@
package XML::Feed::Entry::Format::RSS;
use strict;
use warnings;
use v5.10;

our $VERSION = '0.54';

Expand Down Expand Up @@ -30,8 +31,8 @@ sub link {
## For RSS 2.0 output from XML::RSS. Sigh.
$entry->{entry}{permaLink} = $_[0];
} else {
my $link = $entry->{entry}{link} ||
$entry->{entry}{permaLink} ||
my $link = $entry->{entry}{link} //
$entry->{entry}{permaLink} //
$entry->{entry}{guid};
if (defined $link) {
$link =~ s/^\s+//;
Expand Down Expand Up @@ -63,7 +64,7 @@ sub summary {
## typically used for the full content, use <description> as summary.
my $txt;
if ($item->{description} &&
($entry->_content ||
($entry->_content //
$item->{'http://www.w3.org/1999/xhtml'}{body})) {
$txt = $item->{description};
## Blogspot's 'short' RSS feeds do this in the Atom namespace
Expand Down Expand Up @@ -101,8 +102,8 @@ sub content {
} else {
my $base;
my $body =
$entry->_content ||
$item->{'http://www.w3.org/1999/xhtml'}{body} ||
$entry->_content //
$item->{'http://www.w3.org/1999/xhtml'}{body} //
$item->{description};
if ('HASH' eq ref($body)) {
$base = $body->{'xml:base'};
Expand All @@ -120,7 +121,7 @@ sub category {
$item->{category} = [@tmp];
$item->{dc}{subject} = [@tmp];
} else {
my $r = $item->{category} || $item->{dc}{subject};
my $r = $item->{category} // $item->{dc}{subject};
my @r = ref($r) eq 'ARRAY' ? @$r : defined $r? ($r) : ();
return wantarray? @r : $r[0];
}
Expand All @@ -131,7 +132,7 @@ sub author {
if (@_) {
$item->{author} = $item->{dc}{creator} = $_[0];
} else {
$item->{author} || $item->{dc}{creator};
$item->{author} // $item->{dc}{creator};
}
}

Expand All @@ -142,7 +143,7 @@ sub id {
if (@_) {
$item->{guid} = $_[0];
} else {
$item->{guid} || $item->{link};
$item->{guid} // $item->{link};
}
}

Expand Down Expand Up @@ -176,7 +177,7 @@ sub modified {
if (@_) {
$item->{dcterms}{modified} = format_W3CDTF($_[0]);
} else {
if (my $ts = $item->{dcterms}{modified} ||
if (my $ts = $item->{dcterms}{modified} //
$item->{'http://www.w3.org/2005/Atom'}{updated}) {
$ts =~ s/^\s+//;
$ts =~ s/\s+$//;
Expand Down
3 changes: 2 additions & 1 deletion lib/XML/Feed/Format/Atom.pm
@@ -1,6 +1,7 @@
package XML::Feed::Format::Atom;
use strict;
use warnings;
use v5.10;

our $VERSION = '0.54';

Expand All @@ -27,7 +28,7 @@ sub identify {

sub init_empty {
my ($feed, %args) = @_;
$args{'Version'} ||= '1.0';
$args{'Version'} //= '1.0';

$feed->{atom} = XML::Atom::Feed->new(%args);
$feed;
Expand Down
11 changes: 6 additions & 5 deletions lib/XML/Feed/Format/RSS.pm
@@ -1,8 +1,9 @@
package XML::Feed::Format::RSS;
use strict;
use warnings;
use v5.10;

our $VERSION = '0.53';
our $VERSION = '0.54';

use base qw( XML::Feed );
use DateTime::Format::Mail;
Expand All @@ -23,7 +24,7 @@ sub identify {

sub init_empty {
my ($feed, %args) = @_;
$args{'version'} ||= '2.0';
$args{'version'} //= '2.0';
eval "use $PREFERRED_PARSER"; die $@ if $@;
$feed->{rss} = $PREFERRED_PARSER->new(%args);
$feed->{rss}->add_module(prefix => "content", uri => 'http://purl.org/rss/1.0/modules/content/');
Expand Down Expand Up @@ -82,7 +83,7 @@ sub language {
$feed->{rss}->channel('language', $_[0]);
$feed->{rss}->channel->{dc}{language} = $_[0];
} else {
$feed->{rss}->channel('language') ||
$feed->{rss}->channel('language') //
$feed->{rss}->channel->{dc}{language};
}
}
Expand Down Expand Up @@ -120,7 +121,7 @@ sub generator {
$feed->{rss}->channel->{'http://webns.net/mvcb/'}{generatorAgent} =
$_[0];
} else {
$feed->{rss}->channel('generator') ||
$feed->{rss}->channel('generator') //
$feed->{rss}->channel->{'http://webns.net/mvcb/'}{generatorAgent};
}
}
Expand All @@ -131,7 +132,7 @@ sub author {
$feed->{rss}->channel('webMaster', $_[0]);
$feed->{rss}->channel->{dc}{creator} = $_[0];
} else {
$feed->{rss}->channel('webMaster') ||
$feed->{rss}->channel('webMaster') //
$feed->{rss}->channel->{dc}{creator};
}
}
Expand Down

0 comments on commit 14ef0b9

Please sign in to comment.