cpan/Parse-CPAN-Meta/t/03_functions.t
cpan/Parse-CPAN-Meta/t/04_export.t
cpan/Parse-CPAN-Meta/t/05_errors.t
+cpan/Parse-CPAN-Meta/t/data/BadMETA.yml
cpan/Parse-CPAN-Meta/t/data/META-VR.json
cpan/Parse-CPAN-Meta/t/data/META-VR.yml
cpan/Parse-CPAN-Meta/t/lib/Parse/CPAN/Meta/Test.pm
},
'Parse::CPAN::Meta' => {
- 'DISTRIBUTION' => 'DAGOLDEN/Parse-CPAN-Meta-1.4410.tar.gz',
+ 'DISTRIBUTION' => 'DAGOLDEN/Parse-CPAN-Meta-1.4412.tar.gz',
'FILES' => q[cpan/Parse-CPAN-Meta],
'EXCLUDED' => [
qw(t/00-compile.t),
use strict;
package Parse::CPAN::Meta;
# ABSTRACT: Parse META.yml and META.json CPAN metadata files
-our $VERSION = '1.4410'; # VERSION
+our $VERSION = '1.4412'; # VERSION
use Exporter;
use Carp 'croak';
}
sub _slurp {
- open my $fh, "<:utf8", "$_[0]" ## no critic
+ require Encode;
+ require PerlIO::encoding;
+ local $PerlIO::encoding::fallback = Encode::PERLQQ()|Encode::STOP_AT_PARTIAL();
+ open my $fh, "<:encoding(UTF-8)", "$_[0]" ## no critic
or die "can't open $_[0] for reading: $!";
return do { local $/; <$fh> };
}
# Kept for backwards compatibility only
# Create an object from a file
sub LoadFile ($) {
- require CPAN::Meta::YAML;
- my $object = eval { CPAN::Meta::YAML::LoadFile(shift) };
- croak $@ if $@;
- return $object;
+ return Load(_slurp(shift));
}
# Parse a document from a string.
=head1 VERSION
-version 1.4410
+version 1.4412
=head1 SYNOPSIS
# Testing of a known-bad file from an editor
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
+use lib 't/lib';
use File::Spec::Functions ':ALL';
use Parse::CPAN::Meta;
use Parse::CPAN::Meta::Test;
is_deeply($from_yaml, $want, "load from YAML str results in expected data");
}
+{
+ local $ENV{PERL_YAML_BACKEND}; # ensure we get CPAN::META::YAML
+
+ my @yaml = Parse::CPAN::Meta::LoadFile( 't/data/BadMETA.yml' );
+ is($yaml[0]{author}[0], 'Olivier Mengu\xE9', "Bad UTF-8 is replaced");
+}
+
+
SKIP: {
skip "YAML module not installed", 2
unless eval "require YAML; 1";
# Testing of basic document structures
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
# Testing of basic document structures
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
# Testing of basic document structures
-BEGIN {
- if( $ENV{PERL_CORE} ) {
- chdir 't';
- @INC = ('../lib', 'lib');
- }
- else {
- unshift @INC, 't/lib/';
- }
-}
-
use strict;
BEGIN {
$| = 1;
--- /dev/null
+---\r
+abstract: ~\r
+author:\r
+ - 'Olivier Mengué'\r
+build_requires:\r
+ ExtUtils::MakeMaker: 6.36\r
+configure_requires:\r
+ ExtUtils::MakeMaker: 6.36\r
+distribution_type: module\r
+dynamic_config: 1\r
+generated_by: 'Module::Install version 1.06'\r
+license: perl\r
+meta-spec:\r
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html\r
+ version: 1.4\r
+name: Foo\r
+no_index:\r
+ directory:\r
+ - inc\r
+requires:\r
+ perl: 5.005\r
+resources:\r
+ license: http://dev.perl.org/licenses/\r
+version: 0.01\r
}
sub test_data_directory {
- return(
- $ENV{PERL_CORE}
- ? File::Spec->catdir(File::Spec->updir, qw(lib Parse CPAN Meta t data))
- : File::Spec->catdir(qw(t data))
- );
+ return( File::Spec->catdir(qw(t data)) );
}
# 22 tests per call to yaml_ok