YAML-0.84/0000755000372100001440000000000012000063203011745 5ustar matthewtusersYAML-0.84/inc/0000755000372100001440000000000012000063203012516 5ustar matthewtusersYAML-0.84/inc/Module/0000755000372100001440000000000012000063203013743 5ustar matthewtusersYAML-0.84/inc/Module/Package.pm0000644000372100001440000000311412000063154015640 0ustar matthewtusers#line 1 ## # name: Module::Package # abstract: Postmodern Perl Module Packaging # author: Ingy döt Net # license: perl # copyright: 2011 # see: # - Module::Package::Plugin # - Module::Install::Package # - Module::Package::Tutorial package Module::Package; use 5.005; use strict; BEGIN { $Module::Package::VERSION = '0.30'; $inc::Module::Package::VERSION ||= $Module::Package::VERSION; @inc::Module::Package::ISA = __PACKAGE__; } sub import { my $class = shift; $INC{'inc/Module/Install.pm'} = __FILE__; unshift @INC, 'inc' unless $INC[0] eq 'inc'; eval "use Module::Install 1.01 (); 1" or $class->error($@); package main; Module::Install->import(); eval { module_package_internals_version_check($Module::Package::VERSION); module_package_internals_init(@_); }; if ($@) { $Module::Package::ERROR = $@; die $@; } } # XXX Remove this when things are stable. sub error { my ($class, $error) = @_; if (-e 'inc' and not -e 'inc/.author') { require Data::Dumper; $Data::Dumper::Sortkeys = 1; my $dump1 = Data::Dumper::Dumper(\%INC); my $dump2 = Data::Dumper::Dumper(\@INC); die <<"..."; This should not have happened. Hopefully this dump will explain the problem: inc::Module::Package: $inc::Module::Package::VERSION Module::Package: $Module::Package::VERSION inc::Module::Install: $inc::Module::Install::VERSION Module::Install: $Module::Install::VERSION Error: $error %INC: $dump1 \@INC: $dump2 ... } else { die $error; } } 1; YAML-0.84/inc/Module/Install/0000755000372100001440000000000012000063203015351 5ustar matthewtusersYAML-0.84/inc/Module/Install/Fetch.pm0000644000372100001440000000462712000063153016755 0ustar matthewtusers#line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; YAML-0.84/inc/Module/Install/Metadata.pm0000644000372100001440000004327712000063151017446 0ustar matthewtusers#line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) \s* ; /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic => 'http://opensource.org/licenses/artistic-license.php', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashs delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; YAML-0.84/inc/Module/Install/Can.pm0000644000372100001440000000615712000063153016425 0ustar matthewtusers#line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 236 YAML-0.84/inc/Module/Install/Include.pm0000644000372100001440000000101512000063151017271 0ustar matthewtusers#line 1 package Module::Install::Include; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub include { shift()->admin->include(@_); } sub include_deps { shift()->admin->include_deps(@_); } sub auto_include { shift()->admin->auto_include(@_); } sub auto_include_deps { shift()->admin->auto_include_deps(@_); } sub auto_include_dependent_dists { shift()->admin->auto_include_dependent_dists(@_); } 1; YAML-0.84/inc/Module/Install/Makefile.pm0000644000372100001440000002743712000063150017442 0ustar matthewtusers#line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-seperated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 YAML-0.84/inc/Module/Install/Package.pm0000644000372100001440000002340512000063147017255 0ustar matthewtusers#line 1 ## # name: Module::Install::Package # abstract: Module::Install support for Module::Package # author: Ingy döt Net # license: perl # copyright: 2011 # see: # - Module::Package # This module contains the Module::Package logic that must be available to # both the Author and the End User. Author-only logic goes in a # Module::Package::Plugin subclass. package Module::Install::Package; use strict; use Module::Install::Base; use vars qw'@ISA $VERSION'; @ISA = 'Module::Install::Base'; $VERSION = '0.30'; #-----------------------------------------------------------------------------# # XXX BOOTBUGHACK # This is here to try to get us out of Module-Package-0.11 cpantesters hell... # Remove this when the situation has blown over. sub pkg { *inc::Module::Package::VERSION = sub { $VERSION }; my $self = shift; $self->module_package_internals_init($@); } #-----------------------------------------------------------------------------# # We allow the author to specify key/value options after the plugin. These # options need to be available both at author time and install time. #-----------------------------------------------------------------------------# # OO accessor for command line options: sub package_options { @_>1?($_[0]->{package_options}=$_[1]):$_[0]->{package_options}} my $default_options = { deps_list => 1, install_bin => 1, install_share => 1, manifest_skip => 1, requires_from => 1, }; #-----------------------------------------------------------------------------# # Module::Install plugin directives. Use long, ugly names to not pollute the # Module::Install plugin namespace. These are only intended to be called from # Module::Package. #-----------------------------------------------------------------------------# # Module::Package starts off life as a normal call to this Module::Install # plugin directive: my $module_install_plugin; my $module_package_plugin; my $module_package_dist_plugin; # XXX ARGVHACK This @argv thing is a temporary fix for an ugly bug somewhere in the # Wikitext module usage. my @argv; sub module_package_internals_init { my $self = $module_install_plugin = shift; my ($plugin_spec, %options) = @_; $self->package_options({%$default_options, %options}); if ($module_install_plugin->is_admin) { $module_package_plugin = $self->_load_plugin($plugin_spec); $module_package_plugin->mi($module_install_plugin); $module_package_plugin->version_check($VERSION); } else { $module_package_dist_plugin = $self->_load_dist_plugin($plugin_spec); $module_package_dist_plugin->mi($module_install_plugin) if ref $module_package_dist_plugin; } # NOTE - This is the point in time where the body of Makefile.PL runs... return; sub INIT { return unless $module_install_plugin; return if $Module::Package::ERROR; eval { if ($module_install_plugin->is_admin) { $module_package_plugin->initial(); $module_package_plugin->main(); } else { $module_install_plugin->_initial(); $module_package_dist_plugin->_initial() if ref $module_package_dist_plugin; $module_install_plugin->_main(); $module_package_dist_plugin->_main() if ref $module_package_dist_plugin; } }; if ($@) { $Module::Package::ERROR = $@; die $@; } @argv = @ARGV; # XXX ARGVHACK } # If this Module::Install plugin was used (by Module::Package) then wrap # up any loose ends. This will get called after Makefile.PL has completed. sub END { @ARGV = @argv; # XXX ARGVHACK return unless $module_install_plugin; return if $Module::Package::ERROR; $module_package_plugin ? do { $module_package_plugin->final; $module_package_plugin->replicate_module_package; } : do { $module_install_plugin->_final; $module_package_dist_plugin->_final() if ref $module_package_dist_plugin; } } } # Module::Package, Module::Install::Package and Module::Package::Plugin # must all have the same version. Seems wise. sub module_package_internals_version_check { my ($self, $version) = @_; return if $version < 0.1800001; # XXX BOOTBUGHACK!! die <<"..." unless $version == $VERSION; Error! Something has gone awry: Module::Package version=$version is using Module::Install::Package version=$VERSION If you are the author of this module, try upgrading Module::Package. Otherwise, please notify the author of this error. ... } # Find and load the author side plugin: sub _load_plugin { my ($self, $spec, $namespace) = @_; $spec ||= ''; $namespace ||= 'Module::Package'; my $version = ''; $Module::Package::plugin_version = 0; if ($spec =~ s/\s+(\S+)\s*//) { $version = $1; $Module::Package::plugin_version = $version; } my ($module, $plugin) = not($spec) ? ('Plugin', "Plugin::basic") : ($spec =~ /^\w(\w|::)*$/) ? ($spec, $spec) : ($spec =~ /^:(\w+)$/) ? ('Plugin', "Plugin::$1") : ($spec =~ /^(\S*\w):(\w+)$/) ? ($1, "$1::$2") : die "$spec is invalid"; $module = "${namespace}::${module}"; $plugin = "${namespace}::${plugin}"; eval "use $module $version (); 1" or die $@; return $plugin->new(); } # Find and load the user side plugin: sub _load_dist_plugin { my ($self, $spec, $namespace) = @_; $spec ||= ''; $namespace ||= 'Module::Package::Dist'; my $r = eval { $self->_load_plugin($spec, $namespace); }; return $r if ref $r; return; } #-----------------------------------------------------------------------------# # These are the user side analogs to the author side plugin API calls. # Prefix with '_' to not pollute Module::Install plugin space. #-----------------------------------------------------------------------------# sub _initial { my ($self) = @_; } sub _main { my ($self) = @_; } # NOTE These must match Module::Package::Plugin::final. sub _final { my ($self) = @_; $self->_all_from; $self->_requires_from; $self->_install_bin; $self->_install_share; $self->_WriteAll; } #-----------------------------------------------------------------------------# # This section is where all the useful code bits go. These bits are needed by # both Author and User side runs. #-----------------------------------------------------------------------------# my $all_from = 0; sub _all_from { my $self = shift; return if $all_from++; return if $self->name; my $file = shift || "$main::PM" or die "all_from has no file"; $self->all_from($file); } my $requires_from = 0; sub _requires_from { my $self = shift; return if $requires_from++; return unless $self->package_options->{requires_from}; my $file = shift || "$main::PM" or die "requires_from has no file"; $self->requires_from($main::PM) } my $install_bin = 0; sub _install_bin { my $self = shift; return if $install_bin++; return unless $self->package_options->{install_bin}; return unless -d 'bin'; my @bin; File::Find::find(sub { return unless -f $_; push @bin, $File::Find::name; }, 'bin'); $self->install_script($_) for @bin; } my $install_share = 0; sub _install_share { my $self = shift; return if $install_share++; return unless $self->package_options->{install_share}; return unless -d 'share'; $self->install_share; } my $WriteAll = 0; sub _WriteAll { my $self = shift; return if $WriteAll++; $self->WriteAll(@_); } # Base package for Module::Package plugin distributed components. package Module::Package::Dist; sub new { my ($class, %args) = @_; bless \%args, $class; } sub mi { @_ > 1 ? ($_[0]->{mi}=$_[1]) : $_[0]->{mi}; } sub _initial { my ($self) = @_; } sub _main { my ($self) = @_; } sub _final { my ($self) = @_; } 1; #-----------------------------------------------------------------------------# # Take a guess at the primary .pm and .pod files for 'all_from', and friends. # Put them in global magical vars in the main:: namespace. #-----------------------------------------------------------------------------# package Module::Package::PM; use overload '""' => sub { $_[0]->guess_pm unless @{$_[0]}; return $_[0]->[0]; }; sub set { $_[0]->[0] = $_[1] } sub guess_pm { my $pm = ''; my $self = shift; if (-e 'META.yml') { open META, 'META.yml' or die "Can't open 'META.yml' for input:\n$!"; my $meta = do { local $/; }; close META; $meta =~ /^module_name: (\S+)$/m or die "Can't get module_name from META.yml"; $pm = $1; $pm =~ s!::!/!g; $pm = "lib/$pm.pm"; } else { require File::Find; my @array = (); File::Find::find(sub { return unless /\.pm$/; my $name = $File::Find::name; my $num = ($name =~ s!/+!/!g); my $ary = $array[$num] ||= []; push @$ary, $name; }, 'lib'); shift @array while @array and not defined $array[0]; die "Can't guess main module" unless @array; (($pm) = sort @{$array[0]}) or die "Can't guess main module"; } my $pmc = $pm . 'c'; $pm = $pmc if -e $pmc; $self->set($pm); } $main::PM = bless [$main::PM ? ($main::PM) : ()], __PACKAGE__; package Module::Package::POD; use overload '""' => sub { return $_[0]->[0] if @{$_[0]}; (my $pod = "$main::PM") =~ s/\.pm/.pod/ or die "Module::Package's \$main::PM value should end in '.pm'"; return -e $pod ? $pod : ''; }; sub set { $_[0][0] = $_[1] } $main::POD = bless [$main::POD ? ($main::POD) : ()], __PACKAGE__; 1; YAML-0.84/inc/Module/Install/GithubMeta.pm0000644000372100001440000000224112000063152017742 0ustar matthewtusers#line 1 package Module::Install::GithubMeta; use strict; use warnings; use Cwd; use base qw(Module::Install::Base); use vars qw($VERSION); $VERSION = '0.16'; sub githubmeta { my $self = shift; return unless $Module::Install::AUTHOR; return unless _under_git(); return unless $self->can_run('git'); my $remote = shift || 'origin'; return unless my ($git_url) = `git remote show -n $remote` =~ /URL: (.*)$/m; return unless $git_url =~ /github\.com/; # Not a Github repository my $http_url = $git_url; $git_url =~ s![\w\-]+\@([^:]+):!git://$1/!; $http_url =~ s![\w\-]+\@([^:]+):!https://$1/!; $http_url =~ s!\.git$!/tree!; $self->repository( { type => 'git', url => $git_url, web => $http_url, }, ); $self->homepage( $http_url ) unless $self->homepage(); return 1; } sub _under_git { return 1 if -e '.git'; my $cwd = getcwd; my $last = $cwd; my $found = 0; while (1) { chdir '..' or last; my $current = getcwd; last if $last eq $current; $last = $current; if ( -e '.git' ) { $found = 1; last; } } chdir $cwd; return $found; } 'Github'; __END__ #line 117 YAML-0.84/inc/Module/Install/WriteAll.pm0000644000372100001440000000237612000063153017446 0ustar matthewtusers#line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1; YAML-0.84/inc/Module/Install/Base.pm0000644000372100001440000000214712000063147016574 0ustar matthewtusers#line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.06'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159 YAML-0.84/inc/Module/Install/Win32.pm0000644000372100001440000000340312000063153016615 0ustar matthewtusers#line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.06'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; YAML-0.84/inc/Module/Install.pm0000644000372100001440000003013512000063146015717 0ustar matthewtusers#line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.005; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.06'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::cwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::cwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($subpath . '.pm'); my $in_pod = 0; foreach ( split //, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_NEW sub _read { local *FH; open( FH, "< $_[0]" ) or die "open($_[0]): $!"; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_OLD sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_NEW sub _write { local *FH; open( FH, "> $_[0]" ) or die "open($_[0]): $!"; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_OLD # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version ($) { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp ($$) { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS ($) { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. YAML-0.84/inc/Test/0000755000372100001440000000000012000063203013435 5ustar matthewtusersYAML-0.84/inc/Test/Base/0000755000372100001440000000000012000063203014307 5ustar matthewtusersYAML-0.84/inc/Test/Base/Filter.pm0000644000372100001440000001576612000063151016113 0ustar matthewtusers#line 1 #=============================================================================== # This is the default class for handling Test::Base data filtering. #=============================================================================== package Test::Base::Filter; use Spiffy -Base; use Spiffy ':XXX'; field 'current_block'; our $arguments; sub current_arguments { return undef unless defined $arguments; my $args = $arguments; $args =~ s/(\\s)/ /g; $args =~ s/(\\[a-z])/'"' . $1 . '"'/gee; return $args; } sub assert_scalar { return if @_ == 1; require Carp; my $filter = (caller(1))[3]; $filter =~ s/.*:://; Carp::croak "Input to the '$filter' filter must be a scalar, not a list"; } sub _apply_deepest { my $method = shift; return () unless @_; if (ref $_[0] eq 'ARRAY') { for my $aref (@_) { @$aref = $self->_apply_deepest($method, @$aref); } return @_; } $self->$method(@_); } sub _split_array { map { [$self->split($_)]; } @_; } sub _peel_deepest { return () unless @_; if (ref $_[0] eq 'ARRAY') { if (ref $_[0]->[0] eq 'ARRAY') { for my $aref (@_) { @$aref = $self->_peel_deepest(@$aref); } return @_; } return map { $_->[0] } @_; } return @_; } #=============================================================================== # these filters work on the leaves of nested arrays #=============================================================================== sub Join { $self->_peel_deepest($self->_apply_deepest(join => @_)) } sub Reverse { $self->_apply_deepest(reverse => @_) } sub Split { $self->_apply_deepest(_split_array => @_) } sub Sort { $self->_apply_deepest(sort => @_) } sub append { my $suffix = $self->current_arguments; map { $_ . $suffix } @_; } sub array { return [@_]; } sub base64_decode { $self->assert_scalar(@_); require MIME::Base64; MIME::Base64::decode_base64(shift); } sub base64_encode { $self->assert_scalar(@_); require MIME::Base64; MIME::Base64::encode_base64(shift); } sub chomp { map { CORE::chomp; $_ } @_; } sub chop { map { CORE::chop; $_ } @_; } sub dumper { no warnings 'once'; require Data::Dumper; local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Indent = 1; local $Data::Dumper::Terse = 1; Data::Dumper::Dumper(@_); } sub escape { $self->assert_scalar(@_); my $text = shift; $text =~ s/(\\.)/eval "qq{$1}"/ge; return $text; } sub eval { $self->assert_scalar(@_); my @return = CORE::eval(shift); return $@ if $@; return @return; } sub eval_all { $self->assert_scalar(@_); my $out = ''; my $err = ''; Test::Base::tie_output(*STDOUT, $out); Test::Base::tie_output(*STDERR, $err); my $return = CORE::eval(shift); no warnings; untie *STDOUT; untie *STDERR; return $return, $@, $out, $err; } sub eval_stderr { $self->assert_scalar(@_); my $output = ''; Test::Base::tie_output(*STDERR, $output); CORE::eval(shift); no warnings; untie *STDERR; return $output; } sub eval_stdout { $self->assert_scalar(@_); my $output = ''; Test::Base::tie_output(*STDOUT, $output); CORE::eval(shift); no warnings; untie *STDOUT; return $output; } sub exec_perl_stdout { my $tmpfile = "/tmp/test-blocks-$$"; $self->_write_to($tmpfile, @_); open my $execution, "$^X $tmpfile 2>&1 |" or die "Couldn't open subprocess: $!\n"; local $/; my $output = <$execution>; close $execution; unlink($tmpfile) or die "Couldn't unlink $tmpfile: $!\n"; return $output; } sub flatten { $self->assert_scalar(@_); my $ref = shift; if (ref($ref) eq 'HASH') { return map { ($_, $ref->{$_}); } sort keys %$ref; } if (ref($ref) eq 'ARRAY') { return @$ref; } die "Can only flatten a hash or array ref"; } sub get_url { $self->assert_scalar(@_); my $url = shift; CORE::chomp($url); require LWP::Simple; LWP::Simple::get($url); } sub hash { return +{ @_ }; } sub head { my $size = $self->current_arguments || 1; return splice(@_, 0, $size); } sub join { my $string = $self->current_arguments; $string = '' unless defined $string; CORE::join $string, @_; } sub lines { $self->assert_scalar(@_); my $text = shift; return () unless length $text; my @lines = ($text =~ /^(.*\n?)/gm); return @lines; } sub norm { $self->assert_scalar(@_); my $text = shift; $text = '' unless defined $text; $text =~ s/\015\012/\n/g; $text =~ s/\r/\n/g; return $text; } sub prepend { my $prefix = $self->current_arguments; map { $prefix . $_ } @_; } sub read_file { $self->assert_scalar(@_); my $file = shift; CORE::chomp $file; open my $fh, $file or die "Can't open '$file' for input:\n$!"; CORE::join '', <$fh>; } sub regexp { $self->assert_scalar(@_); my $text = shift; my $flags = $self->current_arguments; if ($text =~ /\n.*?\n/s) { $flags = 'xism' unless defined $flags; } else { CORE::chomp($text); } $flags ||= ''; my $regexp = eval "qr{$text}$flags"; die $@ if $@; return $regexp; } sub reverse { CORE::reverse(@_); } sub slice { die "Invalid args for slice" unless $self->current_arguments =~ /^(\d+)(?:,(\d))?$/; my ($x, $y) = ($1, $2); $y = $x if not defined $y; die "Invalid args for slice" if $x > $y; return splice(@_, $x, 1 + $y - $x); } sub sort { CORE::sort(@_); } sub split { $self->assert_scalar(@_); my $separator = $self->current_arguments; if (defined $separator and $separator =~ s{^/(.*)/$}{$1}) { my $regexp = $1; $separator = qr{$regexp}; } $separator = qr/\s+/ unless $separator; CORE::split $separator, shift; } sub strict { $self->assert_scalar(@_); <<'...' . shift; use strict; use warnings; ... } sub tail { my $size = $self->current_arguments || 1; return splice(@_, @_ - $size, $size); } sub trim { map { s/\A([ \t]*\n)+//; s/(?<=\n)\s*\z//g; $_; } @_; } sub unchomp { map { $_ . "\n" } @_; } sub write_file { my $file = $self->current_arguments or die "No file specified for write_file filter"; if ($file =~ /(.*)[\\\/]/) { my $dir = $1; if (not -e $dir) { require File::Path; File::Path::mkpath($dir) or die "Can't create $dir"; } } open my $fh, ">$file" or die "Can't open '$file' for output\n:$!"; print $fh @_; close $fh; return $file; } sub yaml { $self->assert_scalar(@_); require YAML; return YAML::Load(shift); } sub _write_to { my $filename = shift; open my $script, ">$filename" or die "Couldn't open $filename: $!\n"; print $script @_; close $script or die "Couldn't close $filename: $!\n"; } __DATA__ #line 636 YAML-0.84/inc/Test/Builder/0000755000372100001440000000000012000063203015023 5ustar matthewtusersYAML-0.84/inc/Test/Builder/Module.pm0000644000372100001440000000224112000063152016610 0ustar matthewtusers#line 1 package Test::Builder::Module; use strict; use Test::Builder; require Exporter; our @ISA = qw(Exporter); our $VERSION = '0.98'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) #line 74 sub import { my($class) = shift; # Don't run all this when loading ourself. return 1 if $class eq 'Test::Builder::Module'; my $test = $class->builder; my $caller = caller; $test->exported_to($caller); $class->import_extra( \@_ ); my(@imports) = $class->_strip_imports( \@_ ); $test->plan(@_); $class->export_to_level( 1, $class, @imports ); } sub _strip_imports { my $class = shift; my $list = shift; my @imports = (); my @other = (); my $idx = 0; while( $idx <= $#{$list} ) { my $item = $list->[$idx]; if( defined $item and $item eq 'import' ) { push @imports, @{ $list->[ $idx + 1 ] }; $idx++; } else { push @other, $item; } $idx++; } @$list = @other; return @imports; } #line 137 sub import_extra { } #line 167 sub builder { return Test::Builder->new; } 1; YAML-0.84/inc/Test/Base.pm0000644000372100001440000004306312000063151014655 0ustar matthewtusers#line 1 package Test::Base; use 5.006001; use Spiffy 0.30 -Base; use Spiffy ':XXX'; our $VERSION = '0.60'; my @test_more_exports; BEGIN { @test_more_exports = qw( ok isnt like unlike is_deeply cmp_ok skip todo_skip pass fail eq_array eq_hash eq_set plan can_ok isa_ok diag use_ok $TODO ); } use Test::More import => \@test_more_exports; use Carp; our @EXPORT = (@test_more_exports, qw( is no_diff blocks next_block first_block delimiters spec_file spec_string filters filters_delay filter_arguments run run_compare run_is run_is_deeply run_like run_unlike skip_all_unless_require is_deep run_is_deep WWW XXX YYY ZZZ tie_output no_diag_on_only find_my_self default_object croak carp cluck confess )); field '_spec_file'; field '_spec_string'; field _filters => [qw(norm trim)]; field _filters_map => {}; field spec => -init => '$self->_spec_init'; field block_list => -init => '$self->_block_list_init'; field _next_list => []; field block_delim => -init => '$self->block_delim_default'; field data_delim => -init => '$self->data_delim_default'; field _filters_delay => 0; field _no_diag_on_only => 0; field block_delim_default => '==='; field data_delim_default => '---'; my $default_class; my $default_object; my $reserved_section_names = {}; sub default_object { $default_object ||= $default_class->new; return $default_object; } my $import_called = 0; sub import() { $import_called = 1; my $class = (grep /^-base$/i, @_) ? scalar(caller) : $_[0]; if (not defined $default_class) { $default_class = $class; } # else { # croak "Can't use $class after using $default_class" # unless $default_class->isa($class); # } unless (grep /^-base$/i, @_) { my @args; for (my $ii = 1; $ii <= $#_; ++$ii) { if ($_[$ii] eq '-package') { ++$ii; } else { push @args, $_[$ii]; } } Test::More->import(import => \@test_more_exports, @args) if @args; } _strict_warnings(); goto &Spiffy::import; } # Wrap Test::Builder::plan my $plan_code = \&Test::Builder::plan; my $Have_Plan = 0; { no warnings 'redefine'; *Test::Builder::plan = sub { $Have_Plan = 1; goto &$plan_code; }; } my $DIED = 0; $SIG{__DIE__} = sub { $DIED = 1; die @_ }; sub block_class { $self->find_class('Block') } sub filter_class { $self->find_class('Filter') } sub find_class { my $suffix = shift; my $class = ref($self) . "::$suffix"; return $class if $class->can('new'); $class = __PACKAGE__ . "::$suffix"; return $class if $class->can('new'); eval "require $class"; return $class if $class->can('new'); die "Can't find a class for $suffix"; } sub check_late { if ($self->{block_list}) { my $caller = (caller(1))[3]; $caller =~ s/.*:://; croak "Too late to call $caller()" } } sub find_my_self() { my $self = ref($_[0]) eq $default_class ? splice(@_, 0, 1) : default_object(); return $self, @_; } sub blocks() { (my ($self), @_) = find_my_self(@_); croak "Invalid arguments passed to 'blocks'" if @_ > 1; croak sprintf("'%s' is invalid argument to blocks()", shift(@_)) if @_ && $_[0] !~ /^[a-zA-Z]\w*$/; my $blocks = $self->block_list; my $section_name = shift || ''; my @blocks = $section_name ? (grep { exists $_->{$section_name} } @$blocks) : (@$blocks); return scalar(@blocks) unless wantarray; return (@blocks) if $self->_filters_delay; for my $block (@blocks) { $block->run_filters unless $block->is_filtered; } return (@blocks); } sub next_block() { (my ($self), @_) = find_my_self(@_); my $list = $self->_next_list; if (@$list == 0) { $list = [@{$self->block_list}, undef]; $self->_next_list($list); } my $block = shift @$list; if (defined $block and not $block->is_filtered) { $block->run_filters; } return $block; } sub first_block() { (my ($self), @_) = find_my_self(@_); $self->_next_list([]); $self->next_block; } sub filters_delay() { (my ($self), @_) = find_my_self(@_); $self->_filters_delay(defined $_[0] ? shift : 1); } sub no_diag_on_only() { (my ($self), @_) = find_my_self(@_); $self->_no_diag_on_only(defined $_[0] ? shift : 1); } sub delimiters() { (my ($self), @_) = find_my_self(@_); $self->check_late; my ($block_delimiter, $data_delimiter) = @_; $block_delimiter ||= $self->block_delim_default; $data_delimiter ||= $self->data_delim_default; $self->block_delim($block_delimiter); $self->data_delim($data_delimiter); return $self; } sub spec_file() { (my ($self), @_) = find_my_self(@_); $self->check_late; $self->_spec_file(shift); return $self; } sub spec_string() { (my ($self), @_) = find_my_self(@_); $self->check_late; $self->_spec_string(shift); return $self; } sub filters() { (my ($self), @_) = find_my_self(@_); if (ref($_[0]) eq 'HASH') { $self->_filters_map(shift); } else { my $filters = $self->_filters; push @$filters, @_; } return $self; } sub filter_arguments() { $Test::Base::Filter::arguments; } sub have_text_diff { eval { require Text::Diff; 1 } && $Text::Diff::VERSION >= 0.35 && $Algorithm::Diff::VERSION >= 1.15; } sub is($$;$) { (my ($self), @_) = find_my_self(@_); my ($actual, $expected, $name) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; if ($ENV{TEST_SHOW_NO_DIFFS} or not defined $actual or not defined $expected or $actual eq $expected or not($self->have_text_diff) or $expected !~ /\n./s ) { Test::More::is($actual, $expected, $name); } else { $name = '' unless defined $name; ok $actual eq $expected, $name . "\n" . Text::Diff::diff(\$expected, \$actual); } } sub run(&;$) { (my ($self), @_) = find_my_self(@_); my $callback = shift; for my $block (@{$self->block_list}) { $block->run_filters unless $block->is_filtered; &{$callback}($block); } } my $name_error = "Can't determine section names"; sub _section_names { return @_ if @_ == 2; my $block = $self->first_block or croak $name_error; my @names = grep { $_ !~ /^(ONLY|LAST|SKIP)$/; } @{$block->{_section_order}[0] || []}; croak "$name_error. Need two sections in first block" unless @names == 2; return @names; } sub _assert_plan { plan('no_plan') unless $Have_Plan; } sub END { run_compare() unless $Have_Plan or $DIED or not $import_called; } sub run_compare() { (my ($self), @_) = find_my_self(@_); $self->_assert_plan; my ($x, $y) = $self->_section_names(@_); local $Test::Builder::Level = $Test::Builder::Level + 1; for my $block (@{$self->block_list}) { next unless exists($block->{$x}) and exists($block->{$y}); $block->run_filters unless $block->is_filtered; if (ref $block->$x) { is_deeply($block->$x, $block->$y, $block->name ? $block->name : ()); } elsif (ref $block->$y eq 'Regexp') { my $regexp = ref $y ? $y : $block->$y; like($block->$x, $regexp, $block->name ? $block->name : ()); } else { is($block->$x, $block->$y, $block->name ? $block->name : ()); } } } sub run_is() { (my ($self), @_) = find_my_self(@_); $self->_assert_plan; my ($x, $y) = $self->_section_names(@_); local $Test::Builder::Level = $Test::Builder::Level + 1; for my $block (@{$self->block_list}) { next unless exists($block->{$x}) and exists($block->{$y}); $block->run_filters unless $block->is_filtered; is($block->$x, $block->$y, $block->name ? $block->name : () ); } } sub run_is_deeply() { (my ($self), @_) = find_my_self(@_); $self->_assert_plan; my ($x, $y) = $self->_section_names(@_); for my $block (@{$self->block_list}) { next unless exists($block->{$x}) and exists($block->{$y}); $block->run_filters unless $block->is_filtered; is_deeply($block->$x, $block->$y, $block->name ? $block->name : () ); } } sub run_like() { (my ($self), @_) = find_my_self(@_); $self->_assert_plan; my ($x, $y) = $self->_section_names(@_); for my $block (@{$self->block_list}) { next unless exists($block->{$x}) and defined($y); $block->run_filters unless $block->is_filtered; my $regexp = ref $y ? $y : $block->$y; like($block->$x, $regexp, $block->name ? $block->name : () ); } } sub run_unlike() { (my ($self), @_) = find_my_self(@_); $self->_assert_plan; my ($x, $y) = $self->_section_names(@_); for my $block (@{$self->block_list}) { next unless exists($block->{$x}) and defined($y); $block->run_filters unless $block->is_filtered; my $regexp = ref $y ? $y : $block->$y; unlike($block->$x, $regexp, $block->name ? $block->name : () ); } } sub skip_all_unless_require() { (my ($self), @_) = find_my_self(@_); my $module = shift; eval "require $module; 1" or Test::More::plan( skip_all => "$module failed to load" ); } sub is_deep() { (my ($self), @_) = find_my_self(@_); require Test::Deep; Test::Deep::cmp_deeply(@_); } sub run_is_deep() { (my ($self), @_) = find_my_self(@_); $self->_assert_plan; my ($x, $y) = $self->_section_names(@_); for my $block (@{$self->block_list}) { next unless exists($block->{$x}) and exists($block->{$y}); $block->run_filters unless $block->is_filtered; is_deep($block->$x, $block->$y, $block->name ? $block->name : () ); } } sub _pre_eval { my $spec = shift; return $spec unless $spec =~ s/\A\s*<<<(.*?)>>>\s*$//sm; my $eval_code = $1; eval "package main; $eval_code"; croak $@ if $@; return $spec; } sub _block_list_init { my $spec = $self->spec; $spec = $self->_pre_eval($spec); my $cd = $self->block_delim; my @hunks = ($spec =~ /^(\Q${cd}\E.*?(?=^\Q${cd}\E|\z))/msg); my $blocks = $self->_choose_blocks(@hunks); $self->block_list($blocks); # Need to set early for possible filter use my $seq = 1; for my $block (@$blocks) { $block->blocks_object($self); $block->seq_num($seq++); } return $blocks; } sub _choose_blocks { my $blocks = []; for my $hunk (@_) { my $block = $self->_make_block($hunk); if (exists $block->{ONLY}) { diag "I found ONLY: maybe you're debugging?" unless $self->_no_diag_on_only; return [$block]; } next if exists $block->{SKIP}; push @$blocks, $block; if (exists $block->{LAST}) { return $blocks; } } return $blocks; } sub _check_reserved { my $id = shift; croak "'$id' is a reserved name. Use something else.\n" if $reserved_section_names->{$id} or $id =~ /^_/; } sub _make_block { my $hunk = shift; my $cd = $self->block_delim; my $dd = $self->data_delim; my $block = $self->block_class->new; $hunk =~ s/\A\Q${cd}\E[ \t]*(.*)\s+// or die; my $name = $1; my @parts = split /^\Q${dd}\E +\(?(\w+)\)? *(.*)?\n/m, $hunk; my $description = shift @parts; $description ||= ''; unless ($description =~ /\S/) { $description = $name; } $description =~ s/\s*\z//; $block->set_value(description => $description); my $section_map = {}; my $section_order = []; while (@parts) { my ($type, $filters, $value) = splice(@parts, 0, 3); $self->_check_reserved($type); $value = '' unless defined $value; $filters = '' unless defined $filters; if ($filters =~ /:(\s|\z)/) { croak "Extra lines not allowed in '$type' section" if $value =~ /\S/; ($filters, $value) = split /\s*:(?:\s+|\z)/, $filters, 2; $value = '' unless defined $value; $value =~ s/^\s*(.*?)\s*$/$1/; } $section_map->{$type} = { filters => $filters, }; push @$section_order, $type; $block->set_value($type, $value); } $block->set_value(name => $name); $block->set_value(_section_map => $section_map); $block->set_value(_section_order => $section_order); return $block; } sub _spec_init { return $self->_spec_string if $self->_spec_string; local $/; my $spec; if (my $spec_file = $self->_spec_file) { open FILE, $spec_file or die $!; $spec = ; close FILE; } else { $spec = do { package main; no warnings 'once'; ; }; } return $spec; } sub _strict_warnings() { require Filter::Util::Call; my $done = 0; Filter::Util::Call::filter_add( sub { return 0 if $done; my ($data, $end) = ('', ''); while (my $status = Filter::Util::Call::filter_read()) { return $status if $status < 0; if (/^__(?:END|DATA)__\r?$/) { $end = $_; last; } $data .= $_; $_ = ''; } $_ = "use strict;use warnings;$data$end"; $done = 1; } ); } sub tie_output() { my $handle = shift; die "No buffer to tie" unless @_; tie *$handle, 'Test::Base::Handle', $_[0]; } sub no_diff { $ENV{TEST_SHOW_NO_DIFFS} = 1; } package Test::Base::Handle; sub TIEHANDLE() { my $class = shift; bless \ $_[0], $class; } sub PRINT { $$self .= $_ for @_; } #=============================================================================== # Test::Base::Block # # This is the default class for accessing a Test::Base block object. #=============================================================================== package Test::Base::Block; our @ISA = qw(Spiffy); our @EXPORT = qw(block_accessor); sub AUTOLOAD { return; } sub block_accessor() { my $accessor = shift; no strict 'refs'; return if defined &$accessor; *$accessor = sub { my $self = shift; if (@_) { Carp::croak "Not allowed to set values for '$accessor'"; } my @list = @{$self->{$accessor} || []}; return wantarray ? (@list) : $list[0]; }; } block_accessor 'name'; block_accessor 'description'; Spiffy::field 'seq_num'; Spiffy::field 'is_filtered'; Spiffy::field 'blocks_object'; Spiffy::field 'original_values' => {}; sub set_value { no strict 'refs'; my $accessor = shift; block_accessor $accessor unless defined &$accessor; $self->{$accessor} = [@_]; } sub run_filters { my $map = $self->_section_map; my $order = $self->_section_order; Carp::croak "Attempt to filter a block twice" if $self->is_filtered; for my $type (@$order) { my $filters = $map->{$type}{filters}; my @value = $self->$type; $self->original_values->{$type} = $value[0]; for my $filter ($self->_get_filters($type, $filters)) { $Test::Base::Filter::arguments = $filter =~ s/=(.*)$// ? $1 : undef; my $function = "main::$filter"; no strict 'refs'; if (defined &$function) { local $_ = (@value == 1 and not defined($value[0])) ? undef : join '', @value; my $old = $_; @value = &$function(@value); if (not(@value) or @value == 1 and defined($value[0]) and $value[0] =~ /\A(\d+|)\z/ ) { if ($value[0] && $_ eq $old) { Test::Base::diag("Filters returning numbers are supposed to do munging \$_: your filter '$function' apparently doesn't."); } @value = ($_); } } else { my $filter_object = $self->blocks_object->filter_class->new; die "Can't find a function or method for '$filter' filter\n" unless $filter_object->can($filter); $filter_object->current_block($self); @value = $filter_object->$filter(@value); } # Set the value after each filter since other filters may be # introspecting. $self->set_value($type, @value); } } $self->is_filtered(1); } sub _get_filters { my $type = shift; my $string = shift || ''; $string =~ s/\s*(.*?)\s*/$1/; my @filters = (); my $map_filters = $self->blocks_object->_filters_map->{$type} || []; $map_filters = [ $map_filters ] unless ref $map_filters; my @append = (); for ( @{$self->blocks_object->_filters}, @$map_filters, split(/\s+/, $string), ) { my $filter = $_; last unless length $filter; if ($filter =~ s/^-//) { @filters = grep { $_ ne $filter } @filters; } elsif ($filter =~ s/^\+//) { push @append, $filter; } else { push @filters, $filter; } } return @filters, @append; } { %$reserved_section_names = map { ($_, 1); } keys(%Test::Base::Block::), qw( new DESTROY ); } __DATA__ =encoding utf8 #line 1374 YAML-0.84/inc/Test/Builder.pm0000644000372100001440000010671512000063152015376 0ustar matthewtusers#line 1 package Test::Builder; use 5.006; use strict; use warnings; our $VERSION = '0.98'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) BEGIN { if( $] < 5.008 ) { require Test::Builder::IO::Scalar; } } # Make Test::Builder thread-safe for ithreads. BEGIN { use Config; # Load threads::shared when threads are turned on. # 5.8.0's threads are so busted we no longer support them. if( $] >= 5.008001 && $Config{useithreads} && $INC{'threads.pm'} ) { require threads::shared; # Hack around YET ANOTHER threads::shared bug. It would # occasionally forget the contents of the variable when sharing it. # So we first copy the data, then share, then put our copy back. *share = sub (\[$@%]) { my $type = ref $_[0]; my $data; if( $type eq 'HASH' ) { %$data = %{ $_[0] }; } elsif( $type eq 'ARRAY' ) { @$data = @{ $_[0] }; } elsif( $type eq 'SCALAR' ) { $$data = ${ $_[0] }; } else { die( "Unknown type: " . $type ); } $_[0] = &threads::shared::share( $_[0] ); if( $type eq 'HASH' ) { %{ $_[0] } = %$data; } elsif( $type eq 'ARRAY' ) { @{ $_[0] } = @$data; } elsif( $type eq 'SCALAR' ) { ${ $_[0] } = $$data; } else { die( "Unknown type: " . $type ); } return $_[0]; }; } # 5.8.0's threads::shared is busted when threads are off # and earlier Perls just don't have that module at all. else { *share = sub { return $_[0] }; *lock = sub { 0 }; } } #line 117 our $Test = Test::Builder->new; sub new { my($class) = shift; $Test ||= $class->create; return $Test; } #line 139 sub create { my $class = shift; my $self = bless {}, $class; $self->reset; return $self; } #line 168 sub child { my( $self, $name ) = @_; if( $self->{Child_Name} ) { $self->croak("You already have a child named ($self->{Child_Name}) running"); } my $parent_in_todo = $self->in_todo; # Clear $TODO for the child. my $orig_TODO = $self->find_TODO(undef, 1, undef); my $child = bless {}, ref $self; $child->reset; # Add to our indentation $child->_indent( $self->_indent . ' ' ); $child->{$_} = $self->{$_} foreach qw{Out_FH Todo_FH Fail_FH}; if ($parent_in_todo) { $child->{Fail_FH} = $self->{Todo_FH}; } # This will be reset in finalize. We do this here lest one child failure # cause all children to fail. $child->{Child_Error} = $?; $? = 0; $child->{Parent} = $self; $child->{Parent_TODO} = $orig_TODO; $child->{Name} = $name || "Child of " . $self->name; $self->{Child_Name} = $child->name; return $child; } #line 211 sub subtest { my $self = shift; my($name, $subtests) = @_; if ('CODE' ne ref $subtests) { $self->croak("subtest()'s second argument must be a code ref"); } # Turn the child into the parent so anyone who has stored a copy of # the Test::Builder singleton will get the child. my($error, $child, %parent); { # child() calls reset() which sets $Level to 1, so we localize # $Level first to limit the scope of the reset to the subtest. local $Test::Builder::Level = $Test::Builder::Level + 1; $child = $self->child($name); %parent = %$self; %$self = %$child; my $run_the_subtests = sub { $subtests->(); $self->done_testing unless $self->_plan_handled; 1; }; if( !eval { $run_the_subtests->() } ) { $error = $@; } } # Restore the parent and the copied child. %$child = %$self; %$self = %parent; # Restore the parent's $TODO $self->find_TODO(undef, 1, $child->{Parent_TODO}); # Die *after* we restore the parent. die $error if $error and !eval { $error->isa('Test::Builder::Exception') }; local $Test::Builder::Level = $Test::Builder::Level + 1; return $child->finalize; } #line 281 sub _plan_handled { my $self = shift; return $self->{Have_Plan} || $self->{No_Plan} || $self->{Skip_All}; } #line 306 sub finalize { my $self = shift; return unless $self->parent; if( $self->{Child_Name} ) { $self->croak("Can't call finalize() with child ($self->{Child_Name}) active"); } local $? = 0; # don't fail if $subtests happened to set $? nonzero $self->_ending; # XXX This will only be necessary for TAP envelopes (we think) #$self->_print( $self->is_passing ? "PASS\n" : "FAIL\n" ); local $Test::Builder::Level = $Test::Builder::Level + 1; my $ok = 1; $self->parent->{Child_Name} = undef; if ( $self->{Skip_All} ) { $self->parent->skip($self->{Skip_All}); } elsif ( not @{ $self->{Test_Results} } ) { $self->parent->ok( 0, sprintf q[No tests run for subtest "%s"], $self->name ); } else { $self->parent->ok( $self->is_passing, $self->name ); } $? = $self->{Child_Error}; delete $self->{Parent}; return $self->is_passing; } sub _indent { my $self = shift; if( @_ ) { $self->{Indent} = shift; } return $self->{Indent}; } #line 359 sub parent { shift->{Parent} } #line 371 sub name { shift->{Name} } sub DESTROY { my $self = shift; if ( $self->parent and $$ == $self->{Original_Pid} ) { my $name = $self->name; $self->diag(<<"FAIL"); Child ($name) exited without calling finalize() FAIL $self->parent->{In_Destroy} = 1; $self->parent->ok(0, $name); } } #line 395 our $Level; sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms) my($self) = @_; # We leave this a global because it has to be localized and localizing # hash keys is just asking for pain. Also, it was documented. $Level = 1; $self->{Name} = $0; $self->is_passing(1); $self->{Ending} = 0; $self->{Have_Plan} = 0; $self->{No_Plan} = 0; $self->{Have_Output_Plan} = 0; $self->{Done_Testing} = 0; $self->{Original_Pid} = $$; $self->{Child_Name} = undef; $self->{Indent} ||= ''; share( $self->{Curr_Test} ); $self->{Curr_Test} = 0; $self->{Test_Results} = &share( [] ); $self->{Exported_To} = undef; $self->{Expected_Tests} = 0; $self->{Skip_All} = 0; $self->{Use_Nums} = 1; $self->{No_Header} = 0; $self->{No_Ending} = 0; $self->{Todo} = undef; $self->{Todo_Stack} = []; $self->{Start_Todo} = 0; $self->{Opened_Testhandles} = 0; $self->_dup_stdhandles; return; } #line 474 my %plan_cmds = ( no_plan => \&no_plan, skip_all => \&skip_all, tests => \&_plan_tests, ); sub plan { my( $self, $cmd, $arg ) = @_; return unless $cmd; local $Level = $Level + 1; $self->croak("You tried to plan twice") if $self->{Have_Plan}; if( my $method = $plan_cmds{$cmd} ) { local $Level = $Level + 1; $self->$method($arg); } else { my @args = grep { defined } ( $cmd, $arg ); $self->croak("plan() doesn't understand @args"); } return 1; } sub _plan_tests { my($self, $arg) = @_; if($arg) { local $Level = $Level + 1; return $self->expected_tests($arg); } elsif( !defined $arg ) { $self->croak("Got an undefined number of tests"); } else { $self->croak("You said to run 0 tests"); } return; } #line 529 sub expected_tests { my $self = shift; my($max) = @_; if(@_) { $self->croak("Number of tests must be a positive integer. You gave it '$max'") unless $max =~ /^\+?\d+$/; $self->{Expected_Tests} = $max; $self->{Have_Plan} = 1; $self->_output_plan($max) unless $self->no_header; } return $self->{Expected_Tests}; } #line 553 sub no_plan { my($self, $arg) = @_; $self->carp("no_plan takes no arguments") if $arg; $self->{No_Plan} = 1; $self->{Have_Plan} = 1; return 1; } #line 586 sub _output_plan { my($self, $max, $directive, $reason) = @_; $self->carp("The plan was already output") if $self->{Have_Output_Plan}; my $plan = "1..$max"; $plan .= " # $directive" if defined $directive; $plan .= " $reason" if defined $reason; $self->_print("$plan\n"); $self->{Have_Output_Plan} = 1; return; } #line 638 sub done_testing { my($self, $num_tests) = @_; # If done_testing() specified the number of tests, shut off no_plan. if( defined $num_tests ) { $self->{No_Plan} = 0; } else { $num_tests = $self->current_test; } if( $self->{Done_Testing} ) { my($file, $line) = @{$self->{Done_Testing}}[1,2]; $self->ok(0, "done_testing() was already called at $file line $line"); return; } $self->{Done_Testing} = [caller]; if( $self->expected_tests && $num_tests != $self->expected_tests ) { $self->ok(0, "planned to run @{[ $self->expected_tests ]} ". "but done_testing() expects $num_tests"); } else { $self->{Expected_Tests} = $num_tests; } $self->_output_plan($num_tests) unless $self->{Have_Output_Plan}; $self->{Have_Plan} = 1; # The wrong number of tests were run $self->is_passing(0) if $self->{Expected_Tests} != $self->{Curr_Test}; # No tests were run $self->is_passing(0) if $self->{Curr_Test} == 0; return 1; } #line 689 sub has_plan { my $self = shift; return( $self->{Expected_Tests} ) if $self->{Expected_Tests}; return('no_plan') if $self->{No_Plan}; return(undef); } #line 706 sub skip_all { my( $self, $reason ) = @_; $self->{Skip_All} = $self->parent ? $reason : 1; $self->_output_plan(0, "SKIP", $reason) unless $self->no_header; if ( $self->parent ) { die bless {} => 'Test::Builder::Exception'; } exit(0); } #line 731 sub exported_to { my( $self, $pack ) = @_; if( defined $pack ) { $self->{Exported_To} = $pack; } return $self->{Exported_To}; } #line 761 sub ok { my( $self, $test, $name ) = @_; if ( $self->{Child_Name} and not $self->{In_Destroy} ) { $name = 'unnamed test' unless defined $name; $self->is_passing(0); $self->croak("Cannot run test ($name) with active children"); } # $test might contain an object which we don't want to accidentally # store, so we turn it into a boolean. $test = $test ? 1 : 0; lock $self->{Curr_Test}; $self->{Curr_Test}++; # In case $name is a string overloaded object, force it to stringify. $self->_unoverload_str( \$name ); $self->diag(<<"ERR") if defined $name and $name =~ /^[\d\s]+$/; You named your test '$name'. You shouldn't use numbers for your test names. Very confusing. ERR # Capture the value of $TODO for the rest of this ok() call # so it can more easily be found by other routines. my $todo = $self->todo(); my $in_todo = $self->in_todo; local $self->{Todo} = $todo if $in_todo; $self->_unoverload_str( \$todo ); my $out; my $result = &share( {} ); unless($test) { $out .= "not "; @$result{ 'ok', 'actual_ok' } = ( ( $self->in_todo ? 1 : 0 ), 0 ); } else { @$result{ 'ok', 'actual_ok' } = ( 1, $test ); } $out .= "ok"; $out .= " $self->{Curr_Test}" if $self->use_numbers; if( defined $name ) { $name =~ s|#|\\#|g; # # in a name can confuse Test::Harness. $out .= " - $name"; $result->{name} = $name; } else { $result->{name} = ''; } if( $self->in_todo ) { $out .= " # TODO $todo"; $result->{reason} = $todo; $result->{type} = 'todo'; } else { $result->{reason} = ''; $result->{type} = ''; } $self->{Test_Results}[ $self->{Curr_Test} - 1 ] = $result; $out .= "\n"; $self->_print($out); unless($test) { my $msg = $self->in_todo ? "Failed (TODO)" : "Failed"; $self->_print_to_fh( $self->_diag_fh, "\n" ) if $ENV{HARNESS_ACTIVE}; my( undef, $file, $line ) = $self->caller; if( defined $name ) { $self->diag(qq[ $msg test '$name'\n]); $self->diag(qq[ at $file line $line.\n]); } else { $self->diag(qq[ $msg test at $file line $line.\n]); } } $self->is_passing(0) unless $test || $self->in_todo; # Check that we haven't violated the plan $self->_check_is_passing_plan(); return $test ? 1 : 0; } # Check that we haven't yet violated the plan and set # is_passing() accordingly sub _check_is_passing_plan { my $self = shift; my $plan = $self->has_plan; return unless defined $plan; # no plan yet defined return unless $plan !~ /\D/; # no numeric plan $self->is_passing(0) if $plan < $self->{Curr_Test}; } sub _unoverload { my $self = shift; my $type = shift; $self->_try(sub { require overload; }, die_on_fail => 1); foreach my $thing (@_) { if( $self->_is_object($$thing) ) { if( my $string_meth = overload::Method( $$thing, $type ) ) { $$thing = $$thing->$string_meth(); } } } return; } sub _is_object { my( $self, $thing ) = @_; return $self->_try( sub { ref $thing && $thing->isa('UNIVERSAL') } ) ? 1 : 0; } sub _unoverload_str { my $self = shift; return $self->_unoverload( q[""], @_ ); } sub _unoverload_num { my $self = shift; $self->_unoverload( '0+', @_ ); for my $val (@_) { next unless $self->_is_dualvar($$val); $$val = $$val + 0; } return; } # This is a hack to detect a dualvar such as $! sub _is_dualvar { my( $self, $val ) = @_; # Objects are not dualvars. return 0 if ref $val; no warnings 'numeric'; my $numval = $val + 0; return $numval != 0 and $numval ne $val ? 1 : 0; } #line 939 sub is_eq { my( $self, $got, $expect, $name ) = @_; local $Level = $Level + 1; if( !defined $got || !defined $expect ) { # undef only matches undef and nothing else my $test = !defined $got && !defined $expect; $self->ok( $test, $name ); $self->_is_diag( $got, 'eq', $expect ) unless $test; return $test; } return $self->cmp_ok( $got, 'eq', $expect, $name ); } sub is_num { my( $self, $got, $expect, $name ) = @_; local $Level = $Level + 1; if( !defined $got || !defined $expect ) { # undef only matches undef and nothing else my $test = !defined $got && !defined $expect; $self->ok( $test, $name ); $self->_is_diag( $got, '==', $expect ) unless $test; return $test; } return $self->cmp_ok( $got, '==', $expect, $name ); } sub _diag_fmt { my( $self, $type, $val ) = @_; if( defined $$val ) { if( $type eq 'eq' or $type eq 'ne' ) { # quote and force string context $$val = "'$$val'"; } else { # force numeric context $self->_unoverload_num($val); } } else { $$val = 'undef'; } return; } sub _is_diag { my( $self, $got, $type, $expect ) = @_; $self->_diag_fmt( $type, $_ ) for \$got, \$expect; local $Level = $Level + 1; return $self->diag(<<"DIAGNOSTIC"); got: $got expected: $expect DIAGNOSTIC } sub _isnt_diag { my( $self, $got, $type ) = @_; $self->_diag_fmt( $type, \$got ); local $Level = $Level + 1; return $self->diag(<<"DIAGNOSTIC"); got: $got expected: anything else DIAGNOSTIC } #line 1032 sub isnt_eq { my( $self, $got, $dont_expect, $name ) = @_; local $Level = $Level + 1; if( !defined $got || !defined $dont_expect ) { # undef only matches undef and nothing else my $test = defined $got || defined $dont_expect; $self->ok( $test, $name ); $self->_isnt_diag( $got, 'ne' ) unless $test; return $test; } return $self->cmp_ok( $got, 'ne', $dont_expect, $name ); } sub isnt_num { my( $self, $got, $dont_expect, $name ) = @_; local $Level = $Level + 1; if( !defined $got || !defined $dont_expect ) { # undef only matches undef and nothing else my $test = defined $got || defined $dont_expect; $self->ok( $test, $name ); $self->_isnt_diag( $got, '!=' ) unless $test; return $test; } return $self->cmp_ok( $got, '!=', $dont_expect, $name ); } #line 1081 sub like { my( $self, $this, $regex, $name ) = @_; local $Level = $Level + 1; return $self->_regex_ok( $this, $regex, '=~', $name ); } sub unlike { my( $self, $this, $regex, $name ) = @_; local $Level = $Level + 1; return $self->_regex_ok( $this, $regex, '!~', $name ); } #line 1105 my %numeric_cmps = map { ( $_, 1 ) } ( "<", "<=", ">", ">=", "==", "!=", "<=>" ); sub cmp_ok { my( $self, $got, $type, $expect, $name ) = @_; my $test; my $error; { ## no critic (BuiltinFunctions::ProhibitStringyEval) local( $@, $!, $SIG{__DIE__} ); # isolate eval my($pack, $file, $line) = $self->caller(); # This is so that warnings come out at the caller's level $test = eval qq[ #line $line "(eval in cmp_ok) $file" \$got $type \$expect; ]; $error = $@; } local $Level = $Level + 1; my $ok = $self->ok( $test, $name ); # Treat overloaded objects as numbers if we're asked to do a # numeric comparison. my $unoverload = $numeric_cmps{$type} ? '_unoverload_num' : '_unoverload_str'; $self->diag(<<"END") if $error; An error occurred while using $type: ------------------------------------ $error ------------------------------------ END unless($ok) { $self->$unoverload( \$got, \$expect ); if( $type =~ /^(eq|==)$/ ) { $self->_is_diag( $got, $type, $expect ); } elsif( $type =~ /^(ne|!=)$/ ) { $self->_isnt_diag( $got, $type ); } else { $self->_cmp_diag( $got, $type, $expect ); } } return $ok; } sub _cmp_diag { my( $self, $got, $type, $expect ) = @_; $got = defined $got ? "'$got'" : 'undef'; $expect = defined $expect ? "'$expect'" : 'undef'; local $Level = $Level + 1; return $self->diag(<<"DIAGNOSTIC"); $got $type $expect DIAGNOSTIC } sub _caller_context { my $self = shift; my( $pack, $file, $line ) = $self->caller(1); my $code = ''; $code .= "#line $line $file\n" if defined $file and defined $line; return $code; } #line 1205 sub BAIL_OUT { my( $self, $reason ) = @_; $self->{Bailed_Out} = 1; $self->_print("Bail out! $reason"); exit 255; } #line 1218 { no warnings 'once'; *BAILOUT = \&BAIL_OUT; } #line 1232 sub skip { my( $self, $why ) = @_; $why ||= ''; $self->_unoverload_str( \$why ); lock( $self->{Curr_Test} ); $self->{Curr_Test}++; $self->{Test_Results}[ $self->{Curr_Test} - 1 ] = &share( { 'ok' => 1, actual_ok => 1, name => '', type => 'skip', reason => $why, } ); my $out = "ok"; $out .= " $self->{Curr_Test}" if $self->use_numbers; $out .= " # skip"; $out .= " $why" if length $why; $out .= "\n"; $self->_print($out); return 1; } #line 1273 sub todo_skip { my( $self, $why ) = @_; $why ||= ''; lock( $self->{Curr_Test} ); $self->{Curr_Test}++; $self->{Test_Results}[ $self->{Curr_Test} - 1 ] = &share( { 'ok' => 1, actual_ok => 0, name => '', type => 'todo_skip', reason => $why, } ); my $out = "not ok"; $out .= " $self->{Curr_Test}" if $self->use_numbers; $out .= " # TODO & SKIP $why\n"; $self->_print($out); return 1; } #line 1353 sub maybe_regex { my( $self, $regex ) = @_; my $usable_regex = undef; return $usable_regex unless defined $regex; my( $re, $opts ); # Check for qr/foo/ if( _is_qr($regex) ) { $usable_regex = $regex; } # Check for '/foo/' or 'm,foo,' elsif(( $re, $opts ) = $regex =~ m{^ /(.*)/ (\w*) $ }sx or ( undef, $re, $opts ) = $regex =~ m,^ m([^\w\s]) (.+) \1 (\w*) $,sx ) { $usable_regex = length $opts ? "(?$opts)$re" : $re; } return $usable_regex; } sub _is_qr { my $regex = shift; # is_regexp() checks for regexes in a robust manner, say if they're # blessed. return re::is_regexp($regex) if defined &re::is_regexp; return ref $regex eq 'Regexp'; } sub _regex_ok { my( $self, $this, $regex, $cmp, $name ) = @_; my $ok = 0; my $usable_regex = $self->maybe_regex($regex); unless( defined $usable_regex ) { local $Level = $Level + 1; $ok = $self->ok( 0, $name ); $self->diag(" '$regex' doesn't look much like a regex to me."); return $ok; } { ## no critic (BuiltinFunctions::ProhibitStringyEval) my $test; my $context = $self->_caller_context; local( $@, $!, $SIG{__DIE__} ); # isolate eval $test = eval $context . q{$test = $this =~ /$usable_regex/ ? 1 : 0}; $test = !$test if $cmp eq '!~'; local $Level = $Level + 1; $ok = $self->ok( $test, $name ); } unless($ok) { $this = defined $this ? "'$this'" : 'undef'; my $match = $cmp eq '=~' ? "doesn't match" : "matches"; local $Level = $Level + 1; $self->diag( sprintf <<'DIAGNOSTIC', $this, $match, $regex ); %s %13s '%s' DIAGNOSTIC } return $ok; } # I'm not ready to publish this. It doesn't deal with array return # values from the code or context. #line 1449 sub _try { my( $self, $code, %opts ) = @_; my $error; my $return; { local $!; # eval can mess up $! local $@; # don't set $@ in the test local $SIG{__DIE__}; # don't trip an outside DIE handler. $return = eval { $code->() }; $error = $@; } die $error if $error and $opts{die_on_fail}; return wantarray ? ( $return, $error ) : $return; } #line 1478 sub is_fh { my $self = shift; my $maybe_fh = shift; return 0 unless defined $maybe_fh; return 1 if ref $maybe_fh eq 'GLOB'; # its a glob ref return 1 if ref \$maybe_fh eq 'GLOB'; # its a glob return eval { $maybe_fh->isa("IO::Handle") } || eval { tied($maybe_fh)->can('TIEHANDLE') }; } #line 1521 sub level { my( $self, $level ) = @_; if( defined $level ) { $Level = $level; } return $Level; } #line 1553 sub use_numbers { my( $self, $use_nums ) = @_; if( defined $use_nums ) { $self->{Use_Nums} = $use_nums; } return $self->{Use_Nums}; } #line 1586 foreach my $attribute (qw(No_Header No_Ending No_Diag)) { my $method = lc $attribute; my $code = sub { my( $self, $no ) = @_; if( defined $no ) { $self->{$attribute} = $no; } return $self->{$attribute}; }; no strict 'refs'; ## no critic *{ __PACKAGE__ . '::' . $method } = $code; } #line 1639 sub diag { my $self = shift; $self->_print_comment( $self->_diag_fh, @_ ); } #line 1654 sub note { my $self = shift; $self->_print_comment( $self->output, @_ ); } sub _diag_fh { my $self = shift; local $Level = $Level + 1; return $self->in_todo ? $self->todo_output : $self->failure_output; } sub _print_comment { my( $self, $fh, @msgs ) = @_; return if $self->no_diag; return unless @msgs; # Prevent printing headers when compiling (i.e. -c) return if $^C; # Smash args together like print does. # Convert undef to 'undef' so its readable. my $msg = join '', map { defined($_) ? $_ : 'undef' } @msgs; # Escape the beginning, _print will take care of the rest. $msg =~ s/^/# /; local $Level = $Level + 1; $self->_print_to_fh( $fh, $msg ); return 0; } #line 1704 sub explain { my $self = shift; return map { ref $_ ? do { $self->_try(sub { require Data::Dumper }, die_on_fail => 1); my $dumper = Data::Dumper->new( [$_] ); $dumper->Indent(1)->Terse(1); $dumper->Sortkeys(1) if $dumper->can("Sortkeys"); $dumper->Dump; } : $_ } @_; } #line 1733 sub _print { my $self = shift; return $self->_print_to_fh( $self->output, @_ ); } sub _print_to_fh { my( $self, $fh, @msgs ) = @_; # Prevent printing headers when only compiling. Mostly for when # tests are deparsed with B::Deparse return if $^C; my $msg = join '', @msgs; my $indent = $self->_indent; local( $\, $", $, ) = ( undef, ' ', '' ); # Escape each line after the first with a # so we don't # confuse Test::Harness. $msg =~ s{\n(?!\z)}{\n$indent# }sg; # Stick a newline on the end if it needs it. $msg .= "\n" unless $msg =~ /\n\z/; return print $fh $indent, $msg; } #line 1793 sub output { my( $self, $fh ) = @_; if( defined $fh ) { $self->{Out_FH} = $self->_new_fh($fh); } return $self->{Out_FH}; } sub failure_output { my( $self, $fh ) = @_; if( defined $fh ) { $self->{Fail_FH} = $self->_new_fh($fh); } return $self->{Fail_FH}; } sub todo_output { my( $self, $fh ) = @_; if( defined $fh ) { $self->{Todo_FH} = $self->_new_fh($fh); } return $self->{Todo_FH}; } sub _new_fh { my $self = shift; my($file_or_fh) = shift; my $fh; if( $self->is_fh($file_or_fh) ) { $fh = $file_or_fh; } elsif( ref $file_or_fh eq 'SCALAR' ) { # Scalar refs as filehandles was added in 5.8. if( $] >= 5.008 ) { open $fh, ">>", $file_or_fh or $self->croak("Can't open scalar ref $file_or_fh: $!"); } # Emulate scalar ref filehandles with a tie. else { $fh = Test::Builder::IO::Scalar->new($file_or_fh) or $self->croak("Can't tie scalar ref $file_or_fh"); } } else { open $fh, ">", $file_or_fh or $self->croak("Can't open test output log $file_or_fh: $!"); _autoflush($fh); } return $fh; } sub _autoflush { my($fh) = shift; my $old_fh = select $fh; $| = 1; select $old_fh; return; } my( $Testout, $Testerr ); sub _dup_stdhandles { my $self = shift; $self->_open_testhandles; # Set everything to unbuffered else plain prints to STDOUT will # come out in the wrong order from our own prints. _autoflush($Testout); _autoflush( \*STDOUT ); _autoflush($Testerr); _autoflush( \*STDERR ); $self->reset_outputs; return; } sub _open_testhandles { my $self = shift; return if $self->{Opened_Testhandles}; # We dup STDOUT and STDERR so people can change them in their # test suites while still getting normal test output. open( $Testout, ">&STDOUT" ) or die "Can't dup STDOUT: $!"; open( $Testerr, ">&STDERR" ) or die "Can't dup STDERR: $!"; $self->_copy_io_layers( \*STDOUT, $Testout ); $self->_copy_io_layers( \*STDERR, $Testerr ); $self->{Opened_Testhandles} = 1; return; } sub _copy_io_layers { my( $self, $src, $dst ) = @_; $self->_try( sub { require PerlIO; my @src_layers = PerlIO::get_layers($src); _apply_layers($dst, @src_layers) if @src_layers; } ); return; } sub _apply_layers { my ($fh, @layers) = @_; my %seen; my @unique = grep { $_ ne 'unix' and !$seen{$_}++ } @layers; binmode($fh, join(":", "", "raw", @unique)); } #line 1926 sub reset_outputs { my $self = shift; $self->output ($Testout); $self->failure_output($Testerr); $self->todo_output ($Testout); return; } #line 1952 sub _message_at_caller { my $self = shift; local $Level = $Level + 1; my( $pack, $file, $line ) = $self->caller; return join( "", @_ ) . " at $file line $line.\n"; } sub carp { my $self = shift; return warn $self->_message_at_caller(@_); } sub croak { my $self = shift; return die $self->_message_at_caller(@_); } #line 1992 sub current_test { my( $self, $num ) = @_; lock( $self->{Curr_Test} ); if( defined $num ) { $self->{Curr_Test} = $num; # If the test counter is being pushed forward fill in the details. my $test_results = $self->{Test_Results}; if( $num > @$test_results ) { my $start = @$test_results ? @$test_results : 0; for( $start .. $num - 1 ) { $test_results->[$_] = &share( { 'ok' => 1, actual_ok => undef, reason => 'incrementing test number', type => 'unknown', name => undef } ); } } # If backward, wipe history. Its their funeral. elsif( $num < @$test_results ) { $#{$test_results} = $num - 1; } } return $self->{Curr_Test}; } #line 2040 sub is_passing { my $self = shift; if( @_ ) { $self->{Is_Passing} = shift; } return $self->{Is_Passing}; } #line 2062 sub summary { my($self) = shift; return map { $_->{'ok'} } @{ $self->{Test_Results} }; } #line 2117 sub details { my $self = shift; return @{ $self->{Test_Results} }; } #line 2146 sub todo { my( $self, $pack ) = @_; return $self->{Todo} if defined $self->{Todo}; local $Level = $Level + 1; my $todo = $self->find_TODO($pack); return $todo if defined $todo; return ''; } #line 2173 sub find_TODO { my( $self, $pack, $set, $new_value ) = @_; $pack = $pack || $self->caller(1) || $self->exported_to; return unless $pack; no strict 'refs'; ## no critic my $old_value = ${ $pack . '::TODO' }; $set and ${ $pack . '::TODO' } = $new_value; return $old_value; } #line 2193 sub in_todo { my $self = shift; local $Level = $Level + 1; return( defined $self->{Todo} || $self->find_TODO ) ? 1 : 0; } #line 2243 sub todo_start { my $self = shift; my $message = @_ ? shift : ''; $self->{Start_Todo}++; if( $self->in_todo ) { push @{ $self->{Todo_Stack} } => $self->todo; } $self->{Todo} = $message; return; } #line 2265 sub todo_end { my $self = shift; if( !$self->{Start_Todo} ) { $self->croak('todo_end() called without todo_start()'); } $self->{Start_Todo}--; if( $self->{Start_Todo} && @{ $self->{Todo_Stack} } ) { $self->{Todo} = pop @{ $self->{Todo_Stack} }; } else { delete $self->{Todo}; } return; } #line 2298 sub caller { ## no critic (Subroutines::ProhibitBuiltinHomonyms) my( $self, $height ) = @_; $height ||= 0; my $level = $self->level + $height + 1; my @caller; do { @caller = CORE::caller( $level ); $level--; } until @caller; return wantarray ? @caller : $caller[0]; } #line 2315 #line 2329 #'# sub _sanity_check { my $self = shift; $self->_whoa( $self->{Curr_Test} < 0, 'Says here you ran a negative number of tests!' ); $self->_whoa( $self->{Curr_Test} != @{ $self->{Test_Results} }, 'Somehow you got a different number of results than tests ran!' ); return; } #line 2350 sub _whoa { my( $self, $check, $desc ) = @_; if($check) { local $Level = $Level + 1; $self->croak(<<"WHOA"); WHOA! $desc This should never happen! Please contact the author immediately! WHOA } return; } #line 2374 sub _my_exit { $? = $_[0]; ## no critic (Variables::RequireLocalizedPunctuationVars) return 1; } #line 2386 sub _ending { my $self = shift; return if $self->no_ending; return if $self->{Ending}++; my $real_exit_code = $?; # Don't bother with an ending if this is a forked copy. Only the parent # should do the ending. if( $self->{Original_Pid} != $$ ) { return; } # Ran tests but never declared a plan or hit done_testing if( !$self->{Have_Plan} and $self->{Curr_Test} ) { $self->is_passing(0); $self->diag("Tests were run but no plan was declared and done_testing() was not seen."); } # Exit if plan() was never called. This is so "require Test::Simple" # doesn't puke. if( !$self->{Have_Plan} ) { return; } # Don't do an ending if we bailed out. if( $self->{Bailed_Out} ) { $self->is_passing(0); return; } # Figure out if we passed or failed and print helpful messages. my $test_results = $self->{Test_Results}; if(@$test_results) { # The plan? We have no plan. if( $self->{No_Plan} ) { $self->_output_plan($self->{Curr_Test}) unless $self->no_header; $self->{Expected_Tests} = $self->{Curr_Test}; } # Auto-extended arrays and elements which aren't explicitly # filled in with a shared reference will puke under 5.8.0 # ithreads. So we have to fill them in by hand. :( my $empty_result = &share( {} ); for my $idx ( 0 .. $self->{Expected_Tests} - 1 ) { $test_results->[$idx] = $empty_result unless defined $test_results->[$idx]; } my $num_failed = grep !$_->{'ok'}, @{$test_results}[ 0 .. $self->{Curr_Test} - 1 ]; my $num_extra = $self->{Curr_Test} - $self->{Expected_Tests}; if( $num_extra != 0 ) { my $s = $self->{Expected_Tests} == 1 ? '' : 's'; $self->diag(<<"FAIL"); Looks like you planned $self->{Expected_Tests} test$s but ran $self->{Curr_Test}. FAIL $self->is_passing(0); } if($num_failed) { my $num_tests = $self->{Curr_Test}; my $s = $num_failed == 1 ? '' : 's'; my $qualifier = $num_extra == 0 ? '' : ' run'; $self->diag(<<"FAIL"); Looks like you failed $num_failed test$s of $num_tests$qualifier. FAIL $self->is_passing(0); } if($real_exit_code) { $self->diag(<<"FAIL"); Looks like your test exited with $real_exit_code just after $self->{Curr_Test}. FAIL $self->is_passing(0); _my_exit($real_exit_code) && return; } my $exit_code; if($num_failed) { $exit_code = $num_failed <= 254 ? $num_failed : 254; } elsif( $num_extra != 0 ) { $exit_code = 255; } else { $exit_code = 0; } _my_exit($exit_code) && return; } elsif( $self->{Skip_All} ) { _my_exit(0) && return; } elsif($real_exit_code) { $self->diag(<<"FAIL"); Looks like your test exited with $real_exit_code before it could output anything. FAIL $self->is_passing(0); _my_exit($real_exit_code) && return; } else { $self->diag("No tests run!\n"); $self->is_passing(0); _my_exit(255) && return; } $self->is_passing(0); $self->_whoa( 1, "We fell off the end of _ending()" ); } END { $Test->_ending if defined $Test; } #line 2574 1; YAML-0.84/inc/Test/More.pm0000644000372100001440000004140012000063152014677 0ustar matthewtusers#line 1 package Test::More; use 5.006; use strict; use warnings; #---- perlcritic exemptions. ----# # We use a lot of subroutine prototypes ## no critic (Subroutines::ProhibitSubroutinePrototypes) # Can't use Carp because it might cause use_ok() to accidentally succeed # even though the module being used forgot to use Carp. Yes, this # actually happened. sub _carp { my( $file, $line ) = ( caller(1) )[ 1, 2 ]; return warn @_, " at $file line $line\n"; } our $VERSION = '0.98'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Builder::Module; our @ISA = qw(Test::Builder::Module); our @EXPORT = qw(ok use_ok require_ok is isnt like unlike is_deeply cmp_ok skip todo todo_skip pass fail eq_array eq_hash eq_set $TODO plan done_testing can_ok isa_ok new_ok diag note explain subtest BAIL_OUT ); #line 164 sub plan { my $tb = Test::More->builder; return $tb->plan(@_); } # This implements "use Test::More 'no_diag'" but the behavior is # deprecated. sub import_extra { my $class = shift; my $list = shift; my @other = (); my $idx = 0; while( $idx <= $#{$list} ) { my $item = $list->[$idx]; if( defined $item and $item eq 'no_diag' ) { $class->builder->no_diag(1); } else { push @other, $item; } $idx++; } @$list = @other; return; } #line 217 sub done_testing { my $tb = Test::More->builder; $tb->done_testing(@_); } #line 289 sub ok ($;$) { my( $test, $name ) = @_; my $tb = Test::More->builder; return $tb->ok( $test, $name ); } #line 372 sub is ($$;$) { my $tb = Test::More->builder; return $tb->is_eq(@_); } sub isnt ($$;$) { my $tb = Test::More->builder; return $tb->isnt_eq(@_); } *isn't = \&isnt; #line 416 sub like ($$;$) { my $tb = Test::More->builder; return $tb->like(@_); } #line 431 sub unlike ($$;$) { my $tb = Test::More->builder; return $tb->unlike(@_); } #line 476 sub cmp_ok($$$;$) { my $tb = Test::More->builder; return $tb->cmp_ok(@_); } #line 511 sub can_ok ($@) { my( $proto, @methods ) = @_; my $class = ref $proto || $proto; my $tb = Test::More->builder; unless($class) { my $ok = $tb->ok( 0, "->can(...)" ); $tb->diag(' can_ok() called with empty class or reference'); return $ok; } unless(@methods) { my $ok = $tb->ok( 0, "$class->can(...)" ); $tb->diag(' can_ok() called with no methods'); return $ok; } my @nok = (); foreach my $method (@methods) { $tb->_try( sub { $proto->can($method) } ) or push @nok, $method; } my $name = (@methods == 1) ? "$class->can('$methods[0]')" : "$class->can(...)" ; my $ok = $tb->ok( !@nok, $name ); $tb->diag( map " $class->can('$_') failed\n", @nok ); return $ok; } #line 577 sub isa_ok ($$;$) { my( $object, $class, $obj_name ) = @_; my $tb = Test::More->builder; my $diag; if( !defined $object ) { $obj_name = 'The thing' unless defined $obj_name; $diag = "$obj_name isn't defined"; } else { my $whatami = ref $object ? 'object' : 'class'; # We can't use UNIVERSAL::isa because we want to honor isa() overrides my( $rslt, $error ) = $tb->_try( sub { $object->isa($class) } ); if($error) { if( $error =~ /^Can't call method "isa" on unblessed reference/ ) { # Its an unblessed reference $obj_name = 'The reference' unless defined $obj_name; if( !UNIVERSAL::isa( $object, $class ) ) { my $ref = ref $object; $diag = "$obj_name isn't a '$class' it's a '$ref'"; } } elsif( $error =~ /Can't call method "isa" without a package/ ) { # It's something that can't even be a class $obj_name = 'The thing' unless defined $obj_name; $diag = "$obj_name isn't a class or reference"; } else { die <isa on your $whatami and got some weird error. Here's the error. $error WHOA } } else { $obj_name = "The $whatami" unless defined $obj_name; if( !$rslt ) { my $ref = ref $object; $diag = "$obj_name isn't a '$class' it's a '$ref'"; } } } my $name = "$obj_name isa $class"; my $ok; if($diag) { $ok = $tb->ok( 0, $name ); $tb->diag(" $diag\n"); } else { $ok = $tb->ok( 1, $name ); } return $ok; } #line 656 sub new_ok { my $tb = Test::More->builder; $tb->croak("new_ok() must be given at least a class") unless @_; my( $class, $args, $object_name ) = @_; $args ||= []; $object_name = "The object" unless defined $object_name; my $obj; my( $success, $error ) = $tb->_try( sub { $obj = $class->new(@$args); 1 } ); if($success) { local $Test::Builder::Level = $Test::Builder::Level + 1; isa_ok $obj, $class, $object_name; } else { $tb->ok( 0, "new() died" ); $tb->diag(" Error was: $error"); } return $obj; } #line 741 sub subtest { my ($name, $subtests) = @_; my $tb = Test::More->builder; return $tb->subtest(@_); } #line 765 sub pass (;$) { my $tb = Test::More->builder; return $tb->ok( 1, @_ ); } sub fail (;$) { my $tb = Test::More->builder; return $tb->ok( 0, @_ ); } #line 833 sub use_ok ($;@) { my( $module, @imports ) = @_; @imports = () unless @imports; my $tb = Test::More->builder; my( $pack, $filename, $line ) = caller; my $code; if( @imports == 1 and $imports[0] =~ /^\d+(?:\.\d+)?$/ ) { # probably a version check. Perl needs to see the bare number # for it to work with non-Exporter based modules. $code = <ok( $eval_result, "use $module;" ); unless($ok) { chomp $eval_error; $@ =~ s{^BEGIN failed--compilation aborted at .*$} {BEGIN failed--compilation aborted at $filename line $line.}m; $tb->diag(<builder; my $pack = caller; # Try to determine if we've been given a module name or file. # Module names must be barewords, files not. $module = qq['$module'] unless _is_module_name($module); my $code = <ok( $eval_result, "require $module;" ); unless($ok) { chomp $eval_error; $tb->diag(<builder; unless( @_ == 2 or @_ == 3 ) { my $msg = <<'WARNING'; is_deeply() takes two or three args, you gave %d. This usually means you passed an array or hash instead of a reference to it WARNING chop $msg; # clip off newline so carp() will put in line/file _carp sprintf $msg, scalar @_; return $tb->ok(0); } my( $got, $expected, $name ) = @_; $tb->_unoverload_str( \$expected, \$got ); my $ok; if( !ref $got and !ref $expected ) { # neither is a reference $ok = $tb->is_eq( $got, $expected, $name ); } elsif( !ref $got xor !ref $expected ) { # one's a reference, one isn't $ok = $tb->ok( 0, $name ); $tb->diag( _format_stack({ vals => [ $got, $expected ] }) ); } else { # both references local @Data_Stack = (); if( _deep_check( $got, $expected ) ) { $ok = $tb->ok( 1, $name ); } else { $ok = $tb->ok( 0, $name ); $tb->diag( _format_stack(@Data_Stack) ); } } return $ok; } sub _format_stack { my(@Stack) = @_; my $var = '$FOO'; my $did_arrow = 0; foreach my $entry (@Stack) { my $type = $entry->{type} || ''; my $idx = $entry->{'idx'}; if( $type eq 'HASH' ) { $var .= "->" unless $did_arrow++; $var .= "{$idx}"; } elsif( $type eq 'ARRAY' ) { $var .= "->" unless $did_arrow++; $var .= "[$idx]"; } elsif( $type eq 'REF' ) { $var = "\${$var}"; } } my @vals = @{ $Stack[-1]{vals} }[ 0, 1 ]; my @vars = (); ( $vars[0] = $var ) =~ s/\$FOO/ \$got/; ( $vars[1] = $var ) =~ s/\$FOO/\$expected/; my $out = "Structures begin differing at:\n"; foreach my $idx ( 0 .. $#vals ) { my $val = $vals[$idx]; $vals[$idx] = !defined $val ? 'undef' : _dne($val) ? "Does not exist" : ref $val ? "$val" : "'$val'"; } $out .= "$vars[0] = $vals[0]\n"; $out .= "$vars[1] = $vals[1]\n"; $out =~ s/^/ /msg; return $out; } sub _type { my $thing = shift; return '' if !ref $thing; for my $type (qw(Regexp ARRAY HASH REF SCALAR GLOB CODE)) { return $type if UNIVERSAL::isa( $thing, $type ); } return ''; } #line 1139 sub diag { return Test::More->builder->diag(@_); } sub note { return Test::More->builder->note(@_); } #line 1165 sub explain { return Test::More->builder->explain(@_); } #line 1231 ## no critic (Subroutines::RequireFinalReturn) sub skip { my( $why, $how_many ) = @_; my $tb = Test::More->builder; unless( defined $how_many ) { # $how_many can only be avoided when no_plan is in use. _carp "skip() needs to know \$how_many tests are in the block" unless $tb->has_plan eq 'no_plan'; $how_many = 1; } if( defined $how_many and $how_many =~ /\D/ ) { _carp "skip() was passed a non-numeric number of tests. Did you get the arguments backwards?"; $how_many = 1; } for( 1 .. $how_many ) { $tb->skip($why); } no warnings 'exiting'; last SKIP; } #line 1315 sub todo_skip { my( $why, $how_many ) = @_; my $tb = Test::More->builder; unless( defined $how_many ) { # $how_many can only be avoided when no_plan is in use. _carp "todo_skip() needs to know \$how_many tests are in the block" unless $tb->has_plan eq 'no_plan'; $how_many = 1; } for( 1 .. $how_many ) { $tb->todo_skip($why); } no warnings 'exiting'; last TODO; } #line 1370 sub BAIL_OUT { my $reason = shift; my $tb = Test::More->builder; $tb->BAIL_OUT($reason); } #line 1409 #'# sub eq_array { local @Data_Stack = (); _deep_check(@_); } sub _eq_array { my( $a1, $a2 ) = @_; if( grep _type($_) ne 'ARRAY', $a1, $a2 ) { warn "eq_array passed a non-array ref"; return 0; } return 1 if $a1 eq $a2; my $ok = 1; my $max = $#$a1 > $#$a2 ? $#$a1 : $#$a2; for( 0 .. $max ) { my $e1 = $_ > $#$a1 ? $DNE : $a1->[$_]; my $e2 = $_ > $#$a2 ? $DNE : $a2->[$_]; next if _equal_nonrefs($e1, $e2); push @Data_Stack, { type => 'ARRAY', idx => $_, vals => [ $e1, $e2 ] }; $ok = _deep_check( $e1, $e2 ); pop @Data_Stack if $ok; last unless $ok; } return $ok; } sub _equal_nonrefs { my( $e1, $e2 ) = @_; return if ref $e1 or ref $e2; if ( defined $e1 ) { return 1 if defined $e2 and $e1 eq $e2; } else { return 1 if !defined $e2; } return; } sub _deep_check { my( $e1, $e2 ) = @_; my $tb = Test::More->builder; my $ok = 0; # Effectively turn %Refs_Seen into a stack. This avoids picking up # the same referenced used twice (such as [\$a, \$a]) to be considered # circular. local %Refs_Seen = %Refs_Seen; { $tb->_unoverload_str( \$e1, \$e2 ); # Either they're both references or both not. my $same_ref = !( !ref $e1 xor !ref $e2 ); my $not_ref = ( !ref $e1 and !ref $e2 ); if( defined $e1 xor defined $e2 ) { $ok = 0; } elsif( !defined $e1 and !defined $e2 ) { # Shortcut if they're both undefined. $ok = 1; } elsif( _dne($e1) xor _dne($e2) ) { $ok = 0; } elsif( $same_ref and( $e1 eq $e2 ) ) { $ok = 1; } elsif($not_ref) { push @Data_Stack, { type => '', vals => [ $e1, $e2 ] }; $ok = 0; } else { if( $Refs_Seen{$e1} ) { return $Refs_Seen{$e1} eq $e2; } else { $Refs_Seen{$e1} = "$e2"; } my $type = _type($e1); $type = 'DIFFERENT' unless _type($e2) eq $type; if( $type eq 'DIFFERENT' ) { push @Data_Stack, { type => $type, vals => [ $e1, $e2 ] }; $ok = 0; } elsif( $type eq 'ARRAY' ) { $ok = _eq_array( $e1, $e2 ); } elsif( $type eq 'HASH' ) { $ok = _eq_hash( $e1, $e2 ); } elsif( $type eq 'REF' ) { push @Data_Stack, { type => $type, vals => [ $e1, $e2 ] }; $ok = _deep_check( $$e1, $$e2 ); pop @Data_Stack if $ok; } elsif( $type eq 'SCALAR' ) { push @Data_Stack, { type => 'REF', vals => [ $e1, $e2 ] }; $ok = _deep_check( $$e1, $$e2 ); pop @Data_Stack if $ok; } elsif($type) { push @Data_Stack, { type => $type, vals => [ $e1, $e2 ] }; $ok = 0; } else { _whoa( 1, "No type in _deep_check" ); } } } return $ok; } sub _whoa { my( $check, $desc ) = @_; if($check) { die <<"WHOA"; WHOA! $desc This should never happen! Please contact the author immediately! WHOA } } #line 1556 sub eq_hash { local @Data_Stack = (); return _deep_check(@_); } sub _eq_hash { my( $a1, $a2 ) = @_; if( grep _type($_) ne 'HASH', $a1, $a2 ) { warn "eq_hash passed a non-hash ref"; return 0; } return 1 if $a1 eq $a2; my $ok = 1; my $bigger = keys %$a1 > keys %$a2 ? $a1 : $a2; foreach my $k ( keys %$bigger ) { my $e1 = exists $a1->{$k} ? $a1->{$k} : $DNE; my $e2 = exists $a2->{$k} ? $a2->{$k} : $DNE; next if _equal_nonrefs($e1, $e2); push @Data_Stack, { type => 'HASH', idx => $k, vals => [ $e1, $e2 ] }; $ok = _deep_check( $e1, $e2 ); pop @Data_Stack if $ok; last unless $ok; } return $ok; } #line 1615 sub eq_set { my( $a1, $a2 ) = @_; return 0 unless @$a1 == @$a2; no warnings 'uninitialized'; # It really doesn't matter how we sort them, as long as both arrays are # sorted with the same algorithm. # # Ensure that references are not accidentally treated the same as a # string containing the reference. # # Have to inline the sort routine due to a threading/sort bug. # See [rt.cpan.org 6782] # # I don't know how references would be sorted so we just don't sort # them. This means eq_set doesn't really work with refs. return eq_array( [ grep( ref, @$a1 ), sort( grep( !ref, @$a1 ) ) ], [ grep( ref, @$a2 ), sort( grep( !ref, @$a2 ) ) ], ); } #line 1817 1; YAML-0.84/inc/Spiffy.pm0000644000372100001440000003623112000063151014323 0ustar matthewtusers#line 1 package Spiffy; use strict; use 5.006001; use warnings; use Carp; require Exporter; our $VERSION = '0.30'; our @EXPORT = (); our @EXPORT_BASE = qw(field const stub super); our @EXPORT_OK = (@EXPORT_BASE, qw(id WWW XXX YYY ZZZ)); our %EXPORT_TAGS = (XXX => [qw(WWW XXX YYY ZZZ)]); my $stack_frame = 0; my $dump = 'yaml'; my $bases_map = {}; sub WWW; sub XXX; sub YYY; sub ZZZ; # This line is here to convince "autouse" into believing we are autousable. sub can { ($_[1] eq 'import' and caller()->isa('autouse')) ? \&Exporter::import # pacify autouse's equality test : $_[0]->SUPER::can($_[1]) # normal case } # TODO # # Exported functions like field and super should be hidden so as not to # be confused with methods that can be inherited. # sub new { my $class = shift; $class = ref($class) || $class; my $self = bless {}, $class; while (@_) { my $method = shift; $self->$method(shift); } return $self; } my $filtered_files = {}; my $filter_dump = 0; my $filter_save = 0; our $filter_result = ''; sub import { no strict 'refs'; no warnings; my $self_package = shift; # XXX Using parse_arguments here might cause confusion, because the # subclass's boolean_arguments and paired_arguments can conflict, causing # difficult debugging. Consider using something truly local. my ($args, @export_list) = do { local *boolean_arguments = sub { qw( -base -Base -mixin -selfless -XXX -dumper -yaml -filter_dump -filter_save ) }; local *paired_arguments = sub { qw(-package) }; $self_package->parse_arguments(@_); }; return spiffy_mixin_import(scalar(caller(0)), $self_package, @export_list) if $args->{-mixin}; $filter_dump = 1 if $args->{-filter_dump}; $filter_save = 1 if $args->{-filter_save}; $dump = 'yaml' if $args->{-yaml}; $dump = 'dumper' if $args->{-dumper}; local @EXPORT_BASE = @EXPORT_BASE; if ($args->{-XXX}) { push @EXPORT_BASE, @{$EXPORT_TAGS{XXX}} unless grep /^XXX$/, @EXPORT_BASE; } spiffy_filter() if ($args->{-selfless} or $args->{-Base}) and not $filtered_files->{(caller($stack_frame))[1]}++; my $caller_package = $args->{-package} || caller($stack_frame); push @{"$caller_package\::ISA"}, $self_package if $args->{-Base} or $args->{-base}; for my $class (@{all_my_bases($self_package)}) { next unless $class->isa('Spiffy'); my @export = grep { not defined &{"$caller_package\::$_"}; } ( @{"$class\::EXPORT"}, ($args->{-Base} or $args->{-base}) ? @{"$class\::EXPORT_BASE"} : (), ); my @export_ok = grep { not defined &{"$caller_package\::$_"}; } @{"$class\::EXPORT_OK"}; # Avoid calling the expensive Exporter::export # if there is nothing to do (optimization) my %exportable = map { ($_, 1) } @export, @export_ok; next unless keys %exportable; my @export_save = @{"$class\::EXPORT"}; my @export_ok_save = @{"$class\::EXPORT_OK"}; @{"$class\::EXPORT"} = @export; @{"$class\::EXPORT_OK"} = @export_ok; my @list = grep { (my $v = $_) =~ s/^[\!\:]//; $exportable{$v} or ${"$class\::EXPORT_TAGS"}{$v}; } @export_list; Exporter::export($class, $caller_package, @list); @{"$class\::EXPORT"} = @export_save; @{"$class\::EXPORT_OK"} = @export_ok_save; } } sub spiffy_filter { require Filter::Util::Call; my $done = 0; Filter::Util::Call::filter_add( sub { return 0 if $done; my ($data, $end) = ('', ''); while (my $status = Filter::Util::Call::filter_read()) { return $status if $status < 0; if (/^__(?:END|DATA)__\r?$/) { $end = $_; last; } $data .= $_; $_ = ''; } $_ = $data; my @my_subs; s[^(sub\s+\w+\s+\{)(.*\n)] [${1}my \$self = shift;$2]gm; s[^(sub\s+\w+)\s*\(\s*\)(\s+\{.*\n)] [${1}${2}]gm; s[^my\s+sub\s+(\w+)(\s+\{)(.*)((?s:.*?\n))\}\n] [push @my_subs, $1; "\$$1 = sub$2my \$self = shift;$3$4\};\n"]gem; my $preclare = ''; if (@my_subs) { $preclare = join ',', map "\$$_", @my_subs; $preclare = "my($preclare);"; } $_ = "use strict;use warnings;$preclare${_};1;\n$end"; if ($filter_dump) { print; exit } if ($filter_save) { $filter_result = $_; $_ = $filter_result; } $done = 1; } ); } sub base { push @_, -base; goto &import; } sub all_my_bases { my $class = shift; return $bases_map->{$class} if defined $bases_map->{$class}; my @bases = ($class); no strict 'refs'; for my $base_class (@{"${class}::ISA"}) { push @bases, @{all_my_bases($base_class)}; } my $used = {}; $bases_map->{$class} = [grep {not $used->{$_}++} @bases]; } my %code = ( sub_start => "sub {\n", set_default => " \$_[0]->{%s} = %s\n unless exists \$_[0]->{%s};\n", init => " return \$_[0]->{%s} = do { my \$self = \$_[0]; %s }\n" . " unless \$#_ > 0 or defined \$_[0]->{%s};\n", weak_init => " return do {\n" . " \$_[0]->{%s} = do { my \$self = \$_[0]; %s };\n" . " Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n" . " \$_[0]->{%s};\n" . " } unless \$#_ > 0 or defined \$_[0]->{%s};\n", return_if_get => " return \$_[0]->{%s} unless \$#_ > 0;\n", set => " \$_[0]->{%s} = \$_[1];\n", weaken => " Scalar::Util::weaken(\$_[0]->{%s}) if ref \$_[0]->{%s};\n", sub_end => " return \$_[0]->{%s};\n}\n", ); sub field { my $package = caller; my ($args, @values) = do { no warnings; local *boolean_arguments = sub { (qw(-weak)) }; local *paired_arguments = sub { (qw(-package -init)) }; Spiffy->parse_arguments(@_); }; my ($field, $default) = @values; $package = $args->{-package} if defined $args->{-package}; die "Cannot have a default for a weakened field ($field)" if defined $default && $args->{-weak}; return if defined &{"${package}::$field"}; require Scalar::Util if $args->{-weak}; my $default_string = ( ref($default) eq 'ARRAY' and not @$default ) ? '[]' : (ref($default) eq 'HASH' and not keys %$default ) ? '{}' : default_as_code($default); my $code = $code{sub_start}; if ($args->{-init}) { my $fragment = $args->{-weak} ? $code{weak_init} : $code{init}; $code .= sprintf $fragment, $field, $args->{-init}, ($field) x 4; } $code .= sprintf $code{set_default}, $field, $default_string, $field if defined $default; $code .= sprintf $code{return_if_get}, $field; $code .= sprintf $code{set}, $field; $code .= sprintf $code{weaken}, $field, $field if $args->{-weak}; $code .= sprintf $code{sub_end}, $field; my $sub = eval $code; die $@ if $@; no strict 'refs'; *{"${package}::$field"} = $sub; return $code if defined wantarray; } sub default_as_code { require Data::Dumper; local $Data::Dumper::Sortkeys = 1; my $code = Data::Dumper::Dumper(shift); $code =~ s/^\$VAR1 = //; $code =~ s/;$//; return $code; } sub const { my $package = caller; my ($args, @values) = do { no warnings; local *paired_arguments = sub { (qw(-package)) }; Spiffy->parse_arguments(@_); }; my ($field, $default) = @values; $package = $args->{-package} if defined $args->{-package}; no strict 'refs'; return if defined &{"${package}::$field"}; *{"${package}::$field"} = sub { $default } } sub stub { my $package = caller; my ($args, @values) = do { no warnings; local *paired_arguments = sub { (qw(-package)) }; Spiffy->parse_arguments(@_); }; my ($field, $default) = @values; $package = $args->{-package} if defined $args->{-package}; no strict 'refs'; return if defined &{"${package}::$field"}; *{"${package}::$field"} = sub { require Carp; Carp::confess "Method $field in package $package must be subclassed"; } } sub parse_arguments { my $class = shift; my ($args, @values) = ({}, ()); my %booleans = map { ($_, 1) } $class->boolean_arguments; my %pairs = map { ($_, 1) } $class->paired_arguments; while (@_) { my $elem = shift; if (defined $elem and defined $booleans{$elem}) { $args->{$elem} = (@_ and $_[0] =~ /^[01]$/) ? shift : 1; } elsif (defined $elem and defined $pairs{$elem} and @_) { $args->{$elem} = shift; } else { push @values, $elem; } } return wantarray ? ($args, @values) : $args; } sub boolean_arguments { () } sub paired_arguments { () } # get a unique id for any node sub id { if (not ref $_[0]) { return 'undef' if not defined $_[0]; \$_[0] =~ /\((\w+)\)$/o or die; return "$1-S"; } require overload; overload::StrVal($_[0]) =~ /\((\w+)\)$/o or die; return $1; } #=============================================================================== # It's super, man. #=============================================================================== package DB; { no warnings 'redefine'; sub super_args { my @dummy = caller(@_ ? $_[0] : 2); return @DB::args; } } package Spiffy; sub super { my $method; my $frame = 1; while ($method = (caller($frame++))[3]) { $method =~ s/.*::// and last; } my @args = DB::super_args($frame); @_ = @_ ? ($args[0], @_) : @args; my $class = ref $_[0] ? ref $_[0] : $_[0]; my $caller_class = caller; my $seen = 0; my @super_classes = reverse grep { ($seen or $seen = ($_ eq $caller_class)) ? 0 : 1; } reverse @{all_my_bases($class)}; for my $super_class (@super_classes) { no strict 'refs'; next if $super_class eq $class; if (defined &{"${super_class}::$method"}) { ${"$super_class\::AUTOLOAD"} = ${"$class\::AUTOLOAD"} if $method eq 'AUTOLOAD'; return &{"${super_class}::$method"}; } } return; } #=============================================================================== # This code deserves a spanking, because it is being very naughty. # It is exchanging base.pm's import() for its own, so that people # can use base.pm with Spiffy modules, without being the wiser. #=============================================================================== my $real_base_import; my $real_mixin_import; BEGIN { require base unless defined $INC{'base.pm'}; $INC{'mixin.pm'} ||= 'Spiffy/mixin.pm'; $real_base_import = \&base::import; $real_mixin_import = \&mixin::import; no warnings; *base::import = \&spiffy_base_import; *mixin::import = \&spiffy_mixin_import; } # my $i = 0; # while (my $caller = caller($i++)) { # next unless $caller eq 'base' or $caller eq 'mixin'; # croak <isa('Spiffy'); } @base_classes; my $inheritor = caller(0); for my $base_class (@base_classes) { next if $inheritor->isa($base_class); croak "Can't mix Spiffy and non-Spiffy classes in 'use base'.\n", "See the documentation of Spiffy.pm for details\n " unless $base_class->isa('Spiffy'); $stack_frame = 1; # tell import to use different caller import($base_class, '-base'); $stack_frame = 0; } } sub mixin { my $self = shift; my $target_class = ref($self); spiffy_mixin_import($target_class, @_) } sub spiffy_mixin_import { my $target_class = shift; $target_class = caller(0) if $target_class eq 'mixin'; my $mixin_class = shift or die "Nothing to mixin"; eval "require $mixin_class"; my @roles = @_; my $pseudo_class = join '-', $target_class, $mixin_class, @roles; my %methods = spiffy_mixin_methods($mixin_class, @roles); no strict 'refs'; no warnings; @{"$pseudo_class\::ISA"} = @{"$target_class\::ISA"}; @{"$target_class\::ISA"} = ($pseudo_class); for (keys %methods) { *{"$pseudo_class\::$_"} = $methods{$_}; } } sub spiffy_mixin_methods { my $mixin_class = shift; no strict 'refs'; my %methods = spiffy_all_methods($mixin_class); map { $methods{$_} ? ($_, \ &{"$methods{$_}\::$_"}) : ($_, \ &{"$mixin_class\::$_"}) } @_ ? (get_roles($mixin_class, @_)) : (keys %methods); } sub get_roles { my $mixin_class = shift; my @roles = @_; while (grep /^!*:/, @roles) { @roles = map { s/!!//g; /^!:(.*)/ ? do { my $m = "_role_$1"; map("!$_", $mixin_class->$m); } : /^:(.*)/ ? do { my $m = "_role_$1"; ($mixin_class->$m); } : ($_) } @roles; } if (@roles and $roles[0] =~ /^!/) { my %methods = spiffy_all_methods($mixin_class); unshift @roles, keys(%methods); } my %roles; for (@roles) { s/!!//g; delete $roles{$1}, next if /^!(.*)/; $roles{$_} = 1; } keys %roles; } sub spiffy_all_methods { no strict 'refs'; my $class = shift; return if $class eq 'Spiffy'; my %methods = map { ($_, $class) } grep { defined &{"$class\::$_"} and not /^_/ } keys %{"$class\::"}; my %super_methods; %super_methods = spiffy_all_methods(${"$class\::ISA"}[0]) if @{"$class\::ISA"}; %{{%super_methods, %methods}}; } # END of naughty code. #=============================================================================== # Debugging support #=============================================================================== sub spiffy_dump { no warnings; if ($dump eq 'dumper') { require Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; return Data::Dumper::Dumper(@_); } require YAML; $YAML::UseVersion = 0; return YAML::Dump(@_) . "...\n"; } sub at_line_number { my ($file_path, $line_number) = (caller(1))[1,2]; " at $file_path line $line_number\n"; } sub WWW { warn spiffy_dump(@_) . at_line_number; return wantarray ? @_ : $_[0]; } sub XXX { die spiffy_dump(@_) . at_line_number; } sub YYY { print spiffy_dump(@_) . at_line_number; return wantarray ? @_ : $_[0]; } sub ZZZ { require Carp; Carp::confess spiffy_dump(@_); } 1; __END__ #line 1066 YAML-0.84/lib/0000755000372100001440000000000012000063203012513 5ustar matthewtusersYAML-0.84/lib/Test/0000755000372100001440000000000012000063203013432 5ustar matthewtusersYAML-0.84/lib/Test/YAML.pm0000644000372100001440000001341112000060557014543 0ustar matthewtuserspackage Test::YAML; use Test::Base 0.47 -Base; use lib 'lib'; our $VERSION = '0.84'; our $YAML = 'YAML'; our @EXPORT = qw( no_diff run_yaml_tests run_roundtrip_nyn roundtrip_nyn run_load_passes load_passes dumper Load Dump LoadFile DumpFile XXX ); delimiters('===', '+++'); sub Dump () { YAML(Dump => @_) } sub Load () { YAML(Load => @_) } sub DumpFile () { YAML(DumpFile => @_) } sub LoadFile () { YAML(LoadFile => @_) } sub YAML () { load_yaml_pm(); my $meth = shift; my $code = $YAML->can($meth) or die "$YAML cannot do $meth"; goto &$code; } sub load_yaml_pm { my $file = "$YAML.pm"; $file =~ s{::}{/}g; require $file; } sub run_yaml_tests() { run { my $block = shift; &{_get_function($block)}($block) unless _skip_tests_for_now($block) or _skip_yaml_tests($block); }; } sub run_roundtrip_nyn() { my @options = @_; run { my $block = shift; roundtrip_nyn($block, @options); }; } sub roundtrip_nyn() { my $block = shift; my $option = shift || ''; die "'perl' data section required" unless exists $block->{perl}; my @values = eval $block->perl; die "roundtrip_nyn eval perl error: $@" if $@; my $config = $block->config || ''; my $result = eval "$config; Dump(\@values)"; die "roundtrip_nyn YAML::Dump error: $@" if $@; if (exists $block->{yaml}) { is $result, $block->yaml, $block->description . ' (n->y)'; } else { pass $block->description . ' (n->y)'; } return if exists $block->{no_round_trip} or not exists $block->{yaml}; if ($option eq 'dumper') { is dumper(Load($block->yaml)), dumper(@values), $block->description . ' (y->n)'; } else { is_deeply [Load($block->yaml)], [@values], $block->description . ' (y->n)'; } } sub count_roundtrip_nyn() { my $block = shift or die "Bad call to count_roundtrip_nyn"; return 1 if exists $block->{skip_this_for_now}; my $count = 0; $count++ if exists $block->{perl}; $count++ unless exists $block->{no_round_trip} or not exists $block->{yaml}; die "Invalid test definition" unless $count; return $count; } sub run_load_passes() { run { my $block = shift; my $yaml = $block->yaml; eval { YAML(Load => $yaml) }; is("$@", ""); }; } sub load_passes() { my $block = shift; my $yaml = $block->yaml; eval { YAML(Load => $yaml) }; is "$@", "", $block->description; } sub count_load_passes() {1} sub dumper() { require Data::Dumper; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1; return Data::Dumper::Dumper(@_); } sub _count_tests() { my $block = shift or die "Bad call to _count_tests"; no strict 'refs'; &{'count_' . _get_function_name($block)}($block); } sub _get_function_name() { my $block = shift; return $block->function || 'roundtrip_nyn'; } sub _get_function() { my $block = shift; no strict 'refs'; \ &{_get_function_name($block)}; } sub _skip_tests_for_now() { my $block = shift; if (exists $block->{skip_this_for_now}) { _skip_test( $block->description, _count_tests($block), ); return 1; } return 0; } sub _skip_yaml_tests() { my $block = shift; if ($block->skip_unless_modules) { my @modules = split /[\s\,]+/, $block->skip_unless_modules; for my $module (@modules) { eval "require $module"; if ($@) { _skip_test( "This test requires the '$module' module", _count_tests($block), ); return 1; } } } return 0; } sub _skip_test() { my ($message, $count) = @_; SKIP: { skip($message, $count); } } #------------------------------------------------------------------------------- package Test::YAML::Filter; use Test::Base::Filter (); our @ISA = 'Test::Base::Filter'; sub yaml_dump { Test::YAML::Dump(@_); } sub yaml_load { Test::YAML::Load(@_); } sub Dump { goto &Test::YAML::Dump } sub Load { goto &Test::YAML::Load } sub DumpFile { goto &Test::YAML::DumpFile } sub LoadFile { goto &Test::YAML::LoadFile } sub yaml_load_or_fail { my ($result, $error, $warning) = $self->_yaml_load_result_error_warning(@_); return $error || $result; } sub yaml_load_error_or_warning { my ($result, $error, $warning) = $self->_yaml_load_result_error_warning(@_); return $error || $warning || ''; } sub perl_eval_error_or_warning { my ($result, $error, $warning) = $self->_perl_eval_result_error_warning(@_); return $error || $warning || ''; } sub _yaml_load_result_error_warning { $self->assert_scalar(@_); my $yaml = shift; my $warning = ''; local $SIG{__WARN__} = sub { $warning = join '', @_ }; my $result = eval { $self->yaml_load($yaml); }; return ($result, $@, $warning); } sub _perl_eval_result_error_warning { $self->assert_scalar(@_); my $perl = shift; my $warning = ''; local $SIG{__WARN__} = sub { $warning = join '', @_ }; my $result = eval $perl; return ($result, $@, $warning); } 1; =head1 NAME Test::YAML - Testing Module for YAML Implementations =head1 SYNOPSIS use Test::YAML tests => 1; pass; =head1 DESCRIPTION Test::YAML is a subclass of Test::Base with YAML specific support. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML.pm0000644000372100001440000006044412000060557013634 0ustar matthewtusersuse 5.008001; package YAML; use YAML::Mo; our $VERSION = '0.84'; use Exporter; push @YAML::ISA, 'Exporter'; our @EXPORT = qw{ Dump Load }; our @EXPORT_OK = qw{ freeze thaw DumpFile LoadFile Bless Blessed }; use YAML::Node; # XXX This is a temp fix for Module::Build # XXX This VALUE nonsense needs to go. use constant VALUE => "\x07YAML\x07VALUE\x07"; # YAML Object Properties has dumper_class => default => sub {'YAML::Dumper'}; has loader_class => default => sub {'YAML::Loader'}; has dumper_object => default => sub {$_[0]->init_action_object("dumper")}; has loader_object => default => sub {$_[0]->init_action_object("loader")}; sub Dump { my $yaml = YAML->new; $yaml->dumper_class($YAML::DumperClass) if $YAML::DumperClass; return $yaml->dumper_object->dump(@_); } sub Load { my $yaml = YAML->new; $yaml->loader_class($YAML::LoaderClass) if $YAML::LoaderClass; return $yaml->loader_object->load(@_); } { no warnings 'once'; # freeze/thaw is the API for Storable string serialization. Some # modules make use of serializing packages on if they use freeze/thaw. *freeze = \ &Dump; *thaw = \ &Load; } sub DumpFile { my $OUT; my $filename = shift; if (ref $filename eq 'GLOB') { $OUT = $filename; } else { my $mode = '>'; if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) { ($mode, $filename) = ($1, $2); } open $OUT, $mode, $filename or YAML::Mo::Object->die('YAML_DUMP_ERR_FILE_OUTPUT', $filename, $!); } binmode $OUT, ':utf8'; # if $Config{useperlio} eq 'define'; local $/ = "\n"; # reset special to "sane" print $OUT Dump(@_); } sub LoadFile { my $IN; my $filename = shift; if (ref $filename eq 'GLOB') { $IN = $filename; } else { open $IN, '<', $filename or YAML::Mo::Object->die('YAML_LOAD_ERR_FILE_INPUT', $filename, $!); } binmode $IN, ':utf8'; # if $Config{useperlio} eq 'define'; return Load(do { local $/; <$IN> }); } sub init_action_object { my $self = shift; my $object_class = (shift) . '_class'; my $module_name = $self->$object_class; eval "require $module_name"; $self->die("Error in require $module_name - $@") if $@ and "$@" !~ /Can't locate/; my $object = $self->$object_class->new; $object->set_global_options; return $object; } my $global = {}; sub Bless { require YAML::Dumper::Base; YAML::Dumper::Base::bless($global, @_) } sub Blessed { require YAML::Dumper::Base; YAML::Dumper::Base::blessed($global, @_) } sub global_object { $global } 1; __END__ =encoding utf8 =head1 NAME YAML - YAML Ain't Markup Language (tm) =head1 NOTE This module has been released to CPAN as YAML::Old, and soon YAML.pm will be changed to just be a frontend interface module for all the various Perl YAML implementation modules, including YAML::Old. If you want robust and fast YAML processing using the normal Dump/Load API, please consider switching to YAML::XS. It is by far the best Perl module for YAML at this time. It requires that you have a C compiler, since it is written in C. If you really need to use this version of YAML.pm it will always be available as YAML::Old. If you don't care which YAML module use, as long as it's the best one installed on your system, use YAML::Any. The rest of this documentation is left unchanged, until YAML.pm is switched over to the new UI-only version. =head1 SYNOPSIS use YAML; # Load a YAML stream of 3 YAML documents into Perl data structures. my ($hashref, $arrayref, $string) = Load(<<'...'); --- name: ingy age: old weight: heavy # I should comment that I also like pink, but don't tell anybody. favorite colors: - red - green - blue --- - Clark Evans - Oren Ben-Kiki - Ingy döt Net --- > You probably think YAML stands for "Yet Another Markup Language". It ain't! YAML is really a data serialization language. But if you want to think of it as a markup, that's OK with me. A lot of people try to use XML as a serialization format. "YAML" is catchy and fun to say. Try it. "YAML, YAML, YAML!!!" ... # Dump the Perl data structures back into YAML. print Dump($string, $arrayref, $hashref); # YAML::Dump is used the same way you'd use Data::Dumper::Dumper use Data::Dumper; print Dumper($string, $arrayref, $hashref); =head1 DESCRIPTION The YAML.pm module implements a YAML Loader and Dumper based on the YAML 1.0 specification. L YAML is a generic data serialization language that is optimized for human readability. It can be used to express the data structures of most modern programming languages. (Including Perl!!!) For information on the YAML syntax, please refer to the YAML specification. =head1 WHY YAML IS COOL =over 4 =item YAML is readable for people. It makes clear sense out of complex data structures. You should find that YAML is an exceptional data dumping tool. Structure is shown through indentation, YAML supports recursive data, and hash keys are sorted by default. In addition, YAML supports several styles of scalar formatting for different types of data. =item YAML is editable. YAML was designed from the ground up to be an excellent syntax for configuration files. Almost all programs need configuration files, so why invent a new syntax for each one? And why subject users to the complexities of XML or native Perl code? =item YAML is multilingual. Yes, YAML supports Unicode. But I'm actually referring to programming languages. YAML was designed to meet the serialization needs of Perl, Python, Ruby, Tcl, PHP, Javascript and Java. It was also designed to be interoperable between those languages. That means YAML serializations produced by Perl can be processed by Python. =item YAML is taint safe. Using modules like Data::Dumper for serialization is fine as long as you can be sure that nobody can tamper with your data files or transmissions. That's because you need to use Perl's C built-in to deserialize the data. Somebody could add a snippet of Perl to erase your files. YAML's parser does not need to eval anything. =item YAML is full featured. YAML can accurately serialize all of the common Perl data structures and deserialize them again without losing data relationships. Although it is not 100% perfect (no serializer is or can be perfect), it fares as well as the popular current modules: Data::Dumper, Storable, XML::Dumper and Data::Denter. YAML.pm also has the ability to handle code (subroutine) references and typeglobs. (Still experimental) These features are not found in Perl's other serialization modules. =item YAML is extensible. The YAML language has been designed to be flexible enough to solve it's own problems. The markup itself has 3 basic construct which resemble Perl's hash, array and scalar. By default, these map to their Perl equivalents. But each YAML node also supports a tagging mechanism (type system) which can cause that node to be interpreted in a completely different manner. That's how YAML can support object serialization and oddball structures like Perl's typeglob. =back =head1 YAML IMPLEMENTATIONS IN PERL This module, YAML.pm, is really just the interface module for YAML modules written in Perl. The basic interface for YAML consists of two functions: C and C. The real work is done by the modules YAML::Dumper and YAML::Loader. Different YAML module distributions can be created by subclassing YAML.pm and YAML::Loader and YAML::Dumper. For example, YAML-Simple consists of YAML::Simple YAML::Dumper::Simple and YAML::Loader::Simple. Why would there be more than one implementation of YAML? Well, despite YAML's offering of being a simple data format, YAML is actually very deep and complex. Implementing the entirety of the YAML specification is a daunting task. For this reason I am currently working on 3 different YAML implementations. =over =item YAML The main YAML distribution will keeping evolving to support the entire YAML specification in pure Perl. This may not be the fastest or most stable module though. Currently, YAML.pm has lots of known bugs. It is mostly a great tool for dumping Perl data structures to a readable form. =item YAML::Tiny The point of YAML::Tiny is to strip YAML down to the 90% that people use most and offer that in a small, fast, stable, pure Perl form. YAML::Tiny will simply die when it is asked to do something it can't. =item YAML::Syck C is the C based YAML processing library used by the Ruby programming language (and also Python, PHP and Pugs). YAML::Syck is the Perl binding to C. It should be very fast, but may have problems of its own. It will also require C compilation. NOTE: Audrey Tang has actually completed this module and it works great and is 10 times faster than YAML.pm. =back In the future, there will likely be even more YAML modules. Remember, people other than Ingy are allowed to write YAML modules! =head1 FUNCTIONAL USAGE YAML is completely OO under the hood. Still it exports a few useful top level functions so that it is dead simple to use. These functions just do the OO stuff for you. If you want direct access to the OO API see the documentation for YAML::Dumper and YAML::Loader. =head2 Exported Functions The following functions are exported by YAML.pm by default. The reason they are exported is so that YAML works much like Data::Dumper. If you don't want functions to be imported, just use YAML with an empty import list: use YAML (); =over 4 =item Dump(list-of-Perl-data-structures) Turn Perl data into YAML. This function works very much like Data::Dumper::Dumper(). It takes a list of Perl data strucures and dumps them into a serialized form. It returns a string containing the YAML stream. The structures can be references or plain scalars. =item Load(string-containing-a-YAML-stream) Turn YAML into Perl data. This is the opposite of Dump. Just like Storable's thaw() function or the eval() function in relation to Data::Dumper. It parses a string containing a valid YAML stream into a list of Perl data structures. =back =head2 Exportable Functions These functions are not exported by default but you can request them in an import list like this: use YAML qw'freeze thaw Bless'; =over 4 =item freeze() and thaw() Aliases to Dump() and Load() for Storable fans. This will also allow YAML.pm to be plugged directly into modules like POE.pm, that use the freeze/thaw API for internal serialization. =item DumpFile(filepath, list) Writes the YAML stream to a file instead of just returning a string. =item LoadFile(filepath) Reads the YAML stream from a file instead of a string. =item Bless(perl-node, [yaml-node | class-name]) Associate a normal Perl node, with a yaml node. A yaml node is an object tied to the YAML::Node class. The second argument is either a yaml node that you've already created or a class (package) name that supports a yaml_dump() function. A yaml_dump() function should take a perl node and return a yaml node. If no second argument is provided, Bless will create a yaml node. This node is not returned, but can be retrieved with the Blessed() function. Here's an example of how to use Bless. Say you have a hash containing three keys, but you only want to dump two of them. Furthermore the keys must be dumped in a certain order. Here's how you do that: use YAML qw(Dump Bless); $hash = {apple => 'good', banana => 'bad', cauliflower => 'ugly'}; print Dump $hash; Bless($hash)->keys(['banana', 'apple']); print Dump $hash; produces: --- apple: good banana: bad cauliflower: ugly --- banana: bad apple: good Bless returns the tied part of a yaml-node, so that you can call the YAML::Node methods. This is the same thing that YAML::Node::ynode() returns. So another way to do the above example is: use YAML qw(Dump Bless); use YAML::Node; $hash = {apple => 'good', banana => 'bad', cauliflower => 'ugly'}; print Dump $hash; Bless($hash); $ynode = ynode(Blessed($hash)); $ynode->keys(['banana', 'apple']); print Dump $hash; Note that Blessing a Perl data structure does not change it anyway. The extra information is stored separately and looked up by the Blessed node's memory address. =item Blessed(perl-node) Returns the yaml node that a particular perl node is associated with (see above). Returns undef if the node is not (YAML) Blessed. =back =head1 GLOBAL OPTIONS YAML options are set using a group of global variables in the YAML namespace. This is similar to how Data::Dumper works. For example, to change the indentation width, do something like: local $YAML::Indent = 3; The current options are: =over 4 =item DumperClass You can override which module/class YAML uses for Dumping data. =item LoaderClass You can override which module/class YAML uses for Loading data. =item Indent This is the number of space characters to use for each indentation level when doing a Dump(). The default is 2. By the way, YAML can use any number of characters for indentation at any level. So if you are editing YAML by hand feel free to do it anyway that looks pleasing to you; just be consistent for a given level. =item SortKeys Default is 1. (true) Tells YAML.pm whether or not to sort hash keys when storing a document. YAML::Node objects can have their own sort order, which is usually what you want. To override the YAML::Node order and sort the keys anyway, set SortKeys to 2. =item Stringify Default is 0. (false) Objects with string overloading should honor the overloading and dump the stringification of themselves, rather than the actual object's guts. =item UseHeader Default is 1. (true) This tells YAML.pm whether to use a separator string for a Dump operation. This only applies to the first document in a stream. Subsequent documents must have a YAML header by definition. =item UseVersion Default is 0. (false) Tells YAML.pm whether to include the YAML version on the separator/header. --- %YAML:1.0 =item AnchorPrefix Default is ''. Anchor names are normally numeric. YAML.pm simply starts with '1' and increases by one for each new anchor. This option allows you to specify a string to be prepended to each anchor number. =item UseCode Setting the UseCode option is a shortcut to set both the DumpCode and LoadCode options at once. Setting UseCode to '1' tells YAML.pm to dump Perl code references as Perl (using B::Deparse) and to load them back into memory using eval(). The reason this has to be an option is that using eval() to parse untrusted code is, well, untrustworthy. =item DumpCode Determines if and how YAML.pm should serialize Perl code references. By default YAML.pm will dump code references as dummy placeholders (much like Data::Dumper). If DumpCode is set to '1' or 'deparse', code references will be dumped as actual Perl code. DumpCode can also be set to a subroutine reference so that you can write your own serializing routine. YAML.pm passes you the code ref. You pass back the serialization (as a string) and a format indicator. The format indicator is a simple string like: 'deparse' or 'bytecode'. =item LoadCode LoadCode is the opposite of DumpCode. It tells YAML if and how to deserialize code references. When set to '1' or 'deparse' it will use C. Since this is potentially risky, only use this option if you know where your YAML has been. LoadCode can also be set to a subroutine reference so that you can write your own deserializing routine. YAML.pm passes the serialization (as a string) and a format indicator. You pass back the code reference. =item UseBlock YAML.pm uses heuristics to guess which scalar style is best for a given node. Sometimes you'll want all multiline scalars to use the 'block' style. If so, set this option to 1. NOTE: YAML's block style is akin to Perl's here-document. =item UseFold If you want to force YAML to use the 'folded' style for all multiline scalars, then set $UseFold to 1. NOTE: YAML's folded style is akin to the way HTML folds text, except smarter. =item UseAliases YAML has an alias mechanism such that any given structure in memory gets serialized once. Any other references to that structure are serialized only as alias markers. This is how YAML can serialize duplicate and recursive structures. Sometimes, when you KNOW that your data is nonrecursive in nature, you may want to serialize such that every node is expressed in full. (ie as a copy of the original). Setting $YAML::UseAliases to 0 will allow you to do this. This also may result in faster processing because the lookup overhead is by bypassed. THIS OPTION CAN BE DANGEROUS. *If* your data is recursive, this option *will* cause Dump() to run in an endless loop, chewing up your computers memory. You have been warned. =item CompressSeries Default is 1. Compresses the formatting of arrays of hashes: - foo: bar - bar: foo becomes: - foo: bar - bar: foo Since this output is usually more desirable, this option is turned on by default. =back =head1 YAML TERMINOLOGY YAML is a full featured data serialization language, and thus has its own terminology. It is important to remember that although YAML is heavily influenced by Perl and Python, it is a language in its own right, not merely just a representation of Perl structures. YAML has three constructs that are conspicuously similar to Perl's hash, array, and scalar. They are called mapping, sequence, and string respectively. By default, they do what you would expect. But each instance may have an explicit or implicit tag (type) that makes it behave differently. In this manner, YAML can be extended to represent Perl's Glob or Python's tuple, or Ruby's Bigint. =over 4 =item stream A YAML stream is the full sequence of unicode characters that a YAML parser would read or a YAML emitter would write. A stream may contain one or more YAML documents separated by YAML headers. --- a: mapping foo: bar --- - a - sequence =item document A YAML document is an independent data structure representation within a stream. It is a top level node. Each document in a YAML stream must begin with a YAML header line. Actually the header is optional on the first document. --- This: top level mapping is: - a - YAML - document =item header A YAML header is a line that begins a YAML document. It consists of three dashes, possibly followed by more info. Another purpose of the header line is that it serves as a place to put top level tag and anchor information. --- !recursive-sequence &001 - * 001 - * 001 =item node A YAML node is the representation of a particular data stucture. Nodes may contain other nodes. (In Perl terms, nodes are like scalars. Strings, arrayrefs and hashrefs. But this refers to the serialized format, not the in-memory structure.) =item tag This is similar to a type. It indicates how a particular YAML node serialization should be transferred into or out of memory. For instance a Foo::Bar object would use the tag 'perl/Foo::Bar': - !perl/Foo::Bar foo: 42 bar: stool =item collection A collection is the generic term for a YAML data grouping. YAML has two types of collections: mappings and sequences. (Similar to hashes and arrays) =item mapping A mapping is a YAML collection defined by unordered key/value pairs with unique keys. By default YAML mappings are loaded into Perl hashes. a mapping: foo: bar two: times two is 4 =item sequence A sequence is a YAML collection defined by an ordered list of elements. By default YAML sequences are loaded into Perl arrays. a sequence: - one bourbon - one scotch - one beer =item scalar A scalar is a YAML node that is a single value. By default YAML scalars are loaded into Perl scalars. a scalar key: a scalar value YAML has many styles for representing scalars. This is important because varying data will have varying formatting requirements to retain the optimum human readability. =item plain scalar A plain scalar is unquoted. All plain scalars are automatic candidates for "implicit tagging". This means that their tag may be determined automatically by examination. The typical uses for this are plain alpha strings, integers, real numbers, dates, times and currency. - a plain string - -42 - 3.1415 - 12:34 - 123 this is an error =item single quoted scalar This is similar to Perl's use of single quotes. It means no escaping except for single quotes which are escaped by using two adjacent single quotes. - 'When I say ''\n'' I mean "backslash en"' =item double quoted scalar This is similar to Perl's use of double quotes. Character escaping can be used. - "This scalar\nhas two lines, and a bell -->\a" =item folded scalar This is a multiline scalar which begins on the next line. It is indicated by a single right angle bracket. It is unescaped like the single quoted scalar. Line folding is also performed. - > This is a multiline scalar which begins on the next line. It is indicated by a single carat. It is unescaped like the single quoted scalar. Line folding is also performed. =item block scalar This final multiline form is akin to Perl's here-document except that (as in all YAML data) scope is indicated by indentation. Therefore, no ending marker is required. The data is verbatim. No line folding. - | QTY DESC PRICE TOTAL --- ---- ----- ----- 1 Foo Fighters $19.95 $19.95 2 Bar Belles $29.95 $59.90 =item parser A YAML processor has four stages: parse, load, dump, emit. A parser parses a YAML stream. YAML.pm's Load() function contains a parser. =item loader The other half of the Load() function is a loader. This takes the information from the parser and loads it into a Perl data structure. =item dumper The Dump() function consists of a dumper and an emitter. The dumper walks through each Perl data structure and gives info to the emitter. =item emitter The emitter takes info from the dumper and turns it into a YAML stream. NOTE: In YAML.pm the parser/loader and the dumper/emitter code are currently very closely tied together. In the future they may be broken into separate stages. =back For more information please refer to the immensely helpful YAML specification available at L. =head1 ysh - The YAML Shell The YAML distribution ships with a script called 'ysh', the YAML shell. ysh provides a simple, interactive way to play with YAML. If you type in Perl code, it displays the result in YAML. If you type in YAML it turns it into Perl code. To run ysh, (assuming you installed it along with YAML.pm) simply type: ysh [options] Please read the C documentation for the full details. There are lots of options. =head1 BUGS & DEFICIENCIES If you find a bug in YAML, please try to recreate it in the YAML Shell with logging turned on ('ysh -L'). When you have successfully reproduced the bug, please mail the LOG file to the author (ingy@cpan.org). WARNING: This is still *ALPHA* code. Well, most of this code has been around for years... BIGGER WARNING: YAML.pm has been slow in the making, but I am committed to having top notch YAML tools in the Perl world. The YAML team is close to finalizing the YAML 1.1 spec. This version of YAML.pm is based off of a very old pre 1.0 spec. In actuality there isn't a ton of difference, and this YAML.pm is still fairly useful. Things will get much better in the future. =head1 RESOURCES L is the mailing list. This is where the language is discussed and designed. L is the official YAML website. L is the YAML 1.0 specification. L is the official YAML wiki. =head1 SEE ALSO See YAML::XS. Fast! =head1 AUTHOR Ingy döt Net is resonsible for YAML.pm. The YAML serialization language is the result of years of collaboration between Oren Ben-Kiki, Clark Evans and Ingy döt Net. Several others have added help along the way. =head1 COPYRIGHT Copyright (c) 2005, 2006, 2008, 2011-2012. Ingy döt Net. Copyright (c) 2001, 2002, 2005. Brian Ingerson. Some parts copyright (c) 2009 - 2010 Adam Kennedy This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/0000755000372100001440000000000012000063203013255 5ustar matthewtusersYAML-0.84/lib/YAML/Types.pm0000644000372100001440000001506012000060557014732 0ustar matthewtuserspackage YAML::Types; use YAML::Mo; our $VERSION = '0.84'; use YAML::Node; # XXX These classes and their APIs could still use some refactoring, # but at least they work for now. #------------------------------------------------------------------------------- package YAML::Type::blessed; use YAML::Mo; # XXX sub yaml_dump { my $self = shift; my ($value) = @_; my ($class, $type) = YAML::Mo::Object->node_info($value); no strict 'refs'; my $kind = lc($type) . ':'; my $tag = ${$class . '::ClassTag'} || "!perl/$kind$class"; if ($type eq 'REF') { YAML::Node->new( {(&YAML::VALUE, ${$_[0]})}, $tag ); } elsif ($type eq 'SCALAR') { $_[1] = $$value; YAML::Node->new($_[1], $tag); } else { YAML::Node->new($value, $tag); } } #------------------------------------------------------------------------------- package YAML::Type::undef; sub yaml_dump { my $self = shift; } sub yaml_load { my $self = shift; } #------------------------------------------------------------------------------- package YAML::Type::glob; sub yaml_dump { my $self = shift; my $ynode = YAML::Node->new({}, '!perl/glob:'); for my $type (qw(PACKAGE NAME SCALAR ARRAY HASH CODE IO)) { my $value = *{$_[0]}{$type}; $value = $$value if $type eq 'SCALAR'; if (defined $value) { if ($type eq 'IO') { my @stats = qw(device inode mode links uid gid rdev size atime mtime ctime blksize blocks); undef $value; $value->{stat} = YAML::Node->new({}); if ($value->{fileno} = fileno(*{$_[0]})) { local $^W; map {$value->{stat}{shift @stats} = $_} stat(*{$_[0]}); $value->{tell} = tell(*{$_[0]}); } } $ynode->{$type} = $value; } } return $ynode; } sub yaml_load { my $self = shift; my ($node, $class, $loader) = @_; my ($name, $package); if (defined $node->{NAME}) { $name = $node->{NAME}; delete $node->{NAME}; } else { $loader->warn('YAML_LOAD_WARN_GLOB_NAME'); return undef; } if (defined $node->{PACKAGE}) { $package = $node->{PACKAGE}; delete $node->{PACKAGE}; } else { $package = 'main'; } no strict 'refs'; if (exists $node->{SCALAR}) { *{"${package}::$name"} = \$node->{SCALAR}; delete $node->{SCALAR}; } for my $elem (qw(ARRAY HASH CODE IO)) { if (exists $node->{$elem}) { if ($elem eq 'IO') { $loader->warn('YAML_LOAD_WARN_GLOB_IO'); delete $node->{IO}; next; } *{"${package}::$name"} = $node->{$elem}; delete $node->{$elem}; } } for my $elem (sort keys %$node) { $loader->warn('YAML_LOAD_WARN_BAD_GLOB_ELEM', $elem); } return *{"${package}::$name"}; } #------------------------------------------------------------------------------- package YAML::Type::code; my $dummy_warned = 0; my $default = '{ "DUMMY" }'; sub yaml_dump { my $self = shift; my $code; my ($dumpflag, $value) = @_; my ($class, $type) = YAML::Mo::Object->node_info($value); my $tag = "!perl/code"; $tag .= ":$class" if defined $class; if (not $dumpflag) { $code = $default; } else { bless $value, "CODE" if $class; eval { use B::Deparse }; return if $@; my $deparse = B::Deparse->new(); eval { local $^W = 0; $code = $deparse->coderef2text($value); }; if ($@) { warn YAML::YAML_DUMP_WARN_DEPARSE_FAILED() if $^W; $code = $default; } bless $value, $class if $class; chomp $code; $code .= "\n"; } $_[2] = $code; YAML::Node->new($_[2], $tag); } sub yaml_load { my $self = shift; my ($node, $class, $loader) = @_; if ($loader->load_code) { my $code = eval "package main; sub $node"; if ($@) { $loader->warn('YAML_LOAD_WARN_PARSE_CODE', $@); return sub {}; } else { CORE::bless $code, $class if $class; return $code; } } else { return CORE::bless sub {}, $class if $class; return sub {}; } } #------------------------------------------------------------------------------- package YAML::Type::ref; sub yaml_dump { my $self = shift; YAML::Node->new({(&YAML::VALUE, ${$_[0]})}, '!perl/ref') } sub yaml_load { my $self = shift; my ($node, $class, $loader) = @_; $loader->die('YAML_LOAD_ERR_NO_DEFAULT_VALUE', 'ptr') unless exists $node->{&YAML::VALUE}; return \$node->{&YAML::VALUE}; } #------------------------------------------------------------------------------- package YAML::Type::regexp; # XXX Be sure to handle blessed regexps (if possible) sub yaml_dump { die "YAML::Type::regexp::yaml_dump not currently implemented"; } use constant _QR_TYPES => { '' => sub { qr{$_[0]} }, x => sub { qr{$_[0]}x }, i => sub { qr{$_[0]}i }, s => sub { qr{$_[0]}s }, m => sub { qr{$_[0]}m }, ix => sub { qr{$_[0]}ix }, sx => sub { qr{$_[0]}sx }, mx => sub { qr{$_[0]}mx }, si => sub { qr{$_[0]}si }, mi => sub { qr{$_[0]}mi }, ms => sub { qr{$_[0]}sm }, six => sub { qr{$_[0]}six }, mix => sub { qr{$_[0]}mix }, msx => sub { qr{$_[0]}msx }, msi => sub { qr{$_[0]}msi }, msix => sub { qr{$_[0]}msix }, }; sub yaml_load { my $self = shift; my ($node, $class) = @_; return qr{$node} unless $node =~ /^\(\?([\^\-xism]*):(.*)\)\z/s; my ($flags, $re) = ($1, $2); $flags =~ s/-.*//; $flags =~ s/^\^//; my $sub = _QR_TYPES->{$flags} || sub { qr{$_[0]} }; my $qr = &$sub($re); bless $qr, $class if length $class; return $qr; } 1; __END__ =head1 NAME YAML::Types - Marshall Perl internal data types to/from YAML =head1 SYNOPSIS $::foo = 42; print YAML::Dump(*::foo); print YAML::Dump(qr{match me}); =head1 DESCRIPTION This module has the helper classes for transferring objects, subroutines, references, globs, regexps and file handles to and from YAML. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Any.pm0000644000372100001440000001014612000060557014355 0ustar matthewtuserspackage YAML::Any; our $VERSION = '0.84'; use strict; use Exporter (); @YAML::Any::ISA = 'Exporter'; @YAML::Any::EXPORT = qw(Dump Load); @YAML::Any::EXPORT_OK = qw(DumpFile LoadFile); my @dump_options = qw( UseCode DumpCode SpecVersion Indent UseHeader UseVersion SortKeys AnchorPrefix UseBlock UseFold CompressSeries InlineSeries UseAliases Purity Stringify ); my @load_options = qw( UseCode LoadCode ); my @implementations = qw( YAML::XS YAML::Syck YAML::Old YAML YAML::Tiny ); sub import { __PACKAGE__->implementation; goto &Exporter::import; } sub Dump { no strict 'refs'; my $implementation = __PACKAGE__->implementation; for my $option (@dump_options) { my $var = "$implementation\::$option"; my $value = $$var; local $$var; $$var = defined $value ? $value : ${"YAML::$option"}; } return &{"$implementation\::Dump"}(@_); } sub DumpFile { no strict 'refs'; my $implementation = __PACKAGE__->implementation; for my $option (@dump_options) { my $var = "$implementation\::$option"; my $value = $$var; local $$var; $$var = defined $value ? $value : ${"YAML::$option"}; } return &{"$implementation\::DumpFile"}(@_); } sub Load { no strict 'refs'; my $implementation = __PACKAGE__->implementation; for my $option (@load_options) { my $var = "$implementation\::$option"; my $value = $$var; local $$var; $$var = defined $value ? $value : ${"YAML::$option"}; } return &{"$implementation\::Load"}(@_); } sub LoadFile { no strict 'refs'; my $implementation = __PACKAGE__->implementation; for my $option (@load_options) { my $var = "$implementation\::$option"; my $value = $$var; local $$var; $$var = defined $value ? $value : ${"YAML::$option"}; } return &{"$implementation\::LoadFile"}(@_); } sub order { return @YAML::Any::_TEST_ORDER if @YAML::Any::_TEST_ORDER; return @implementations; } sub implementation { my @order = __PACKAGE__->order; for my $module (@order) { my $path = $module; $path =~ s/::/\//g; $path .= '.pm'; return $module if exists $INC{$path}; eval "require $module; 1" and return $module; } croak("YAML::Any couldn't find any of these YAML implementations: @order"); } sub croak { require Carp; Carp::Croak(@_); } 1; =head1 NAME YAML::Any - Pick a YAML implementation and use it. =head1 SYNOPSIS use YAML::Any; $YAML::Indent = 3; my $yaml = Dump(@objects); =head1 DESCRIPTION There are several YAML implementations that support the Dump/Load API. This module selects the best one available and uses it. =head1 ORDER Currently, YAML::Any will choose the first one of these YAML implementations that is installed on your system: YAML::XS YAML::Syck YAML::Old YAML YAML::Tiny =head1 OPTIONS If you specify an option like: $YAML::Indent = 4; And YAML::Any is using YAML::XS, it will use the proper variable: $YAML::XS::Indent. =head1 SUBROUTINES Like all the YAML modules that YAML::Any uses, the following subroutines are exported by default: Dump Load and the following subroutines are exportable by request: DumpFile LoadFile =head1 METHODS YAML::Any provides the following class methods. =over =item YAML::Any->order; This method returns a list of the current possible implementations that YAML::Any will search for. =item YAML::Any->implementation; This method returns the implementation the YAML::Any will use. This result is obtained by finding the first member of YAML::Any->order that is either already loaded in C<%INC> or that can be loaded using C. If no implementation is found, an error will be thrown. =back =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2008. Ingy döt Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Dumper/0000755000372100001440000000000012000063203014511 5ustar matthewtusersYAML-0.84/lib/YAML/Dumper/Base.pm0000644000372100001440000000767012000060557015744 0ustar matthewtuserspackage YAML::Dumper::Base; use YAML::Mo; our $VERSION = '0.84'; use YAML::Node; # YAML Dumping options has spec_version => default => sub {'1.0'}; has indent_width => default => sub {2}; has use_header => default => sub {1}; has use_version => default => sub {0}; has sort_keys => default => sub {1}; has anchor_prefix => default => sub {''}; has dump_code => default => sub {0}; has use_block => default => sub {0}; has use_fold => default => sub {0}; has compress_series => default => sub {1}; has inline_series => default => sub {0}; has use_aliases => default => sub {1}; has purity => default => sub {0}; has stringify => default => sub {0}; # Properties has stream => default => sub {''}; has document => default => sub {0}; has transferred => default => sub {{}}; has id_refcnt => default => sub {{}}; has id_anchor => default => sub {{}}; has anchor => default => sub {1}; has level => default => sub {0}; has offset => default => sub {[]}; has headless => default => sub {0}; has blessed_map => default => sub {{}}; # Global Options are an idea taken from Data::Dumper. Really they are just # sugar on top of real OO properties. They make the simple Dump/Load API # easy to configure. sub set_global_options { my $self = shift; $self->spec_version($YAML::SpecVersion) if defined $YAML::SpecVersion; $self->indent_width($YAML::Indent) if defined $YAML::Indent; $self->use_header($YAML::UseHeader) if defined $YAML::UseHeader; $self->use_version($YAML::UseVersion) if defined $YAML::UseVersion; $self->sort_keys($YAML::SortKeys) if defined $YAML::SortKeys; $self->anchor_prefix($YAML::AnchorPrefix) if defined $YAML::AnchorPrefix; $self->dump_code($YAML::DumpCode || $YAML::UseCode) if defined $YAML::DumpCode or defined $YAML::UseCode; $self->use_block($YAML::UseBlock) if defined $YAML::UseBlock; $self->use_fold($YAML::UseFold) if defined $YAML::UseFold; $self->compress_series($YAML::CompressSeries) if defined $YAML::CompressSeries; $self->inline_series($YAML::InlineSeries) if defined $YAML::InlineSeries; $self->use_aliases($YAML::UseAliases) if defined $YAML::UseAliases; $self->purity($YAML::Purity) if defined $YAML::Purity; $self->stringify($YAML::Stringify) if defined $YAML::Stringify; } sub dump { my $self = shift; $self->die('dump() not implemented in this class.'); } sub blessed { my $self = shift; my ($ref) = @_; $ref = \$_[0] unless ref $ref; my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref); $self->{blessed_map}->{$node_id}; } sub bless { my $self = shift; my ($ref, $blessing) = @_; my $ynode; $ref = \$_[0] unless ref $ref; my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref); if (not defined $blessing) { $ynode = YAML::Node->new($ref); } elsif (ref $blessing) { $self->die() unless ynode($blessing); $ynode = $blessing; } else { no strict 'refs'; my $transfer = $blessing . "::yaml_dump"; $self->die() unless defined &{$transfer}; $ynode = &{$transfer}($ref); $self->die() unless ynode($ynode); } $self->{blessed_map}->{$node_id} = $ynode; my $object = ynode($ynode) or $self->die(); return $object; } 1; __END__ =head1 NAME YAML::Dumper::Base - Base class for YAML Dumper classes =head1 SYNOPSIS package YAML::Dumper::Something; use YAML::Dumper::Base -base; =head1 DESCRIPTION YAML::Dumper::Base is a base class for creating YAML dumper classes. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Mo.pm0000644000372100001440000000564012000060557014204 0ustar matthewtuserspackage YAML::Mo; $VERSION = '0.84'; # use Mo qw[builder default import]; # The following line of code was produced from the previous line by # Mo::Inline version 0.31 no warnings;my$M=__PACKAGE__.'::';*{$M.Object::new}=sub{bless{@_[1..$#_]},$_[0]};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.'::';shift;eval"no Mo::$_",&{$M.$_.::e}($P,\%e,\%o,\@_)for@_;return if$e{M};%e=(extends,sub{eval"no $_[0]()";@{$P.ISA}=$_[0]},has,sub{my$n=shift;my$m=sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}};$m=$o{$_}->($m,$n,@_)for sort keys%o;*{$P.$n}=$m},%e,);*{$P.$_}=$e{$_}for keys%e;@{$P.ISA}=$M.Object};*{$M.'builder::e'}=sub{my($P,$e,$o)=@_;$o->{builder}=sub{my($m,$n,%a)=@_;my$b=$a{builder}or return$m;sub{$#_?$m->(@_):!exists$_[0]{$n}?$_[0]{$n}=$_[0]->$b:$m->(@_)}}};*{$M.'default::e'}=sub{my($P,$e,$o)=@_;$o->{default}=sub{my($m,$n,%a)=@_;$a{default}or return$m;sub{$#_?$m->(@_):!exists$_[0]{$n}?$_[0]{$n}=$a{default}->(@_):$m->(@_)}}};my$i=\&import;*{$M.import}=sub{(@_==2 and not $_[1])?pop@_:@_==1?push@_,grep!/import/,@f:();goto&$i};@f=qw[builder default import];use strict;use warnings; our $DumperModule = 'Data::Dumper'; my ($_new_error, $_info, $_scalar_info); no strict 'refs'; *{$M.'Object::die'} = sub { my $self = shift; my $error = $self->$_new_error(@_); $error->type('Error'); Carp::croak($error->format_message); }; *{$M.'Object::warn'} = sub { my $self = shift; return unless $^W; my $error = $self->$_new_error(@_); $error->type('Warning'); Carp::cluck($error->format_message); }; # This code needs to be refactored to be simpler and more precise, and no, # Scalar::Util doesn't DWIM. # # Can't handle: # * blessed regexp *{$M.'Object::node_info'} = sub { my $self = shift; my $stringify = $_[1] || 0; my ($class, $type, $id) = ref($_[0]) ? $stringify ? &$_info("$_[0]") : do { require overload; my @info = &$_info(overload::StrVal($_[0])); if (ref($_[0]) eq 'Regexp') { @info[0, 1] = (undef, 'REGEXP'); } @info; } : &$_scalar_info($_[0]); ($class, $type, $id) = &$_scalar_info("$_[0]") unless $id; return wantarray ? ($class, $type, $id) : $id; }; #------------------------------------------------------------------------------- $_info = sub { return (($_[0]) =~ qr{^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$}o); }; $_scalar_info = sub { my $id = 'undef'; if (defined $_[0]) { \$_[0] =~ /\((\w+)\)$/o or CORE::die(); $id = "$1-S"; } return (undef, undef, $id); }; $_new_error = sub { require Carp; my $self = shift; require YAML::Error; my $code = shift || 'unknown error'; my $error = YAML::Error->new(code => $code); $error->line($self->line) if $self->can('line'); $error->document($self->document) if $self->can('document'); $error->arguments([@_]); return $error; }; 1; YAML-0.84/lib/YAML/Dumper.pm0000644000372100001440000004145212000060557015066 0ustar matthewtuserspackage YAML::Dumper; use YAML::Mo; extends 'YAML::Dumper::Base'; our $VERSION = '0.84'; use YAML::Dumper::Base; use YAML::Node; use YAML::Types; # Context constants use constant KEY => 3; use constant BLESSED => 4; use constant FROMARRAY => 5; use constant VALUE => "\x07YAML\x07VALUE\x07"; # Common YAML character sets my $ESCAPE_CHAR = '[\\x00-\\x08\\x0b-\\x0d\\x0e-\\x1f]'; my $LIT_CHAR = '|'; #============================================================================== # OO version of Dump. YAML->new->dump($foo); sub dump { my $self = shift; $self->stream(''); $self->document(0); for my $document (@_) { $self->{document}++; $self->transferred({}); $self->id_refcnt({}); $self->id_anchor({}); $self->anchor(1); $self->level(0); $self->offset->[0] = 0 - $self->indent_width; $self->_prewalk($document); $self->_emit_header($document); $self->_emit_node($document); } return $self->stream; } # Every YAML document in the stream must begin with a YAML header, unless # there is only a single document and the user requests "no header". sub _emit_header { my $self = shift; my ($node) = @_; if (not $self->use_header and $self->document == 1 ) { $self->die('YAML_DUMP_ERR_NO_HEADER') unless ref($node) =~ /^(HASH|ARRAY)$/; $self->die('YAML_DUMP_ERR_NO_HEADER') if ref($node) eq 'HASH' and keys(%$node) == 0; $self->die('YAML_DUMP_ERR_NO_HEADER') if ref($node) eq 'ARRAY' and @$node == 0; # XXX Also croak if aliased, blessed, or ynode $self->headless(1); return; } $self->{stream} .= '---'; # XXX Consider switching to 1.1 style if ($self->use_version) { # $self->{stream} .= " #YAML:1.0"; } } # Walk the tree to be dumped and keep track of its reference counts. # This function is where the Dumper does all its work. All type # transfers happen here. sub _prewalk { my $self = shift; my $stringify = $self->stringify; my ($class, $type, $node_id) = $self->node_info(\$_[0], $stringify); # Handle typeglobs if ($type eq 'GLOB') { $self->transferred->{$node_id} = YAML::Type::glob->yaml_dump($_[0]); $self->_prewalk($self->transferred->{$node_id}); return; } # Handle regexps if (ref($_[0]) eq 'Regexp') { return; } # Handle Purity for scalars. # XXX can't find a use case yet. Might be YAGNI. if (not ref $_[0]) { $self->{id_refcnt}{$node_id}++ if $self->purity; return; } # Make a copy of original my $value = $_[0]; ($class, $type, $node_id) = $self->node_info($value, $stringify); # Must be a stringified object. return if (ref($value) and not $type); # Look for things already transferred. if ($self->transferred->{$node_id}) { (undef, undef, $node_id) = (ref $self->transferred->{$node_id}) ? $self->node_info($self->transferred->{$node_id}, $stringify) : $self->node_info(\ $self->transferred->{$node_id}, $stringify); $self->{id_refcnt}{$node_id}++; return; } # Handle code refs if ($type eq 'CODE') { $self->transferred->{$node_id} = 'placeholder'; YAML::Type::code->yaml_dump( $self->dump_code, $_[0], $self->transferred->{$node_id} ); ($class, $type, $node_id) = $self->node_info(\ $self->transferred->{$node_id}, $stringify); $self->{id_refcnt}{$node_id}++; return; } # Handle blessed things if (defined $class) { if ($value->can('yaml_dump')) { $value = $value->yaml_dump; } elsif ($type eq 'SCALAR') { $self->transferred->{$node_id} = 'placeholder'; YAML::Type::blessed->yaml_dump ($_[0], $self->transferred->{$node_id}); ($class, $type, $node_id) = $self->node_info(\ $self->transferred->{$node_id}, $stringify); $self->{id_refcnt}{$node_id}++; return; } else { $value = YAML::Type::blessed->yaml_dump($value); } $self->transferred->{$node_id} = $value; (undef, $type, $node_id) = $self->node_info($value, $stringify); } # Handle YAML Blessed things if (defined YAML->global_object()->{blessed_map}{$node_id}) { $value = YAML->global_object()->{blessed_map}{$node_id}; $self->transferred->{$node_id} = $value; ($class, $type, $node_id) = $self->node_info($value, $stringify); $self->_prewalk($value); return; } # Handle hard refs if ($type eq 'REF' or $type eq 'SCALAR') { $value = YAML::Type::ref->yaml_dump($value); $self->transferred->{$node_id} = $value; (undef, $type, $node_id) = $self->node_info($value, $stringify); } # Handle ref-to-glob's elsif ($type eq 'GLOB') { my $ref_ynode = $self->transferred->{$node_id} = YAML::Type::ref->yaml_dump($value); my $glob_ynode = $ref_ynode->{&VALUE} = YAML::Type::glob->yaml_dump($$value); (undef, undef, $node_id) = $self->node_info($glob_ynode, $stringify); $self->transferred->{$node_id} = $glob_ynode; $self->_prewalk($glob_ynode); return; } # Increment ref count for node return if ++($self->{id_refcnt}{$node_id}) > 1; # Keep on walking if ($type eq 'HASH') { $self->_prewalk($value->{$_}) for keys %{$value}; return; } elsif ($type eq 'ARRAY') { $self->_prewalk($_) for @{$value}; return; } # Unknown type. Need to know about it. $self->warn(<<"..."); YAML::Dumper can't handle dumping this type of data. Please report this to the author. id: $node_id type: $type class: $class value: $value ... return; } # Every data element and sub data element is a node. # Everything emitted goes through this function. sub _emit_node { my $self = shift; my ($type, $node_id); my $ref = ref($_[0]); if ($ref) { if ($ref eq 'Regexp') { $self->_emit(' !!perl/regexp'); $self->_emit_str("$_[0]"); return; } (undef, $type, $node_id) = $self->node_info($_[0], $self->stringify); } else { $type = $ref || 'SCALAR'; (undef, undef, $node_id) = $self->node_info(\$_[0], $self->stringify); } my ($ynode, $tag) = ('') x 2; my ($value, $context) = (@_, 0); if (defined $self->transferred->{$node_id}) { $value = $self->transferred->{$node_id}; $ynode = ynode($value); if (ref $value) { $tag = defined $ynode ? $ynode->tag->short : ''; (undef, $type, $node_id) = $self->node_info($value, $self->stringify); } else { $ynode = ynode($self->transferred->{$node_id}); $tag = defined $ynode ? $ynode->tag->short : ''; $type = 'SCALAR'; (undef, undef, $node_id) = $self->node_info( \ $self->transferred->{$node_id}, $self->stringify ); } } elsif ($ynode = ynode($value)) { $tag = $ynode->tag->short; } if ($self->use_aliases) { $self->{id_refcnt}{$node_id} ||= 0; if ($self->{id_refcnt}{$node_id} > 1) { if (defined $self->{id_anchor}{$node_id}) { $self->{stream} .= ' *' . $self->{id_anchor}{$node_id} . "\n"; return; } my $anchor = $self->anchor_prefix . $self->{anchor}++; $self->{stream} .= ' &' . $anchor; $self->{id_anchor}{$node_id} = $anchor; } } return $self->_emit_str("$value") # Stringified object if ref($value) and not $type; return $self->_emit_scalar($value, $tag) if $type eq 'SCALAR' and $tag; return $self->_emit_str($value) if $type eq 'SCALAR'; return $self->_emit_mapping($value, $tag, $node_id, $context) if $type eq 'HASH'; return $self->_emit_sequence($value, $tag) if $type eq 'ARRAY'; $self->warn('YAML_DUMP_WARN_BAD_NODE_TYPE', $type); return $self->_emit_str("$value"); } # A YAML mapping is akin to a Perl hash. sub _emit_mapping { my $self = shift; my ($value, $tag, $node_id, $context) = @_; $self->{stream} .= " !$tag" if $tag; # Sometimes 'keys' fails. Like on a bad tie implementation. my $empty_hash = not(eval {keys %$value}); $self->warn('YAML_EMIT_WARN_KEYS', $@) if $@; return ($self->{stream} .= " {}\n") if $empty_hash; # If CompressSeries is on (default) and legal is this context, then # use it and make the indent level be 2 for this node. if ($context == FROMARRAY and $self->compress_series and not (defined $self->{id_anchor}{$node_id} or $tag or $empty_hash) ) { $self->{stream} .= ' '; $self->offset->[$self->level+1] = $self->offset->[$self->level] + 2; } else { $context = 0; $self->{stream} .= "\n" unless $self->headless && not($self->headless(0)); $self->offset->[$self->level+1] = $self->offset->[$self->level] + $self->indent_width; } $self->{level}++; my @keys; if ($self->sort_keys == 1) { if (ynode($value)) { @keys = keys %$value; } else { @keys = sort keys %$value; } } elsif ($self->sort_keys == 2) { @keys = sort keys %$value; } # XXX This is hackish but sometimes handy. Not sure whether to leave it in. elsif (ref($self->sort_keys) eq 'ARRAY') { my $i = 1; my %order = map { ($_, $i++) } @{$self->sort_keys}; @keys = sort { (defined $order{$a} and defined $order{$b}) ? ($order{$a} <=> $order{$b}) : ($a cmp $b); } keys %$value; } else { @keys = keys %$value; } # Force the YAML::VALUE ('=') key to sort last. if (exists $value->{&VALUE}) { for (my $i = 0; $i < @keys; $i++) { if ($keys[$i] eq &VALUE) { splice(@keys, $i, 1); push @keys, &VALUE; last; } } } for my $key (@keys) { $self->_emit_key($key, $context); $context = 0; $self->{stream} .= ':'; $self->_emit_node($value->{$key}); } $self->{level}--; } # A YAML series is akin to a Perl array. sub _emit_sequence { my $self = shift; my ($value, $tag) = @_; $self->{stream} .= " !$tag" if $tag; return ($self->{stream} .= " []\n") if @$value == 0; $self->{stream} .= "\n" unless $self->headless && not($self->headless(0)); # XXX Really crufty feature. Better implemented by ynodes. if ($self->inline_series and @$value <= $self->inline_series and not (scalar grep {ref or /\n/} @$value) ) { $self->{stream} =~ s/\n\Z/ /; $self->{stream} .= '['; for (my $i = 0; $i < @$value; $i++) { $self->_emit_str($value->[$i], KEY); last if $i == $#{$value}; $self->{stream} .= ', '; } $self->{stream} .= "]\n"; return; } $self->offset->[$self->level + 1] = $self->offset->[$self->level] + $self->indent_width; $self->{level}++; for my $val (@$value) { $self->{stream} .= ' ' x $self->offset->[$self->level]; $self->{stream} .= '-'; $self->_emit_node($val, FROMARRAY); } $self->{level}--; } # Emit a mapping key sub _emit_key { my $self = shift; my ($value, $context) = @_; $self->{stream} .= ' ' x $self->offset->[$self->level] unless $context == FROMARRAY; $self->_emit_str($value, KEY); } # Emit a blessed SCALAR sub _emit_scalar { my $self = shift; my ($value, $tag) = @_; $self->{stream} .= " !$tag"; $self->_emit_str($value, BLESSED); } sub _emit { my $self = shift; $self->{stream} .= join '', @_; } # Emit a string value. YAML has many scalar styles. This routine attempts to # guess the best style for the text. sub _emit_str { my $self = shift; my $type = $_[1] || 0; # Use heuristics to find the best scalar emission style. $self->offset->[$self->level + 1] = $self->offset->[$self->level] + $self->indent_width; $self->{level}++; my $sf = $type == KEY ? '' : ' '; my $sb = $type == KEY ? '? ' : ' '; my $ef = $type == KEY ? '' : "\n"; my $eb = "\n"; while (1) { $self->_emit($sf), $self->_emit_plain($_[0]), $self->_emit($ef), last if not defined $_[0]; $self->_emit($sf, '=', $ef), last if $_[0] eq VALUE; $self->_emit($sf), $self->_emit_double($_[0]), $self->_emit($ef), last if $_[0] =~ /$ESCAPE_CHAR/; if ($_[0] =~ /\n/) { $self->_emit($sb), $self->_emit_block($LIT_CHAR, $_[0]), $self->_emit($eb), last if $self->use_block; Carp::cluck "[YAML] \$UseFold is no longer supported" if $self->use_fold; $self->_emit($sf), $self->_emit_double($_[0]), $self->_emit($ef), last if length $_[0] <= 30; $self->_emit($sf), $self->_emit_double($_[0]), $self->_emit($ef), last if $_[0] !~ /\n\s*\S/; $self->_emit($sb), $self->_emit_block($LIT_CHAR, $_[0]), $self->_emit($eb), last; } $self->_emit($sf), $self->_emit_plain($_[0]), $self->_emit($ef), last if $self->is_valid_plain($_[0]); $self->_emit($sf), $self->_emit_double($_[0]), $self->_emit($ef), last if $_[0] =~ /'/; $self->_emit($sf), $self->_emit_single($_[0]), $self->_emit($ef); last; } $self->{level}--; return; } # Check whether or not a scalar should be emitted as an plain scalar. sub is_valid_plain { my $self = shift; return 0 unless length $_[0]; # refer to YAML::Loader::parse_inline_simple() return 0 if $_[0] =~ /^[\s\{\[\~\`\'\"\!\@\#\>\|\%\&\?\*\^]/; return 0 if $_[0] =~ /[\{\[\]\},]/; return 0 if $_[0] =~ /[:\-\?]\s/; return 0 if $_[0] =~ /\s#/; return 0 if $_[0] =~ /\:(\s|$)/; return 0 if $_[0] =~ /[\s\|\>]$/; return 1; } sub _emit_block { my $self = shift; my ($indicator, $value) = @_; $self->{stream} .= $indicator; $value =~ /(\n*)\Z/; my $chomp = length $1 ? (length $1 > 1) ? '+' : '' : '-'; $value = '~' if not defined $value; $self->{stream} .= $chomp; $self->{stream} .= $self->indent_width if $value =~ /^\s/; $self->{stream} .= $self->indent($value); } # Plain means that the scalar is unquoted. sub _emit_plain { my $self = shift; $self->{stream} .= defined $_[0] ? $_[0] : '~'; } # Double quoting is for single lined escaped strings. sub _emit_double { my $self = shift; (my $escaped = $self->escape($_[0])) =~ s/"/\\"/g; $self->{stream} .= qq{"$escaped"}; } # Single quoting is for single lined unescaped strings. sub _emit_single { my $self = shift; my $item = shift; $item =~ s{'}{''}g; $self->{stream} .= "'$item'"; } #============================================================================== # Utility subroutines. #============================================================================== # Indent a scalar to the current indentation level. sub indent { my $self = shift; my ($text) = @_; return $text unless length $text; $text =~ s/\n\Z//; my $indent = ' ' x $self->offset->[$self->level]; $text =~ s/^/$indent/gm; $text = "\n$text"; return $text; } # Escapes for unprintable characters my @escapes = qw(\0 \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 ); # Escape the unprintable characters sub escape { my $self = shift; my ($text) = @_; $text =~ s/\\/\\\\/g; $text =~ s/([\x00-\x1f])/$escapes[ord($1)]/ge; return $text; } 1; __END__ =head1 NAME YAML::Dumper - YAML class for dumping Perl objects to YAML =head1 SYNOPSIS use YAML::Dumper; my $dumper = YAML::Dumper->new; $dumper->indent_width(4); print $dumper->dump({foo => 'bar'}); =head1 DESCRIPTION YAML::Dumper is the module that YAML.pm used to serialize Perl objects to YAML. It is fully object oriented and usable on its own. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Tag.pm0000644000372100001440000000125312000060557014340 0ustar matthewtusersuse strict; use warnings; package YAML::Tag; our $VERSION = '0.84'; use overload '""' => sub { ${$_[0]} }; sub new { my ($class, $self) = @_; bless \$self, $class } sub short { ${$_[0]} } sub canonical { ${$_[0]} } 1; __END__ =head1 NAME YAML::Tag - Tag URI object class for YAML =head1 SYNOPSIS use YAML::Tag; =head1 DESCRIPTION Used by YAML::Node. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Marshall.pm0000644000372100001440000000265412000060557015376 0ustar matthewtusersuse strict; use warnings; package YAML::Marshall; our $VERSION = '0.84'; use YAML::Node (); sub import { my $class = shift; no strict 'refs'; my $package = caller; unless (grep { $_ eq $class} @{$package . '::ISA'}) { push @{$package . '::ISA'}, $class; } my $tag = shift; if ( $tag ) { no warnings 'once'; $YAML::TagClass->{$tag} = $package; ${$package . "::YamlTag"} = $tag; } } sub yaml_dump { my $self = shift; no strict 'refs'; my $tag = ${ref($self) . "::YamlTag"} || 'perl/' . ref($self); $self->yaml_node($self, $tag); } sub yaml_load { my ($class, $node) = @_; if (my $ynode = $class->yaml_ynode($node)) { $node = $ynode->{NODE}; } bless $node, $class; } sub yaml_node { shift; YAML::Node->new(@_); } sub yaml_ynode { shift; YAML::Node::ynode(@_); } 1; __END__ =head1 NAME YAML::Marshall - YAML marshalling class you can mixin to your classes =head1 SYNOPSIS package Bar; use Foo -base; use YAML::Marshall -mixin; =head1 DESCRIPTION For classes that want to handle their own YAML serialization. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Node.pm0000644000372100001440000001517512000060557014522 0ustar matthewtusersuse strict; use warnings; package YAML::Node; our $VERSION = '0.84'; use YAML::Tag; require YAML::Mo; use Exporter; our @ISA = qw(Exporter YAML::Mo::Object); our @EXPORT = qw(ynode); sub ynode { my $self; if (ref($_[0]) eq 'HASH') { $self = tied(%{$_[0]}); } elsif (ref($_[0]) eq 'ARRAY') { $self = tied(@{$_[0]}); } elsif (ref(\$_[0]) eq 'GLOB') { $self = tied(*{$_[0]}); } else { $self = tied($_[0]); } return (ref($self) =~ /^yaml_/) ? $self : undef; } sub new { my ($class, $node, $tag) = @_; my $self; $self->{NODE} = $node; my (undef, $type) = YAML::Mo::Object->node_info($node); $self->{KIND} = (not defined $type) ? 'scalar' : ($type eq 'ARRAY') ? 'sequence' : ($type eq 'HASH') ? 'mapping' : $class->die("Can't create YAML::Node from '$type'"); tag($self, ($tag || '')); if ($self->{KIND} eq 'scalar') { yaml_scalar->new($self, $_[1]); return \ $_[1]; } my $package = "yaml_" . $self->{KIND}; $package->new($self) } sub node { $_->{NODE} } sub kind { $_->{KIND} } sub tag { my ($self, $value) = @_; if (defined $value) { $self->{TAG} = YAML::Tag->new($value); return $self; } else { return $self->{TAG}; } } sub keys { my ($self, $value) = @_; if (defined $value) { $self->{KEYS} = $value; return $self; } else { return $self->{KEYS}; } } #============================================================================== package yaml_scalar; @yaml_scalar::ISA = qw(YAML::Node); sub new { my ($class, $self) = @_; tie $_[2], $class, $self; } sub TIESCALAR { my ($class, $self) = @_; bless $self, $class; $self } sub FETCH { my ($self) = @_; $self->{NODE} } sub STORE { my ($self, $value) = @_; $self->{NODE} = $value } #============================================================================== package yaml_sequence; @yaml_sequence::ISA = qw(YAML::Node); sub new { my ($class, $self) = @_; my $new; tie @$new, $class, $self; $new } sub TIEARRAY { my ($class, $self) = @_; bless $self, $class } sub FETCHSIZE { my ($self) = @_; scalar @{$self->{NODE}}; } sub FETCH { my ($self, $index) = @_; $self->{NODE}[$index] } sub STORE { my ($self, $index, $value) = @_; $self->{NODE}[$index] = $value } sub undone { die "Not implemented yet"; # XXX } *STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS = *STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS = *undone; # XXX Must implement before release #============================================================================== package yaml_mapping; @yaml_mapping::ISA = qw(YAML::Node); sub new { my ($class, $self) = @_; @{$self->{KEYS}} = sort keys %{$self->{NODE}}; my $new; tie %$new, $class, $self; $new } sub TIEHASH { my ($class, $self) = @_; bless $self, $class } sub FETCH { my ($self, $key) = @_; if (exists $self->{NODE}{$key}) { return (grep {$_ eq $key} @{$self->{KEYS}}) ? $self->{NODE}{$key} : undef; } return $self->{HASH}{$key}; } sub STORE { my ($self, $key, $value) = @_; if (exists $self->{NODE}{$key}) { $self->{NODE}{$key} = $value; } elsif (exists $self->{HASH}{$key}) { $self->{HASH}{$key} = $value; } else { if (not grep {$_ eq $key} @{$self->{KEYS}}) { push(@{$self->{KEYS}}, $key); } $self->{HASH}{$key} = $value; } $value } sub DELETE { my ($self, $key) = @_; my $return; if (exists $self->{NODE}{$key}) { $return = $self->{NODE}{$key}; } elsif (exists $self->{HASH}{$key}) { $return = delete $self->{NODE}{$key}; } for (my $i = 0; $i < @{$self->{KEYS}}; $i++) { if ($self->{KEYS}[$i] eq $key) { splice(@{$self->{KEYS}}, $i, 1); } } return $return; } sub CLEAR { my ($self) = @_; @{$self->{KEYS}} = (); %{$self->{HASH}} = (); } sub FIRSTKEY { my ($self) = @_; $self->{ITER} = 0; $self->{KEYS}[0] } sub NEXTKEY { my ($self) = @_; $self->{KEYS}[++$self->{ITER}] } sub EXISTS { my ($self, $key) = @_; exists $self->{NODE}{$key} } 1; __END__ =head1 NAME YAML::Node - A generic data node that encapsulates YAML information =head1 SYNOPSIS use YAML; use YAML::Node; my $ynode = YAML::Node->new({}, 'ingerson.com/fruit'); %$ynode = qw(orange orange apple red grape green); print Dump $ynode; yields: --- !ingerson.com/fruit orange: orange apple: red grape: green =head1 DESCRIPTION A generic node in YAML is similar to a plain hash, array, or scalar node in Perl except that it must also keep track of its type. The type is a URI called the YAML type tag. YAML::Node is a class for generating and manipulating these containers. A YAML node (or ynode) is a tied hash, array or scalar. In most ways it behaves just like the plain thing. But you can assign and retrieve and YAML type tag URI to it. For the hash flavor, you can also assign the order that the keys will be retrieved in. By default a ynode will offer its keys in the same order that they were assigned. YAML::Node has a class method call new() that will return a ynode. You pass it a regular node and an optional type tag. After that you can use it like a normal Perl node, but when you YAML::Dump it, the magical properties will be honored. This is how you can control the sort order of hash keys during a YAML serialization. By default, YAML sorts keys alphabetically. But notice in the above example that the keys were Dumped in the same order they were assigned. YAML::Node exports a function called ynode(). This function returns the tied object so that you can call special methods on it like ->keys(). keys() works like this: use YAML; use YAML::Node; %$node = qw(orange orange apple red grape green); $ynode = YAML::Node->new($node); ynode($ynode)->keys(['grape', 'apple']); print Dump $ynode; produces: --- grape: green apple: red It tells the ynode which keys and what order to use. ynodes will play a very important role in how programs use YAML. They are the foundation of how a Perl class can marshall the Loading and Dumping of its objects. The upcoming versions of YAML.pm will have much more information on this. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. Copyright (c) 2002. Brian Ingerson. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Error.pm0000644000372100001440000001434012000060557014717 0ustar matthewtuserspackage YAML::Error; use YAML::Mo; our $VERSION = '0.84'; has 'code'; has 'type' => default => sub {'Error'}; has 'line'; has 'document'; has 'arguments' => default => sub {[]}; my ($error_messages, %line_adjust); sub format_message { my $self = shift; my $output = 'YAML ' . $self->type . ': '; my $code = $self->code; if ($error_messages->{$code}) { $code = sprintf($error_messages->{$code}, @{$self->arguments}); } $output .= $code . "\n"; $output .= ' Code: ' . $self->code . "\n" if defined $self->code; $output .= ' Line: ' . $self->line . "\n" if defined $self->line; $output .= ' Document: ' . $self->document . "\n" if defined $self->document; return $output; } sub error_messages { $error_messages; } %$error_messages = map {s/^\s+//;$_} split "\n", <<'...'; YAML_PARSE_ERR_BAD_CHARS Invalid characters in stream. This parser only supports printable ASCII YAML_PARSE_ERR_NO_FINAL_NEWLINE Stream does not end with newline character YAML_PARSE_ERR_BAD_MAJOR_VERSION Can't parse a %s document with a 1.0 parser YAML_PARSE_WARN_BAD_MINOR_VERSION Parsing a %s document with a 1.0 parser YAML_PARSE_WARN_MULTIPLE_DIRECTIVES '%s directive used more than once' YAML_PARSE_ERR_TEXT_AFTER_INDICATOR No text allowed after indicator YAML_PARSE_ERR_NO_ANCHOR No anchor for alias '*%s' YAML_PARSE_ERR_NO_SEPARATOR Expected separator '---' YAML_PARSE_ERR_SINGLE_LINE Couldn't parse single line value YAML_PARSE_ERR_BAD_ANCHOR Invalid anchor YAML_DUMP_ERR_INVALID_INDENT Invalid Indent width specified: '%s' YAML_LOAD_USAGE usage: YAML::Load($yaml_stream_scalar) YAML_PARSE_ERR_BAD_NODE Can't parse node YAML_PARSE_ERR_BAD_EXPLICIT Unsupported explicit transfer: '%s' YAML_DUMP_USAGE_DUMPCODE Invalid value for DumpCode: '%s' YAML_LOAD_ERR_FILE_INPUT Couldn't open %s for input:\n%s YAML_DUMP_ERR_FILE_CONCATENATE Can't concatenate to YAML file %s YAML_DUMP_ERR_FILE_OUTPUT Couldn't open %s for output:\n%s YAML_DUMP_ERR_NO_HEADER With UseHeader=0, the node must be a plain hash or array YAML_DUMP_WARN_BAD_NODE_TYPE Can't perform serialization for node type: '%s' YAML_EMIT_WARN_KEYS Encountered a problem with 'keys':\n%s YAML_DUMP_WARN_DEPARSE_FAILED Deparse failed for CODE reference YAML_DUMP_WARN_CODE_DUMMY Emitting dummy subroutine for CODE reference YAML_PARSE_ERR_MANY_EXPLICIT More than one explicit transfer YAML_PARSE_ERR_MANY_IMPLICIT More than one implicit request YAML_PARSE_ERR_MANY_ANCHOR More than one anchor YAML_PARSE_ERR_ANCHOR_ALIAS Can't define both an anchor and an alias YAML_PARSE_ERR_BAD_ALIAS Invalid alias YAML_PARSE_ERR_MANY_ALIAS More than one alias YAML_LOAD_ERR_NO_CONVERT Can't convert implicit '%s' node to explicit '%s' node YAML_LOAD_ERR_NO_DEFAULT_VALUE No default value for '%s' explicit transfer YAML_LOAD_ERR_NON_EMPTY_STRING Only the empty string can be converted to a '%s' YAML_LOAD_ERR_BAD_MAP_TO_SEQ Can't transfer map as sequence. Non numeric key '%s' encountered. YAML_DUMP_ERR_BAD_GLOB '%s' is an invalid value for Perl glob YAML_DUMP_ERR_BAD_REGEXP '%s' is an invalid value for Perl Regexp YAML_LOAD_ERR_BAD_MAP_ELEMENT Invalid element in map YAML_LOAD_WARN_DUPLICATE_KEY Duplicate map key found. Ignoring. YAML_LOAD_ERR_BAD_SEQ_ELEMENT Invalid element in sequence YAML_PARSE_ERR_INLINE_MAP Can't parse inline map YAML_PARSE_ERR_INLINE_SEQUENCE Can't parse inline sequence YAML_PARSE_ERR_BAD_DOUBLE Can't parse double quoted string YAML_PARSE_ERR_BAD_SINGLE Can't parse single quoted string YAML_PARSE_ERR_BAD_INLINE_IMPLICIT Can't parse inline implicit value '%s' YAML_PARSE_ERR_BAD_IMPLICIT Unrecognized implicit value '%s' YAML_PARSE_ERR_INDENTATION Error. Invalid indentation level YAML_PARSE_ERR_INCONSISTENT_INDENTATION Inconsistent indentation level YAML_LOAD_WARN_UNRESOLVED_ALIAS Can't resolve alias *%s YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP No 'REGEXP' element for Perl regexp YAML_LOAD_WARN_BAD_REGEXP_ELEM Unknown element '%s' in Perl regexp YAML_LOAD_WARN_GLOB_NAME No 'NAME' element for Perl glob YAML_LOAD_WARN_PARSE_CODE Couldn't parse Perl code scalar: %s YAML_LOAD_WARN_CODE_DEPARSE Won't parse Perl code unless $YAML::LoadCode is set YAML_EMIT_ERR_BAD_LEVEL Internal Error: Bad level detected YAML_PARSE_WARN_AMBIGUOUS_TAB Amibiguous tab converted to spaces YAML_LOAD_WARN_BAD_GLOB_ELEM Unknown element '%s' in Perl glob YAML_PARSE_ERR_ZERO_INDENT Can't use zero as an indentation width YAML_LOAD_WARN_GLOB_IO Can't load an IO filehandle. Yet!!! ... %line_adjust = map {($_, 1)} qw(YAML_PARSE_ERR_BAD_MAJOR_VERSION YAML_PARSE_WARN_BAD_MINOR_VERSION YAML_PARSE_ERR_TEXT_AFTER_INDICATOR YAML_PARSE_ERR_NO_ANCHOR YAML_PARSE_ERR_MANY_EXPLICIT YAML_PARSE_ERR_MANY_IMPLICIT YAML_PARSE_ERR_MANY_ANCHOR YAML_PARSE_ERR_ANCHOR_ALIAS YAML_PARSE_ERR_BAD_ALIAS YAML_PARSE_ERR_MANY_ALIAS YAML_LOAD_ERR_NO_CONVERT YAML_LOAD_ERR_NO_DEFAULT_VALUE YAML_LOAD_ERR_NON_EMPTY_STRING YAML_LOAD_ERR_BAD_MAP_TO_SEQ YAML_LOAD_ERR_BAD_STR_TO_INT YAML_LOAD_ERR_BAD_STR_TO_DATE YAML_LOAD_ERR_BAD_STR_TO_TIME YAML_LOAD_WARN_DUPLICATE_KEY YAML_PARSE_ERR_INLINE_MAP YAML_PARSE_ERR_INLINE_SEQUENCE YAML_PARSE_ERR_BAD_DOUBLE YAML_PARSE_ERR_BAD_SINGLE YAML_PARSE_ERR_BAD_INLINE_IMPLICIT YAML_PARSE_ERR_BAD_IMPLICIT YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP YAML_LOAD_WARN_BAD_REGEXP_ELEM YAML_LOAD_WARN_REGEXP_CREATE YAML_LOAD_WARN_GLOB_NAME YAML_LOAD_WARN_PARSE_CODE YAML_LOAD_WARN_CODE_DEPARSE YAML_LOAD_WARN_BAD_GLOB_ELEM YAML_PARSE_ERR_ZERO_INDENT ); package YAML::Warning; our @ISA = 'YAML::Error'; 1; __END__ =head1 NAME YAML::Error - Error formatting class for YAML modules =head1 SYNOPSIS $self->die('YAML_PARSE_ERR_NO_ANCHOR', $alias); $self->warn('YAML_LOAD_WARN_DUPLICATE_KEY'); =head1 DESCRIPTION This module provides a C and a C facility. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Loader.pm0000644000372100001440000005740512000060557015045 0ustar matthewtuserspackage YAML::Loader; use YAML::Mo; extends 'YAML::Loader::Base'; our $VERSION = '0.84'; use YAML::Loader::Base; use YAML::Types; # Context constants use constant LEAF => 1; use constant COLLECTION => 2; use constant VALUE => "\x07YAML\x07VALUE\x07"; use constant COMMENT => "\x07YAML\x07COMMENT\x07"; # Common YAML character sets my $ESCAPE_CHAR = '[\\x00-\\x08\\x0b-\\x0d\\x0e-\\x1f]'; my $FOLD_CHAR = '>'; my $LIT_CHAR = '|'; my $LIT_CHAR_RX = "\\$LIT_CHAR"; sub load { my $self = shift; $self->stream($_[0] || ''); return $self->_parse(); } # Top level function for parsing. Parse each document in order and # handle processing for YAML headers. sub _parse { my $self = shift; my (%directives, $preface); $self->{stream} =~ s|\015\012|\012|g; $self->{stream} =~ s|\015|\012|g; $self->line(0); $self->die('YAML_PARSE_ERR_BAD_CHARS') if $self->stream =~ /$ESCAPE_CHAR/; $self->die('YAML_PARSE_ERR_NO_FINAL_NEWLINE') if length($self->stream) and $self->{stream} !~ s/(.)\n\Z/$1/s; $self->lines([split /\x0a/, $self->stream, -1]); $self->line(1); # Throw away any comments or blanks before the header (or start of # content for headerless streams) $self->_parse_throwaway_comments(); $self->document(0); $self->documents([]); # Add an "assumed" header if there is no header and the stream is # not empty (after initial throwaways). if (not $self->eos) { if ($self->lines->[0] !~ /^---(\s|$)/) { unshift @{$self->lines}, '---'; $self->{line}--; } } # Main Loop. Parse out all the top level nodes and return them. while (not $self->eos) { $self->anchor2node({}); $self->{document}++; $self->done(0); $self->level(0); $self->offset->[0] = -1; if ($self->lines->[0] =~ /^---\s*(.*)$/) { my @words = split /\s+/, $1; %directives = (); while (@words && $words[0] =~ /^#(\w+):(\S.*)$/) { my ($key, $value) = ($1, $2); shift(@words); if (defined $directives{$key}) { $self->warn('YAML_PARSE_WARN_MULTIPLE_DIRECTIVES', $key, $self->document); next; } $directives{$key} = $value; } $self->preface(join ' ', @words); } else { $self->die('YAML_PARSE_ERR_NO_SEPARATOR'); } if (not $self->done) { $self->_parse_next_line(COLLECTION); } if ($self->done) { $self->{indent} = -1; $self->content(''); } $directives{YAML} ||= '1.0'; $directives{TAB} ||= 'NONE'; ($self->{major_version}, $self->{minor_version}) = split /\./, $directives{YAML}, 2; $self->die('YAML_PARSE_ERR_BAD_MAJOR_VERSION', $directives{YAML}) if $self->major_version ne '1'; $self->warn('YAML_PARSE_WARN_BAD_MINOR_VERSION', $directives{YAML}) if $self->minor_version ne '0'; $self->die('Unrecognized TAB policy') unless $directives{TAB} =~ /^(NONE|\d+)(:HARD)?$/; push @{$self->documents}, $self->_parse_node(); } return wantarray ? @{$self->documents} : $self->documents->[-1]; } # This function is the dispatcher for parsing each node. Every node # recurses back through here. (Inlines are an exception as they have # their own sub-parser.) sub _parse_node { my $self = shift; my $preface = $self->preface; $self->preface(''); my ($node, $type, $indicator, $escape, $chomp) = ('') x 5; my ($anchor, $alias, $explicit, $implicit, $class) = ('') x 5; ($anchor, $alias, $explicit, $implicit, $preface) = $self->_parse_qualifiers($preface); if ($anchor) { $self->anchor2node->{$anchor} = CORE::bless [], 'YAML-anchor2node'; } $self->inline(''); while (length $preface) { my $line = $self->line - 1; if ($preface =~ s/^($FOLD_CHAR|$LIT_CHAR_RX)(-|\+)?\d*\s*//) { $indicator = $1; $chomp = $2 if defined($2); } else { $self->die('YAML_PARSE_ERR_TEXT_AFTER_INDICATOR') if $indicator; $self->inline($preface); $preface = ''; } } if ($alias) { $self->die('YAML_PARSE_ERR_NO_ANCHOR', $alias) unless defined $self->anchor2node->{$alias}; if (ref($self->anchor2node->{$alias}) ne 'YAML-anchor2node') { $node = $self->anchor2node->{$alias}; } else { $node = do {my $sv = "*$alias"}; push @{$self->anchor2node->{$alias}}, [\$node, $self->line]; } } elsif (length $self->inline) { $node = $self->_parse_inline(1, $implicit, $explicit); if (length $self->inline) { $self->die('YAML_PARSE_ERR_SINGLE_LINE'); } } elsif ($indicator eq $LIT_CHAR) { $self->{level}++; $node = $self->_parse_block($chomp); $node = $self->_parse_implicit($node) if $implicit; $self->{level}--; } elsif ($indicator eq $FOLD_CHAR) { $self->{level}++; $node = $self->_parse_unfold($chomp); $node = $self->_parse_implicit($node) if $implicit; $self->{level}--; } else { $self->{level}++; $self->offset->[$self->level] ||= 0; if ($self->indent == $self->offset->[$self->level]) { if ($self->content =~ /^-( |$)/) { $node = $self->_parse_seq($anchor); } elsif ($self->content =~ /(^\?|\:( |$))/) { $node = $self->_parse_mapping($anchor); } elsif ($preface =~ /^\s*$/) { $node = $self->_parse_implicit(''); } else { $self->die('YAML_PARSE_ERR_BAD_NODE'); } } else { $node = undef; } $self->{level}--; } $#{$self->offset} = $self->level; if ($explicit) { if ($class) { if (not ref $node) { my $copy = $node; undef $node; $node = \$copy; } CORE::bless $node, $class; } else { $node = $self->_parse_explicit($node, $explicit); } } if ($anchor) { if (ref($self->anchor2node->{$anchor}) eq 'YAML-anchor2node') { # XXX Can't remember what this code actually does for my $ref (@{$self->anchor2node->{$anchor}}) { ${$ref->[0]} = $node; $self->warn('YAML_LOAD_WARN_UNRESOLVED_ALIAS', $anchor, $ref->[1]); } } $self->anchor2node->{$anchor} = $node; } return $node; } # Preprocess the qualifiers that may be attached to any node. sub _parse_qualifiers { my $self = shift; my ($preface) = @_; my ($anchor, $alias, $explicit, $implicit, $token) = ('') x 5; $self->inline(''); while ($preface =~ /^[&*!]/) { my $line = $self->line - 1; if ($preface =~ s/^\!(\S+)\s*//) { $self->die('YAML_PARSE_ERR_MANY_EXPLICIT') if $explicit; $explicit = $1; } elsif ($preface =~ s/^\!\s*//) { $self->die('YAML_PARSE_ERR_MANY_IMPLICIT') if $implicit; $implicit = 1; } elsif ($preface =~ s/^\&([^ ,:]+)\s*//) { $token = $1; $self->die('YAML_PARSE_ERR_BAD_ANCHOR') unless $token =~ /^[a-zA-Z0-9]+$/; $self->die('YAML_PARSE_ERR_MANY_ANCHOR') if $anchor; $self->die('YAML_PARSE_ERR_ANCHOR_ALIAS') if $alias; $anchor = $token; } elsif ($preface =~ s/^\*([^ ,:]+)\s*//) { $token = $1; $self->die('YAML_PARSE_ERR_BAD_ALIAS') unless $token =~ /^[a-zA-Z0-9]+$/; $self->die('YAML_PARSE_ERR_MANY_ALIAS') if $alias; $self->die('YAML_PARSE_ERR_ANCHOR_ALIAS') if $anchor; $alias = $token; } } return ($anchor, $alias, $explicit, $implicit, $preface); } # Morph a node to it's explicit type sub _parse_explicit { my $self = shift; my ($node, $explicit) = @_; my ($type, $class); if ($explicit =~ /^\!?perl\/(hash|array|ref|scalar)(?:\:(\w(\w|\:\:)*)?)?$/) { ($type, $class) = (($1 || ''), ($2 || '')); # FIXME # die unless uc($type) eq ref($node) ? if ( $type eq "ref" ) { $self->die('YAML_LOAD_ERR_NO_DEFAULT_VALUE', 'XXX', $explicit) unless exists $node->{VALUE()} and scalar(keys %$node) == 1; my $value = $node->{VALUE()}; $node = \$value; } if ( $type eq "scalar" and length($class) and !ref($node) ) { my $value = $node; $node = \$value; } if ( length($class) ) { CORE::bless($node, $class); } return $node; } if ($explicit =~ m{^!?perl/(glob|regexp|code)(?:\:(\w(\w|\:\:)*)?)?$}) { ($type, $class) = (($1 || ''), ($2 || '')); my $type_class = "YAML::Type::$type"; no strict 'refs'; if ($type_class->can('yaml_load')) { return $type_class->yaml_load($node, $class, $self); } else { $self->die('YAML_LOAD_ERR_NO_CONVERT', 'XXX', $explicit); } } # This !perl/@Foo and !perl/$Foo are deprecated but still parsed elsif ($YAML::TagClass->{$explicit} || $explicit =~ m{^perl/(\@|\$)?([a-zA-Z](\w|::)+)$} ) { $class = $YAML::TagClass->{$explicit} || $2; if ($class->can('yaml_load')) { require YAML::Node; return $class->yaml_load(YAML::Node->new($node, $explicit)); } else { if (ref $node) { return CORE::bless $node, $class; } else { return CORE::bless \$node, $class; } } } elsif (ref $node) { require YAML::Node; return YAML::Node->new($node, $explicit); } else { # XXX This is likely wrong. Failing test: # --- !unknown 'scalar value' return $node; } } # Parse a YAML mapping into a Perl hash sub _parse_mapping { my $self = shift; my ($anchor) = @_; my $mapping = {}; $self->anchor2node->{$anchor} = $mapping; my $key; while (not $self->done and $self->indent == $self->offset->[$self->level]) { # If structured key: if ($self->{content} =~ s/^\?\s*//) { $self->preface($self->content); $self->_parse_next_line(COLLECTION); $key = $self->_parse_node(); $key = "$key"; } # If "default" key (equals sign) elsif ($self->{content} =~ s/^\=\s*//) { $key = VALUE; } # If "comment" key (slash slash) elsif ($self->{content} =~ s/^\=\s*//) { $key = COMMENT; } # Regular scalar key: else { $self->inline($self->content); $key = $self->_parse_inline(); $key = "$key"; $self->content($self->inline); $self->inline(''); } unless ($self->{content} =~ s/^:\s*//) { $self->die('YAML_LOAD_ERR_BAD_MAP_ELEMENT'); } $self->preface($self->content); my $line = $self->line; $self->_parse_next_line(COLLECTION); my $value = $self->_parse_node(); if (exists $mapping->{$key}) { $self->warn('YAML_LOAD_WARN_DUPLICATE_KEY'); } else { $mapping->{$key} = $value; } } return $mapping; } # Parse a YAML sequence into a Perl array sub _parse_seq { my $self = shift; my ($anchor) = @_; my $seq = []; $self->anchor2node->{$anchor} = $seq; while (not $self->done and $self->indent == $self->offset->[$self->level]) { if ($self->content =~ /^-(?: (.*))?$/) { $self->preface(defined($1) ? $1 : ''); } else { $self->die('YAML_LOAD_ERR_BAD_SEQ_ELEMENT'); } if ($self->preface =~ /^(\s*)(\w.*\:(?: |$).*)$/) { $self->indent($self->offset->[$self->level] + 2 + length($1)); $self->content($2); $self->level($self->level + 1); $self->offset->[$self->level] = $self->indent; $self->preface(''); push @$seq, $self->_parse_mapping(''); $self->{level}--; $#{$self->offset} = $self->level; } else { $self->_parse_next_line(COLLECTION); push @$seq, $self->_parse_node(); } } return $seq; } # Parse an inline value. Since YAML supports inline collections, this is # the top level of a sub parsing. sub _parse_inline { my $self = shift; my ($top, $top_implicit, $top_explicit) = (@_, '', '', ''); $self->{inline} =~ s/^\s*(.*)\s*$/$1/; # OUCH - mugwump my ($node, $anchor, $alias, $explicit, $implicit) = ('') x 5; ($anchor, $alias, $explicit, $implicit, $self->{inline}) = $self->_parse_qualifiers($self->inline); if ($anchor) { $self->anchor2node->{$anchor} = CORE::bless [], 'YAML-anchor2node'; } $implicit ||= $top_implicit; $explicit ||= $top_explicit; ($top_implicit, $top_explicit) = ('', ''); if ($alias) { $self->die('YAML_PARSE_ERR_NO_ANCHOR', $alias) unless defined $self->anchor2node->{$alias}; if (ref($self->anchor2node->{$alias}) ne 'YAML-anchor2node') { $node = $self->anchor2node->{$alias}; } else { $node = do {my $sv = "*$alias"}; push @{$self->anchor2node->{$alias}}, [\$node, $self->line]; } } elsif ($self->inline =~ /^\{/) { $node = $self->_parse_inline_mapping($anchor); } elsif ($self->inline =~ /^\[/) { $node = $self->_parse_inline_seq($anchor); } elsif ($self->inline =~ /^"/) { $node = $self->_parse_inline_double_quoted(); $node = $self->_unescape($node); $node = $self->_parse_implicit($node) if $implicit; } elsif ($self->inline =~ /^'/) { $node = $self->_parse_inline_single_quoted(); $node = $self->_parse_implicit($node) if $implicit; } else { if ($top) { $node = $self->inline; $self->inline(''); } else { $node = $self->_parse_inline_simple(); } $node = $self->_parse_implicit($node) unless $explicit; } if ($explicit) { $node = $self->_parse_explicit($node, $explicit); } if ($anchor) { if (ref($self->anchor2node->{$anchor}) eq 'YAML-anchor2node') { for my $ref (@{$self->anchor2node->{$anchor}}) { ${$ref->[0]} = $node; $self->warn('YAML_LOAD_WARN_UNRESOLVED_ALIAS', $anchor, $ref->[1]); } } $self->anchor2node->{$anchor} = $node; } return $node; } # Parse the inline YAML mapping into a Perl hash sub _parse_inline_mapping { my $self = shift; my ($anchor) = @_; my $node = {}; $self->anchor2node->{$anchor} = $node; $self->die('YAML_PARSE_ERR_INLINE_MAP') unless $self->{inline} =~ s/^\{\s*//; while (not $self->{inline} =~ s/^\s*\}//) { my $key = $self->_parse_inline(); $self->die('YAML_PARSE_ERR_INLINE_MAP') unless $self->{inline} =~ s/^\: \s*//; my $value = $self->_parse_inline(); if (exists $node->{$key}) { $self->warn('YAML_LOAD_WARN_DUPLICATE_KEY'); } else { $node->{$key} = $value; } next if $self->inline =~ /^\s*\}/; $self->die('YAML_PARSE_ERR_INLINE_MAP') unless $self->{inline} =~ s/^\,\s*//; } return $node; } # Parse the inline YAML sequence into a Perl array sub _parse_inline_seq { my $self = shift; my ($anchor) = @_; my $node = []; $self->anchor2node->{$anchor} = $node; $self->die('YAML_PARSE_ERR_INLINE_SEQUENCE') unless $self->{inline} =~ s/^\[\s*//; while (not $self->{inline} =~ s/^\s*\]//) { my $value = $self->_parse_inline(); push @$node, $value; next if $self->inline =~ /^\s*\]/; $self->die('YAML_PARSE_ERR_INLINE_SEQUENCE') unless $self->{inline} =~ s/^\,\s*//; } return $node; } # Parse the inline double quoted string. sub _parse_inline_double_quoted { my $self = shift; my $node; if ($self->inline =~ /^"((?:\\"|[^"])*)"\s*(.*)$/) { $node = $1; $self->inline($2); $node =~ s/\\"/"/g; } else { $self->die('YAML_PARSE_ERR_BAD_DOUBLE'); } return $node; } # Parse the inline single quoted string. sub _parse_inline_single_quoted { my $self = shift; my $node; if ($self->inline =~ /^'((?:''|[^'])*)'\s*(.*)$/) { $node = $1; $self->inline($2); $node =~ s/''/'/g; } else { $self->die('YAML_PARSE_ERR_BAD_SINGLE'); } return $node; } # Parse the inline unquoted string and do implicit typing. sub _parse_inline_simple { my $self = shift; my $value; if ($self->inline =~ /^(|[^!@#%^&*].*?)(?=[\[\]\{\},]|, |: |- |:\s*$|$)/) { $value = $1; substr($self->{inline}, 0, length($1)) = ''; } else { $self->die('YAML_PARSE_ERR_BAD_INLINE_IMPLICIT', $value); } return $value; } sub _parse_implicit { my $self = shift; my ($value) = @_; $value =~ s/\s*$//; return $value if $value eq ''; return undef if $value =~ /^~$/; return $value unless $value =~ /^[\@\`\^]/ or $value =~ /^[\-\?]\s/; $self->die('YAML_PARSE_ERR_BAD_IMPLICIT', $value); } # Unfold a YAML multiline scalar into a single string. sub _parse_unfold { my $self = shift; my ($chomp) = @_; my $node = ''; my $space = 0; while (not $self->done and $self->indent == $self->offset->[$self->level]) { $node .= $self->content. "\n"; $self->_parse_next_line(LEAF); } $node =~ s/^(\S.*)\n(?=\S)/$1 /gm; $node =~ s/^(\S.*)\n(\n+\S)/$1$2/gm; $node =~ s/\n*\Z// unless $chomp eq '+'; $node .= "\n" unless $chomp; return $node; } # Parse a YAML block style scalar. This is like a Perl here-document. sub _parse_block { my $self = shift; my ($chomp) = @_; my $node = ''; while (not $self->done and $self->indent == $self->offset->[$self->level]) { $node .= $self->content . "\n"; $self->_parse_next_line(LEAF); } return $node if '+' eq $chomp; $node =~ s/\n*\Z/\n/; $node =~ s/\n\Z// if $chomp eq '-'; return $node; } # Handle Perl style '#' comments. Comments must be at the same indentation # level as the collection line following them. sub _parse_throwaway_comments { my $self = shift; while (@{$self->lines} and $self->lines->[0] =~ m{^\s*(\#|$)} ) { shift @{$self->lines}; $self->{line}++; } $self->eos($self->{done} = not @{$self->lines}); } # This is the routine that controls what line is being parsed. It gets called # once for each line in the YAML stream. # # This routine must: # 1) Skip past the current line # 2) Determine the indentation offset for a new level # 3) Find the next _content_ line # A) Skip over any throwaways (Comments/blanks) # B) Set $self->indent, $self->content, $self->line # 4) Expand tabs appropriately sub _parse_next_line { my $self = shift; my ($type) = @_; my $level = $self->level; my $offset = $self->offset->[$level]; $self->die('YAML_EMIT_ERR_BAD_LEVEL') unless defined $offset; shift @{$self->lines}; $self->eos($self->{done} = not @{$self->lines}); return if $self->eos; $self->{line}++; # Determine the offset for a new leaf node if ($self->preface =~ qr/(?:^|\s)(?:$FOLD_CHAR|$LIT_CHAR_RX)(?:-|\+)?(\d*)\s*$/ ) { $self->die('YAML_PARSE_ERR_ZERO_INDENT') if length($1) and $1 == 0; $type = LEAF; if (length($1)) { $self->offset->[$level + 1] = $offset + $1; } else { # First get rid of any comments. while (@{$self->lines} && ($self->lines->[0] =~ /^\s*#/)) { $self->lines->[0] =~ /^( *)/ or die; last unless length($1) <= $offset; shift @{$self->lines}; $self->{line}++; } $self->eos($self->{done} = not @{$self->lines}); return if $self->eos; if ($self->lines->[0] =~ /^( *)\S/ and length($1) > $offset) { $self->offset->[$level+1] = length($1); } else { $self->offset->[$level+1] = $offset + 1; } } $offset = $self->offset->[++$level]; } # Determine the offset for a new collection level elsif ($type == COLLECTION and $self->preface =~ /^(\s*(\!\S*|\&\S+))*\s*$/) { $self->_parse_throwaway_comments(); if ($self->eos) { $self->offset->[$level+1] = $offset + 1; return; } else { $self->lines->[0] =~ /^( *)\S/ or die; if (length($1) > $offset) { $self->offset->[$level+1] = length($1); } else { $self->offset->[$level+1] = $offset + 1; } } $offset = $self->offset->[++$level]; } if ($type == LEAF) { while (@{$self->lines} and $self->lines->[0] =~ m{^( *)(\#)} and length($1) < $offset ) { shift @{$self->lines}; $self->{line}++; } $self->eos($self->{done} = not @{$self->lines}); } else { $self->_parse_throwaway_comments(); } return if $self->eos; if ($self->lines->[0] =~ /^---(\s|$)/) { $self->done(1); return; } if ($type == LEAF and $self->lines->[0] =~ /^ {$offset}(.*)$/ ) { $self->indent($offset); $self->content($1); } elsif ($self->lines->[0] =~ /^\s*$/) { $self->indent($offset); $self->content(''); } else { $self->lines->[0] =~ /^( *)(\S.*)$/; while ($self->offset->[$level] > length($1)) { $level--; } $self->die('YAML_PARSE_ERR_INCONSISTENT_INDENTATION') if $self->offset->[$level] != length($1); $self->indent(length($1)); $self->content($2); } $self->die('YAML_PARSE_ERR_INDENTATION') if $self->indent - $offset > 1; } #============================================================================== # Utility subroutines. #============================================================================== # Printable characters for escapes my %unescapes = ( 0 => "\x00", a => "\x07", t => "\x09", n => "\x0a", 'v' => "\x0b", # Potential v-string error on 5.6.2 if not quoted f => "\x0c", r => "\x0d", e => "\x1b", '\\' => '\\', ); # Transform all the backslash style escape characters to their literal meaning sub _unescape { my $self = shift; my ($node) = @_; $node =~ s/\\([never\\fart0]|x([0-9a-fA-F]{2}))/ (length($1)>1)?pack("H2",$2):$unescapes{$1}/gex; return $node; } 1; __END__ =head1 NAME YAML::Loader - YAML class for loading Perl objects to YAML =head1 SYNOPSIS use YAML::Loader; my $loader = YAML::Loader->new; my $hash = $loader->load(<<'...'); foo: bar ... =head1 DESCRIPTION YAML::Loader is the module that YAML.pm used to deserialize YAML to Perl objects. It is fully object oriented and usable on its own. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/lib/YAML/Loader/0000755000372100001440000000000012000063203014463 5ustar matthewtusersYAML-0.84/lib/YAML/Loader/Base.pm0000644000372100001440000000303312000060557015703 0ustar matthewtuserspackage YAML::Loader::Base; use YAML::Mo; our $VERSION = '0.84'; has load_code => default => sub {0}; has stream => default => sub {''}; has document => default => sub {0}; has line => default => sub {0}; has documents => default => sub {[]}; has lines => default => sub {[]}; has eos => default => sub {0}; has done => default => sub {0}; has anchor2node => default => sub {{}}; has level => default => sub {0}; has offset => default => sub {[]}; has preface => default => sub {''}; has content => default => sub {''}; has indent => default => sub {0}; has major_version => default => sub {0}; has minor_version => default => sub {0}; has inline => default => sub {''}; sub set_global_options { my $self = shift; $self->load_code($YAML::LoadCode || $YAML::UseCode) if defined $YAML::LoadCode or defined $YAML::UseCode; } sub load { die 'load() not implemented in this class.'; } 1; __END__ =head1 NAME YAML::Loader::Base - Base class for YAML Loader classes =head1 SYNOPSIS package YAML::Loader::Something; use YAML::Loader::Base -base; =head1 DESCRIPTION YAML::Loader::Base is a base class for creating YAML loader classes. =head1 AUTHOR Ingy döt Net =head1 COPYRIGHT Copyright (c) 2006, 2011-2012. Ingy döt Net. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut YAML-0.84/README0000644000372100001440000006010712000063151012633 0ustar matthewtusersNAME YAML - YAML Ain't Markup Language (tm) NOTE This module has been released to CPAN as YAML::Old, and soon YAML.pm will be changed to just be a frontend interface module for all the various Perl YAML implementation modules, including YAML::Old. If you want robust and fast YAML processing using the normal Dump/Load API, please consider switching to YAML::XS. It is by far the best Perl module for YAML at this time. It requires that you have a C compiler, since it is written in C. If you really need to use this version of YAML.pm it will always be available as YAML::Old. If you don't care which YAML module use, as long as it's the best one installed on your system, use YAML::Any. The rest of this documentation is left unchanged, until YAML.pm is switched over to the new UI-only version. SYNOPSIS use YAML; # Load a YAML stream of 3 YAML documents into Perl data structures. my ($hashref, $arrayref, $string) = Load(<<'...'); --- name: ingy age: old weight: heavy # I should comment that I also like pink, but don't tell anybody. favorite colors: - red - green - blue --- - Clark Evans - Oren Ben-Kiki - Ingy döt Net --- > You probably think YAML stands for "Yet Another Markup Language". It ain't! YAML is really a data serialization language. But if you want to think of it as a markup, that's OK with me. A lot of people try to use XML as a serialization format. "YAML" is catchy and fun to say. Try it. "YAML, YAML, YAML!!!" ... # Dump the Perl data structures back into YAML. print Dump($string, $arrayref, $hashref); # YAML::Dump is used the same way you'd use Data::Dumper::Dumper use Data::Dumper; print Dumper($string, $arrayref, $hashref); DESCRIPTION The YAML.pm module implements a YAML Loader and Dumper based on the YAML 1.0 specification. YAML is a generic data serialization language that is optimized for human readability. It can be used to express the data structures of most modern programming languages. (Including Perl!!!) For information on the YAML syntax, please refer to the YAML specification. WHY YAML IS COOL YAML is readable for people. It makes clear sense out of complex data structures. You should find that YAML is an exceptional data dumping tool. Structure is shown through indentation, YAML supports recursive data, and hash keys are sorted by default. In addition, YAML supports several styles of scalar formatting for different types of data. YAML is editable. YAML was designed from the ground up to be an excellent syntax for configuration files. Almost all programs need configuration files, so why invent a new syntax for each one? And why subject users to the complexities of XML or native Perl code? YAML is multilingual. Yes, YAML supports Unicode. But I'm actually referring to programming languages. YAML was designed to meet the serialization needs of Perl, Python, Ruby, Tcl, PHP, Javascript and Java. It was also designed to be interoperable between those languages. That means YAML serializations produced by Perl can be processed by Python. YAML is taint safe. Using modules like Data::Dumper for serialization is fine as long as you can be sure that nobody can tamper with your data files or transmissions. That's because you need to use Perl's "eval()" built-in to deserialize the data. Somebody could add a snippet of Perl to erase your files. YAML's parser does not need to eval anything. YAML is full featured. YAML can accurately serialize all of the common Perl data structures and deserialize them again without losing data relationships. Although it is not 100% perfect (no serializer is or can be perfect), it fares as well as the popular current modules: Data::Dumper, Storable, XML::Dumper and Data::Denter. YAML.pm also has the ability to handle code (subroutine) references and typeglobs. (Still experimental) These features are not found in Perl's other serialization modules. YAML is extensible. The YAML language has been designed to be flexible enough to solve it's own problems. The markup itself has 3 basic construct which resemble Perl's hash, array and scalar. By default, these map to their Perl equivalents. But each YAML node also supports a tagging mechanism (type system) which can cause that node to be interpreted in a completely different manner. That's how YAML can support object serialization and oddball structures like Perl's typeglob. YAML IMPLEMENTATIONS IN PERL This module, YAML.pm, is really just the interface module for YAML modules written in Perl. The basic interface for YAML consists of two functions: "Dump" and "Load". The real work is done by the modules YAML::Dumper and YAML::Loader. Different YAML module distributions can be created by subclassing YAML.pm and YAML::Loader and YAML::Dumper. For example, YAML-Simple consists of YAML::Simple YAML::Dumper::Simple and YAML::Loader::Simple. Why would there be more than one implementation of YAML? Well, despite YAML's offering of being a simple data format, YAML is actually very deep and complex. Implementing the entirety of the YAML specification is a daunting task. For this reason I am currently working on 3 different YAML implementations. YAML The main YAML distribution will keeping evolving to support the entire YAML specification in pure Perl. This may not be the fastest or most stable module though. Currently, YAML.pm has lots of known bugs. It is mostly a great tool for dumping Perl data structures to a readable form. YAML::Tiny The point of YAML::Tiny is to strip YAML down to the 90% that people use most and offer that in a small, fast, stable, pure Perl form. YAML::Tiny will simply die when it is asked to do something it can't. YAML::Syck "libsyck" is the C based YAML processing library used by the Ruby programming language (and also Python, PHP and Pugs). YAML::Syck is the Perl binding to "libsyck". It should be very fast, but may have problems of its own. It will also require C compilation. NOTE: Audrey Tang has actually completed this module and it works great and is 10 times faster than YAML.pm. In the future, there will likely be even more YAML modules. Remember, people other than Ingy are allowed to write YAML modules! FUNCTIONAL USAGE YAML is completely OO under the hood. Still it exports a few useful top level functions so that it is dead simple to use. These functions just do the OO stuff for you. If you want direct access to the OO API see the documentation for YAML::Dumper and YAML::Loader. Exported Functions The following functions are exported by YAML.pm by default. The reason they are exported is so that YAML works much like Data::Dumper. If you don't want functions to be imported, just use YAML with an empty import list: use YAML (); Dump(list-of-Perl-data-structures) Turn Perl data into YAML. This function works very much like Data::Dumper::Dumper(). It takes a list of Perl data strucures and dumps them into a serialized form. It returns a string containing the YAML stream. The structures can be references or plain scalars. Load(string-containing-a-YAML-stream) Turn YAML into Perl data. This is the opposite of Dump. Just like Storable's thaw() function or the eval() function in relation to Data::Dumper. It parses a string containing a valid YAML stream into a list of Perl data structures. Exportable Functions These functions are not exported by default but you can request them in an import list like this: use YAML qw'freeze thaw Bless'; freeze() and thaw() Aliases to Dump() and Load() for Storable fans. This will also allow YAML.pm to be plugged directly into modules like POE.pm, that use the freeze/thaw API for internal serialization. DumpFile(filepath, list) Writes the YAML stream to a file instead of just returning a string. LoadFile(filepath) Reads the YAML stream from a file instead of a string. Bless(perl-node, [yaml-node | class-name]) Associate a normal Perl node, with a yaml node. A yaml node is an object tied to the YAML::Node class. The second argument is either a yaml node that you've already created or a class (package) name that supports a yaml_dump() function. A yaml_dump() function should take a perl node and return a yaml node. If no second argument is provided, Bless will create a yaml node. This node is not returned, but can be retrieved with the Blessed() function. Here's an example of how to use Bless. Say you have a hash containing three keys, but you only want to dump two of them. Furthermore the keys must be dumped in a certain order. Here's how you do that: use YAML qw(Dump Bless); $hash = {apple => 'good', banana => 'bad', cauliflower => 'ugly'}; print Dump $hash; Bless($hash)->keys(['banana', 'apple']); print Dump $hash; produces: --- apple: good banana: bad cauliflower: ugly --- banana: bad apple: good Bless returns the tied part of a yaml-node, so that you can call the YAML::Node methods. This is the same thing that YAML::Node::ynode() returns. So another way to do the above example is: use YAML qw(Dump Bless); use YAML::Node; $hash = {apple => 'good', banana => 'bad', cauliflower => 'ugly'}; print Dump $hash; Bless($hash); $ynode = ynode(Blessed($hash)); $ynode->keys(['banana', 'apple']); print Dump $hash; Note that Blessing a Perl data structure does not change it anyway. The extra information is stored separately and looked up by the Blessed node's memory address. Blessed(perl-node) Returns the yaml node that a particular perl node is associated with (see above). Returns undef if the node is not (YAML) Blessed. GLOBAL OPTIONS YAML options are set using a group of global variables in the YAML namespace. This is similar to how Data::Dumper works. For example, to change the indentation width, do something like: local $YAML::Indent = 3; The current options are: DumperClass You can override which module/class YAML uses for Dumping data. LoaderClass You can override which module/class YAML uses for Loading data. Indent This is the number of space characters to use for each indentation level when doing a Dump(). The default is 2. By the way, YAML can use any number of characters for indentation at any level. So if you are editing YAML by hand feel free to do it anyway that looks pleasing to you; just be consistent for a given level. SortKeys Default is 1. (true) Tells YAML.pm whether or not to sort hash keys when storing a document. YAML::Node objects can have their own sort order, which is usually what you want. To override the YAML::Node order and sort the keys anyway, set SortKeys to 2. Stringify Default is 0. (false) Objects with string overloading should honor the overloading and dump the stringification of themselves, rather than the actual object's guts. UseHeader Default is 1. (true) This tells YAML.pm whether to use a separator string for a Dump operation. This only applies to the first document in a stream. Subsequent documents must have a YAML header by definition. UseVersion Default is 0. (false) Tells YAML.pm whether to include the YAML version on the separator/header. --- %YAML:1.0 AnchorPrefix Default is ''. Anchor names are normally numeric. YAML.pm simply starts with '1' and increases by one for each new anchor. This option allows you to specify a string to be prepended to each anchor number. UseCode Setting the UseCode option is a shortcut to set both the DumpCode and LoadCode options at once. Setting UseCode to '1' tells YAML.pm to dump Perl code references as Perl (using B::Deparse) and to load them back into memory using eval(). The reason this has to be an option is that using eval() to parse untrusted code is, well, untrustworthy. DumpCode Determines if and how YAML.pm should serialize Perl code references. By default YAML.pm will dump code references as dummy placeholders (much like Data::Dumper). If DumpCode is set to '1' or 'deparse', code references will be dumped as actual Perl code. DumpCode can also be set to a subroutine reference so that you can write your own serializing routine. YAML.pm passes you the code ref. You pass back the serialization (as a string) and a format indicator. The format indicator is a simple string like: 'deparse' or 'bytecode'. LoadCode LoadCode is the opposite of DumpCode. It tells YAML if and how to deserialize code references. When set to '1' or 'deparse' it will use "eval()". Since this is potentially risky, only use this option if you know where your YAML has been. LoadCode can also be set to a subroutine reference so that you can write your own deserializing routine. YAML.pm passes the serialization (as a string) and a format indicator. You pass back the code reference. UseBlock YAML.pm uses heuristics to guess which scalar style is best for a given node. Sometimes you'll want all multiline scalars to use the 'block' style. If so, set this option to 1. NOTE: YAML's block style is akin to Perl's here-document. UseFold If you want to force YAML to use the 'folded' style for all multiline scalars, then set $UseFold to 1. NOTE: YAML's folded style is akin to the way HTML folds text, except smarter. UseAliases YAML has an alias mechanism such that any given structure in memory gets serialized once. Any other references to that structure are serialized only as alias markers. This is how YAML can serialize duplicate and recursive structures. Sometimes, when you KNOW that your data is nonrecursive in nature, you may want to serialize such that every node is expressed in full. (ie as a copy of the original). Setting $YAML::UseAliases to 0 will allow you to do this. This also may result in faster processing because the lookup overhead is by bypassed. THIS OPTION CAN BE DANGEROUS. *If* your data is recursive, this option *will* cause Dump() to run in an endless loop, chewing up your computers memory. You have been warned. CompressSeries Default is 1. Compresses the formatting of arrays of hashes: - foo: bar - bar: foo becomes: - foo: bar - bar: foo Since this output is usually more desirable, this option is turned on by default. YAML TERMINOLOGY YAML is a full featured data serialization language, and thus has its own terminology. It is important to remember that although YAML is heavily influenced by Perl and Python, it is a language in its own right, not merely just a representation of Perl structures. YAML has three constructs that are conspicuously similar to Perl's hash, array, and scalar. They are called mapping, sequence, and string respectively. By default, they do what you would expect. But each instance may have an explicit or implicit tag (type) that makes it behave differently. In this manner, YAML can be extended to represent Perl's Glob or Python's tuple, or Ruby's Bigint. stream A YAML stream is the full sequence of unicode characters that a YAML parser would read or a YAML emitter would write. A stream may contain one or more YAML documents separated by YAML headers. --- a: mapping foo: bar --- - a - sequence document A YAML document is an independent data structure representation within a stream. It is a top level node. Each document in a YAML stream must begin with a YAML header line. Actually the header is optional on the first document. --- This: top level mapping is: - a - YAML - document header A YAML header is a line that begins a YAML document. It consists of three dashes, possibly followed by more info. Another purpose of the header line is that it serves as a place to put top level tag and anchor information. --- !recursive-sequence &001 - * 001 - * 001 node A YAML node is the representation of a particular data stucture. Nodes may contain other nodes. (In Perl terms, nodes are like scalars. Strings, arrayrefs and hashrefs. But this refers to the serialized format, not the in-memory structure.) tag This is similar to a type. It indicates how a particular YAML node serialization should be transferred into or out of memory. For instance a Foo::Bar object would use the tag 'perl/Foo::Bar': - !perl/Foo::Bar foo: 42 bar: stool collection A collection is the generic term for a YAML data grouping. YAML has two types of collections: mappings and sequences. (Similar to hashes and arrays) mapping A mapping is a YAML collection defined by unordered key/value pairs with unique keys. By default YAML mappings are loaded into Perl hashes. a mapping: foo: bar two: times two is 4 sequence A sequence is a YAML collection defined by an ordered list of elements. By default YAML sequences are loaded into Perl arrays. a sequence: - one bourbon - one scotch - one beer scalar A scalar is a YAML node that is a single value. By default YAML scalars are loaded into Perl scalars. a scalar key: a scalar value YAML has many styles for representing scalars. This is important because varying data will have varying formatting requirements to retain the optimum human readability. plain scalar A plain scalar is unquoted. All plain scalars are automatic candidates for "implicit tagging". This means that their tag may be determined automatically by examination. The typical uses for this are plain alpha strings, integers, real numbers, dates, times and currency. - a plain string - -42 - 3.1415 - 12:34 - 123 this is an error single quoted scalar This is similar to Perl's use of single quotes. It means no escaping except for single quotes which are escaped by using two adjacent single quotes. - 'When I say ''\n'' I mean "backslash en"' double quoted scalar This is similar to Perl's use of double quotes. Character escaping can be used. - "This scalar\nhas two lines, and a bell -->\a" folded scalar This is a multiline scalar which begins on the next line. It is indicated by a single right angle bracket. It is unescaped like the single quoted scalar. Line folding is also performed. - > This is a multiline scalar which begins on the next line. It is indicated by a single carat. It is unescaped like the single quoted scalar. Line folding is also performed. block scalar This final multiline form is akin to Perl's here-document except that (as in all YAML data) scope is indicated by indentation. Therefore, no ending marker is required. The data is verbatim. No line folding. - | QTY DESC PRICE TOTAL --- ---- ----- ----- 1 Foo Fighters $19.95 $19.95 2 Bar Belles $29.95 $59.90 parser A YAML processor has four stages: parse, load, dump, emit. A parser parses a YAML stream. YAML.pm's Load() function contains a parser. loader The other half of the Load() function is a loader. This takes the information from the parser and loads it into a Perl data structure. dumper The Dump() function consists of a dumper and an emitter. The dumper walks through each Perl data structure and gives info to the emitter. emitter The emitter takes info from the dumper and turns it into a YAML stream. NOTE: In YAML.pm the parser/loader and the dumper/emitter code are currently very closely tied together. In the future they may be broken into separate stages. For more information please refer to the immensely helpful YAML specification available at . ysh - The YAML Shell The YAML distribution ships with a script called 'ysh', the YAML shell. ysh provides a simple, interactive way to play with YAML. If you type in Perl code, it displays the result in YAML. If you type in YAML it turns it into Perl code. To run ysh, (assuming you installed it along with YAML.pm) simply type: ysh [options] Please read the "ysh" documentation for the full details. There are lots of options. BUGS & DEFICIENCIES If you find a bug in YAML, please try to recreate it in the YAML Shell with logging turned on ('ysh -L'). When you have successfully reproduced the bug, please mail the LOG file to the author (ingy@cpan.org). WARNING: This is still *ALPHA* code. Well, most of this code has been around for years... BIGGER WARNING: YAML.pm has been slow in the making, but I am committed to having top notch YAML tools in the Perl world. The YAML team is close to finalizing the YAML 1.1 spec. This version of YAML.pm is based off of a very old pre 1.0 spec. In actuality there isn't a ton of difference, and this YAML.pm is still fairly useful. Things will get much better in the future. RESOURCES is the mailing list. This is where the language is discussed and designed. is the official YAML website. is the YAML 1.0 specification. is the official YAML wiki. SEE ALSO See YAML::XS. Fast! AUTHOR Ingy döt Net is resonsible for YAML.pm. The YAML serialization language is the result of years of collaboration between Oren Ben-Kiki, Clark Evans and Ingy döt Net. Several others have added help along the way. COPYRIGHT Copyright (c) 2005, 2006, 2008, 2011-2012. Ingy döt Net. Copyright (c) 2001, 2002, 2005. Brian Ingerson. Some parts copyright (c) 2009 - 2010 Adam Kennedy This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See YAML-0.84/t/0000755000372100001440000000000012000063203012210 5ustar matthewtusersYAML-0.84/t/dump-perl-types-514.t0000644000372100001440000000072511715272433016002 0ustar matthewtusersuse Test::More; BEGIN { unless ( qr/x/ =~ /\(\?\^/ ){ plan skip_all => "test only for perls v5.13.5-11-gfb85c04 or later"; } } use t::TestYAML tests => 2; filters { perl => ['eval', 'yaml_dump'] }; no_diff; run_is ( perl => 'yaml' ); __DATA__ === Regular Expression +++ perl: qr{perfect match}; +++ yaml --- !!perl/regexp (?^:perfect match) === Regular Expression with newline +++ perl qr{perfect match}x; +++ yaml --- !!perl/regexp "(?^x:perfect\nmatch)" YAML-0.84/t/dump-blessed.t0000644000372100001440000000131011715272433014777 0ustar matthewtusersuse t::TestYAML tests => 2; package Foo::Bar; use t::Base; our @ISA = 't::Base'; sub yaml_dump { my $self = shift; my $node = YAML::Node->new({ two => $self->{two} - 1, one => $self->{one} + 1, }, 'perl/Foo::Bar'); YAML::Node::ynode($node)->keys(['two', 'one']); return $node; } sub yaml_load { my $class = shift; my $node = shift; my $self = $class->new; $self->{one} = ($node->{one} - 1); $self->{two} = ($node->{two} + 1); return $self; } package main; no_diff; run_roundtrip_nyn; __END__ === Object class handles marshalling +++ perl my $fb = Foo::Bar->new(); $fb->{one} = 5; $fb->{two} = 3; $fb; +++ yaml --- !perl/Foo::Bar two: 2 one: 6 YAML-0.84/t/dump-works.t0000644000372100001440000000023511715272433014530 0ustar matthewtusersuse t::TestYAML; run_is; sub yaml_dump { return Dump(@_); } __DATA__ === A one key hash +++ perl eval yaml_dump +{foo => 'bar'} +++ yaml --- foo: bar YAML-0.84/t/load-spec.t0000644000372100001440000002776011715272433014303 0ustar matthewtusersuse t::TestYAML tests => 52; run_load_passes(); __DATA__ === +++ yaml - Mark McGwire - Sammy Sosa - Ken Griffey === +++ yaml hr: 65 avg: 0.278 rbi: 147 === +++ yaml american: - Boston Red Sox - Detroit Tigers - New York Yankees - Texas Rangers national: - New York Mets - Chicago Cubs - Atlanta Braves - Montreal Expos === +++ yaml - name: Mark McGwire hr: 65 avg: 0.278 rbi: 147 - name: Sammy Sosa hr: 63 avg: 0.288 rbi: 141 === +++ yaml ? - New York Yankees - Atlanta Braves : - 2001-07-02 - 2001-08-12 - 2001-08-14 ? - Detroit Tigers - Chicago Cubs : - 2001-07-23 === +++ yaml invoice: 34843 date : 2001-01-23 bill-to: given : Chris family : Dumars product: - quantity: 4 desc : Basketball - quantity: 1 desc : Super Hoop === +++ yaml --- name: Mark McGwire hr: 65 avg: 0.278 rbi: 147 --- name: Sammy Sosa hr: 63 avg: 0.288 rbi: 141 === +++ yaml # Ranking of players by # season home runs. --- - Mark McGwire - Sammy Sosa - Ken Griffey === +++ yaml #hr: # Home runs # # 1998 record # - Mark McGwire # - Sammy Sosa #rbi: # Runs batted in # - Sammy Sosa # - Ken Griffey === +++ yaml hr: - Mark McGwire # Name "Sammy Sosa" scalar SS - &SS Sammy Sosa rbi: # So it can be referenced later. - *SS - Ken Griffey === +++ yaml --- > Mark McGwire's year was crippled by a knee injury. === +++ yaml --- | \/|\/| / | |_ === +++ yaml --- >- Sosa completed another fine season. === +++ yaml #name: Mark McGwire #occupation: baseball player #comments: Mark set a major # league home run # record in 1998. === +++ yaml years: "1998\t1999\t2000\n" msg: "Sosa did fine. \u263A" === +++ yaml - ' \/|\/| ' - ' / | |_ ' === +++ yaml - [ name , hr , avg ] - [ Mark McGwire , 65 , 0.278 ] - [ Sammy Sosa , 63 , 0.288 ] === +++ yaml #Mark McGwire: {hr: 65, avg: 0.278} #Sammy Sosa: {hr: 63, # avg: 0.288} === +++ yaml invoice: 34843 date : 2001-01-23 buyer: given : Chris family : Dumars product: - Basketball: 4 - Superhoop: 1 === +++ yaml #invoice: !int|dec 34843 #date : !time 2001-01-23 #buyer: !map # given : !str Chris # family : !str Dumars #product: !seq # - !str Basketball: !int 4 # - !str Superhoop: !int 1 === +++ yaml #invoice: !str 34843 #date : !str 2001-01-23 === +++ yaml #--- !clarkevans.com/schedule/^entry #who: Clark C. Evans #when: 2001-11-18 #hours: !^hours 3 #description: > # Wrote up these examples # and learned a lot about # baseball statistics. === +++ yaml #--- !clarkevans.com/graph/^shape #- !^circle # center: &ORIGIN {x: 73, y: 129} # radius: 7 #- !^line [23, 32, 300, 200] #- !^text # center: *ORIGIN # color: 0x02FDBA === +++ yaml --- !clarkevans.com/^invoice invoice: 34843 date : 2001-01-23 bill-to: &id001 given : Chris family : Dumars address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 ship-to: *id001 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: > Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. === +++ yaml --- Date: 2001-11-23 Time: 15:01:42 User: ed Warning: > This is an error message for the log file --- Date: 2001-11-23 Time: 15:02:31 User: ed Warning: > A slightly different error message. --- Date: 2001-11-23 Time: 15:03:17 User: ed Fatal: > Unknown variable "bar" Stack: - file: TopClass.py line: 23 code: | x = MoreObject("345\n") - file: MoreClass.py line: 58 code: | foo = bar === +++ yaml ################################### ## These are four throwaway comment # ## lines (the second line is empty). #this: | # Comments may trail lines. # contains three lines of text. # The third one starts with a # # character. This isn't a comment. # ## These are four throwaway comment ## lines (the first line is empty). ################################### === +++ yaml --- > This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end. === +++ yaml --- at: 2001-08-12T09:25:00.00 type: GET HTTP: '1.0' url: '/index.html' --- at: 2001-08-12T09:25:10.00 type: GET HTTP: '1.0' url: '/toc.html' === +++ yaml ## The following is a sequence of three documents. ## The first contains an empty mapping, the second ## an empty sequence, and the last an empty string. #--- {} #--- [ ] #--- '' === +++ yaml ## All entries in the sequence ## have the same type and value. #- 10.0 #- !float 10 #- !yaml.org/^float '10' #- !http://yaml.org/float "\ # 1\ # 0" === +++ yaml ## Private types are per-document. #--- #pool: !!ball # number: 8 # color: black #--- #bearing: !!ball # material: steel === +++ yaml ## 'http://domain.tld/invoice' is some type family. #invoice: !domain.tld/^invoice # # 'seq' is shorthand for 'http://yaml.org/seq'. # # This does not effect '^customer' below # # because it is does not specify a prefix. # customers: !seq # # '^customer' is shorthand for the full # # notation 'http://domain.tld/customer'. # - !^customer # given : Chris # family : Dumars === +++ yaml ## It is possible to use XML namespace URIs as ## YAML namespaces. Using the ancestor's URI ## allows specifying it only once. The $ separates ## between the XML namespace URI and the tag name. #doc: !http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd$^html # - !^body # - !^p This is an HTML paragraph. === +++ yaml anchor : &A001 This scalar has an anchor. override : &A001 > The alias node below is a repeated use of this value. alias : *A001 === +++ yaml #empty: [] #in-line: [ one, two, three # May span lines, # , four, # indentation is # five ] # mostly ignored. #nested: # - First item in top sequence # - # - Subordinate sequence entry # - > # A multi-line # sequence entry # - Sixth item in top sequence === +++ yaml #empty: {} #in-line: { one: 1, two: 2 } #spanning: { one: 1, # two: 2 } #nested: # first : First entry # second: # key: Subordinate mapping # third: # - Subordinate sequence # - { } # - Previous mapping is empty. # - A key: value pair in a sequence. # A second: key:value pair. # - The previous entry is equal to the following one. # - # A key: value pair in a sequence. # A second: key:value pair. # !float 12 : This key is a float. # ? > # ? # : This key had to be protected. # "\a" : This key had to be escaped. # ? > # This is a # multi-line # folded key # : Whose value is # also multi-line. # ? # - This key # - is a sequence # : # - With a sequence value. # ? # This: key # is a: mapping # : # with a: mapping value. === +++ yaml empty: | detected: | The \ ' " characters may be freely used. Leading white space is significant. All line breaks are significant, including the final one. Thus this value contains one empty line and ends with a line break, but does not start with one. # Comments may follow a nested # scalar value. They must be # less indented. # Explicit indentation must # be given in all the three # following cases. leading spaces: |2 This value starts with four spaces. It ends with one line break and an empty comment line. leading line break: |2 This value starts with a line break and ends with one. leading comment indicator: |2 # first line starts with a #. This value does not start with a line break but ends with one. # Explicit indentation may # also be given when it is # not required. redundant: |2 This value is indented 2 spaces. stripped: |- This contains no newline. kept: |+ This contains two newlines. # Comments may follow. === +++ yaml #empty: > #detected: > # Line feeds are converted # to spaces, so this value # contains no line breaks # except for the final one. # #explicit: >2 # # An empty line, either # at the start or in # the value: # # Is interpreted as a # line break. Thus this # value contains three # line breaks. # #stripped: >-1 # This starts with a space # and contains no newline. # #kept: >1+ # This starts with a space # and contains two newlines. # #indented: > # This is a folded # paragraph followed # by a list: # * first entry # * second entry # Followed by another # folded paragraph, # another list: # # * first entry # # * second entry # # And a final folded # paragraph. #block: | # Equal to above. # This is a folded paragraph followed by a list: # * first entry # * second entry # Followed by another folded paragraph and list: # # * first entry # # * second entry # # And a final folded paragraph. # ## Explicit comments may follow ## but must be less indented. === +++ yaml #empty: '' #second: '! : \ etc. can be used freely.' #third: 'a single quote '' must be escaped.' #span: 'this contains # six spaces # # and one # line break' === +++ yaml #empty: "" #second: "! : etc. can be used freely." #third: "a \" or a \\ must be escaped." #fourth: "this value ends with an LF.\n" #span: "this contains # four \ # spaces" === +++ yaml #first: There is no unquoted empty string. #second: 12 ## This is an integer. #third: !str 12 ## This is a string. #span: this contains # six spaces # # and one # line break #indicators: this has no comments. # #foo and bar# are # all text. #in-line: [ can span # lines, # comment # like # this ] #note: { one-line keys: but # multi-line values } === +++ yaml ## The following are equal seqs ## with different identities. #in-line: [ one, two ] #spanning: [ one, # two: ] #nested: # - one # - two === +++ yaml # The following are equal maps # with different identities. in-line: { one: 1, two: 2 } nested: one: 1 two: 2 === +++ yaml #- 12 # An integer ## The following scalars ## are loaded to the ## string value '1' '2'. #- !str 12 #- '12' #- "12" #- "\ # 1\ # 2\ # " === +++ yaml #canonical: ~ #verbose: (null) #sparse: # - ~ # - Second entry. # - (nil) # - This sequence has 4 entries, two with values. #three: > # This mapping has three keys, # only two with values. === +++ yaml #canonical: - #logical: (true) #informal: (no) === +++ yaml #canonical: 12345 #decimal: +12,345 #octal: 014 #hexadecimal: 0xC === +++ yaml #canonical: 1.23015e+3 #exponential: 12.3015e+02 #fixed: 1,230.15 #negative infinity: (-inf) #not a number: (NaN) === +++ yaml canonical: 2001-12-15T02:59:43.1Z valid iso8601: 2001-12-14t21:59:43.10-05:00 space separated: 2001-12-14 21:59:43.10 -05:00 date (noon UTC): 2002-12-14 === +++ yaml #canonical: !binary "\ # R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf\ # n515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaW\ # NjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++\ # f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUg\ # d2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuN\ # AFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84Bww\ # EeECcgggoBADs=" #base64: !binary | # R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf # n515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaW # NjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++ # f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUg # d2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuN # AFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84Bww # EeECcgggoBADs= #description: > # The binary value above is a tiny arrow # encoded as a gif image. === +++ yaml ## Old schema #--- #link with: # - library1.dll # - library2.dll # ## New schema #--- #link with: # - = : library1.dll # version: 1.2 # - = : library2.dll # version: 2.1 === +++ yaml #"!": These three keys #"&": had to be quoted #"=": and are normal strings. ## NOTE: the following encoded node ## should NOT be serialized this way. #encoded node : # !special '!' : '!type' # !special '&' : 12 # = : value ## The proper way to serialize the ## above structure is as follows: #node : !!type &12 value YAML-0.84/t/svk-config.yaml0000644000372100001440000002360311715272433015171 0ustar matthewtusers--- checkout: !perl/Data::Hierarchy hash: /home/jesse/README: depotpath: //local/rt-3.4/README encoding: ascii revision: 17371 /home/jesse/foo: depotpath: //local/foo encoding: ascii revision: 19501 /home/jesse/svk/1.0-releng: depotpath: //mirror/svk/branches/1.0-releng/ encoding: ascii revision: 20905 /home/jesse/svk/Acme-Net-OdiousPlan: depotpath: //mirror//bps-public/Acme-Net-OdiousPlan/ encoding: ascii revision: 13820 /home/jesse/svk/Business-Hours: depotpath: //local/Business-Hours encoding: iso-8859-1 revision: 17426 /home/jesse/svk/DBIx-DBSchema: depotpath: //local/DBIx-DBSchema encoding: utf-8-strict revision: 19508 /home/jesse/svk/DBIx-SearchBuilder: depotpath: //local/DBIx-SearchBuilder/ encoding: iso-8859-1 revision: 21870 /home/jesse/svk/Data-ICal: depotpath: //local/Data-ICal encoding: iso-8859-1 revision: 17222 /home/jesse/svk/Devel-ebug: depotpath: //local/Devel-ebug/ encoding: ascii revision: 15097 /home/jesse/svk/Devel-ebug-HTTP: depotpath: //local/Devel-ebug-HTTP/ encoding: ascii revision: 15099 /home/jesse/svk/HTTP-Server-Simple: depotpath: //local/HTTP-Server-Simple/ encoding: iso-8859-1 revision: 18459 /home/jesse/svk/HTTP-Server-Simple-Mason: depotpath: //local/HTTP-Server-Simple-Mason/ encoding: ascii revision: 13726 /home/jesse/svk/HTTP-Server-Simple-Recorder: depotpath: //local/HTTP-Server-Simple-Recorder encoding: ascii revision: 13245 /home/jesse/svk/Module-Install-RTx: depotpath: //local/Module-Install-RTx/ encoding: ascii revision: 19842 /home/jesse/svk/Module-Refresh: depotpath: //local/Module-Refresh encoding: iso-8859-1 revision: 20956 /home/jesse/svk/RT-Extension-ActivityReports: depotpath: //local/RT-Extension-ActivityReports/ encoding: ascii revision: 22084 /home/jesse/svk/RT-Extension-MergeUsers: depotpath: //local/RT-Extension-MergeUsers/ encoding: ascii revision: 18043 /home/jesse/svk/RT-Extension-Redacted: depotpath: //local/RT-Extension-Redacted/ encoding: ascii revision: 20453 /home/jesse/svk/RT-Integration-SVN: depotpath: //local/RT-Integration-SVN/ encoding: iso-8859-1 revision: 4915 /home/jesse/svk/RT-KeyBindings: depotpath: //local/RT-KeyBindings encoding: ascii revision: 15495 /home/jesse/svk/RT-OnlineDocs: depotpath: //local/RT-OnlineDocs/ encoding: ascii revision: 20473 /home/jesse/svk/RT-TicketWhiteboard: depotpath: //local/RT-TicketWhiteboard/ encoding: utf-8-strict revision: 20454 /home/jesse/svk/RT-Todo: depotpath: //local/RT-Todo encoding: iso-8859-1 revision: 7320 /home/jesse/svk/RT-View-Directory: depotpath: //local/RT-View-Directory/ encoding: ascii revision: 20455 /home/jesse/svk/RT-View-Tree: depotpath: //local/RT-View-Tree/ encoding: iso-8859-1 revision: 4918 /home/jesse/svk/Test-HTTP-Server-Simple: depotpath: //mirror/bps-public/Test-HTTP-Server-Simple/ encoding: ascii revision: 7358 /home/jesse/svk/WWW-Mechanize-FromRecording: depotpath: //mirror/bps-public/WWW-Mechanize-FromRecording/ encoding: ascii revision: 15347 /home/jesse/svk/chaldea: depotpath: //local/chaldea encoding: ascii revision: 19696 /home/jesse/svk/chaldea/html/Ticket/ModifyAll.html: revision: 19797 /home/jesse/svk/clkao: depotpath: //local/clkao encoding: ascii revision: 15496 /home/jesse/svk/customers: depotpath: //local/customers encoding: ascii revision: 20447 /home/jesse/svk/hiveminder-trunk: depotpath: //local/hiveminder-trunk/ encoding: ascii revision: 21802 /home/jesse/svk/jifty.org: depotpath: //local/jifty.org encoding: ascii revision: 22079 /home/jesse/svk/logo: depotpath: //mirror/bps-private/docs/logo encoding: ascii revision: 7032 /home/jesse/svk/modinstal: depotpath: //local/modinstal encoding: ascii revision: 20926 /home/jesse/svk/people: depotpath: //local/people encoding: ascii revision: 7029 /home/jesse/svk/people/kevinr: revision: 7633 /home/jesse/svk/perl6-doc: depotpath: //local/perl6-doc/ encoding: iso-8859-1 revision: 17030 /home/jesse/svk/personal: depotpath: //local/personal encoding: ascii revision: 13817 /home/jesse/svk/planetsix: depotpath: //local/planetsix encoding: ascii revision: 21020 /home/jesse/svk/private-docs: depotpath: //local/private-docs encoding: ascii revision: 18093 /home/jesse/svk/quebec: depotpath: //local/quebec encoding: ascii revision: 19693 /home/jesse/svk/rt-3.0: depotpath: //local/rt-3.0 encoding: iso-8859-1 revision: 18019 /home/jesse/svk/rt-3.2: depotpath: //local/rt-3.2 encoding: iso-8859-1 revision: 17458 /home/jesse/svk/rt-3.4: depotpath: //local/rt-3.4 encoding: iso-8859-1 revision: 20436 /home/jesse/svk/rt-3.5: depotpath: //local/rt-3.5 encoding: iso-8859-1 revision: 20493 /home/jesse/svk/rt-book: depotpath: //local/rt-book/ encoding: ascii revision: 4893 /home/jesse/svk/rt.cpan.org: depotpath: //local/rt.cpan.org encoding: ascii revision: 17911 /home/jesse/svk/rtfm-2.0: depotpath: //local/rtfm-2.0 encoding: ascii revision: 16160 /home/jesse/svk/rtfm-2.1: depotpath: //local/rtfm-2.1 encoding: ascii revision: 19705 /home/jesse/svk/rtir-1.0: depotpath: //local/rtir-1.0 encoding: iso-8859-1 revision: 17456 /home/jesse/svk/svk-trunk: depotpath: //local/svk-trunk encoding: ascii revision: 21697 /home/jesse/svk/svkbook: depotpath: //local/svkbook-trunk encoding: ascii revision: 18587 /home/jesse/svk/training: depotpath: //local/training encoding: ascii revision: 22081 /home/jesse/svk/trunk: depotpath: //local/svk/trunk encoding: ascii revision: 0 /tmp/3.5-TESTING: depotpath: //mirror/bps-public/rt/branches/3.5-TESTING/ encoding: ascii revision: 19687 /tmp/gtd: depotpath: //local/gtd encoding: ascii revision: 0 /tmp/hm/hiveminder-trunk: depotpath: //local/hiveminder-trunk encoding: ascii revision: 15375 /tmp/svl-checkous/Acme-Colour: depotpath: //_default_/acme/Acme-Colour encoding: ascii revision: 7268 /tmp/svlco/Acme-Colour: depotpath: //_default_/acme/Acme-Colour encoding: ascii revision: 7268 /tmp/trunk: depotpath: //mirror/bps-private/hiveminder/trunk encoding: utf-8-strict revision: 19754 sep: / sticky: /home/jesse/svk/1.0-releng/lib/SVK/Target.pm: .newprop: {} /home/jesse/svk/hiveminder-trunk/Jifty: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/Makefile: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/Makefile.old: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/blib: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/doc: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/doc/session: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/inc: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/jifty: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/lib: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty/DefaultApp: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty/Manual: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty/Manual/ObjectModel.pod: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/pm_to_blib: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/Makefile.old: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/continuations: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/continuationstest: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/inc: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Mapper: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Mapper/mapper: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/Mapper/mappertest: .conflict: 1 /home/jesse/svk/hiveminder-trunk/Jifty/t/utils.pl: .conflict: 1 /home/jesse/svk/jifty.org: .newprop: svk:merge: e84bef0a-9b06-0410-84ba-c4c9edb13aeb:/:428 .schedule: prop /home/jesse/svk/rt.cpan.org/rt2-existing/local/WebRT/html/NoAuth/bugs.tsv: .newprop: svn:executable: '*' .schedule: add /home/jesse/svk/training: .newprop: svk:merge: |- 6641d27c-1bcc-0310-8a77-bef5c512aa61:/training:1585 a51291e0-c2ea-0310-847b-fbb8d8170edb:/local/training:5752 .schedule: prop /home/jesse/svk/training/developer_training: .newprop: svk:merge: |- 5f29b386-91d9-0310-ba9f-d3bca794479a:/rttraining/local:1354 5f29b386-91d9-0310-ba9f-d3bca794479a:/rttraining/local-merge-9322:1032 5f88e03f-dcfa-0310-a525-a1f853655784:/rt-developer-training:1586 8d5e1d6e-e2eb-0310-9379-fb19c180b7be:/dev_training-local:1241 .schedule: prop depotmap: '': /home/jesse/.svk/local parrot: /home/jesse/.svk/parrot YAML-0.84/t/dump-nested.t0000644000372100001440000000751111715272433014651 0ustar matthewtusersuse t::TestYAML tests => 20; no_diff(); run_roundtrip_nyn(); __DATA__ === +++ perl ['foo ' x 20] +++ yaml --- - 'foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo ' === +++ perl [q{YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals:}] +++ yaml --- - 'YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals:' === +++ perl [q{It reads one character at a time, with the ability to push back any number of characters up to a maximum, and with nested mark() / reset() / unmark() functions. The input of the stream reader is any java.io.Reader. The output are characters. The parser (and event generator) The input of the parser are characters. These characters are directly fed into the functions that implement the different productions. The output of the parser are events, a well defined and small set of events.}] +++ yaml --- - |- It reads one character at a time, with the ability to push back any number of characters up to a maximum, and with nested mark() / reset() / unmark() functions. The input of the stream reader is any java.io.Reader. The output are characters. The parser (and event generator) The input of the parser are characters. These characters are directly fed into the functions that implement the different productions. The output of the parser are events, a well defined and small set of events. === +++ perl < 4; filters { yaml => [yaml => 'dumper'], perl => [strict => eval => 'dumper'], }; run_is yaml => 'perl'; __END__ === A simple map +++ yaml --- one: foo two: bar three: baz +++ perl +{qw(one foo two bar three baz)} === Common String Types +++ yaml --- one: simple string two: 42 three: '1 Single Quoted String' four: "YAML's Double Quoted String" five: | A block with several lines. six: |- A "chomped" block seven: > A folded string +++ perl { one => "simple string", two => '42', three => "1 Single Quoted String", four => "YAML's Double Quoted String", five => "A block\n with several\n lines.\n", six => 'A "chomped" block', seven => "A folded\n string\n", } === Multiple documents +++ yaml --- foo: bar --- bar: two +++ perl +{qw(foo bar)}, {qw(bar two)}; === Comments +++ yaml # Leading Comment --- # Preceding Comment foo: bar # Two # Comments --- # Indented comment bar: two bee: three # Intermediate comment bore: four +++ perl +{qw(foo bar)}, {qw(bar two bee three bore four)} YAML-0.84/t/test.t0000644000372100001440000000007711715272433013403 0ustar matthewtusersuse t::TestYAML tests => 1; pass('TestYAML framework loads'); YAML-0.84/t/load-tests.t0000644000372100001440000001440111715272433014477 0ustar matthewtusersuse t::TestYAML tests => 28; run { my $block = shift; my @result = eval { Load($block->yaml) }; my $error1 = $@ || ''; if ( $error1 ) { # $error1 =~ s{line: (\d+)}{"line: $1 ($0:".($1+$test->{lines}{yaml}-1).")"}e; } my @expect = eval $block->perl; my $error2 = $@ || ''; if (my $errors = $error1 . $error2) { fail($block->description . $errors); next; } is_deeply( \@result, \@expect, $block->description, ) or do { require Data::Dumper; diag("Wanted: ".Data::Dumper::Dumper(\@expect)); diag("Got: ".Data::Dumper::Dumper(\@result)); } }; __DATA__ === a yaml error log +++ yaml --- date: Sun Oct 28 20:41:17 2001 error msg: Premature end of script headers --- date: Sun Oct 28 20:41:44 2001 error msg: malformed header from script. Bad header= --- date: Sun Oct 28 20:42:19 2001 error msg: malformed header from script. Bad header= +++ perl my $a = { map {split /:\s*/, $_, 2} split /\n/, < END my $c = { map {split /:\s*/, $_, 2} split /\n/, < END ($a, $b, $c) === comments and some top level documents +++ yaml # Top level documents # # Note that inline (single line) values # are not allowed at the top level. This # includes implicit values, quoted values # and inline collections. --- a: map --- - a - sequence --- > plain scalar --- | This is a block. It's kinda like a here document. --- |- A chomped block. +++ perl my $a = {a => 'map'}; my $b = ['a', 'sequence']; my $c = "plain scalar\n"; my $d = < 'bar', baz => 'too'}; my $f = []; my $g = {}; my $h = {'09:00:00' => 'Breakfast', '12:00:00' => 'lunch time'}; my $i = bless {small => 'object'}, 'XYZ'; my $j = bless [bless([qw(a b c)], 'DEF'), bless({do => 're', mi => 'fa', so => 'la', ti => 'do'}, 'GHI'), ], 'ABC'; my $k = []; push @$k, $k, $k, $k; my $l = [{name => 'Ingy'}, {name => 'Clark'}, {name => 'Oren'}, ]; [$a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l] === a bunch of small top level thingies +++ yaml --- 42 --- foo --- " bar " --- [] --- #YAML:1.0 {} --- '#YAML:9.9' --- {foo: [1, 2, 3], 12:34:56: bar} +++ perl my $a = 42; my $b = "foo"; my $c = " bar "; my $d = []; my $e = {}; my $f = "#YAML:9.9"; my $g = {foo => [1, 2, 3], '12:34:56' => 'bar'}; ($a, $b, $c, $d, $e, $f, $g) === a headerless sequence and a map +++ yaml - 2 - 3 - 4 --- #YAML:1.0 foo: bar +++ perl ([2,3,4], {foo => 'bar'}) === comments in various places +++ yaml # A pre header comment --- # comment # comment #comment - 2 # comment # comment - 3 - 4 # comment - 5 # last comment --- #YAML:1.0 boo: far # a comment foo : bar --- - > # Not a comment; # Is a comment #Not a comment --- 42 #Final #Comment +++ perl ([2,3,4,5], {foo => 'bar', boo => 'far'}, ["# Not a comment; #Not a comment\n"], 42) === several docs, some empty +++ yaml --- - foo - bar --- --- - foo - foo --- # comment --- - bar - bar +++ perl (['foo', 'bar'],undef,['foo', 'foo'],undef,['bar', 'bar']) === a perl reference to a scalar +++ yaml --- !perl/ref: =: 42 +++ perl (\42); === date loading +++ yaml --- - 1964-03-25 - ! "1975-04-17" - !date '2001-09-11' - 12:34:00 - ! "12:00:00" - !time '01:23:45' +++ perl ['1964-03-25', '1975-04-17', '2001-09-11', '12:34:00', '12:00:00', '01:23:45', ]; === sequence with trailing comment +++ yaml --- - fee - fie - foe # no num defined +++ perl [qw(fee fie foe)] === a simple literal block +++ yaml --- - | foo bar +++ perl ["foo\nbar\n"] === an unchomped literal +++ yaml -trim --- - |+ foo bar +++ perl ["foo\nbar\n\n"] === a chomped literal +++ yaml -trim --- - |- foo bar +++ perl ["foo\nbar"] === assorted numerics +++ yaml --- #- - #- + - 44 - -45 - 4.6 - -4.7 - 3e+2 - [-4e+3, 5e-4] - -6e-10 - 2001-12-15 - 2001-12-15T02:59:43.1Z - 2001-12-14T21:59:43.25-05:00 +++ perl [44, -45, 4.6, -4.7, '3e+2', ['-4e+3', '5e-4'], '-6e-10', '2001-12-15', '2001-12-15T02:59:43.1Z', '2001-12-14T21:59:43.25-05:00', ] === an empty string top level doc +++ yaml --- +++ perl undef === an array of various undef +++ yaml --- - - - '' +++ perl [undef,undef,''] === !!perl/array +++ yaml --- !!perl/array - 1 +++ perl [ 1 ] === !!perl/array: +++ yaml --- !!perl/array: - 1 +++ perl [ 1 ] === !!perl/array:moose +++ yaml --- !!perl/array:moose - 1 +++ perl bless([ 1 ], "moose") === foo +++ yaml --- !!perl/hash foo: bar +++ perl { foo => "bar" } === foo +++ yaml --- !!perl/hash: foo: bar +++ perl { foo => "bar" } === foo +++ yaml --- !!perl/array:moose foo: bar +++ perl bless({ foo => "bar" }, "moose") === foo +++ yaml --- !!perl/ref =: 1 +++ perl \1 === foo +++ yaml --- !!perl/ref: =: 1 +++ perl \1 === foo +++ yaml --- !!perl/ref:moose =: 1 +++ perl bless(do { my $x = 1; \$x}, "moose") === foo +++ yaml --- !!perl/scalar 1 +++ perl 1 === foo +++ yaml --- !!perl/scalar: 1 +++ perl 1 === foo +++ yaml --- !!perl/scalar:moose 1 +++ perl bless(do { my $x = 1; \$x}, "moose") YAML-0.84/t/dump-perl-types.t0000644000372100001440000000471711777023401015475 0ustar matthewtusersuse t::TestYAML tests => 14; filters { perl => ['eval', 'yaml_dump'] }; use YAML (); # [CPAN #74687] must load before B::Deparse for B::Deparse < 0.71 use B::Deparse; if (new B::Deparse -> coderef2text ( sub { no strict; 1; use strict; 1; }) =~ 'refs') { local $/; (my $data = ) =~ s/use strict/use strict 'refs'/g; if ($B::Deparse::VERSION > 0.67 and $B::Deparse::VERSION < 0.71) { # [CPAN #73702] $data =~ s/use warnings;/BEGIN {\${^WARNING_BITS} = "UUUUUUUUUUUU\\001"}/g; } open DATA, '<', \$data; } no_diff; run_is perl => 'yaml'; __DATA__ === Scalar +++ perl: 'Hello' +++ yaml --- Hello === Hash +++ perl: +{bar => 'foo', foo => 'bar'} +++ yaml --- bar: foo foo: bar === Array +++ perl: [qw(W O W)] +++ yaml --- - W - O - W === Code +++ perl $YAML::DumpCode = 1; package main; sub { print "Hello, world\n"; } +++ yaml --- !!perl/code | { use warnings; use strict; print "Hello, world\n"; } === Scalar Reference +++ perl: \ 'Goodbye' +++ yaml --- !!perl/ref =: Goodbye === Scalar Glob +++ perl $::var = 'Hola'; *::var; +++ yaml --- !!perl/glob: PACKAGE: main NAME: var SCALAR: Hola === Array Glob +++ perl @::var2 = (qw(xxx yyy zzz)); *::var2; +++ yaml --- !!perl/glob: PACKAGE: main NAME: var2 ARRAY: - xxx - yyy - zzz === Code Glob +++ perl $YAML::DumpCode = 1; package main; sub main::var3 { print "Hello, world\n"; } *var3; +++ yaml --- !!perl/glob: PACKAGE: main NAME: var3 CODE: !!perl/code | { use warnings; use strict; print "Hello, world\n"; } === Blessed Empty Hash +++ perl: bless {}, 'A::B::C'; +++ yaml --- !!perl/hash:A::B::C {} === Blessed Populated Hash +++ perl: bless {qw(foo bar bar foo)}, 'A::B::C'; +++ yaml --- !!perl/hash:A::B::C bar: foo foo: bar === Blessed Empty Array +++ perl: bless [], 'A::B::C'; +++ yaml --- !!perl/array:A::B::C [] === Blessed Populated Array +++ perl: bless [qw(foo bar bar foo)], 'A::B::C'; +++ yaml --- !!perl/array:A::B::C - foo - bar - bar - foo === Blessed Empty String +++ perl: my $e = ''; bless \ $e, 'A::B::C'; +++ yaml --- !!perl/scalar:A::B::C '' === Blessed Populated String +++ perl: my $fbbf = 'foo bar bar foo'; bless \ $fbbf, 'A::B::C'; +++ yaml --- !!perl/scalar:A::B::C foo bar bar foo === Blessed Regular Expression +++ SKIP +++ perl: bless qr{perfect match}, 'A::B::C'; +++ yaml --- !!perl/regexp:A::B::C perfect match === Blessed Glob +++ SKIP +++ perl: $::x = 42; bless \ *::x, 'A::B::C'; +++ yaml --- !!perl/glob:A::B::C PACKAGE: main NAME: x SCALAR: 42 YAML-0.84/t/dump-stringify.t0000644000372100001440000000173611715272433015410 0ustar matthewtusersuse t::TestYAML tests => 6; no_diff; package Foo; use overload '""' => \&stringy; sub stringy { 'Hello mate!' } sub new { bless { 'Hello' => 'mate!' }, shift }; package main; my $foo = Foo->new; my $stringy_dump = <<''; --- Hello mate! my $object_dump = <<''; --- !!perl/hash:Foo Hello: mate! my $yaml; $yaml = Dump($foo); is $yaml, $object_dump, "Global stringification default dump"; $YAML::Stringify = 1; $yaml = Dump($foo); is $yaml, $stringy_dump, "Global stringification enabled dump"; $YAML::Stringify = 0; $yaml = Dump($foo); is $yaml, $object_dump, "Global stringification disabled dump"; require YAML::Dumper; my $dumper = YAML::Dumper->new; $yaml = $dumper->dump($foo); is $yaml, $object_dump, "Local stringification default dump"; $dumper->stringify(1); $yaml = $dumper->dump($foo); is $yaml, $stringy_dump, "Local stringification enabled dump"; $dumper->stringify(0); $yaml = $dumper->dump($foo); is $yaml, $object_dump, "Local stringification disabled dump"; YAML-0.84/t/export.t0000644000372100001440000000046111715272433013742 0ustar matthewtusersuse Test::YAML(); BEGIN { @Test::YAML::EXPORT = grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT; } use t::TestYAML tests => 3; use YAML; ok defined(&Dump), 'Dump() is exported'; ok defined(&Load), 'Load() is exported'; ok not(defined &Store), 'Store() is not exported'; YAML-0.84/t/svk.t0000644000372100001440000000077511715272433013234 0ustar matthewtusersuse t::TestYAML tests => 3; my $test_file = 't/svk-config.yaml'; my $node = LoadFile($test_file); is ref($node), 'HASH', "loaded svk file is a hash"; open IN, $test_file or die "Can't open $test_file for input: $!"; my $yaml_from_file = do {local $/; }; like $yaml_from_file, qr{^---\ncheckout: !perl/Data::Hierarchy\n}, "at least first two lines of file are right"; my $yaml_from_node = Dump($node); is Dump(Load($yaml_from_node)), Dump(Load($yaml_from_file)), "svk data roundtrips!";; YAML-0.84/t/dump-tests-514.t0000644000372100001440000000067411715272433015043 0ustar matthewtusersuse Test::More; BEGIN { unless ( qr/x/ =~ /\(\?\^/ ){ plan skip_all => "test only for perls v5.13.5-11-gfb85c04 or later"; } } use t::TestYAML tests => 1; no_diff(); run_roundtrip_nyn('dumper'); __DATA__ === +++ no_round_trip Since we don't use eval for regexp reconstitution any more (for safety sake) this test doesn't roundtrip even though the values are equivalent. +++ perl [qr{bozo$}i] +++ yaml --- - !!perl/regexp (?^i:bozo$) YAML-0.84/t/dump-tests.t0000644000372100001440000001246111715272433014531 0ustar matthewtusersuse t::TestYAML tests => 57; no_diff(); run_roundtrip_nyn('dumper'); __DATA__ === +++ perl [ "foo\nbar", "I like pie\nYou like pie\nWe all like pie" ] +++ yaml --- - "foo\nbar" - |- I like pie You like pie We all like pie === +++ perl {name => 'Ingy dot Net', rank => 'JAPH', 'serial number' => '8675309', }; +++ yaml --- name: Ingy dot Net rank: JAPH serial number: 8675309 === +++ perl {fruits => [qw(apples oranges pears)], meats => [qw(beef pork chicken)], vegetables => [qw(carrots peas corn)], } +++ yaml --- fruits: - apples - oranges - pears meats: - beef - pork - chicken vegetables: - carrots - peas - corn === +++ perl ['42', '43', '-44', '45'] +++ yaml --- - 42 - 43 - -44 - 45 === +++ perl [ 'foo bar', 'http://www.yaml.org', '12:34' ] +++ yaml --- - foo bar - http://www.yaml.org - 12:34 === +++ perl ('1', " foo ", "bar\n", [], {}) +++ yaml --- 1 --- ' foo ' --- "bar\n" --- [] --- {} === +++ perl '8\'-0" x 24" Lightweight' +++ yaml --- 8'-0" x 24" Lightweight === +++ perl bless {}, 'Foo::Bar' +++ yaml --- !!perl/hash:Foo::Bar {} === +++ perl bless {qw(foo 42 bar 43)}, 'Foo::Bar' +++ yaml --- !!perl/hash:Foo::Bar bar: 43 foo: 42 === +++ perl bless [], 'Foo::Bar' +++ yaml --- !!perl/array:Foo::Bar [] === +++ perl bless [map "$_",42..45], 'Foo::Bar' +++ yaml --- !!perl/array:Foo::Bar - 42 - 43 - 44 - 45 === +++ perl my $yn = YAML::Node->new({}, 'foo.com/bar'); $yn->{foo} = 'bar'; $yn->{bar} = 'baz'; $yn->{baz} = 'foo'; $yn +++ yaml --- !foo.com/bar foo: bar bar: baz baz: foo === +++ perl use YAML::Node; +++ no_round_trip +++ perl my $a = ''; bless \$a, 'Foo::Bark'; +++ yaml --- !!perl/scalar:Foo::Bark '' === Strings with nulls +++ perl "foo\0bar" +++ yaml --- "foo\0bar" === +++ no_round_trip XXX: probably a YAML.pm bug +++ perl &YAML::VALUE +++ yaml --- = === +++ perl my $ref = {foo => 'bar'}; [$ref, $ref] +++ yaml --- - &1 foo: bar - *1 === +++ perl no strict; package main; $joe_random_global = 42; @joe_random_global = (43, 44); *joe_random_global +++ yaml --- !!perl/glob: PACKAGE: main NAME: joe_random_global SCALAR: 42 ARRAY: - 43 - 44 === +++ perl no strict; package main; \*joe_random_global +++ yaml --- !!perl/ref =: !!perl/glob: PACKAGE: main NAME: joe_random_global SCALAR: 42 ARRAY: - 43 - 44 === +++ no_round_trip +++ perl my $foo = {qw(apple 1 banana 2 carrot 3 date 4)}; YAML::Bless($foo)->keys([qw(banana apple date)]); $foo +++ yaml --- banana: 2 apple: 1 date: 4 === +++ no_round_trip +++ perl use YAML::Node; my $foo = {qw(apple 1 banana 2 carrot 3 date 4)}; my $yn = YAML::Node->new($foo); YAML::Bless($foo, $yn)->keys([qw(apple)]); # red herring ynode($yn)->keys([qw(banana date)]); $foo +++ yaml --- banana: 2 date: 4 === +++ no_round_trip XXX: probably a test driver bug +++ perl my $joe_random_global = {qw(apple 1 banana 2 carrot 3 date 4)}; YAML::Bless($joe_random_global, 'TestBless'); return [$joe_random_global, $joe_random_global]; package TestBless; use YAML::Node; sub yaml_dump { my $yn = YAML::Node->new($_[0]); ynode($yn)->keys([qw(apple pear carrot)]); $yn->{pear} = $yn; return $yn; } +++ yaml --- - &1 apple: 1 pear: *1 carrot: 3 - *1 === +++ no_round_trip +++ perl use YAML::Node; my $joe_random_global = {qw(apple 1 banana 2 carrot 3 date 4)}; YAML::Bless($joe_random_global); my $yn = YAML::Blessed($joe_random_global); delete $yn->{banana}; $joe_random_global +++ yaml --- apple: 1 carrot: 3 date: 4 === +++ perl my $joe_random_global = \\\\\\\'42'; [ $joe_random_global, $$$$joe_random_global, $joe_random_global, $$$$$$$joe_random_global, $$$$$$$$joe_random_global ] +++ yaml --- - &1 !!perl/ref =: !!perl/ref =: !!perl/ref =: &2 !!perl/ref =: !!perl/ref =: !!perl/ref =: &3 !!perl/ref =: 42 - *2 - *1 - *3 - 42 === +++ perl local $YAML::Indent = 1; [{qw(foo 42 bar 44)}] +++ yaml --- - bar: 44 foo: 42 === +++ perl local $YAML::Indent = 4; [{qw(foo 42 bar 44)}] +++ yaml --- - bar: 44 foo: 42 === +++ perl [undef, undef] +++ yaml --- - ~ - ~ === +++ perl my $joe_random_global = []; push @$joe_random_global, $joe_random_global; bless $joe_random_global, 'XYZ'; $joe_random_global +++ yaml --- &1 !!perl/array:XYZ - *1 === +++ perl [ '23', '3.45', '123456789012345', ] +++ yaml --- - 23 - 3.45 - 123456789012345 === +++ perl {'foo: bar' => 'baz # boo', 'foo ' => ' monkey', } +++ yaml --- 'foo ': ' monkey' 'foo: bar': 'baz # boo' === +++ no_round_trip +++ perl $a = \\\\\\\\"foo"; $b = $$$$$a; ([$a, $b], [$b, $a]) +++ yaml --- - !!perl/ref =: !!perl/ref =: !!perl/ref =: !!perl/ref =: &1 !!perl/ref =: !!perl/ref =: !!perl/ref =: !!perl/ref =: foo - *1 --- - &1 !!perl/ref =: !!perl/ref =: !!perl/ref =: !!perl/ref =: foo - !!perl/ref =: !!perl/ref =: !!perl/ref =: !!perl/ref =: *1 === +++ no_round_trip XXX an AutoBless feature could make this rt +++ perl $a = YAML::Node->new({qw(a 1 b 2 c 3 d 4)}, 'ingy.com/foo'); YAML::Node::ynode($a)->keys([qw(d b a)]); $a; +++ yaml --- !ingy.com/foo d: 4 b: 2 a: 1 === +++ no_round_trip +++ perl $a = 'bitter buffalo'; bless \$a, 'Heart'; +++ yaml --- !!perl/scalar:Heart bitter buffalo === +++ perl { 'foo[bar]' => 'baz' } +++ yaml --- 'foo[bar]': baz YAML-0.84/t/marshall.t0000644000372100001440000000407311715272433014227 0ustar matthewtusersuse t::TestYAML tests => 10; use strict; use warnings; #------------------------------------------------------------------------------- package Foo::Bar; BEGIN { require t::Base; @Foo::Bar::ISA = 't::Base'; } use YAML::Marshall; sub yaml_dump { my $self = shift; my $array = []; for my $k (sort keys %$self) { push @$array, $k, $self->{$k}; } $self->yaml_node($array, 'perl/Foo::Bar'); } sub yaml_load { my $class = shift; my $node = shift; my $self = $class->new; %$self = @$node; return $self; } #------------------------------------------------------------------------------- package Bar::Baz; BEGIN { require t::Base; @Bar::Baz::ISA = 't::Base'; } use YAML::Marshall 'random/object:bar.baz'; #------------------------------------------------------------------------------- package Baz::Foo; BEGIN { require t::Base; @Bar::Foo::ISA = 't::Base'; } use YAML::Marshall; sub yaml_dump { my $self = shift; my $node = $self->SUPER::yaml_dump(@_); $node->{comment} = "Hi, Mom"; return $node; } sub yaml_load { my $class = shift; my $node = $class->SUPER::yaml_load(@_); delete $node->{comment}; return $node; } #------------------------------------------------------------------------------- package main; no_diff; run_roundtrip_nyn; is $main::BazFoo->{11}, 12, 'first key exists'; is $main::BazFoo->{13}, 14, 'second key exists'; ok not($main::BazFoo->{comment}), 'extra key not added'; __DATA__ === Serialize a hash object as a sequence +++ perl my $fb = Foo::Bar->new; $fb->{x} = 5; $fb->{y} = 'che'; [$fb]; +++ yaml --- - !perl/Foo::Bar - x - 5 - y - che === Use a non-standard tag +++ perl: bless {11 .. 14}, 'Bar::Baz'; +++ yaml --- !random/object:bar.baz 11: 12 13: 14 === super calls to mixins work +++ perl: bless {11 .. 14}, 'Baz::Foo'; +++ yaml --- !perl/Baz::Foo 11: 12 13: 14 comment: 'Hi, Mom' === yaml_dump doesn't mutate original hash +++ no_round_trip +++ perl: $main::BazFoo = bless {11 .. 14}, 'Baz::Foo'; +++ yaml --- !perl/Baz::Foo 11: 12 13: 14 comment: 'Hi, Mom' YAML-0.84/t/bugs-rt.t0000644000372100001440000001340211715272433014003 0ustar matthewtusersuse t::TestYAML tests => 41; run_yaml_tests; __DATA__ === Ticket #105-A YAML doesn't serialize odd objects very well +++ skip_this_for_now +++ skip_unless_modules: FileHandle +++ perl: FileHandle->new( ">/tmp/$$" ); +++ yaml --- !!perl/io:FileHandle - xxx === Ticket #105-B YAML doesn't serialize odd objects very well +++ skip_unless_modules: URI +++ no_round_trip +++ perl: URI->new( "http://localhost/" ) +++ yaml --- !!perl/scalar:URI::http http://localhost/ === Ticket #105-C YAML doesn't serialize odd objects very well +++ skip_unless_modules: URI +++ perl: +{ names => ['james','alexander','duncan'], } +++ yaml --- names: - james - alexander - duncan === Ticket #105-D YAML doesn't serialize odd objects very well +++ perl # CGI->new() bless { '.charset' => 'ISO-8859-1', '.fieldnames' => {}, '.parameters' => [], escape => 1, }, 'CGI'; +++ yaml --- !!perl/hash:CGI .charset: ISO-8859-1 .fieldnames: {} .parameters: [] escape: 1 === Ticket #105-E YAML doesn't serialize odd objects very well +++ perl package MyObj::Class; sub new { return bless ['one','two','three'], $_[0]; } package main; MyObj::Class->new(); +++ yaml --- !!perl/array:MyObj::Class - one - two - three === Ticket #2957 Serializing array-elements with dashes +++ skip_this_for_now +++ perl: [ { "test - " => 23 } ]; +++ yaml --- - 'test - ': 23 === Ticket #3015 wish: folding length option for YAML +++ skip_this_for_now > YAML.pm, line 557, currently has a folding value of 50 hard-coded. > It would be great if this value became an option... for those who > prefer not to fold, or fold less. I wanted that too. The attached patch adds in the $YAML::FoldLimit config variable to achieve this. I've also got a doc patch which describes this, but 'RT' only has one file-upload field so that'll be in the next comment ... Smylers === Ticket #4066 Number vs. string heuristics for dump +++ perl: { 'version' => '1.10' }; +++ yaml --- version: 1.10 === Ticket #4784 Can't create YAML::Node from 'REF' +++ skip_this_for_now +++ perl: my $bar = 1; my $foo = \\\$bar; bless $foo, "bar" +++ yaml === Ticket #4866 Text with embedded newlines +++ perl {'text' => 'Bla: - Foo - Bar '}; +++ yaml --- text: "Bla:\n\n- Foo\n- Bar\n" === Ticket #5299 Load(Dump({"hi, world" => 1})) fails +++ perl: {"hi, world" => 1} +++ yaml --- 'hi, world': 1 === Ticket #5691 Minor doc error in YAML.pod +++ perl: "YAML:1.0" +++ yaml --- YAML:1.0 === Ticket #6095 Hash keys are not always escaped +++ perl: { 'AVE,' => { '??' => { '??' => 1 } } } +++ yaml --- 'AVE,': '??': '??': 1 === Ticket #6139 0.35 can't deserialize blessed scalars +++ perl: my $x = "abc"; bless \ $x, "ABCD"; +++ yaml --- !!perl/scalar:ABCD abc === Ticket #7146 scalar with many spaces doesn't round trip +++ skip_this_for_now Can't get this to work yet. +++ perl: "A".(" "x200)."B" +++ yaml --- 'A B' === Ticket #8795 !!perl/code blocks are evaluated in package main +++ skip_this_for_now This test passes but not sure if this totally represents what was being reported. Check back later. +++ perl: $YAML::UseCode = 1; package Food; sub { 42; } +++ no_round_trip +++ yaml --- !!perl/code | sub { package Food; use warnings; use strict 'refs'; 42; } === Ticket #8818 YAML::Load fails if the last value in the stream ends with '|' +++ perl: ['o|'] +++ yaml --- - 'o|' === Ticket #12729 < and > need to be quoted ? +++ perl: { a => q(>a), b => q( q()} +++ yaml --- a: '>a' b: ' === Ticket #12770 YAML crashes when tab used for indenting +++ skip_this_for_now Even in the latest version, 0.39, YAML fails when tabulator characters are used for indenting. This is expected since the YAML spec forbids this use of tab characters. However, there is no error message; YAML.pm just dies. Here's an example: perl -MYAML -e "Load(\"Testing:\n\t- Item1\n\")" fails with Died at U:\perl-lib\lib/YAML.pm line 1417. It should at least fail with a message like it does when there's no newline at the end: +++ perl === Ticket #12955 DumpCode claims to support a code ref to serialize code, but doesn't +++ skip_this_for_now The DumpCode option says you can set it to a code ref to control the serializing yourself, but this doesn't work. $ perl -MYAML -we ' $YAML::DumpCode = sub { return "dumped code $_[0]", "test" }; print Dump(sub { "foo" });' --- !!perl/code "{\n 'foo';\n}\n" $ _ YAML::Transfer::code::yaml_dump() doesn't look to have any code to support a DumpCode which is a code ref, it only tests it as a boolean. +++ perl === Ticket #12959-a bug - nested inline collections with extra blanks +++ function: load_passes +++ yaml --- { a: {k: v} } === Ticket #12959-b bug - nested inline collections with extra blanks +++ function: load_passes +++ yaml --- { a: [1] } === Ticket #12959-c bug - nested inline collections with extra blanks +++ function: load_passes +++ yaml --- [ {k: v} ] === Ticket #12959-d bug - nested inline collections with extra blanks +++ function: load_passes +++ yaml --- [ [1] ] === Ticket #13016 Plain Multiline Support +++ skip_this_for_now Fix in upcoming release +++ function: load_passes +++ yaml quoted: "So does this quoted scalar.\n" === #13500 Load(Dump("|foo")) fails +++ perl: "|foo" +++ yaml --- '|foo' === Ticket #13510 Another roundtrip fails +++ skip_this_for_now +++ perl [{'RR1 (Schloflplatz - Wannsee)'=> 1, 'm‰fliges Kopfsteinpflaster (Teilstrecke)' => 1}, undef, ] +++ yaml --- - 'RR1 (Schloflplatz - Wannsee)': 1 m‰fliges Kopfsteinpflaster (Teilstrecke): 1 - ~ === Ticket #14938 Load(Dump(">=")) fails +++ perl: ">=" +++ yaml --- '>=' YAML-0.84/t/load-slides.t0000644000372100001440000001300511715272433014617 0ustar matthewtusers# This tests the slides I used for YAPC 2002 use t::TestYAML tests => 28; run_load_passes(); __DATA__ === +++ yaml YAML design goals: - YAML documents are very readable by humans. - YAML interacts well with scripting languages. - YAML uses host languages native data structures. - YAML has a consistent information model. - YAML enables stream-based processing. - YAML is expressive and extensible. - YAML is easy to implement. === +++ yaml --- scripting languages: - Perl - Python - C - Java standards: - RFC0822 (MAIL) - RFC1866 (HTML) - RFC2045 (MIME) - RFC2396 (URI) others: - SOAP - XML - SAX === +++ yaml --- name: Benjamin rank: Private serial number: 1234567890 12:34 PM: My favorite time === +++ yaml --- - red - white - blue - pinko === +++ yaml --- Fruits: - Apples - Tomatoes Veggies: - Spinach - Broccoli Meats: - Burgers - Shrimp Household: - Candles - Incense - Toilet Duck === +++ yaml --- - - 3 - 5 - 7 - - 0 - 0 - 7 - - 9 - 1 - 1 === +++ yaml - Intro - Part 1: - Up - Down - Side to Side - Part 2: - Here - There - Underwear - Part 3: - The Good - The Bad - The Ingy === +++ yaml ## comment before document #--- #DIRECTIVE # comment #foo: bar # inline comment # #phone: number #555-1234 # ### Comment #fact: fiction #--- #blue: bird ## Comment === +++ yaml --- simple: look ma, no quotes quoted: - 'Single quoted. Like Perl, no escapes' - "Double quotes.\nLike Perl, has escapes" - | A YAML block scalar. Much like Perl's here-document. === +++ yaml #--- #simple key: simple value #this value: can span multiple lines # but the key cannot. it would need quotes #stuff: # - foo # - 42 # - 3.14 # - 192.168.2.98 # - m/^(.*)\// === +++ yaml #--- #'contains: colon': '$19.99' #or: ' value has leading/trailing whitespace ' #'key spans #lines': 'double ticks \ for ''escaping''' === +++ yaml #--- #The spec says: "The double quoted style variant adds escaping to the 'single quoted' style variant." # #like this: "null->\z newline->\n bell->\a #smiley->\u263a" # #self escape: "Brian \"Ingy\" Ingerson" === +++ yaml --- what is this: | is it: a YAML mapping or just: a string chomp me: |- sub foo { print "Love me do!"; } === +++ yaml --- #YAML:1.0 old doc: | --- #YAML:1.0 tools: - XML - XSLT new doc: | --- #YAML:1.0 tools: - YAML - cYATL === +++ yaml --- - > Copyright © 2001 Brian Ingerson, Clark Evans & Oren Ben-Kiki, all rights reserved. This document may be freely copied provided that it is not modified. Next paragraph. - foo === +++ yaml --- The YAML Specification starts out by saying: > YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML documents are very readable by humans. YAML interacts well with scripting languages. YAML uses host languages' native data structures. Please join us, the mailing list is at SourceForge. === +++ yaml --- ? >+ Even a key can: 1) Be Folded 2) Have Wiki : cool, eh? === +++ yaml --- Hey Jude: &chorus - na, na, na, - &4 na, na, na, na, - *4 - Hey Jude. - *chorus === +++ yaml headerless: first document --- #YAML:1.0 #TAB:NONE --- > folded top level scalar --- &1 recurse: *1 --- - simple header === +++ yaml #--- #seq: [ 14, 34, 55 ] #map: {purple: rain, blue: skies} #mixed: {sizes: [9, 11], shapes: [round]} #span: {players: [who, what, I don't know], # positions: [first, second, third]} === +++ yaml ## Inline sequences make data more compact #--- #- [3, 5, 7] #- [0, 0, 7] #- [9, 1, 1] # ## Above is equal to below #--- [[3, 5, 7], [0, 0, 7], [9, 1, 1]] # ## A 3D Matrix #--- #- [[3, 5, 7], [0, 0, 7], [9, 1, 1]] #- [[0, 0, 7], [9, 1, 1], [3, 5, 7]] #- [[9, 1, 1], [3, 5, 7], [0, 0, 7]] === +++ yaml --- ? - Kane - Kudra : engaged [Damian, Dominus]: engaging === +++ yaml #same: # - 42 # - !int 42 # - !yaml.org/int 42 # - !http://yaml.org/int 42 #perl: # - !perl/Foo::Bar {} # - !perl.yaml.org/Foo::Bar {} # - !http://perl.yaml.org/Foo::Bar {} === +++ yaml #--- #- 42 # integer #- -3.14 # floating point #- 6.02e+23 # scientific notation #- 0xCAFEBABE # hexadecimal int #- 2001-09-11 # ISO8601 time #- '2001-09-11' # string #- + # boolean true #- (false) # alternate boolean #- ~ # null (undef in Perl) #- 123 Main St # string === +++ yaml #--- #- !str YAML, YAML, YAML! #- !int 42 #- !float 0.707 #- !time 2001-12-14T21:59:43.10-05:00 #- !bool 1 #- !null 0 #- !binary MWYNG84BwwEeECcgggoBADs= === +++ yaml #--- #- !perl/Foo::Bar {} # hash-based class #- !perl/@Foo::Bar [] # array-based class #- !perl/$Foo::Bar '' # scalar-based class #- !perl/glob: # typeglob #- !perl/code: # code reference #- !perl/ref: # hard reference #- !perl/regexp: # regular expression #- !perl/regexp:Foo::Bar # blessed regexp === +++ yaml --- #YAML:1.0 NAME: AddressEntry HASH: - NAME: Name HASH: - NAME: First - NAME: Last OPTIONAL: yes - NAME: EmailAddresses ARRAY: yes - NAME: Phone ARRAY: yes HASH: - NAME: Type OPTIONAL: yes - NAME: Number === +++ yaml --- #YAML:1.0 AddressEntry: Name: First: Brian EmailAddresses: - ingy@CPAN.org - ingy@ttul.org Phone: - Type: Work Number: 604-333-4567 - Number: 843-444-5678 YAML-0.84/t/load-fails.t0000644000372100001440000000113611715272433014434 0ustar matthewtusers# This simply tests that a given piece of invalid YAML fails to parse use t::TestYAML tests => 4; filters { msg => 'regexp', yaml => 'yaml_load_or_fail', }; run_like yaml => 'msg'; __DATA__ === +++ SKIP This test hangs YAML.pm +++ msg YAML Error: Inconsistent indentation level +++ yaml a: * === +++ msg YAML Error: Inconsistent indentation level +++ yaml --- |\ foo\zbar === +++ msg YAML Error: Unrecognized implicit value +++ yaml --- @ 42 === +++ msg YAML Error: Inconsistent indentation level +++ yaml --- - 1 -2 === +++ msg Unrecognized TAB policy +++ yaml --- #TAB:MOBY - foo YAML-0.84/t/dump-code.t0000644000372100001440000000276311777023401014302 0ustar matthewtusersuse t::TestYAML tests => 7; use YAML (); # [CPAN #74687] must load before B::Deparse for B::Deparse < 0.71 use B::Deparse; if (new B::Deparse -> coderef2text ( sub { no strict; 1; use strict; 1; }) =~ 'refs') { local $/; (my $data = ) =~ s/use strict/use strict 'refs'/g if $] < 5.015; if ($B::Deparse::VERSION > 0.67 and $B::Deparse::VERSION < 0.71) { # [CPAN #73702] $data =~ s/use warnings;/BEGIN {\${^WARNING_BITS} = "UUUUUUUUUUUU\\001"}/g; } open DATA, '<', \$data; } no_diff; run_roundtrip_nyn('dumper'); __DATA__ === a code ref +++ config local $YAML::DumpCode = 1; +++ perl package main; return sub { 'Something at least 30 chars' }; +++ yaml --- !!perl/code | { use warnings; use strict; 'Something at least 30 chars'; } === an array of the same code ref +++ config local $YAML::DumpCode = 1; +++ perl package main; my $joe_random_global = sub { 'Something at least 30 chars' }; [$joe_random_global, $joe_random_global, $joe_random_global]; +++ yaml --- - &1 !!perl/code | { use warnings; use strict; 'Something at least 30 chars'; } - *1 - *1 === dummy code ref +++ config local $YAML::DumpCode = 0; +++ perl sub { 'Something at least 30 chars' } +++ yaml --- !!perl/code '{ "DUMMY" }' === blessed code ref +++ config local $YAML::DumpCode = 1; +++ perl package main; bless sub { 'Something at least 30 chars' }, "Foo::Bar"; +++ no_round_trip +++ yaml --- !!perl/code:Foo::Bar | { use warnings; use strict; 'Something at least 30 chars'; } YAML-0.84/t/global-api.t0000644000372100001440000000131611715272433014430 0ustar matthewtusersuse Test::YAML(); BEGIN { @Test::YAML::EXPORT = grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT; } use t::TestYAML tests => 4; use YAML; { no warnings qw'once redefine'; require YAML::Dumper; local *YAML::Dumper::dump = sub { return 'got to dumper' }; require YAML::Loader; local *YAML::Loader::load = sub { return 'got to loader' }; is Dump(\%ENV), 'got to dumper', 'Dump got to the business end'; is Load(\%ENV), 'got to loader', 'Load got to the business end'; is Dump(\%ENV), 'got to dumper', 'YAML::Dump got to the business end'; is Load(\%ENV), 'got to loader', 'YAML::Load got to the business end'; } YAML-0.84/t/long-quoted-value.yaml0000644000372100001440000007601611715272433016501 0ustar matthewtusers--- hello: "A stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA string" YAML-0.84/t/dump-perl-types-512.t0000644000372100001440000000072611715272433016001 0ustar matthewtusersuse Test::More; BEGIN { if ( qr/x/ =~ /\(\?\^/ ){ plan skip_all => "test only for perls before v5.13.5-11-gfb85c04"; } } use t::TestYAML tests => 2; filters { perl => ['eval', 'yaml_dump'] }; no_diff; run_is ( perl => 'yaml' ); __DATA__ === Regular Expression +++ perl: qr{perfect match}; +++ yaml --- !!perl/regexp (?-xism:perfect match) === Regular Expression with newline +++ perl qr{perfect match}x; +++ yaml --- !!perl/regexp "(?x-ism:perfect\nmatch)" YAML-0.84/t/TestYAML.pm0000644000372100001440000000012711715272433014173 0ustar matthewtuserspackage t::TestYAML; use Test::YAML 0.51 -Base; $Test::YAML::YAML = 'YAML'; $^W = 1; YAML-0.84/t/changes.t0000644000372100001440000000017411715272433014032 0ustar matthewtusersuse t::TestYAML tests => 1; SKIP: { skip("Can't parse Changes file yet :(", 1); } # my @values = LoadFile("Changes"); YAML-0.84/t/node-info.t0000644000372100001440000000426611715272433014306 0ustar matthewtusersuse t::TestYAML tests => 16; use YAML::Dumper; package StrIngy; use overload '""', sub { 'A Stringy String' }; sub new {bless {}, shift} package main; my $object = bless {}, 'StrIngy'; # $\ = "\n"; # print ref($object); # print "$object"; # print overload::StrVal($object); # print overload::StrVal(bless {}, 'foo'); # exit; filters { node => ['eval_perl' => 'get_info'], info => ['lines' => 'make_regexp'], }; run_like node => 'info'; sub eval_perl { my $perl = shift; my $stringify = 0; $stringify = 1 if $perl =~ s/^#\s*//; my $node = eval $perl; die "Perl code failed to eval:\n$perl\n$@" if $@; return ($node, $stringify); } sub get_info { my $dumper = YAML::Dumper->new; join ';', map { defined($_) ? $_ : 'undef' } $dumper->node_info(@_); } sub make_regexp { my $string = join ';', map { chomp; s/^~$/undef/; s/^0x\d+/0x[0-9a-fA-F]+/; $_; } @_; qr/^${string}$/; } __DATA__ === Hash Ref +++ node: +{1..4}; +++ info ~ HASH 0x12345678 === Array Ref +++ node: [1..5] +++ info ~ ARRAY 0x12345678 === Scalar +++ node: 'hello'; +++ info ~ ~ 0x12345678-S === Scalar Ref +++ node: \ 'hello'; +++ info ~ SCALAR 0x12345678 === Scalar Ref Ref +++ node: \\ 'hello'; +++ info ~ REF 0x12345678 === Code Ref +++ node: sub { 42; } +++ info ~ CODE 0x12345678 === Code Ref Ref +++ node: \ sub { 42; } +++ info ~ REF 0x12345678 === Glob +++ node: $::x = 5; \ *x; +++ info ~ GLOB 0x12345678 === Regular Expression +++ node: qr{xxx}; +++ info ~ REGEXP 0x12345678 === Blessed Hash Ref +++ node: bless {}, 'ARRAY'; +++ info ARRAY HASH 0x12345678 === Blessed Array Ref +++ node: bless [], 'Foo::Bar'; +++ info Foo::Bar ARRAY 0x12345678 === Blessed Scalar Ref +++ node: my $b = 'boomboom'; bless ((\ $b), 'Foo::Barge'); +++ info Foo::Barge SCALAR 0x12345678 === Blessed Code Ref +++ node: bless sub { 43 }, 'Foo::Barbie'; +++ info Foo::Barbie CODE 0x12345678 === Blessed Glob +++ node: $::x = 5; bless \ *x, 'Che'; +++ info Che GLOB 0x12345678 === Not Stringified Hash Object +++ node: bless {}, 'StrIngy'; +++ info StrIngy HASH 0x12345678 === Stringified Hash Object +++ node: # bless {}, 'StrIngy'; +++ info ~ ~ 0x12345678-S YAML-0.84/t/load-passes.t0000644000372100001440000000133111715272433014631 0ustar matthewtusersuse t::TestYAML tests => 8; run_load_passes(); __DATA__ === Bug reported by Rich Morin +++ SKIP +++ yaml foo: - > This is a test. === Bug reported by audreyt +++ SKIP +++ yaml --- "\n\ \r" === +++ yaml --- foo: bar: baz: poo: bah === +++ yaml --- 42 === +++ yaml # comment --- 42 # comment === +++ yaml --- [1, 2, 3] === +++ yaml --- {foo: bar, bar: 42} === +++ yaml --- !foo.com/bar - 2 === +++ yaml --- &1 !foo.com/bar - 42 === +++ yaml --- - 40 - 41 - foof YAML-0.84/t/freeze-thaw.t0000644000372100001440000000130011715272433014633 0ustar matthewtusersuse Test::YAML(); BEGIN { @Test::YAML::EXPORT = grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT; } use t::TestYAML tests => 9; use YAML qw(Dump Load freeze thaw); my $hash = { foo => 42, bar => 44 }; my $ice = freeze($hash); ok defined(&Dump), 'Dump exported'; ok defined(&Load), 'Load exported'; ok defined(&freeze), 'freeze exported'; ok defined(&thaw), 'thaw exported'; like $ice, qr{bar.*foo}s, 'freeze works'; is $ice, Dump($hash), 'freeze produces same thing as Dump'; my $melt = thaw($ice); is_deeply $melt, Load($ice), 'thaw produces same thing as Load'; is_deeply $melt, $hash, 'freeze/thaw makes a clone'; is ref($melt), 'HASH', 'Melted object really is a hash'; YAML-0.84/t/errors.t0000644000372100001440000001453211715272433013741 0ustar matthewtusersuse t::TestYAML tests => 35; $^W = 1; use YAML::Error; filters { error => 'regexp', yaml => [mutate_yaml => 'yaml_load_error_or_warning' => 'check_yaml'], perl => 'perl_eval_error_or_warning', }; run_like('yaml' => 'error'); run_like('perl' => 'error'); sub mutate_yaml { s/\Q<%CNTL-G%>\E/\007/; chomp if /msg_no_newline/; } sub check_yaml { my $yaml = shift; return $yaml unless ref($yaml); print "YAML actually loaded:\n" . Data::Dumper::Dumper($yaml); return ''; } __DATA__ === YAML_PARSE_ERR_BAD_CHARS +++ error: YAML_PARSE_ERR_BAD_CHARS +++ yaml # Test msg_bad_chars --- - foo # The next line contains an escape character - bell -><%CNTL-G%><- === YAML_PARSE_ERR_NO_FINAL_NEWLINE +++ error: YAML_PARSE_ERR_NO_FINAL_NEWLINE +++ yaml # Test msg_no_newline --- - one - two - three === YAML_PARSE_ERR_BAD_MAJOR_VERSION +++ error: YAML_PARSE_ERR_BAD_MAJOR_VERSION +++ yaml # Test msg_bad_major_version --- - one - two --- #YAML:2.0 - foo - bar === YAML_PARSE_WARN_BAD_MINOR_VERSION +++ error: YAML_PARSE_WARN_BAD_MINOR_VERSION +++ yaml # Test msg_bad_minor_version --- - one - two --- #YAML:1.5 - foo - bar === YAML_PARSE_WARN_MULTIPLE_DIRECTIVES +++ error: YAML_PARSE_WARN_MULTIPLE_DIRECTIVES +++ yaml # Test msg_multiple_directives --- #YAML:1.0 #YAML:1.0 - foo --- #FOO:2 #FOO:3 - bar === YAML_PARSE_ERR_TEXT_AFTER_INDICATOR +++ error: YAML_PARSE_ERR_TEXT_AFTER_INDICATOR +++ yaml # Test msg_text_after_indicator --- - > This is OK. - > But this is not - This is OK === YAML_PARSE_ERR_NO_ANCHOR +++ error: YAML_PARSE_ERR_NO_ANCHOR +++ yaml # Test msg_no_anchor --- - &moo foo - bar - *star - &star far === YAML_PARSE_ERR_INCONSISTENT_INDENTATION +++ error: YAML_PARSE_ERR_INCONSISTENT_INDENTATION +++ yaml --- {foo: bar} - foo - bar === YAML_PARSE_ERR_SINGLE_LINE +++ error: YAML_PARSE_ERR_SINGLE_LINE +++ yaml --- - "foo" bar === YAML_PARSE_ERR_BAD_ANCHOR +++ error: YAML_PARSE_ERR_BAD_ANCHOR +++ yaml --- - &X=y 42 #--- #error: YAML_PARSE_ERR_BAD_NODEX #load: | #--- #error: YAML_PARSE_ERR_BAD_EXPLICITX #load: | # I don't think this one can ever happen (yet) #--- #error: YAML_DUMP_USAGE_DUMPCODE #code: | # local $YAML::DumpCode = [0]; # Dump(sub { $foo + 42 }); === YAML_LOAD_ERR_FILE_INPUT +++ error: YAML_LOAD_ERR_FILE_INPUT +++ perl LoadFile('fooxxx'); # XXX - Causing bus error!?!? #--- #error: YAML_DUMP_ERR_FILE_CONCATENATE #code: | # DumpFile(">> YAML.pod", 42); === YAML_DUMP_ERR_FILE_OUTPUT +++ error: YAML_DUMP_ERR_FILE_OUTPUT +++ perl Test::YAML::DumpFile("x/y/z.yaml", 42); === YAML_DUMP_ERR_NO_HEADER +++ error: YAML_DUMP_ERR_NO_HEADER +++ perl local $YAML::UseHeader = 0; Test::YAML::Dump(42); === YAML_DUMP_ERR_NO_HEADER +++ error: YAML_DUMP_ERR_NO_HEADER +++ perl local $YAML::UseHeader = 0; Test::YAML::Dump([]); === YAML_DUMP_ERR_NO_HEADER +++ error: YAML_DUMP_ERR_NO_HEADER +++ perl local $YAML::UseHeader = 0; Test::YAML::Dump({}); #--- #error: xYAML_DUMP_WARN_BAD_NODE_TYPE #code: | # # #--- #error: YAML_EMIT_WARN_KEYS #code: | # # #--- #error: YAML_DUMP_WARN_DEPARSE_FAILED #code: | # # #--- #error: YAML_DUMP_WARN_CODE_DUMMY #code: | # Dump(sub{ 42 }); === YAML_PARSE_ERR_MANY_EXPLICIT +++ error: YAML_PARSE_ERR_MANY_EXPLICIT +++ yaml --- - !foo !bar 42 === YAML_PARSE_ERR_MANY_IMPLICIT +++ error: YAML_PARSE_ERR_MANY_IMPLICIT +++ yaml --- - ! ! "42" === YAML_PARSE_ERR_MANY_ANCHOR +++ error: YAML_PARSE_ERR_MANY_ANCHOR +++ yaml --- - &foo &bar 42 === YAML_PARSE_ERR_ANCHOR_ALIAS +++ error: YAML_PARSE_ERR_ANCHOR_ALIAS +++ yaml --- - &bar *foo === YAML_PARSE_ERR_BAD_ALIAS +++ error: YAML_PARSE_ERR_BAD_ALIAS +++ yaml --- - *foo=bar === YAML_PARSE_ERR_MANY_ALIAS +++ error: YAML_PARSE_ERR_MANY_ALIAS +++ yaml --- - *foo *bar === YAML_LOAD_ERR_NO_CONVERT +++ SKIP Actually this should load into a ynode... +++ error: YAML_LOAD_ERR_NO_CONVERT +++ yaml --- - !foo shoe === YAML_LOAD_ERR_NO_DEFAULT_VALUE +++ error: YAML_LOAD_ERR_NO_DEFAULT_VALUE +++ yaml --- - !perl/ref foo: bar #--- #error: YAML_LOAD_ERR_NON_EMPTY_STRING #load: | # --- # - !map foo #--- #error: YAML_LOAD_ERR_NON_EMPTY_STRING #load: | # --- # - !seq foo #--- #error: YAML_LOAD_ERR_BAD_MAP_TO_SEQ #load: | # --- !seq # 0: zero # won: one # 2: two # 3: three #--- #error: YAML_LOAD_ERR_BAD_GLOB #load: | # # #--- #error: YAML_LOAD_ERR_BAD_REGEXP #load: | # # === YAML_LOAD_ERR_BAD_MAP_ELEMENT +++ error: YAML_LOAD_ERR_BAD_MAP_ELEMENT +++ yaml --- foo: bar bar === YAML_LOAD_WARN_DUPLICATE_KEY +++ error: YAML_LOAD_WARN_DUPLICATE_KEY +++ yaml --- foo: bar bar: boo foo: baz boo: bah === YAML_LOAD_ERR_BAD_SEQ_ELEMENT +++ error: YAML_LOAD_ERR_BAD_SEQ_ELEMENT +++ yaml --- - 42 foo === YAML_PARSE_ERR_INLINE_MAP +++ error: YAML_PARSE_ERR_INLINE_MAP +++ yaml --- - {foo:bar} === YAML_PARSE_ERR_INLINE_SEQUENCE +++ error: YAML_PARSE_ERR_INLINE_SEQUENCE +++ yaml --- - [foo bar, baz === YAML_PARSE_ERR_BAD_DOUBLE +++ error: YAML_PARSE_ERR_BAD_DOUBLE +++ yaml --- - "foo baz === YAML_PARSE_ERR_BAD_SINGLE +++ error: YAML_PARSE_ERR_BAD_SINGLE +++ yaml --- - 'foo bar === YAML_PARSE_ERR_BAD_INLINE_IMPLICIT +++ error: YAML_PARSE_ERR_BAD_INLINE_IMPLICIT +++ yaml --- - [^gold] === YAML_PARSE_ERR_BAD_IMPLICIT +++ error: YAML_PARSE_ERR_BAD_IMPLICIT +++ yaml --- ! > - 4 foo bar #--- #error: xYAML_PARSE_ERR_INDENTATION #load: | # --- === YAML_PARSE_ERR_INCONSISTENT_INDENTATION +++ error: YAML_PARSE_ERR_INCONSISTENT_INDENTATION +++ yaml --- foo: bar bar: baz #--- #error: xYAML_LOAD_WARN_UNRESOLVED_ALIAS #load: | # --- # foo: *bar # === YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP # +++ error: YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP # +++ yaml # --- # - !perl/regexp: # foo: bar # # === YAML_LOAD_WARN_BAD_REGEXP_ELEM # +++ error: YAML_LOAD_WARN_BAD_REGEXP_ELEM # +++ yaml # --- # - !perl/regexp: # REGEXP: foo # foo: bar === YAML_LOAD_WARN_GLOB_NAME +++ error: YAML_LOAD_WARN_GLOB_NAME +++ yaml --- - !perl/glob: foo: bar #--- #error: xYAML_LOAD_WARN_PARSE_CODE #load: | # --- #--- #error: YAML_LOAD_WARN_CODE_DEPARSE #load: | # --- # - !perl/code | # sub { "foo" } #--- #error: xYAML_EMIT_ERR_BAD_LEVEL #code: # # #--- #error: YAML_PARSE_WARN_AMBIGUOUS_TAB #load: | # --- # - | # foo # bar === YAML_LOAD_WARN_BAD_GLOB_ELEM +++ error: YAML_LOAD_WARN_BAD_GLOB_ELEM +++ yaml --- - !perl/glob: NAME: foo bar: SHAME === YAML_PARSE_ERR_ZERO_INDENT +++ error: YAML_PARSE_ERR_ZERO_INDENT +++ yaml --- - |0 foo YAML-0.84/t/load-works.t0000644000372100001440000000025011715272433014477 0ustar matthewtusersuse t::TestYAML; filters { perl => 'eval', yaml => 'yaml_load', }; run_is_deeply; __DATA__ === A one key hash +++ perl +{foo => 'bar'} +++ yaml --- foo: bar YAML-0.84/t/dump-file.t0000644000372100001440000000071111715272433014301 0ustar matthewtusersuse Test::YAML(); BEGIN { @Test::YAML::EXPORT = grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT; } use t::TestYAML tests => 3; use YAML 'DumpFile'; ok defined &DumpFile, 'Dumpfile exported'; my $file = 't/dump.yaml'; DumpFile($file, [1..3]); ok -e $file, 'Output file exists'; open IN, $file or die $!; my $yaml = join '', ; close IN; is $yaml, <<'...', 'DumpFile YAML is correct'; --- - 1 - 2 - 3 ... unlink $file; YAML-0.84/t/Base.pm0000644000372100001440000000024011715272433013437 0ustar matthewtuserspackage t::Base; sub new { my $self = bless {}, shift; while (my ($k, $v) = splice @_, 0, 2) { $self->{$k} = $v; } return $self; } 1; YAML-0.84/t/references.t0000644000372100001440000000124711715272433014545 0ustar matthewtusersuse Test::YAML tests => 10; no_diff; run_yaml_tests; __DATA__ === A scalar ref +++ perl: \ 42 +++ yaml --- !!perl/ref =: 42 === A ref to a scalar ref +++ perl: \\ "yellow" +++ yaml --- !!perl/ref =: !!perl/ref =: yellow === A ref to a ref to a scalar ref +++ perl: \\\ 123 +++ yaml --- !!perl/ref =: !!perl/ref =: !!perl/ref =: 123 === A blessed container reference +++ perl my $array_ref = [ 1, 3, 5]; my $container_ref = \ $array_ref; bless $container_ref, 'Wax'; +++ yaml --- !!perl/ref:Wax =: - 1 - 3 - 5 === A blessed scalar reference +++ perl my $scalar = "omg"; my $scalar_ref = \ $scalar; bless $scalar_ref, 'Wax'; +++ yaml --- !!perl/scalar:Wax omg YAML-0.84/t/dump-opts.t0000644000372100001440000000416011715272433014351 0ustar matthewtusersuse t::TestYAML tests => 19; run_roundtrip_nyn(); __DATA__ === +++ config local $YAML::UseHeader = 0 +++ perl (['34', '45'], ['56', '67']) +++ yaml - 34 - 45 --- - 56 - 67 === +++ no_round_trip +++ config local $YAML::UseAliases = 0 +++ perl my $ref = {foo => 'bar'}; [$ref, $ref] +++ yaml --- - foo: bar - foo: bar === +++ config local $YAML::CompressSeries = 1 +++ perl [ {foo => 'bar'}, {lips => 'red', crown => 'head'}, {trix => [ 'foo', {silly => 'rabbit', bratty => 'kids', } ] }, ] +++ yaml --- - foo: bar - crown: head lips: red - trix: - foo - bratty: kids silly: rabbit === +++ config local $YAML::CompressSeries = 0; local $YAML::Indent = 5 +++ perl [ {one => 'fun', pun => 'none'}, two => 'foo', {three => [ {free => 'willy', dally => 'dilly'} ]}, ] +++ yaml --- - one: fun pun: none - two - foo - three: - dally: dilly free: willy === +++ config local $YAML::CompressSeries = 1; local $YAML::Indent = 5 +++ perl [ {one => 'fun', pun => 'none'}, two => {foo => {true => 'blue'}}, {three => [ {free => 'willy', dally => 'dilly'} ]}, ] +++ yaml --- - one: fun pun: none - two - foo: true: blue - three: - dally: dilly free: willy === +++ config local $YAML::Indent = 3 +++ perl [{ one => 'two', three => 'four' }, { foo => 'bar' }, ] +++ yaml --- - one: two three: four - foo: bar === +++ config local $YAML::CompressSeries = 1 +++ perl [ 'The', {speed => 'quick', color => 'brown', &YAML::VALUE => 'fox'}, 'jumped over the', {speed => 'lazy', &YAML::VALUE, 'dog'}, ] +++ yaml --- - The - color: brown speed: quick =: fox - jumped over the - speed: lazy =: dog === +++ config local $YAML::InlineSeries = 3 +++ perl [ ['10', '20', '30'], ['foo', 'bar'], ['thank', 'god', "it's", 'friday'], ] +++ yaml --- - [10, 20, 30] - [foo, bar] - - thank - god - it's - friday === +++ config local $YAML::SortKeys = [qw(foo bar baz)] +++ perl {foo=>'42',bar=>'99',baz=>'4'} +++ yaml --- foo: 42 bar: 99 baz: 4 === +++ perl {foo => '42', bar => 'baz'} +++ yaml --- bar: baz foo: 42 YAML-0.84/t/dump-tests-512.t0000644000372100001440000000067111715272433015036 0ustar matthewtusersuse Test::More; BEGIN { if ( qr/x/ =~ /\(\?\^/ ){ plan skip_all => "test only for perls before v5.13.5-11-gfb85c04"; } } use t::TestYAML tests => 1; no_diff(); run_roundtrip_nyn('dumper'); __DATA__ === +++ no_round_trip Since we don't use eval for regexp reconstitution any more (for safety sake) this test doesn't roundtrip even though the values are equivalent. +++ perl [qr{bozo$}i] +++ yaml --- - !!perl/regexp (?i-xsm:bozo$) YAML-0.84/t/pugs-objects.t0000644000372100001440000000052611715272433015030 0ustar matthewtusersuse t::TestYAML tests => 2; { no warnings 'once'; $Foo::Bar::ClassTag = '!pugs/object:Foo::Bar'; $YAML::TagClass->{'!pugs/object:Foo::Bar'} = 'Foo::Bar'; } no_diff; run_roundtrip_nyn('dumper'); __DATA__ === Turn Perl object to Pugs object +++ perl: bless { 'a'..'d' }, 'Foo::Bar'; +++ yaml --- !!pugs/object:Foo::Bar a: b c: d YAML-0.84/t/inbox.t0000644000372100001440000000105511715272433013540 0ustar matthewtusersuse t::TestYAML tests => 3; SKIP: { skip 'fix this next release', 3; my $x; is(Dump(bless(\$x)), 'foo'); } __END__ 03:14 < audreyt> ingy: 03:14 < audreyt> use YAML; my $x; print Dump bless(\$x); 03:14 < audreyt> is erroneous 03:14 < audreyt> then 03:14 < audreyt> use YAML; my $x = \3; print Dump bless(\$x); 03:14 < audreyt> is fatal error 03:15 < audreyt> use YAML; my $x; $x = \$x; print Dump bless(\$x); 03:15 < audreyt> is scary fatal error 03:15 < audreyt> (YAML::Syck handles all three ^^;) 03:16 * audreyt goes back to do $job work YAML-0.84/t/regexp.t0000644000372100001440000000352411715272433013716 0ustar matthewtusersuse t::TestYAML tests => 11; use YAML(); no warnings 'once'; my $m_xis = "m-xis"; my $_xism = "-xism"; if (qr/x/ =~ /\(\?\^/){ $m_xis = "^m"; $_xism = "^"; } my @blocks = blocks; my $block = $blocks[0]; $YAML::UseCode = 1; my $hash = YAML::Load($block->yaml); is $hash->{key}, "(?$m_xis:foo\$)", 'Regexps load'; is YAML::Dump(eval $block->perl), <<"...", 'Regexps dump'; --- key: !!perl/regexp (?$m_xis:foo\$) ... my $re = $hash->{key}; is ref($re), 'Regexp', 'The regexp is a Regexp'; like "Hello\nBarfoo", $re, 'The regexp works'; #------------------------------------------------------------------------------- $block = $blocks[1]; $hash = YAML::Load($block->yaml); is $hash->{key}, "(?$m_xis:foo\$)", 'Regexps load'; # XXX Dumper can't detect a blessed regexp # is YAML::Dump(eval $block->perl), <<"...", 'Regexps dump'; # --- # key: !!perl/regexp (?$m_xis:foo\$) # ... $re = $hash->{key}; is ref($re), 'Classy', 'The regexp is a Classy :('; # XXX Test more doesn't think a blessed regexp is a regexp (for like) # like "Hello\nBarfoo", $re, 'The regexp works'; ok(("Hello\nBarfoo" =~ $re), 'The regexp works'); #------------------------------------------------------------------------------- $block = $blocks[2]; $hash = YAML::Load($block->yaml); is $hash->{key}, "(?$_xism:foo\$)", 'Regexps load'; is YAML::Dump(eval $block->perl), <<"...", 'Regexps dump'; --- key: !!perl/regexp (?$_xism:foo\$) ... $re = $hash->{key}; is ref($re), 'Regexp', 'The regexp is a Regexp'; like "Barfoo", $re, 'The regexp works'; __END__ === A regexp with flag +++ yaml --- key: !!perl/regexp (?m-xis:foo$) +++ perl +{key => qr/foo$/m} === A blessed rexexp +++ yaml --- key: !!perl/regexp:Classy (?m-xis:foo$) +++ perl +{key => bless(qr/foo$/m, 'Classy')} === A regexp with no flag +++ yaml --- key: !!perl/regexp (?-xism:foo$) +++ perl +{key => qr/foo$/} YAML-0.84/t/bugs-emailed.t0000644000372100001440000001322211715272433014756 0ustar matthewtusersuse t::TestYAML tests => 25; no_diff; run_yaml_tests; __DATA__ === Date: Tue, 03 Jan 2006 18:04:56 +++ perl: { key1 => '>value1' } +++ yaml --- key1: '>value1' === Date: Wed, 04 Jan 2006 10:23:18 +++ perl: { key1 => '|value' } +++ yaml --- key1: '|value' === Date: Thu, 3 Mar 2005 14:12:10 +++ perl: { "foo,bar" => "baz"} +++ yaml --- 'foo,bar': baz === Date: Wed, 9 Mar 2005 09:16:19 +++ perl: {'a,v' => 'c'} +++ yaml --- 'a,v': c === Date: Fri, 18 Mar 2005 15:08:57 +++ perl: {'foo[bar', 'baz'} +++ yaml --- 'foo[bar': baz === Date: Sun, 20 Mar 2005 16:32:50 +++ subject: Argument "E5" isn't numeric in multiplication (*) +++ function: load_passes +++ yaml --- #YAML:1.0 !!perl/Blam::Game board: E5: R1 history: - 1E5 === Date: Sat, 26 Mar 2005 22:55:55 +++ perl: {"a - a" => 1} +++ yaml --- 'a - a': 1 === Date: Sun, 8 May 2005 15:42:04 +++ skip_this_for_now +++ perl: [{q => {any_key => { } }}] +++ yaml --- - /.*/: any_key: {} === Date: Thu, 12 May 2005 14:57:20 +++ function: load_passes +++ yaml --- #YAML:1.0 WilsonSereno1998: authors: - Wilson, Jeffrey. A - Paul C. Sereno title: Early evolution and Higher-level phylogeny of sauropod dinosaurs year: 1998 journal: Journal of Vertebrate Paleontology, memoir volume: 5 pages: 1-68 WedelEtAl2000: authors: - Wedel, M. J. - R. L. Cifelli - R. K. Sanders year: 2000 title: _Sauroposeidon proteles_, a new sauropod from the Early Cretaceous of Oklahoma. journal: Journal of Vertebrate Paleontology volume: 20 issue: 1 pages: 109-114 === Date: Thu, 09 Jun 2005 18:49:01 +++ perl: {'test' => '|testing'} +++ yaml --- test: '|testing' === Date: Mon, 22 Aug 2005 16:52:47 +++ skip_this_for_now +++ perl my $y = { ok_list_of_hashes => [ {one => 1}, {two => 2}, ], error_list_of_hashes => [ {-one => 1}, {-two => 2}, ], }; +++ yaml --- error_list_of_hashes: - -one: 1 - -two: 2 ok_list_of_hashes: - one: 1 - two: 2 === Date: Wed, 12 Oct 2005 17:16:48 +++ skip_this_for_now +++ function: load_passes +++ yaml fontsize_small: '9px' # labelsmall fontsize: '11px' # maintext, etc fontsize_big: '12px' # largetext, button fontsize_header: '13px' # sectionheaders fontsize_banner: '16px' # title === Date: Mon, 07 Nov 2005 15:49:07 +++ perl: \ '|something' +++ yaml --- !!perl/ref =: '|something' === Date: Thu, 24 Nov 2005 10:49:06 +++ perl: { url => 'http://www.test.com/product|1|2|333333', zzz => '' } +++ yaml --- url: http://www.test.com/product|1|2|333333 zzz: '' === Date: Sat, 3 Dec 2005 14:26:23 +++ perl my @keys = qw/001 002 300 400 500/; my $h = {}; map {$h->{$_} = 1} @keys; $h; +++ yaml --- 001: 1 002: 1 300: 1 400: 1 500: 1 YAML-0.84/t/dump-file-utf8.t0000644000372100001440000000133611715272433015171 0ustar matthewtusersuse utf8; use Test::YAML(); BEGIN { @Test::YAML::EXPORT = grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT; } use t::TestYAML tests => 6; use YAML qw/DumpFile LoadFile/; ok defined &DumpFile, 'DumpFile exported'; ok defined &LoadFile, 'LoadFile exported'; my $file = 't/dump.yaml'; # A scalar containing non-ASCII characters my $data = 'Olivier Mengué'; is length($data), 14, 'Test source is correctly encoded'; DumpFile($file, $data); ok -e $file, 'Output file exists'; open IN, '<:utf8', $file or die $!; my $yaml = do { local $/; }; close IN; is $yaml, "--- $data\n", 'DumpFile YAML encoding is correct'; my $read = LoadFile($file); is $read, $data, 'LoadFile is ok'; unlink $file; YAML-0.84/t/dump-basics.t0000644000372100001440000000143411715272433014631 0ustar matthewtusersuse t::TestYAML tests => 6; filters { perl => [qw'eval yaml_dump'], }; run_is; __DATA__ === A map +++ perl +{ foo => 'bar', baz => 'boo' } +++ yaml --- baz: boo foo: bar === A list +++ perl [ qw'foo bar baz' ] +++ yaml --- - foo - bar - baz === A List of maps +++ perl [{ foo => 42, bar => 44}, {one => 'two', three => 'four'}] +++ yaml --- - bar: 44 foo: 42 - one: two three: four === A map of lists +++ perl +{numbers => [ 5..7 ], words => [qw'five six seven']} +++ yaml --- numbers: - 5 - 6 - 7 words: - five - six - seven === Top level scalar +++ perl: 'The eagle has landed' +++ yaml --- The eagle has landed === Top level literal scalar +++ perl <<'...' sub foo { return "Don't eat the foo"; } ... +++ yaml --- | sub foo { return "Don't eat the foo"; } YAML-0.84/t/2-scalars.t0000644000372100001440000000075311715272433014214 0ustar matthewtusers# This test modified from YAML::Syck suite use strict; use Test::More tests => 9; require YAML; ok(YAML->VERSION); YAML->import; is(Dump(42), "--- 42\n"); is(Load("--- 42\n"), 42); is(Dump(undef), "--- ~\n"); is(Load("--- ~\n"), undef); is(Load("---\n"), undef); is(Load("--- ''\n"), ''); is(Load("--- true\n"), "true"); is(Load("--- false\n"), "false"); # $YAML::Syck::ImplicitTyping = $YAML::Syck::ImplicitTyping = 1; # # is(Load("--- true\n"), 1); # is(Load("--- false\n"), ''); YAML-0.84/META.yml0000644000372100001440000000136112000063154013224 0ustar matthewtusers--- abstract: "YAML Ain't Markup Language (tm)" author: - 'Ingy döt Net ' build_requires: ExtUtils::MakeMaker: 6.59 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.06' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 module_name: YAML name: YAML no_index: directory: - inc - t - xt requires: Filter::Util::Call: 0 perl: 5.8.1 resources: homepage: https://github.com/ingydotnet/yaml-pm/tree license: http://dev.perl.org/licenses/ repository: type: git url: git://github.com/ingydotnet/yaml-pm.git web: https://github.com/ingydotnet/yaml-pm/tree version: 0.84 YAML-0.84/LICENSE0000644000372100001440000004357712000063152012775 0ustar matthewtusersThis software is copyright (c) 2012 by Ingy döt Net . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012 by Ingy döt Net . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012 by Ingy döt Net . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End YAML-0.84/MANIFEST0000644000372100001440000000260412000063154013105 0ustar matthewtusersChanges inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/GithubMeta.pm inc/Module/Install/Include.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Package.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm inc/Module/Package.pm inc/Spiffy.pm inc/Test/Base.pm inc/Test/Base/Filter.pm inc/Test/Builder.pm inc/Test/Builder/Module.pm inc/Test/More.pm lib/Test/YAML.pm lib/YAML.pm lib/YAML/Any.pm lib/YAML/Dumper.pm lib/YAML/Dumper/Base.pm lib/YAML/Error.pm lib/YAML/Loader.pm lib/YAML/Loader/Base.pm lib/YAML/Marshall.pm lib/YAML/Mo.pm lib/YAML/Node.pm lib/YAML/Tag.pm lib/YAML/Types.pm LICENSE Makefile.PL MANIFEST This list of files META.yml README t/2-scalars.t t/Base.pm t/basic-tests.t t/bugs-emailed.t t/bugs-rt.t t/changes.t t/dump-basics.t t/dump-blessed.t t/dump-code.t t/dump-file-utf8.t t/dump-file.t t/dump-nested.t t/dump-opts.t t/dump-perl-types-512.t t/dump-perl-types-514.t t/dump-perl-types.t t/dump-stringify.t t/dump-tests-512.t t/dump-tests-514.t t/dump-tests.t t/dump-works.t t/errors.t t/export.t t/freeze-thaw.t t/global-api.t t/inbox.t t/load-fails.t t/load-passes.t t/load-slides.t t/load-spec.t t/load-tests.t t/load-works.t t/long-quoted-value.yaml t/marshall.t t/node-info.t t/pugs-objects.t t/references.t t/regexp.t t/svk-config.yaml t/svk.t t/test.t t/TestYAML.pm YAML-0.84/Makefile.PL0000644000372100001440000000015611715272433013744 0ustar matthewtusersBEGIN { $main::PM = 'lib/YAML.pm' } use inc::Module::Package 'Ingy:modern 0.17'; use_test_base() if is_admin; YAML-0.84/Changes0000644000372100001440000002640612000063146013256 0ustar matthewtusers--- version: 0.84 date: Fri Jul 13 18:17:27 GMT 2012 changes: - Resolve distribution error that caused .git to be shipped in the .tar.gz --- version: 0.83 date: Fri Jul 13 15:44:03 GMT 2012 changes: - Only call stat() and tell() on a filehandle if fileno existed - Explicit tied() call on globs to avoid a 5.16 deprecation warning --- version: 0.82 date: Thu Jul 12 18:49:45 GMT 2012 changes: - Test scalar @array rather than deprecated defined @array (Sebastian Stumpf) --- version: 0.81 date: Thu Apr 19 11:03:38 PDT 2012 changes: - Patch from https://rt.cpan.org/Public/Bug/Display.html?id=74826 - YAML::Mo uses Safe Mo https://rt.cpan.org/Public/Bug/Display.html?id=76664 --- version: 0.80 date: Fri Feb 10 12:56:08 PST 2012 changes: - Patch from https://rt.cpan.org/Ticket/Display.html?id=73702 - Make YAML::Node subclass YAML::Mo::Object as well as Exporter (MSTROUT) --- version: 0.79 date: Wed Feb 8 17:25:55 PST 2012 changes: - Peter Scott and others noticed Mo::xxx causing problems on newer perls. Removed xxx for now. --- version: 0.78 date: Sun Jan 1 23:53:57 PST 2012 changes: - Apply patch from ANDK++ to deal with B::Deparse changes. --- version: 0.77 date: Thu Sep 29 18:28:25 CEST 2011 changes: - Add $VERSION back to all modules. - Released from Liz++ and Wendy++ garage attic! --- version: 0.76 date: Wed Sep 28 12:05:08 CEST 2011 changes: - Removed YAML::import per mst. --- version: 0.75 date: Tue Sep 27 00:46:19 CEST 2011 changes: - Switch to Mo for OO (YAML::Mo) - use_test_base in Makefile.PL. --- version: 0.74 date: Sun Sep 25 22:05:05 CEST 2011 changes: - Switch to Module::Package - Removed extra $VERSION lines from submodules - Released from Liz++ and Wendy++'s Tool Basement! --- version: 0.73 date: Tue Apr 19 20:14:59 EST 2011 changes: - Apply ANDK's patch for 5.14.0 --- version: 0.72 date: Wed Sep 1 11:54:00 AEST 2010 changes: - Upgrade to Module::Install 1.00 - Upgraded author tests via new ADAMK release automation - Normalise Ingy's name to ASCII in Makefile.PL so that we don't have Unicode in our own META.yml --- version: 0.71 date: Sun Jan 3 12:25:00 AEST 2010 changes: - Set file encoding to UTF-8 in LoadFile/DumpFile (RT#25434) by Olivier Mengué - We shouldn't have to care about 5.8.0. Since it's causing CPAN Testers failures, bump the minimum Perl to 5.8.1 --- version: 0.70 date: Tue Aug 11 02:52:10 AEST 2009 changes: - Updated Module::Install dependency to 0.91 - Bumping dependency to 5.8.0 but I think it's only in the test suite. However, I can't prove it. So if anyone wants 5.6 compatibility back you need to fix or rewrite the test suite. --- version: 0.69_02 date: Mon Aug 10 22:37:37 AEST 2009 changes: - Developer $VERSION now has eval correction --- version: 0.69_01 date: Sun Jul 9 02:01:12 AEST 2009 changes: - Added $VERSION to all modules - Removed the use of use base - Imported into the svn.ali.as repo --- version: 0.68 date: Thu Dec 4 01:00:44 PST 2008 changes: - Used update Test::Base to ensure Filter::Util::Call --- version: 0.67 date: Mon Dec 1 02:34:21 PST 2008 changes: - Add YAML::Any - Move ysh to YAML::Shell - Add doc section explaining YAML::Old --- version: 0.66 date: Thu Sep 27 01:37:16 PDT 2007 changes: - Blessed code refs with LoadCode=0 still get blessed. rafl++ --- version: 0.65 date: Thu Jun 21 17:37:32 PDT 2007 changes: - \z is really \0 - Speed up regexp loading. audreyt++ --- version: 0.64 date: Thu Jun 21 14:31:20 PDT 2007 changes: - Better support for loading regexps. audreyt++ --- version: 0.63 date: Wed Jun 20 16:03:22 PDT 2007 changes: - Don't emit nodes blessed into '' in the new tag scheme, and improve semantics of loading such nodes. - New support for dumping/loading regexps. --- version: 0.62 date: Mon Jul 3 15:41:20 PDT 2006 changes: - Patch from rgs for Catalyst users --- version: 0.61 date: Sun Jul 2 15:25:08 CDT 2006 changes: - New CGI.pm made test fail. --- version: 0.60 date: Fri Jun 30 21:55:55 CDT 2006 changes: - Changed object tag format in non backwards compatible way - Removed support for folded scalar emission - Added new tests - Sync with YAML::Syck --- version: 0.58 date: Tue Feb 14 12:42:34 PST 2006 changes: - Fixed bug reported by Slaven Rezic on 5.8.0 - Fixed a ysh bug reported on rt. 17589 --- version: 0.57 date: Wed Feb 1 23:06:25 PST 2006 changes: - Add obligatory '1;' to end of each module. --- version: 0.56 date: Mon Jan 30 10:26:33 PST 2006 change: - Add Module::Install::TestBase support --- version: 0.55 date: Sun Jan 29 19:03:35 PST 2006 change: - Load YAML::Node because Module::Build expects it to be loaded. We can undo this when Module::Build starts loading it for itself. --- version: 0.54 date: Sun Jan 29 17:28:46 PST 2006 change: - Remove dependency on Class::Spiffy (and/or Spiffy). --- version: 0.53 date: Thu Jan 19 06:03:17 PST 2006 change: - Depend on Class::Spiffy instead of Spiffy. No source filtering. --- version: 0.52 date: Wed Jan 18 14:25:24 PST 2006 change: - Error in Spiffy-0.26 causing problems. Require 0.27 --- version: 0.51 date: Sat Jan 14 17:09:09 GMT 2006 change: - Tests pass on win32 and cygwin - Don't gpg sign the distribution tarball --- version: 0.50 date: Sun Dec 25 11:09:18 PST 2005 changes: - Major refactoring of YAML.pm - Completely OO with same old functional UI - Support the $YAML::Stringify option which most be on for objects to get stringified. Otherwise dump the object. - Can dump overloaded objects now. - Completely refactor test suite using Test::Base - Create Test::YAML - Make test framework compatible with YAML::Syck - Test-Base-0.45 - Reviewed all rt bugs. fixed many - Reviewed all emailed bugs. Fixed many. - Helped audrey complete YAML::Syck and worked on interoperability issues - Test well known yaml docs like svk and META.yml - Eliminate unsafe string evals - Can use with autouse. Spiffy-0.25 - Support YAML::Marshall to help classes that want to do their own marshalling - Make objects tags configurable - -M option for ysh to test other implementations like YAML::Syck --- version: 0.39 date: Tue Apr 12 15:28:40 PDT 2005 changes: - Need newer Test::More or tests hang. --- version: 0.38 date: Thu Mar 31 01:43:21 PST 2005 changes: - Deleted Spiffy -XXX artifact :( --- version: 0.37 date: Thu Mar 31 01:56:24 CST 2005 changes: - All the edge cases with hash key dumping (commas, [], {}, etc) should now be covered --- version: 0.36 date: Sun Jan 30 21:00:28 PST 2005 changes: - Slight changes to the way things are dumped. - Fixed bugs dumping "foo\nbar" for svk acceptance --- version: 0.32 date: Sat May 11 19:54:52 EDT 2002 changes: Moved error handling into YAML::Error --- version: 0.32 date: Mon May 6 13:42:44 EDT 2002 changes: Enabled UseAliases=0 to mean skip Dump checking of alias nodes. --- version: 0.32 date: Mon May 6 13:42:44 EDT 2002 changes: Changed Defaults. Indent=2. CompressSeries=1. --- version: 0.32 date: Mon May 6 13:42:44 EDT 2002 changes: Deprecated Store() in favor of Dump() --- version: 0.32 date: Mon Apr 22 00:57:21 EDT 2002 changes: Refactored test suite --- version: 0.32 date: Mon Apr 22 00:57:21 EDT 2002 changes: Added key list to SortKeys --- version: 0.32 date: Mon Apr 22 00:57:21 EDT 2002 changes: Added ForceBlock option --- version: 0.32 date: Sat Feb 16 17:56:27 PST 2002 changes: CONTROL-D can be used to terminate ysh. Ryan King will be happy. --- version: 0.32 date: Sun Feb 10 22:38:32 PST 2002 change: Added the ability to direct STDIN to the ysh. --- version: 0.27 date: Tue Jan 15 01:46:18 PST 2002 change: Make '-' chomp all trailing newlines --- version: 0.27 date: Tue Jan 15 01:46:18 PST 2002 change: Change folded indicator from '^' to ']'. --- version: 0.27 date: Mon Jan 14 20:30:21 PST 2002 change: YAC-010 Allow a map as a sequence entry to be collapsed to one line. --- version: 0.27 date: Mon Jan 14 16:52:27 PST 2002 change: > Changed the nextline scalar indicators. '^' means folded, and escaping ('\') can be applied to folded or blocks. Chomping is now '-'. --- version: 0.27 date: Mon Jan 14 16:52:27 PST 2002 change: > YAC-013. Generic indentation. This change was big, ugly, hard and it really made my brain hurt. But look. It works! :) --- version: 0.27 date: Mon Jan 14 16:52:27 PST 2002 change: > YAC-012. Added ability to put comments anywhere, at any indentation level. --- version: 0.27 date: Fri Jan 11 16:04:31 PST 2002 change: Added $YAML::UseBlock and $YAML::UseFold --- version: 0.27 date: Fri Jan 11 16:04:31 PST 2002 change: Changed $YAML::PerlCode to $YAML::UseCode --- version: 0.27 date: Fri Jan 11 16:04:31 PST 2002 change: Added $YAML::Indent config option --- version: 0.27 date: Thu Jan 10 15:50:06 PST 2002 change: > YAC-012. Handled all Throwaway Issues. Blank lines and comments can be used anywhere, and they will work appropriately. --- version: 0.27 date: Thu Jan 10 11:46:05 PST 2002 change: Converted Changes file (this file) to use YAML --- version: 0.27 date: Thu Jan 10 11:36:48 PST 2002 change: > YAC-016. Support "assumed header" (--- #YAML:1.0) if no header. --- version: 0.27 date: Thu Jan 10 11:36:48 PST 2002 change: Added $YAML::UseBlock option --- version: 0.27 date: Thu Jan 10 03:26:02 PST 2002 change: YAC-015. Support Top Level Inline nodes --- version: 0.27 date: Thu Jan 10 01:38:52 PST 2002 change: > Added testing for Store to test suite. (Now there's no excuse not to create lot's of new tests. :) --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Detect implicit scalars more correctly --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Refactor test suite --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Proofed documentation --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Fix ysh doc. Document flags in the pod. --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Move test code out of YAML.pm and into testlib --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Change directives to use # --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Parse regexes --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: YAC-017. Change !perl/ syntax --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Emit regexes --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: support 'ysh -v' and 'ysh -V' and 'ysh -h' --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Support blessed globs --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Make ysh installable --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Parse CODE leaves --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Support blessed scalars --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Test warnings as well as errors --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Use B::Deparse to serialize code --- version: 0.26 date: Wed Jan 9 21:13:45 PST 2002 change: Change 'implicit' to 'simple' --- version: 0.25 date: Wed Dec 19 02:34:38 PST 2001 change: Initial module shipped to CPAN --- version: 0.01 date: Mon Oct 15 19:18:49 2001 change: original version; created by h2xs 1.19 # The End (Or is it the beginning?)