In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/722c92c735f2ffe585718e77631832aa1a283a72?hp=c144baaa125e0fe9cca51c4563fd00c448c9b873>
- Log ----------------------------------------------------------------- commit 722c92c735f2ffe585718e77631832aa1a283a72 Author: Chris 'BinGOs' Williams <[email protected]> Date: Tue Oct 1 13:15:39 2013 +0100 Regen META files for CPAN::Meta update M META.json M META.yml commit 14d9af8fe4d87cf2f530e4370eb9ab0a447593a2 Author: Chris 'BinGOs' Williams <[email protected]> Date: Tue Oct 1 13:14:11 2013 +0100 Update CPAN-Meta to CPAN version 2.132661 [DELTA] 2.132661 2013-09-23 13:27:46 America/New_York [FIXED] - updated Makefile.PL logic to support PERL_NO_HIGHLANDER [PREREQS] - Dropped ExtUtils::MakeMaker configure_requires dependency to 6.17 2.132660 2013-09-23 06:04:04 America/New_York [FIXED] - Installation on Perls < 5.12 will uninstall older versions installed due to being bundled with ExtUtils::MakeMaker M Porting/Maintainers.pl M cpan/CPAN-Meta/Changes M cpan/CPAN-Meta/lib/CPAN/Meta.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm M cpan/CPAN-Meta/lib/CPAN/Meta/History.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm commit 56284aa925d98c8e8e8f6705ab5e7b3bd5a54cda Author: Chris 'BinGOs' Williams <[email protected]> Date: Tue Oct 1 13:12:33 2013 +0100 Update CPAN-Meta-Requirements to CPAN version 2.125 [DELTA] 2.125 2013-09-23 14:51:14 America/New_York [FIXED] - updated Makefile.PL logic to support PERL_NO_HIGHLANDER 2.124 2013-09-23 06:40:07 America/New_York [FIXED] - Better fix than 2.123. On old perls, rather than install into 'core', we continue to install into the proper 'site' library, but force UNINST=1 when necessary to remove stale copies from ExtUtils::MakeMaker M Porting/Maintainers.pl M cpan/CPAN-Meta-Requirements/Changes M cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm commit 7d7e3722046fdccae6de41456b34b7452a7c426e Author: Chris 'BinGOs' Williams <[email protected]> Date: Tue Oct 1 13:10:22 2013 +0100 Update Parse-CPAN-Meta to CPAN version 1.4409 [DELTA] 1.4409 2013-09-23 13:17:18 America/New_York [FIXED] - updated Makefile.PL logic to support PERL_NO_HIGHLANDER 1.4408 2013-09-23 11:06:35 America/New_York [FIXED] - Installation on Perls < 5.12 will uninstall older versions installed due to being bundled with ExtUtils::MakeMaker M Porting/Maintainers.pl M cpan/Parse-CPAN-Meta/Changes M cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm commit 9c5cc6d5f2f3230ec5491e7c32b781210129c3cd Author: Chris 'BinGOs' Williams <[email protected]> Date: Tue Oct 1 13:08:33 2013 +0100 Update CPAN-Meta-YAML to CPAN version 0.010 [DELTA] 0.010 2013-09-23 13:11:20 America/New_York - Generated from ETHER/YAML-Tiny-1.55.tar.gz - Fix broken test when copying from YAML-Tiny - updated Makefile.PL logic to support PERL_NO_HIGHLANDER 0.009 2013-09-23 10:16:19 America/New_York - Generated from ETHER/YAML-Tiny-1.55.tar.gz - Makefile.PL will use UNINST=1 on old perls that might have an old version incorrectly installed into the core library path M Porting/Maintainers.pl M cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm M cpan/CPAN-Meta-YAML/t/01_compile.t M cpan/CPAN-Meta-YAML/t/02_basic.t M cpan/CPAN-Meta-YAML/t/03_regression.t M cpan/CPAN-Meta-YAML/t/05_export.t M cpan/CPAN-Meta-YAML/t/11_meta_yml.t M cpan/CPAN-Meta-YAML/t/12_plagger.t M cpan/CPAN-Meta-YAML/t/13_perl_smith.t M cpan/CPAN-Meta-YAML/t/14_yaml_org.t M cpan/CPAN-Meta-YAML/t/15_multibyte.t M cpan/CPAN-Meta-YAML/t/16_nullrefs.t M cpan/CPAN-Meta-YAML/t/17_toolbar.t M cpan/CPAN-Meta-YAML/t/18_tap.t M cpan/CPAN-Meta-YAML/t/19_errors.t M cpan/CPAN-Meta-YAML/t/20_subclass.t M cpan/CPAN-Meta-YAML/t/21_bom.t M cpan/CPAN-Meta-YAML/t/22_comments.t M cpan/CPAN-Meta-YAML/t/lib/Test.pm commit 7867c8228bb087815f7050b80053680ad9ccb2e6 Author: Chris 'BinGOs' Williams <[email protected]> Date: Tue Oct 1 13:06:43 2013 +0100 Update Getopt-Long to CPAN version 2.42 [DELTA] Changes in version 2.42 ----------------------- * Fix bug https://rt.cpan.org/Ticket/Display.html?id=88707 M Porting/Maintainers.pl M cpan/Getopt-Long/CHANGES M cpan/Getopt-Long/lib/Getopt/Long.pm ----------------------------------------------------------------------- Summary of changes: META.json | 2 +- META.yml | 2 +- Porting/Maintainers.pl | 10 +- cpan/CPAN-Meta-Requirements/Changes | 19 +- .../lib/CPAN/Meta/Requirements.pm | 10 +- cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm | 1056 ++++++++++---------- cpan/CPAN-Meta-YAML/t/01_compile.t | 8 +- cpan/CPAN-Meta-YAML/t/02_basic.t | 230 ++--- cpan/CPAN-Meta-YAML/t/03_regression.t | 426 ++++---- cpan/CPAN-Meta-YAML/t/05_export.t | 8 +- cpan/CPAN-Meta-YAML/t/11_meta_yml.t | 498 ++++----- cpan/CPAN-Meta-YAML/t/12_plagger.t | 114 +-- cpan/CPAN-Meta-YAML/t/13_perl_smith.t | 252 ++--- cpan/CPAN-Meta-YAML/t/14_yaml_org.t | 76 +- cpan/CPAN-Meta-YAML/t/15_multibyte.t | 40 +- cpan/CPAN-Meta-YAML/t/16_nullrefs.t | 14 +- cpan/CPAN-Meta-YAML/t/17_toolbar.t | 52 +- cpan/CPAN-Meta-YAML/t/18_tap.t | 86 +- cpan/CPAN-Meta-YAML/t/19_errors.t | 12 +- cpan/CPAN-Meta-YAML/t/20_subclass.t | 52 +- cpan/CPAN-Meta-YAML/t/21_bom.t | 14 +- cpan/CPAN-Meta-YAML/t/22_comments.t | 100 +- cpan/CPAN-Meta-YAML/t/lib/Test.pm | 490 ++++----- cpan/CPAN-Meta/Changes | 18 + cpan/CPAN-Meta/lib/CPAN/Meta.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/History.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm | 4 +- cpan/Getopt-Long/CHANGES | 5 + cpan/Getopt-Long/lib/Getopt/Long.pm | 11 +- cpan/Parse-CPAN-Meta/Changes | 145 ++- cpan/Parse-CPAN-Meta/lib/Parse/CPAN/Meta.pm | 8 +- 35 files changed, 1943 insertions(+), 1843 deletions(-) diff --git a/META.json b/META.json index e5821b8..7506812 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "[email protected]" ], "dynamic_config" : 1, - "generated_by" : "CPAN::Meta version 2.132620", + "generated_by" : "CPAN::Meta version 2.132661", "license" : [ "perl_5" ], diff --git a/META.yml b/META.yml index ea72cb3..4a3bcd4 100644 --- a/META.yml +++ b/META.yml @@ -4,7 +4,7 @@ author: - [email protected] build_requires: {} dynamic_config: 1 -generated_by: 'CPAN::Meta version 2.132620, CPAN::Meta::Converter version 2.132620' +generated_by: 'CPAN::Meta version 2.132661, CPAN::Meta::Converter version 2.132661' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 9dc057f..4df2940 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -454,7 +454,7 @@ use File::Glob qw(:case); # perl -Icpan/CPAN-Meta/lib Porting/makemeta 'CPAN::Meta' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-2.132620.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-2.132661.tar.gz', 'FILES' => q[cpan/CPAN-Meta], 'EXCLUDED' => [ qw(t/00-compile.t), @@ -468,7 +468,7 @@ use File::Glob qw(:case); 'CPAN::Meta::Requirements' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-Requirements-2.123.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-Requirements-2.125.tar.gz', 'FILES' => q[cpan/CPAN-Meta-Requirements], 'EXCLUDED' => [ qw(t/00-compile.t), @@ -481,7 +481,7 @@ use File::Glob qw(:case); 'CPAN::Meta::YAML' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-YAML-0.008.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-YAML-0.010.tar.gz', 'FILES' => q[cpan/CPAN-Meta-YAML], 'EXCLUDED' => [ 't/00-compile.t', @@ -887,7 +887,7 @@ use File::Glob qw(:case); 'Getopt::Long' => { 'MAINTAINER' => 'jv', - 'DISTRIBUTION' => 'JV/Getopt-Long-2.41.tar.gz', + 'DISTRIBUTION' => 'JV/Getopt-Long-2.42.tar.gz', 'FILES' => q[cpan/Getopt-Long], 'EXCLUDED' => [ qr{^examples/}, @@ -1313,7 +1313,7 @@ use File::Glob qw(:case); 'Parse::CPAN::Meta' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/Parse-CPAN-Meta-1.4407.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/Parse-CPAN-Meta-1.4409.tar.gz', 'FILES' => q[cpan/Parse-CPAN-Meta], 'EXCLUDED' => [ qw(t/00-compile.t), diff --git a/cpan/CPAN-Meta-Requirements/Changes b/cpan/CPAN-Meta-Requirements/Changes index bbe42f3..dbfbf99 100644 --- a/cpan/CPAN-Meta-Requirements/Changes +++ b/cpan/CPAN-Meta-Requirements/Changes @@ -1,8 +1,23 @@ Revision history for CPAN-Meta-Requirements +2.125 2013-09-23 14:51:14 America/New_York + + [FIXED] + + - updated Makefile.PL logic to support PERL_NO_HIGHLANDER + +2.124 2013-09-23 06:40:07 America/New_York + + [FIXED] + + - Better fix than 2.123. On old perls, rather than install into + 'core', we continue to install into the proper 'site' library, + but force UNINST=1 when necessary to remove stale copies + from ExtUtils::MakeMaker + 2.123 2013-08-30 12:17:14 America/New_York - [Fixed] + [FIXED] - On Perls prior to v5.12, CPAN::Meta::Requirements will be installed into the 'core' library path to avoid an older version bundled with @@ -10,7 +25,7 @@ Revision history for CPAN-Meta-Requirements 2.122 2012-05-02 17:29:17 America/New_York - [Fixed] + [FIXED] - Fix typo in documentation: the exclusion symbol is "!=" rather than just "!". The implemenation was correct, just the docs were wrong. diff --git a/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm b/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm index e552e68..621550c 100644 --- a/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm +++ b/cpan/CPAN-Meta-Requirements/lib/CPAN/Meta/Requirements.pm @@ -1,7 +1,7 @@ use strict; use warnings; package CPAN::Meta::Requirements; -our $VERSION = '2.123'; # VERSION +our $VERSION = '2.125'; # VERSION # ABSTRACT: a set of version requirements for a CPAN dist @@ -444,7 +444,7 @@ CPAN::Meta::Requirements - a set of version requirements for a CPAN dist =head1 VERSION -version 2.123 +version 2.125 =head1 SYNOPSIS @@ -694,7 +694,7 @@ CPAN::Meta::Requirements object. =head2 Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker -at L<https://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Meta-Requirements>. +at L<https://github.com/dagolden/CPAN-Meta-Requirements/issues>. You will be notified automatically of any progress on your issue. =head2 Source Code @@ -702,9 +702,9 @@ You will be notified automatically of any progress on your issue. This is open source software. The code repository is available for public review and contribution under the terms of the license. -L<https://github.com/dagolden/cpan-meta-requirements> +L<https://github.com/dagolden/CPAN-Meta-Requirements> - git clone git://github.com/dagolden/cpan-meta-requirements.git + git clone https://github.com/dagolden/CPAN-Meta-Requirements.git =head1 AUTHORS diff --git a/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm b/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm index a9f4d6d..260f806 100644 --- a/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm +++ b/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm @@ -1,29 +1,38 @@ package CPAN::Meta::YAML; { - $CPAN::Meta::YAML::VERSION = '0.008'; + $CPAN::Meta::YAML::VERSION = '0.010'; } +BEGIN { + $CPAN::Meta::YAML::AUTHORITY = 'cpan:ADAMK'; +} +{ +; # original $VERSION removed by Doppelgaenger +} +# git description: v1.54-8-g4c3002d + use strict; +use warnings; # UTF Support? sub HAVE_UTF8 () { $] >= 5.007003 } BEGIN { - if ( HAVE_UTF8 ) { - # The string eval helps hide this from Test::MinimumVersion - eval "require utf8;"; - die "Failed to load UTF-8 support" if $@; - } - - # Class structure - require 5.004; - require Exporter; - require Carp; - @CPAN::Meta::YAML::ISA = qw{ Exporter }; - @CPAN::Meta::YAML::EXPORT = qw{ Load Dump }; - @CPAN::Meta::YAML::EXPORT_OK = qw{ LoadFile DumpFile freeze thaw }; - - # Error storage - $CPAN::Meta::YAML::errstr = ''; + if ( HAVE_UTF8 ) { + # The string eval helps hide this from Test::MinimumVersion + eval "require utf8;"; + die "Failed to load UTF-8 support" if $@; + } + + # Class structure + require 5.004; + require Exporter; + require Carp; + @CPAN::Meta::YAML::ISA = qw{ Exporter }; + @CPAN::Meta::YAML::EXPORT = qw{ Load Dump }; + @CPAN::Meta::YAML::EXPORT_OK = qw{ LoadFile DumpFile freeze thaw }; + + # Error storage + $CPAN::Meta::YAML::errstr = ''; } # The character class of all characters we need to escape @@ -33,25 +42,25 @@ BEGIN { # Printed form of the unprintable characters in the lowest range # of ASCII characters, listed by ASCII ordinal position. my @UNPRINTABLE = qw( - z x01 x02 x03 x04 x05 x06 a - x08 t n v f r x0e x0f - x10 x11 x12 x13 x14 x15 x16 x17 - x18 x19 x1a e x1c x1d x1e x1f + z x01 x02 x03 x04 x05 x06 a + x08 t n v f r x0e x0f + x10 x11 x12 x13 x14 x15 x16 x17 + x18 x19 x1a e x1c x1d x1e x1f ); # Printable characters for escapes my %UNESCAPES = ( - z => "\x00", a => "\x07", t => "\x09", - n => "\x0a", v => "\x0b", f => "\x0c", - r => "\x0d", e => "\x1b", '\\' => '\\', + z => "\x00", a => "\x07", t => "\x09", + n => "\x0a", v => "\x0b", f => "\x0c", + r => "\x0d", e => "\x1b", '\\' => '\\', ); # Special magic boolean words my %QUOTE = map { $_ => 1 } qw{ - null Null NULL - y Y yes Yes YES n N no No NO - true True TRUE false False FALSE - on On ON off Off OFF + null Null NULL + y Y yes Yes YES n N no No NO + true True TRUE false False FALSE + on On ON off Off OFF }; @@ -63,496 +72,496 @@ my %QUOTE = map { $_ => 1 } qw{ # Create an empty CPAN::Meta::YAML object sub new { - my $class = shift; - bless [ @_ ], $class; + my $class = shift; + bless [ @_ ], $class; } # Create an object from a file sub read { - my $class = ref $_[0] ? ref shift : shift; - - # Check the file - my $file = shift or return $class->_error( 'You did not specify a file name' ); - return $class->_error( "File '$file' does not exist" ) unless -e $file; - return $class->_error( "'$file' is a directory, not a file" ) unless -f _; - return $class->_error( "Insufficient permissions to read '$file'" ) unless -r _; - - # Slurp in the file - local $/ = undef; - local *CFG; - unless ( open(CFG, $file) ) { - return $class->_error("Failed to open file '$file': $!"); - } - my $contents = <CFG>; - unless ( close(CFG) ) { - return $class->_error("Failed to close file '$file': $!"); - } - - $class->read_string( $contents ); + my $class = ref $_[0] ? ref shift : shift; + + # Check the file + my $file = shift or return $class->_error( 'You did not specify a file name' ); + return $class->_error( "File '$file' does not exist" ) unless -e $file; + return $class->_error( "'$file' is a directory, not a file" ) unless -f _; + return $class->_error( "Insufficient permissions to read '$file'" ) unless -r _; + + # Slurp in the file + local $/ = undef; + local *CFG; + unless ( open(CFG, $file) ) { + return $class->_error("Failed to open file '$file': $!"); + } + my $contents = <CFG>; + unless ( close(CFG) ) { + return $class->_error("Failed to close file '$file': $!"); + } + + $class->read_string( $contents ); } # Create an object from a string sub read_string { - my $class = ref $_[0] ? ref shift : shift; - my $self = bless [], $class; - my $string = $_[0]; - eval { - unless ( defined $string ) { - die \"Did not provide a string to load"; - } - - # Byte order marks - # NOTE: Keeping this here to educate maintainers - # my %BOM = ( - # "\357\273\277" => 'UTF-8', - # "\376\377" => 'UTF-16BE', - # "\377\376" => 'UTF-16LE', - # "\377\376\0\0" => 'UTF-32LE' - # "\0\0\376\377" => 'UTF-32BE', - # ); - if ( $string =~ /^(?:\376\377|\377\376|\377\376\0\0|\0\0\376\377)/ ) { - die \"Stream has a non UTF-8 BOM"; - } else { - # Strip UTF-8 bom if found, we'll just ignore it - $string =~ s/^\357\273\277//; - } - - # Try to decode as utf8 - utf8::decode($string) if HAVE_UTF8; - - # Check for some special cases - return $self unless length $string; - unless ( $string =~ /[\012\015]+\z/ ) { - die \"Stream does not end with newline character"; - } - - # Split the file into lines - my @lines = grep { ! /^\s*(?:\#.*)?\z/ } - split /(?:\015{1,2}\012|\015|\012)/, $string; - - # Strip the initial YAML header - @lines and $lines[0] =~ /^\%YAML[: ][\d\.]+.*\z/ and shift @lines; - - # A nibbling parser - while ( @lines ) { - # Do we have a document header? - if ( $lines[0] =~ /^---\s*(?:(.+)\s*)?\z/ ) { - # Handle scalar documents - shift @lines; - if ( defined $1 and $1 !~ /^(?:\#.+|\%YAML[: ][\d\.]+)\z/ ) { - push @$self, $self->_read_scalar( "$1", [ undef ], \@lines ); - next; - } - } - - if ( ! @lines or $lines[0] =~ /^(?:---|\.\.\.)/ ) { - # A naked document - push @$self, undef; - while ( @lines and $lines[0] !~ /^---/ ) { - shift @lines; - } - - } elsif ( $lines[0] =~ /^\s*\-/ ) { - # An array at the root - my $document = [ ]; - push @$self, $document; - $self->_read_array( $document, [ 0 ], \@lines ); - - } elsif ( $lines[0] =~ /^(\s*)\S/ ) { - # A hash at the root - my $document = { }; - push @$self, $document; - $self->_read_hash( $document, [ length($1) ], \@lines ); - - } else { - die \"CPAN::Meta::YAML failed to classify the line '$lines[0]'"; - } - } - }; - if ( ref $@ eq 'SCALAR' ) { - return $self->_error(${$@}); - } elsif ( $@ ) { - require Carp; - Carp::croak($@); - } - - return $self; + my $class = ref $_[0] ? ref shift : shift; + my $self = bless [], $class; + my $string = $_[0]; + eval { + unless ( defined $string ) { + die \"Did not provide a string to load"; + } + + # Byte order marks + # NOTE: Keeping this here to educate maintainers + # my %BOM = ( + # "\357\273\277" => 'UTF-8', + # "\376\377" => 'UTF-16BE', + # "\377\376" => 'UTF-16LE', + # "\377\376\0\0" => 'UTF-32LE' + # "\0\0\376\377" => 'UTF-32BE', + # ); + if ( $string =~ /^(?:\376\377|\377\376|\377\376\0\0|\0\0\376\377)/ ) { + die \"Stream has a non UTF-8 BOM"; + } else { + # Strip UTF-8 bom if found, we'll just ignore it + $string =~ s/^\357\273\277//; + } + + # Try to decode as utf8 + utf8::decode($string) if HAVE_UTF8; + + # Check for some special cases + return $self unless length $string; + unless ( $string =~ /[\012\015]+\z/ ) { + die \"Stream does not end with newline character"; + } + + # Split the file into lines + my @lines = grep { ! /^\s*(?:\#.*)?\z/ } + split /(?:\015{1,2}\012|\015|\012)/, $string; + + # Strip the initial YAML header + @lines and $lines[0] =~ /^\%YAML[: ][\d\.]+.*\z/ and shift @lines; + + # A nibbling parser + while ( @lines ) { + # Do we have a document header? + if ( $lines[0] =~ /^---\s*(?:(.+)\s*)?\z/ ) { + # Handle scalar documents + shift @lines; + if ( defined $1 and $1 !~ /^(?:\#.+|\%YAML[: ][\d\.]+)\z/ ) { + push @$self, $self->_read_scalar( "$1", [ undef ], \@lines ); + next; + } + } + + if ( ! @lines or $lines[0] =~ /^(?:---|\.\.\.)/ ) { + # A naked document + push @$self, undef; + while ( @lines and $lines[0] !~ /^---/ ) { + shift @lines; + } + + } elsif ( $lines[0] =~ /^\s*\-/ ) { + # An array at the root + my $document = [ ]; + push @$self, $document; + $self->_read_array( $document, [ 0 ], \@lines ); + + } elsif ( $lines[0] =~ /^(\s*)\S/ ) { + # A hash at the root + my $document = { }; + push @$self, $document; + $self->_read_hash( $document, [ length($1) ], \@lines ); + + } else { + die \"CPAN::Meta::YAML failed to classify the line '$lines[0]'"; + } + } + }; + if ( ref $@ eq 'SCALAR' ) { + return $self->_error(${$@}); + } elsif ( $@ ) { + require Carp; + Carp::croak($@); + } + + return $self; } # Deparse a scalar string to the actual scalar sub _read_scalar { - my ($self, $string, $indent, $lines) = @_; - - # Trim trailing whitespace - $string =~ s/\s*\z//; - - # Explitic null/undef - return undef if $string eq '~'; - - # Single quote - if ( $string =~ /^\'(.*?)\'(?:\s+\#.*)?\z/ ) { - return '' unless defined $1; - $string = $1; - $string =~ s/\'\'/\'/g; - return $string; - } - - # Double quote. - # The commented out form is simpler, but overloaded the Perl regex - # engine due to recursion and backtracking problems on strings - # larger than 32,000ish characters. Keep it for reference purposes. - # if ( $string =~ /^\"((?:\\.|[^\"])*)\"\z/ ) { - if ( $string =~ /^\"([^\\"]*(?:\\.[^\\"]*)*)\"(?:\s+\#.*)?\z/ ) { - # Reusing the variable is a little ugly, - # but avoids a new variable and a string copy. - $string = $1; - $string =~ s/\\"/"/g; - $string =~ s/\\([never\\fartz]|x([0-9a-fA-F]{2}))/(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}/gex; - return $string; - } - - # Special cases - if ( $string =~ /^[\'\"!&]/ ) { - die \"CPAN::Meta::YAML does not support a feature in line '$string'"; - } - return {} if $string =~ /^{}(?:\s+\#.*)?\z/; - return [] if $string =~ /^\[\](?:\s+\#.*)?\z/; - - # Regular unquoted string - if ( $string !~ /^[>|]/ ) { - if ( - $string =~ /^(?:-(?:\s|$)|[\@\%\`])/ - or - $string =~ /:(?:\s|$)/ - ) { - die \"CPAN::Meta::YAML found illegal characters in plain scalar: '$string'"; - } - $string =~ s/\s+#.*\z//; - return $string; - } - - # Error - die \"CPAN::Meta::YAML failed to find multi-line scalar content" unless @$lines; - - # Check the indent depth - $lines->[0] =~ /^(\s*)/; - $indent->[-1] = length("$1"); - if ( defined $indent->[-2] and $indent->[-1] <= $indent->[-2] ) { - die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; - } - - # Pull the lines - my @multiline = (); - while ( @$lines ) { - $lines->[0] =~ /^(\s*)/; - last unless length($1) >= $indent->[-1]; - push @multiline, substr(shift(@$lines), length($1)); - } - - my $j = (substr($string, 0, 1) eq '>') ? ' ' : "\n"; - my $t = (substr($string, 1, 1) eq '-') ? '' : "\n"; - return join( $j, @multiline ) . $t; + my ($self, $string, $indent, $lines) = @_; + + # Trim trailing whitespace + $string =~ s/\s*\z//; + + # Explitic null/undef + return undef if $string eq '~'; + + # Single quote + if ( $string =~ /^\'(.*?)\'(?:\s+\#.*)?\z/ ) { + return '' unless defined $1; + $string = $1; + $string =~ s/\'\'/\'/g; + return $string; + } + + # Double quote. + # The commented out form is simpler, but overloaded the Perl regex + # engine due to recursion and backtracking problems on strings + # larger than 32,000ish characters. Keep it for reference purposes. + # if ( $string =~ /^\"((?:\\.|[^\"])*)\"\z/ ) { + if ( $string =~ /^\"([^\\"]*(?:\\.[^\\"]*)*)\"(?:\s+\#.*)?\z/ ) { + # Reusing the variable is a little ugly, + # but avoids a new variable and a string copy. + $string = $1; + $string =~ s/\\"/"/g; + $string =~ s/\\([never\\fartz]|x([0-9a-fA-F]{2}))/(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}/gex; + return $string; + } + + # Special cases + if ( $string =~ /^[\'\"!&]/ ) { + die \"CPAN::Meta::YAML does not support a feature in line '$string'"; + } + return {} if $string =~ /^{}(?:\s+\#.*)?\z/; + return [] if $string =~ /^\[\](?:\s+\#.*)?\z/; + + # Regular unquoted string + if ( $string !~ /^[>|]/ ) { + if ( + $string =~ /^(?:-(?:\s|$)|[\@\%\`])/ + or + $string =~ /:(?:\s|$)/ + ) { + die \"CPAN::Meta::YAML found illegal characters in plain scalar: '$string'"; + } + $string =~ s/\s+#.*\z//; + return $string; + } + + # Error + die \"CPAN::Meta::YAML failed to find multi-line scalar content" unless @$lines; + + # Check the indent depth + $lines->[0] =~ /^(\s*)/; + $indent->[-1] = length("$1"); + if ( defined $indent->[-2] and $indent->[-1] <= $indent->[-2] ) { + die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; + } + + # Pull the lines + my @multiline = (); + while ( @$lines ) { + $lines->[0] =~ /^(\s*)/; + last unless length($1) >= $indent->[-1]; + push @multiline, substr(shift(@$lines), length($1)); + } + + my $j = (substr($string, 0, 1) eq '>') ? ' ' : "\n"; + my $t = (substr($string, 1, 1) eq '-') ? '' : "\n"; + return join( $j, @multiline ) . $t; } # Parse an array sub _read_array { - my ($self, $array, $indent, $lines) = @_; - - while ( @$lines ) { - # Check for a new document - if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { - while ( @$lines and $lines->[0] !~ /^---/ ) { - shift @$lines; - } - return 1; - } - - # Check the indent level - $lines->[0] =~ /^(\s*)/; - if ( length($1) < $indent->[-1] ) { - return 1; - } elsif ( length($1) > $indent->[-1] ) { - die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; - } - - if ( $lines->[0] =~ /^(\s*\-\s+)[^\'\"]\S*\s*:(?:\s+|$)/ ) { - # Inline nested hash - my $indent2 = length("$1"); - $lines->[0] =~ s/-/ /; - push @$array, { }; - $self->_read_hash( $array->[-1], [ @$indent, $indent2 ], $lines ); - - } elsif ( $lines->[0] =~ /^\s*\-(\s*)(.+?)\s*\z/ ) { - # Array entry with a value - shift @$lines; - push @$array, $self->_read_scalar( "$2", [ @$indent, undef ], $lines ); - - } elsif ( $lines->[0] =~ /^\s*\-\s*\z/ ) { - shift @$lines; - unless ( @$lines ) { - push @$array, undef; - return 1; - } - if ( $lines->[0] =~ /^(\s*)\-/ ) { - my $indent2 = length("$1"); - if ( $indent->[-1] == $indent2 ) { - # Null array entry - push @$array, undef; - } else { - # Naked indenter - push @$array, [ ]; - $self->_read_array( $array->[-1], [ @$indent, $indent2 ], $lines ); - } - - } elsif ( $lines->[0] =~ /^(\s*)\S/ ) { - push @$array, { }; - $self->_read_hash( $array->[-1], [ @$indent, length("$1") ], $lines ); - - } else { - die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; - } - - } elsif ( defined $indent->[-2] and $indent->[-1] == $indent->[-2] ) { - # This is probably a structure like the following... - # --- - # foo: - # - list - # bar: value - # - # ... so lets return and let the hash parser handle it - return 1; - - } else { - die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; - } - } - - return 1; + my ($self, $array, $indent, $lines) = @_; + + while ( @$lines ) { + # Check for a new document + if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { + while ( @$lines and $lines->[0] !~ /^---/ ) { + shift @$lines; + } + return 1; + } + + # Check the indent level + $lines->[0] =~ /^(\s*)/; + if ( length($1) < $indent->[-1] ) { + return 1; + } elsif ( length($1) > $indent->[-1] ) { + die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; + } + + if ( $lines->[0] =~ /^(\s*\-\s+)[^\'\"]\S*\s*:(?:\s+|$)/ ) { + # Inline nested hash + my $indent2 = length("$1"); + $lines->[0] =~ s/-/ /; + push @$array, { }; + $self->_read_hash( $array->[-1], [ @$indent, $indent2 ], $lines ); + + } elsif ( $lines->[0] =~ /^\s*\-(\s*)(.+?)\s*\z/ ) { + # Array entry with a value + shift @$lines; + push @$array, $self->_read_scalar( "$2", [ @$indent, undef ], $lines ); + + } elsif ( $lines->[0] =~ /^\s*\-\s*\z/ ) { + shift @$lines; + unless ( @$lines ) { + push @$array, undef; + return 1; + } + if ( $lines->[0] =~ /^(\s*)\-/ ) { + my $indent2 = length("$1"); + if ( $indent->[-1] == $indent2 ) { + # Null array entry + push @$array, undef; + } else { + # Naked indenter + push @$array, [ ]; + $self->_read_array( $array->[-1], [ @$indent, $indent2 ], $lines ); + } + + } elsif ( $lines->[0] =~ /^(\s*)\S/ ) { + push @$array, { }; + $self->_read_hash( $array->[-1], [ @$indent, length("$1") ], $lines ); + + } else { + die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; + } + + } elsif ( defined $indent->[-2] and $indent->[-1] == $indent->[-2] ) { + # This is probably a structure like the following... + # --- + # foo: + # - list + # bar: value + # + # ... so lets return and let the hash parser handle it + return 1; + + } else { + die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; + } + } + + return 1; } # Parse an array sub _read_hash { - my ($self, $hash, $indent, $lines) = @_; - - while ( @$lines ) { - # Check for a new document - if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { - while ( @$lines and $lines->[0] !~ /^---/ ) { - shift @$lines; - } - return 1; - } - - # Check the indent level - $lines->[0] =~ /^(\s*)/; - if ( length($1) < $indent->[-1] ) { - return 1; - } elsif ( length($1) > $indent->[-1] ) { - die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; - } - - # Get the key - unless ( $lines->[0] =~ s/^\s*([^\'\" ][^\n]*?)\s*:(\s+(?:\#.*)?|$)// ) { - if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { - die \"CPAN::Meta::YAML does not support a feature in line '$lines->[0]'"; - } - die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; - } - my $key = $1; - - # Do we have a value? - if ( length $lines->[0] ) { - # Yes - $hash->{$key} = $self->_read_scalar( shift(@$lines), [ @$indent, undef ], $lines ); - } else { - # An indent - shift @$lines; - unless ( @$lines ) { - $hash->{$key} = undef; - return 1; - } - if ( $lines->[0] =~ /^(\s*)-/ ) { - $hash->{$key} = []; - $self->_read_array( $hash->{$key}, [ @$indent, length($1) ], $lines ); - } elsif ( $lines->[0] =~ /^(\s*)./ ) { - my $indent2 = length("$1"); - if ( $indent->[-1] >= $indent2 ) { - # Null hash entry - $hash->{$key} = undef; - } else { - $hash->{$key} = {}; - $self->_read_hash( $hash->{$key}, [ @$indent, length($1) ], $lines ); - } - } - } - } - - return 1; + my ($self, $hash, $indent, $lines) = @_; + + while ( @$lines ) { + # Check for a new document + if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { + while ( @$lines and $lines->[0] !~ /^---/ ) { + shift @$lines; + } + return 1; + } + + # Check the indent level + $lines->[0] =~ /^(\s*)/; + if ( length($1) < $indent->[-1] ) { + return 1; + } elsif ( length($1) > $indent->[-1] ) { + die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; + } + + # Get the key + unless ( $lines->[0] =~ s/^\s*([^\'\" ][^\n]*?)\s*:(\s+(?:\#.*)?|$)// ) { + if ( $lines->[0] =~ /^\s*[?\'\"]/ ) { + die \"CPAN::Meta::YAML does not support a feature in line '$lines->[0]'"; + } + die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; + } + my $key = $1; + + # Do we have a value? + if ( length $lines->[0] ) { + # Yes + $hash->{$key} = $self->_read_scalar( shift(@$lines), [ @$indent, undef ], $lines ); + } else { + # An indent + shift @$lines; + unless ( @$lines ) { + $hash->{$key} = undef; + return 1; + } + if ( $lines->[0] =~ /^(\s*)-/ ) { + $hash->{$key} = []; + $self->_read_array( $hash->{$key}, [ @$indent, length($1) ], $lines ); + } elsif ( $lines->[0] =~ /^(\s*)./ ) { + my $indent2 = length("$1"); + if ( $indent->[-1] >= $indent2 ) { + # Null hash entry + $hash->{$key} = undef; + } else { + $hash->{$key} = {}; + $self->_read_hash( $hash->{$key}, [ @$indent, length($1) ], $lines ); + } + } + } + } + + return 1; } # Save an object to a file sub write { - my $self = shift; - my $file = shift or return $self->_error('No file name provided'); + my $self = shift; + my $file = shift or return $self->_error('No file name provided'); - # Write it to the file - open( CFG, '>' . $file ) or return $self->_error( - "Failed to open file '$file' for writing: $!" - ); - print CFG $self->write_string; - close CFG; + # Write it to the file + open( CFG, '>' . $file ) or return $self->_error( + "Failed to open file '$file' for writing: $!" + ); + print CFG $self->write_string; + close CFG; - return 1; + return 1; } # Save an object to a string sub write_string { - my $self = shift; - return '' unless @$self; - - # Iterate over the documents - my $indent = 0; - my @lines = (); - foreach my $cursor ( @$self ) { - push @lines, '---'; - - # An empty document - if ( ! defined $cursor ) { - # Do nothing - - # A scalar document - } elsif ( ! ref $cursor ) { - $lines[-1] .= ' ' . $self->_write_scalar( $cursor, $indent ); - - # A list at the root - } elsif ( ref $cursor eq 'ARRAY' ) { - unless ( @$cursor ) { - $lines[-1] .= ' []'; - next; - } - push @lines, $self->_write_array( $cursor, $indent, {} ); - - # A hash at the root - } elsif ( ref $cursor eq 'HASH' ) { - unless ( %$cursor ) { - $lines[-1] .= ' {}'; - next; - } - push @lines, $self->_write_hash( $cursor, $indent, {} ); - - } else { - Carp::croak("Cannot serialize " . ref($cursor)); - } - } - - join '', map { "$_\n" } @lines; + my $self = shift; + return '' unless @$self; + + # Iterate over the documents + my $indent = 0; + my @lines = (); + foreach my $cursor ( @$self ) { + push @lines, '---'; + + # An empty document + if ( ! defined $cursor ) { + # Do nothing + + # A scalar document + } elsif ( ! ref $cursor ) { + $lines[-1] .= ' ' . $self->_write_scalar( $cursor, $indent ); + + # A list at the root + } elsif ( ref $cursor eq 'ARRAY' ) { + unless ( @$cursor ) { + $lines[-1] .= ' []'; + next; + } + push @lines, $self->_write_array( $cursor, $indent, {} ); + + # A hash at the root + } elsif ( ref $cursor eq 'HASH' ) { + unless ( %$cursor ) { + $lines[-1] .= ' {}'; + next; + } + push @lines, $self->_write_hash( $cursor, $indent, {} ); + + } else { + Carp::croak("Cannot serialize " . ref($cursor)); + } + } + + join '', map { "$_\n" } @lines; } sub _write_scalar { - my $string = $_[1]; - return '~' unless defined $string; - return "''" unless length $string; - if ( $string =~ /[\x00-\x08\x0b-\x0d\x0e-\x1f\"\'\n]/ ) { - $string =~ s/\\/\\\\/g; - $string =~ s/"/\\"/g; - $string =~ s/\n/\\n/g; - $string =~ s/([\x00-\x1f])/\\$UNPRINTABLE[ord($1)]/g; - return qq|"$string"|; - } - if ( $string =~ /(?:^\W|\s|:\z)/ or $QUOTE{$string} ) { - return "'$string'"; - } - return $string; + my $string = $_[1]; + return '~' unless defined $string; + return "''" unless length $string; + if ( $string =~ /[\x00-\x08\x0b-\x0d\x0e-\x1f\"\'\n]/ ) { + $string =~ s/\\/\\\\/g; + $string =~ s/"/\\"/g; + $string =~ s/\n/\\n/g; + $string =~ s/([\x00-\x1f])/\\$UNPRINTABLE[ord($1)]/g; + return qq|"$string"|; + } + if ( $string =~ /(?:^\W|\s|:\z)/ or $QUOTE{$string} ) { + return "'$string'"; + } + return $string; } sub _write_array { - my ($self, $array, $indent, $seen) = @_; - if ( $seen->{refaddr($array)}++ ) { - die "CPAN::Meta::YAML does not support circular references"; - } - my @lines = (); - foreach my $el ( @$array ) { - my $line = (' ' x $indent) . '-'; - my $type = ref $el; - if ( ! $type ) { - $line .= ' ' . $self->_write_scalar( $el, $indent + 1 ); - push @lines, $line; - - } elsif ( $type eq 'ARRAY' ) { - if ( @$el ) { - push @lines, $line; - push @lines, $self->_write_array( $el, $indent + 1, $seen ); - } else { - $line .= ' []'; - push @lines, $line; - } - - } elsif ( $type eq 'HASH' ) { - if ( keys %$el ) { - push @lines, $line; - push @lines, $self->_write_hash( $el, $indent + 1, $seen ); - } else { - $line .= ' {}'; - push @lines, $line; - } - - } else { - die "CPAN::Meta::YAML does not support $type references"; - } - } - - @lines; + my ($self, $array, $indent, $seen) = @_; + if ( $seen->{refaddr($array)}++ ) { + die "CPAN::Meta::YAML does not support circular references"; + } + my @lines = (); + foreach my $el ( @$array ) { + my $line = (' ' x $indent) . '-'; + my $type = ref $el; + if ( ! $type ) { + $line .= ' ' . $self->_write_scalar( $el, $indent + 1 ); + push @lines, $line; + + } elsif ( $type eq 'ARRAY' ) { + if ( @$el ) { + push @lines, $line; + push @lines, $self->_write_array( $el, $indent + 1, $seen ); + } else { + $line .= ' []'; + push @lines, $line; + } + + } elsif ( $type eq 'HASH' ) { + if ( keys %$el ) { + push @lines, $line; + push @lines, $self->_write_hash( $el, $indent + 1, $seen ); + } else { + $line .= ' {}'; + push @lines, $line; + } + + } else { + die "CPAN::Meta::YAML does not support $type references"; + } + } + + @lines; } sub _write_hash { - my ($self, $hash, $indent, $seen) = @_; - if ( $seen->{refaddr($hash)}++ ) { - die "CPAN::Meta::YAML does not support circular references"; - } - my @lines = (); - foreach my $name ( sort keys %$hash ) { - my $el = $hash->{$name}; - my $line = (' ' x $indent) . "$name:"; - my $type = ref $el; - if ( ! $type ) { - $line .= ' ' . $self->_write_scalar( $el, $indent + 1 ); - push @lines, $line; - - } elsif ( $type eq 'ARRAY' ) { - if ( @$el ) { - push @lines, $line; - push @lines, $self->_write_array( $el, $indent + 1, $seen ); - } else { - $line .= ' []'; - push @lines, $line; - } - - } elsif ( $type eq 'HASH' ) { - if ( keys %$el ) { - push @lines, $line; - push @lines, $self->_write_hash( $el, $indent + 1, $seen ); - } else { - $line .= ' {}'; - push @lines, $line; - } - - } else { - die "CPAN::Meta::YAML does not support $type references"; - } - } - - @lines; + my ($self, $hash, $indent, $seen) = @_; + if ( $seen->{refaddr($hash)}++ ) { + die "CPAN::Meta::YAML does not support circular references"; + } + my @lines = (); + foreach my $name ( sort keys %$hash ) { + my $el = $hash->{$name}; + my $line = (' ' x $indent) . "$name:"; + my $type = ref $el; + if ( ! $type ) { + $line .= ' ' . $self->_write_scalar( $el, $indent + 1 ); + push @lines, $line; + + } elsif ( $type eq 'ARRAY' ) { + if ( @$el ) { + push @lines, $line; + push @lines, $self->_write_array( $el, $indent + 1, $seen ); + } else { + $line .= ' []'; + push @lines, $line; + } + + } elsif ( $type eq 'HASH' ) { + if ( keys %$el ) { + push @lines, $line; + push @lines, $self->_write_hash( $el, $indent + 1, $seen ); + } else { + $line .= ' {}'; + push @lines, $line; + } + + } else { + die "CPAN::Meta::YAML does not support $type references"; + } + } + + @lines; } # Set error sub _error { - $CPAN::Meta::YAML::errstr = $_[1]; - undef; + $CPAN::Meta::YAML::errstr = $_[1]; + undef; } # Retrieve error sub errstr { - $CPAN::Meta::YAML::errstr; + $CPAN::Meta::YAML::errstr; } @@ -563,43 +572,43 @@ sub errstr { # YAML Compatibility sub Dump { - CPAN::Meta::YAML->new(@_)->write_string; + CPAN::Meta::YAML->new(@_)->write_string; } sub Load { - my $self = CPAN::Meta::YAML->read_string(@_); - unless ( $self ) { - Carp::croak("Failed to load YAML document from string"); - } - if ( wantarray ) { - return @$self; - } else { - # To match YAML.pm, return the last document - return $self->[-1]; - } + my $self = CPAN::Meta::YAML->read_string(@_); + unless ( $self ) { + Carp::croak("Failed to load YAML document from string"); + } + if ( wantarray ) { + return @$self; + } else { + # To match YAML.pm, return the last document + return $self->[-1]; + } } BEGIN { - *freeze = *Dump; - *thaw = *Load; + *freeze = *Dump; + *thaw = *Load; } sub DumpFile { - my $file = shift; - CPAN::Meta::YAML->new(@_)->write($file); + my $file = shift; + CPAN::Meta::YAML->new(@_)->write($file); } sub LoadFile { - my $self = CPAN::Meta::YAML->read($_[0]); - unless ( $self ) { - Carp::croak("Failed to load YAML document from '" . ($_[0] || '') . "'"); - } - if ( wantarray ) { - return @$self; - } else { - # Return only the last document to match YAML.pm, - return $self->[-1]; - } + my $self = CPAN::Meta::YAML->read($_[0]); + unless ( $self ) { + Carp::croak("Failed to load YAML document from '" . ($_[0] || '') . "'"); + } + if ( wantarray ) { + return @$self; + } else { + # Return only the last document to match YAML.pm, + return $self->[-1]; + } } @@ -610,45 +619,45 @@ sub LoadFile { # Use Scalar::Util if possible, otherwise emulate it BEGIN { - local $@; - eval { - require Scalar::Util; - }; - my $v = eval("$Scalar::Util::VERSION") || 0; - if ( $@ or $v < 1.18 ) { - eval <<'END_PERL'; + local $@; + eval { + require Scalar::Util; + }; + my $v = eval("$Scalar::Util::VERSION") || 0; + if ( $@ or $v < 1.18 ) { + eval <<'END_PERL'; # Scalar::Util failed to load or too old sub refaddr { - my $pkg = ref($_[0]) or return undef; - if ( !! UNIVERSAL::can($_[0], 'can') ) { - bless $_[0], 'Scalar::Util::Fake'; - } else { - $pkg = undef; - } - "$_[0]" =~ /0x(\w+)/; - my $i = do { local $^W; hex $1 }; - bless $_[0], $pkg if defined $pkg; - $i; + my $pkg = ref($_[0]) or return undef; + if ( !! UNIVERSAL::can($_[0], 'can') ) { + bless $_[0], 'Scalar::Util::Fake'; + } else { + $pkg = undef; + } + "$_[0]" =~ /0x(\w+)/; + my $i = do { local $^W; hex $1 }; + bless $_[0], $pkg if defined $pkg; + $i; } END_PERL - } else { - *refaddr = *Scalar::Util::refaddr; - } + } else { + *refaddr = *Scalar::Util::refaddr; + } } 1; - - =pod +=encoding utf-8 + =head1 NAME CPAN::Meta::YAML - Read and write a subset of YAML for CPAN Meta files =head1 VERSION -version 0.008 +version 0.010 =head1 SYNOPSIS @@ -684,7 +693,7 @@ C<write> methods do B<not> support UTF-8 and should not be used. This module is currently derived from L<YAML::Tiny> by Adam Kennedy. If there are bugs in how it parses a particular META.yml file, please file a bug report in the YAML::Tiny bugtracker: -L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=YAML-Tiny> +L<https://rt.cpan.org/Public/Dist/Display.html?Name=YAML-Tiny> =head1 SEE ALSO @@ -697,7 +706,7 @@ L<YAML::Tiny>, L<YAML>, L<YAML::XS> =head2 Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker -at L<http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Meta-YAML>. +at L<https://github.com/dagolden/CPAN-Meta-YAML/issues>. You will be notified automatically of any progress on your issue. =head2 Source Code @@ -705,9 +714,9 @@ You will be notified automatically of any progress on your issue. This is open source software. The code repository is available for public review and contribution under the terms of the license. -L<https://github.com/dagolden/cpan-meta-yaml> +L<https://github.com/dagolden/CPAN-Meta-YAML> - git clone https://github.com/dagolden/cpan-meta-yaml.git + git clone https://github.com/dagolden/CPAN-Meta-YAML.git =head1 AUTHORS @@ -732,7 +741,6 @@ the same terms as the Perl 5 programming language system itself. =cut - __END__ diff --git a/cpan/CPAN-Meta-YAML/t/01_compile.t b/cpan/CPAN-Meta-YAML/t/01_compile.t index bac1b9c..d85d9aa 100644 --- a/cpan/CPAN-Meta-YAML/t/01_compile.t +++ b/cpan/CPAN-Meta-YAML/t/01_compile.t @@ -1,11 +1,11 @@ -#!/usr/bin/perl - # Load testing for CPAN::Meta::YAML use strict; +use warnings; + BEGIN { - $| = 1; - $^W = 1; + $| = 1; + $^W = 1; } use File::Spec::Functions ':ALL'; diff --git a/cpan/CPAN-Meta-YAML/t/02_basic.t b/cpan/CPAN-Meta-YAML/t/02_basic.t index 14d1132..1aa3686 100644 --- a/cpan/CPAN-Meta-YAML/t/02_basic.t +++ b/cpan/CPAN-Meta-YAML/t/02_basic.t @@ -1,11 +1,11 @@ -#!/usr/bin/perl - # Testing of basic document structures use strict; +use warnings; + BEGIN { - $| = 1; - $^W = 1; + $| = 1; + $^W = 1; } use File::Spec::Functions ':ALL'; @@ -22,138 +22,138 @@ use CPAN::Meta::YAML; # Test a completely empty document yaml_ok( - '', - [ ], - 'empty', + '', + [ ], + 'empty', ); # Just a newline ### YAML.pm has a bug where it dies on a single newline yaml_ok( - "\n\n", - [ ], - 'only_newlines', + "\n\n", + [ ], + 'only_newlines', ); # Just a comment yaml_ok( - "# comment\n", - [ ], - 'only_comment', + "# comment\n", + [ ], + 'only_comment', ); # Empty documents yaml_ok( - "---\n", - [ undef ], - 'only_header', - noyamlperl => 1, + "---\n", + [ undef ], + 'only_header', + noyamlperl => 1, ); yaml_ok( - "---\n---\n", - [ undef, undef ], - 'two_header', - noyamlperl => 1, + "---\n---\n", + [ undef, undef ], + 'two_header', + noyamlperl => 1, ); yaml_ok( - "--- ~\n", - [ undef ], - 'one_undef', - noyamlperl => 1, + "--- ~\n", + [ undef ], + 'one_undef', + noyamlperl => 1, ); yaml_ok( - "--- ~\n", - [ undef ], - 'one_undef2', - noyamlperl => 1, + "--- ~\n", + [ undef ], + 'one_undef2', + noyamlperl => 1, ); yaml_ok( - "--- ~\n---\n", - [ undef, undef ], - 'two_undef', - noyamlperl => 1, + "--- ~\n---\n", + [ undef, undef ], + 'two_undef', + noyamlperl => 1, ); # Just a scalar yaml_ok( - "--- foo\n", - [ 'foo' ], - 'one_scalar', + "--- foo\n", + [ 'foo' ], + 'one_scalar', ); yaml_ok( - "--- foo\n", - [ 'foo' ], - 'one_scalar2', + "--- foo\n", + [ 'foo' ], + 'one_scalar2', ); yaml_ok( - "--- foo\n--- bar\n", - [ 'foo', 'bar' ], - 'two_scalar', - noyamlperl => 1, + "--- foo\n--- bar\n", + [ 'foo', 'bar' ], + 'two_scalar', + noyamlperl => 1, ); # Simple lists yaml_ok( - "---\n- foo\n", - [ [ 'foo' ] ], - 'one_list1', + "---\n- foo\n", + [ [ 'foo' ] ], + 'one_list1', ); yaml_ok( - "---\n- foo\n- bar\n", - [ [ 'foo', 'bar' ] ], - 'one_list2', + "---\n- foo\n- bar\n", + [ [ 'foo', 'bar' ] ], + 'one_list2', ); yaml_ok( - "---\n- ~\n- bar\n", - [ [ undef, 'bar' ] ], - 'one_listundef', - noyamlperl => 1, + "---\n- ~\n- bar\n", + [ [ undef, 'bar' ] ], + 'one_listundef', + noyamlperl => 1, ); # Simple hashs yaml_ok( - "---\nfoo: bar\n", - [ { foo => 'bar' } ], - 'one_hash1', + "---\nfoo: bar\n", + [ { foo => 'bar' } ], + 'one_hash1', ); yaml_ok( - "---\nfoo: bar\nthis: ~\n", - [ { this => undef, foo => 'bar' } ], - 'one_hash2', - noyamlperl => 1, + "---\nfoo: bar\nthis: ~\n", + [ { this => undef, foo => 'bar' } ], + 'one_hash2', + noyamlperl => 1, ); # Simple array inside a hash with an undef yaml_ok( - <<'END_YAML', + <<'END_YAML', --- foo: - bar - ~ - baz END_YAML - [ { foo => [ 'bar', undef, 'baz' ] } ], - 'array_in_hash', - noyamlperl => 1, + [ { foo => [ 'bar', undef, 'baz' ] } ], + 'array_in_hash', + noyamlperl => 1, ); # Simple hash inside a hash with an undef yaml_ok( - <<'END_YAML', + <<'END_YAML', --- foo: ~ bar: foo: bar END_YAML - [ { foo => undef, bar => { foo => 'bar' } } ], - 'hash_in_hash', - noyamlperl => 1, + [ { foo => undef, bar => { foo => 'bar' } } ], + 'hash_in_hash', + noyamlperl => 1, ); # Mixed hash and scalars inside an array yaml_ok( - <<'END_YAML', + <<'END_YAML', --- - foo: ~ @@ -164,92 +164,92 @@ yaml_ok( foo: bar this: that END_YAML - [ [ - { foo => undef, this => 'that' }, - 'foo', - undef, - { foo => 'bar', this => 'that' }, - ] ], - 'hash_in_array', - noyamlperl => 1, + [ [ + { foo => undef, this => 'that' }, + 'foo', + undef, + { foo => 'bar', this => 'that' }, + ] ], + 'hash_in_array', + noyamlperl => 1, ); # Simple single quote yaml_ok( - "---\n- 'foo'\n", - [ [ 'foo' ] ], - 'single_quote1', + "---\n- 'foo'\n", + [ [ 'foo' ] ], + 'single_quote1', ); yaml_ok( - "---\n- ' '\n", - [ [ ' ' ] ], - 'single_spaces', + "---\n- ' '\n", + [ [ ' ' ] ], + 'single_spaces', ); yaml_ok( - "---\n- ''\n", - [ [ '' ] ], - 'single_null', + "---\n- ''\n", + [ [ '' ] ], + 'single_null', ); # Double quotes yaml_ok( - "--- \" \"\n", - [ ' ' ], - "only_spaces", - noyamlpm => 1, - noyamlperl => 1, + "--- \" \"\n", + [ ' ' ], + "only_spaces", + noyamlpm => 1, + noyamlperl => 1, ); yaml_ok( - "--- \" foo\"\n--- \"bar \"\n", - [ " foo", "bar " ], - "leading_trailing_spaces", - noyamlpm => 1, - noyamlperl => 1, + "--- \" foo\"\n--- \"bar \"\n", + [ " foo", "bar " ], + "leading_trailing_spaces", + noyamlpm => 1, + noyamlperl => 1, ); # Implicit document start yaml_ok( - "foo: bar\n", - [ { foo => 'bar' } ], - 'implicit_hash', + "foo: bar\n", + [ { foo => 'bar' } ], + 'implicit_hash', ); yaml_ok( - "- foo\n", - [ [ 'foo' ] ], - 'implicit_array', + "- foo\n", + [ [ 'foo' ] ], + 'implicit_array', ); # Inline nested hash yaml_ok( - <<'END_YAML', + <<'END_YAML', --- - ~ - foo: bar this: that - baz END_YAML - [ [ undef, { foo => 'bar', this => 'that' }, 'baz' ] ], - 'inline_nested_hash', - noyamlperl => 1, + [ [ undef, { foo => 'bar', this => 'that' }, 'baz' ] ], + 'inline_nested_hash', + noyamlperl => 1, ); # Empty comments yaml_ok( - "---\n- foo\n#\n- bar\n", - [ [ 'foo', 'bar' ] ], - 'empty_comment_in_list', + "---\n- foo\n#\n- bar\n", + [ [ 'foo', 'bar' ] ], + 'empty_comment_in_list', ); yaml_ok( - "---\nfoo: bar\n# foo\none: two\n", - [ { foo => 'bar', one => 'two' } ], - 'empty_comment_in_hash', + "---\nfoo: bar\n# foo\none: two\n", + [ { foo => 'bar', one => 'two' } ], + 'empty_comment_in_hash', ); # Complex keys yaml_ok( - "---\na b: c d\n", - [ { 'a b' => 'c d' } ], - 'key_with_whitespace', + "---\na b: c d\n", + [ { 'a b' => 'c d' } ], + 'key_with_whitespace', ); diff --git a/cpan/CPAN-Meta-YAML/t/03_regression.t b/cpan/CPAN-Meta-YAML/t/03_regression.t index 8fae7e4..f85b2ac 100644 --- a/cpan/CPAN-Meta-YAML/t/03_regression.t +++ b/cpan/CPAN-Meta-YAML/t/03_regression.t @@ -1,20 +1,20 @@ -#!/usr/bin/perl - # Testing of common META.yml examples use strict; +use warnings; + BEGIN { - $| = 1; - $^W = 1; + $| = 1; + $^W = 1; } use File::Spec::Functions ':ALL'; use t::lib::Test; use Test::More tests(37, 0, 13); use CPAN::Meta::YAML qw{ - Load Dump - LoadFile DumpFile - freeze thaw + Load Dump + LoadFile DumpFile + freeze thaw }; @@ -40,17 +40,17 @@ ok( defined(&thaw), 'Found exported thaw functiona' ); # Hash key legally containing a colon yaml_ok( - "---\nFoo::Bar: 1\n", - [ { 'Foo::Bar' => 1 } ], - 'module_hash_key', + "---\nFoo::Bar: 1\n", + [ { 'Foo::Bar' => 1 } ], + 'module_hash_key', ); # Hash indented yaml_ok( - "---\n" - . " foo: bar\n", - [ { foo => "bar" } ], - 'hash_indented', + "---\n" + . " foo: bar\n", + [ { foo => "bar" } ], + 'hash_indented', ); @@ -62,25 +62,25 @@ yaml_ok( # Declarative multi-line scalar yaml_ok( - "---\n" - . " foo: >\n" - . " bar\n" - . " baz\n", - [ { foo => "bar baz\n" } ], - 'simple_multiline', + "---\n" + . " foo: >\n" + . " bar\n" + . " baz\n", + [ { foo => "bar baz\n" } ], + 'simple_multiline', ); # Piped multi-line scalar yaml_ok( - <<'END_YAML', + <<'END_YAML', --- - | foo bar - 1 END_YAML - [ [ "foo\nbar\n", 1 ] ], - 'indented', + [ [ "foo\nbar\n", 1 ] ], + 'indented', ); # ... with a pointless hyphen @@ -91,8 +91,8 @@ yaml_ok( <<'END_YAML', bar - 1 END_YAML - [ [ "foo\nbar", 1 ] ], - 'indented', + [ [ "foo\nbar", 1 ] ], + 'indented', ); @@ -104,60 +104,60 @@ END_YAML # Simple inline case (comment variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', --- #YAML:1.0 foo: bar END_YAML - [ { foo => 'bar' } ], - 'simple_doctype_comment', - nosyck => 1, + [ { foo => 'bar' } ], + 'simple_doctype_comment', + nosyck => 1, ); # Simple inline case (percent variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', --- %YAML:1.0 foo: bar END_YAML - [ { foo => 'bar' } ], - 'simple_doctype_percent', - noyamlpm => 1, - noxs => 1, - noyamlperl => 1, + [ { foo => 'bar' } ], + 'simple_doctype_percent', + noyamlpm => 1, + noxs => 1, + noyamlperl => 1, ); # Simple header (comment variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', %YAML:1.0 --- foo: bar END_YAML - [ { foo => 'bar' } ], - 'predocument_1_0', - noyamlpm => 1, - nosyck => 1, - noxs => 1, - noyamlperl => 1, + [ { foo => 'bar' } ], + 'predocument_1_0', + noyamlpm => 1, + nosyck => 1, + noxs => 1, + noyamlperl => 1, ); # Simple inline case (comment variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', %YAML 1.1 --- foo: bar END_YAML - [ { foo => 'bar' } ], - 'predocument_1_1', - noyamlpm => 1, - nosyck => 1, - noyamlperl => 1, + [ { foo => 'bar' } ], + 'predocument_1_1', + noyamlpm => 1, + nosyck => 1, + noyamlperl => 1, ); # Multiple inline documents (comment variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', --- #YAML:1.0 foo: bar --- #YAML:1.0 @@ -165,33 +165,33 @@ foo: bar --- #YAML:1.0 foo: bar END_YAML - [ { foo => 'bar' }, [ 1 ], { foo => 'bar' } ], - 'multi_doctype_comment', + [ { foo => 'bar' }, [ 1 ], { foo => 'bar' } ], + 'multi_doctype_comment', ); # Simple pre-document case (comment variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', %YAML 1.1 --- foo: bar END_YAML - [ { foo => 'bar' } ], - 'predocument_percent', - noyamlpm => 1, - nosyck => 1, - noyamlperl => 1, + [ { foo => 'bar' } ], + 'predocument_percent', + noyamlpm => 1, + nosyck => 1, + noyamlperl => 1, ); # Simple pre-document case (comment variant) yaml_ok( - <<'END_YAML', + <<'END_YAML', #YAML 1.1 --- foo: bar END_YAML - [ { foo => 'bar' } ], - 'predocument_comment', + [ { foo => 'bar' } ], + 'predocument_comment', ); @@ -202,12 +202,12 @@ END_YAML # Hitchhiker Scalar yaml_ok( - <<'END_YAML', + <<'END_YAML', --- 42 END_YAML - [ 42 ], - 'hitchhiker scalar', - serializes => 1, + [ 42 ], + 'hitchhiker scalar', + serializes => 1, ); **** PATCH TRUNCATED AT 2000 LINES -- 3254 NOT SHOWN **** -- Perl5 Master Repository
