summaryrefslogtreecommitdiff
path: root/cpan/Module-Metadata
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2019-09-13 14:23:36 +0100
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2019-09-13 14:23:36 +0100
commitc7fb625702e97df5bc916d4cbf32b73977676beb (patch)
tree3f401f1fea7ad212e4bcfa0ced8330f45978185f /cpan/Module-Metadata
parent9bbd51b76a290c5324a1ca7fb9d3ca23909f36d3 (diff)
downloadperl-c7fb625702e97df5bc916d4cbf32b73977676beb.tar.gz
Update Module-Metadata to CPAN version 1.000037
[DELTA] 1.000037 2019-09-07 18:32:44Z - add decode_pod option for automatic =encoding handling
Diffstat (limited to 'cpan/Module-Metadata')
-rw-r--r--cpan/Module-Metadata/lib/Module/Metadata.pm46
-rw-r--r--cpan/Module-Metadata/t/metadata.t16
2 files changed, 44 insertions, 18 deletions
diff --git a/cpan/Module-Metadata/lib/Module/Metadata.pm b/cpan/Module-Metadata/lib/Module/Metadata.pm
index ecc535f03b..0309d768ae 100644
--- a/cpan/Module-Metadata/lib/Module/Metadata.pm
+++ b/cpan/Module-Metadata/lib/Module/Metadata.pm
@@ -1,6 +1,6 @@
# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
# vim:ts=8:sw=2:et:sta:sts=2:tw=78
-package Module::Metadata; # git description: v1.000035-3-gaa51be1
+package Module::Metadata; # git description: v1.000036-4-g435a294
# ABSTRACT: Gather package and POD information from perl module files
# Adapted from Perl-licensed code originally distributed with
@@ -14,7 +14,7 @@ sub __clean_eval { eval $_[0] }
use strict;
use warnings;
-our $VERSION = '1.000036';
+our $VERSION = '1.000037';
use Carp qw/croak/;
use File::Spec;
@@ -383,7 +383,7 @@ sub _init {
my $handle = delete $props{handle};
my( %valid_props, @valid_props );
- @valid_props = qw( collect_pod inc );
+ @valid_props = qw( collect_pod inc decode_pod );
@valid_props{@valid_props} = delete( @props{@valid_props} );
warn "Unknown properties: @{[keys %props]}\n" if scalar( %props );
@@ -542,6 +542,7 @@ sub _parse_fh {
my $pod_sect = '';
my $pod_data = '';
my $in_end = 0;
+ my $encoding = '';
while (defined( my $line = <$fh> )) {
my $line_num = $.;
@@ -570,6 +571,9 @@ sub _parse_fh {
$pod_sect = $1;
}
elsif ( $self->{collect_pod} ) {
+ if ( $self->{decode_pod} && $line =~ /^=encoding ([\w-]+)/ ) {
+ $encoding = $1;
+ }
$pod_data .= "$line\n";
}
next;
@@ -658,6 +662,11 @@ sub _parse_fh {
$pod{$pod_sect} = $pod_data;
}
+ if ( $self->{decode_pod} && $encoding ) {
+ require Encode;
+ $_ = Encode::decode( $encoding, $_ ) for values %pod;
+ }
+
$self->{versions} = \%vers;
$self->{packages} = \@packages;
$self->{pod} = \%pod;
@@ -841,7 +850,7 @@ Module::Metadata - Gather package and POD information from perl module files
=head1 VERSION
-version 1.000036
+version 1.000037
=head1 SYNOPSIS
@@ -865,7 +874,7 @@ in the CPAN toolchain.
=head1 CLASS METHODS
-=head2 C<< new_from_file($filename, collect_pod => 1) >>
+=head2 C<< new_from_file($filename, collect_pod => 1, decode_pod => 1) >>
Constructs a C<Module::Metadata> object given the path to a file. Returns
undef if the filename does not exist.
@@ -878,7 +887,10 @@ If the file begins by an UTF-8, UTF-16BE or UTF-16LE byte-order mark, then
it is skipped before processing, and the content of the file is also decoded
appropriately starting from perl 5.8.
-=head2 C<< new_from_handle($handle, $filename, collect_pod => 1) >>
+Alternatively, if C<decode_pod> is set, it will decode the collected pod
+sections according to the C<=encoding> declaration.
+
+=head2 C<< new_from_handle($handle, $filename, collect_pod => 1, decode_pod => 1) >>
This works just like C<new_from_file>, except that a handle can be provided
as the first argument.
@@ -891,15 +903,15 @@ mandatory or undef will be returned.
You are responsible for setting the decoding layers on C<$handle> if
required.
-=head2 C<< new_from_module($module, collect_pod => 1, inc => \@dirs) >>
+=head2 C<< new_from_module($module, collect_pod => 1, inc => \@dirs, decode_pod => 1) >>
Constructs a C<Module::Metadata> object given a module or package name.
Returns undef if the module cannot be found.
-In addition to accepting the C<collect_pod> argument as described above,
-this method accepts a C<inc> argument which is a reference to an array of
-directories to search for the module. If none are given, the default is
-@INC.
+In addition to accepting the C<collect_pod> and C<decode_pod> arguments as
+described above, this method accepts a C<inc> argument which is a reference to
+an array of directories to search for the module. If none are given, the
+default is @INC.
If the file that contains the module begins by an UTF-8, UTF-16BE or
UTF-16LE byte-order mark, then it is skipped before processing, and the
@@ -1070,7 +1082,7 @@ assistance from David Golden (xdg) <dagolden@cpan.org>.
=head1 CONTRIBUTORS
-=for stopwords Karen Etheridge David Golden Vincent Pit Matt S Trout Chris Nehren Graham Knop Olivier Mengué Tomas Doran tokuhirom Christian Walde Tatsuhiko Miyagawa Peter Rabbitson Steve Hay Jerry D. Hedden Craig A. Berry Mitchell Steinbrunner Edward Zborowski Gareth Harper James Raspass 'BinGOs' Williams Josh Jore Kent Fredric
+=for stopwords Karen Etheridge David Golden Vincent Pit Matt S Trout Chris Nehren Tomas Doran Olivier Mengué Graham Knop tokuhirom Tatsuhiko Miyagawa Christian Walde Leon Timmermans Peter Rabbitson Steve Hay Jerry D. Hedden Craig A. Berry Mitchell Steinbrunner Edward Zborowski Gareth Harper James Raspass 'BinGOs' Williams Josh Jore Kent Fredric
=over 4
@@ -1096,7 +1108,7 @@ Chris Nehren <apeiron@cpan.org>
=item *
-Graham Knop <haarg@haarg.org>
+Tomas Doran <bobtfish@bobtfish.net>
=item *
@@ -1104,7 +1116,7 @@ Olivier Mengué <dolmen@cpan.org>
=item *
-Tomas Doran <bobtfish@bobtfish.net>
+Graham Knop <haarg@haarg.org>
=item *
@@ -1112,11 +1124,15 @@ tokuhirom <tokuhirom@gmail.com>
=item *
+Tatsuhiko Miyagawa <miyagawa@bulknews.net>
+
+=item *
+
Christian Walde <walde.christian@googlemail.com>
=item *
-Tatsuhiko Miyagawa <miyagawa@bulknews.net>
+Leon Timmermans <fawaka@gmail.com>
=item *
diff --git a/cpan/Module-Metadata/t/metadata.t b/cpan/Module-Metadata/t/metadata.t
index 0f2e414c7f..3eea8d9666 100644
--- a/cpan/Module-Metadata/t/metadata.t
+++ b/cpan/Module-Metadata/t/metadata.t
@@ -3,6 +3,7 @@
use strict;
use warnings;
+use Encode 'decode';
use Test::More 0.82;
use IO::File;
use File::Spec;
@@ -16,7 +17,7 @@ use GeneratePackage;
my $tmpdir = GeneratePackage::tmpdir();
-plan tests => 71;
+plan tests => 72;
require_ok('Module::Metadata');
@@ -209,13 +210,15 @@ $VERSION = '0.01';
package Simple::Ex;
$VERSION = '0.02';
+=encoding UTF-8
+
=head1 NAME
Simple - It's easy.
=head1 AUTHOR
-Simple Simon
+Símple Simon
You can find me on the IRC channel
#simon on irc.perl.org.
@@ -270,7 +273,7 @@ You can find me on the IRC channel
my %expected = (
NAME => q|Simple - It's easy.|,
AUTHOR => <<'EXPECTED'
-Simple Simon
+Símple Simon
You can find me on the IRC channel
#simon on irc.perl.org.
@@ -282,6 +285,13 @@ EXPECTED
}
is( $pod{NAME}, $expected{NAME}, 'collected NAME pod section' );
is( $pod{AUTHOR}, $expected{AUTHOR}, 'collected AUTHOR pod section' );
+
+ my $pm_info2 = Module::Metadata->new_from_module(
+ 'Simple', inc => [ 'lib', @INC ], collect_pod => 1, decode_pod => 1 );
+ my $author = $pm_info2->pod( 'AUTHOR' );
+ $author =~ s/^\s+//;
+ $author =~ s/\s+$//;
+ is( $author, decode('UTF-8', $expected{AUTHOR} ), 'collected AUTHOR pod section in UTF-8' );
}
{