MooseX-YAML-0.04/000755 000765 000024 00000000000 11333067513 015077 5ustar00nothingmuchstaff000000 000000 MooseX-YAML-0.04/Changes000644 000765 000024 00000000417 11333067470 016376 0ustar00nothingmuchstaff000000 000000 0.04 - specify explicit version dependency on MooseX::Blessed::Reconstruct 0.03 - Sub::Exporter provides undef for the flags, check for existence instead 0.02 - Add support for fully qualified functions (i.e. MooseX::YAML::Load) 0.01 - Initial release MooseX-YAML-0.04/lib/000755 000765 000024 00000000000 11333067513 015645 5ustar00nothingmuchstaff000000 000000 MooseX-YAML-0.04/Makefile.PL000644 000765 000024 00000000574 11333067420 017054 0ustar00nothingmuchstaff000000 000000 #!/usr/bin/perl -w use strict; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'MooseX::YAML', VERSION_FROM => 'lib/MooseX/YAML.pm', INSTALLDIRS => 'site', SIGN => 1, PL_FILES => { }, PREREQ_PM => { 'Test::use::ok' => 0, 'YAML' => 0, 'MooseX::Blessed::Reconstruct' => '0.03', 'Sub::Exporter' => '0.982', 'namespace::clean' => 0, }, ); MooseX-YAML-0.04/MANIFEST000644 000765 000024 00000000406 11333067513 016230 0ustar00nothingmuchstaff000000 000000 Changes lib/MooseX/YAML.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP t/basic.t t/fq.t META.yml Module meta-data (added by MakeMaker) SIGNATURE Public-key signature (added by MakeMaker) MooseX-YAML-0.04/MANIFEST.SKIP000644 000765 000024 00000001125 11131764005 016770 0ustar00nothingmuchstaff000000 000000 # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \b_darcs\b # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ # Avoid Devel::Cover files. \bcover_db\b ### DEFAULT MANIFEST.SKIP ENDS HERE #### \.DS_Store$ \.sw.$ (\w+-)*(\w+)-\d\.\d+(?:\.tar\.gz)?$ \.t\.log$ \.prove$ # XS shit \.(?:bs|c|o)$ MooseX-YAML-0.04/META.yml000644 000765 000024 00000001160 11333067513 016346 0ustar00nothingmuchstaff000000 000000 --- #YAML:1.0 name: MooseX-YAML version: 0.04 abstract: ~ author: [] license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: MooseX::Blessed::Reconstruct: 0.03 namespace::clean: 0 Sub::Exporter: 0.982 Test::use::ok: 0 YAML: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 MooseX-YAML-0.04/SIGNATURE000644 000765 000024 00000002251 11333067513 016363 0ustar00nothingmuchstaff000000 000000 This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.61. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 df434963e78cea89fef16e098b17e7701bc83b67 Changes SHA1 6d448889cdc6d56d1965525392a55ca3fef72213 MANIFEST SHA1 190e9058eb9c6446a1a3f3ddf15b082f1ecde152 MANIFEST.SKIP SHA1 07b8fae838528c7b1bab7c54ecb7ced9d98d097e META.yml SHA1 3baba7e5c087c76e2edfe77294f702fbd85e047b Makefile.PL SHA1 e5cf06352706253d08f715b06a09f0f6af4fad64 lib/MooseX/YAML.pm SHA1 0fc8dd58ff1e1354f1c769d318420362a191e50c t/basic.t SHA1 cc6fe78f3c240e5053fdf833180755398b8825cb t/fq.t -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.12 (Darwin) iEYEARECAAYFAktsb0sACgkQVCwRwOvSdBiIUgCgtBRuFsQk+obYz/Gf9jxPQQ+3 bUcAmwc8jAFhoEcTmiQBbefnZJ0FI72f =ZcgJ -----END PGP SIGNATURE----- MooseX-YAML-0.04/t/000755 000765 000024 00000000000 11333067513 015342 5ustar00nothingmuchstaff000000 000000 MooseX-YAML-0.04/t/basic.t000644 000765 000024 00000002570 11131764005 016610 0ustar00nothingmuchstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'MooseX::YAML' => qw(Load); { package Foo; use Moose; has oh => ( is => "ro", isa => "Str" ); has blah => ( is => "ro", default => 3 ); has extra => ( is => "rw" ); sub BUILD { shift->extra("yatta") } } my $yml = <oh, "hai", "simple attr" ); is( $obj->blah, 3, "default" ); is( $obj->extra, "yatta", "BUILD" ); } SKIP: { skip "YAML::XS required", 4 unless eval { require YAML::XS }; package XS_test; MooseX::YAML->import(qw(Load -xs)); my $obj = Load($yml); ::isa_ok( $obj, "Foo" ); ::is( $obj->oh, "hai", "simple attr" ); ::is( $obj->blah, 3, "default" ); ::is( $obj->extra, "yatta", "BUILD" ); } SKIP: { skip "YAML::Syck required", 4 unless eval { require YAML::Syck }; package Syck_test; MooseX::YAML->import(qw(Load -syck)); my $obj = Load($yml); ::isa_ok( $obj, "Foo" ); ::is( $obj->oh, "hai", "simple attr" ); ::is( $obj->blah, 3, "default" ); ::is( $obj->extra, "yatta", "BUILD" ); } SKIP: { skip "YAML required", 4 unless eval { require YAML }; package PP_test; MooseX::YAML->import(qw(Load -pp)); my $obj = Load($yml); ::isa_ok( $obj, "Foo" ); ::is( $obj->oh, "hai", "simple attr" ); ::is( $obj->blah, 3, "default" ); ::is( $obj->extra, "yatta", "BUILD" ); } MooseX-YAML-0.04/t/fq.t000644 000765 000024 00000001000 11131764005 016120 0ustar00nothingmuchstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; require_ok 'MooseX::YAML'; { package Foo; use Moose; has oh => ( is => "ro", isa => "Str" ); has blah => ( is => "ro", default => 3 ); has extra => ( is => "rw" ); sub BUILD { shift->extra("yatta") } } my $yml = <oh, "hai", "simple attr" ); is( $obj->blah, 3, "default" ); is( $obj->extra, "yatta", "BUILD" ); } MooseX-YAML-0.04/lib/MooseX/000755 000765 000024 00000000000 11333067513 017057 5ustar00nothingmuchstaff000000 000000 MooseX-YAML-0.04/lib/MooseX/YAML.pm000644 000765 000024 00000005766 11333067443 020177 0ustar00nothingmuchstaff000000 000000 #!/usr/bin/perl package MooseX::YAML; use strict; use warnings; our $VERSION = "0.04"; use Carp qw(croak); use MooseX::Blessed::Reconstruct; my $v; sub fixup { ($v ||= MooseX::Blessed::Reconstruct->new)->visit(@_) } use namespace::clean; use Sub::Exporter -setup => { exports => [qw(Load LoadFile)], collectors => [ "-xs", "-syck", "-pp" ], generator => sub { foreach my $export ( @_ ) { my $r = $export->{class}->_resolve($export->{name}, $export->{col}); return sub { fixup( $r->(@_) ) }; } }, }; sub _resolve { my ( $class, $routine, $flags ) = @_; if ( keys %$flags ) { croak "Can't use more than one of -xs, -syck or -pp" if keys %$flags > 1; if ( exists $flags->{-xs} ) { require YAML::XS; return YAML::XS->can($routine); } elsif ( exists $flags->{-syck} ) { require YAML::Syck; return YAML::Syck->can($routine); } else { require YAML; return YAML->can($routine); } } else { my $drv = ( do { local $@; eval { require YAML::XS; "YAML::XS" } } or require YAML && "YAML" ); return $drv->can($routine) || croak "Can't find a provided for $routine (fallback is $drv)"; } } my $load; sub Load { $load ||= __PACKAGE__->_resolve("Load"); fixup( $load->(@_) ); } my $loadfile; sub LoadFile { $loadfile ||= __PACKAGE__->_resolve("LoadFile"); fixup( $loadfile->(@_) ); } __PACKAGE__ __END__ =pod =head1 NAME MooseX::YAML - DWIM loading of Moose objects from YAML =head1 SYNOPSIS # given some class: package My::Module; use Moose; has package => ( is => "ro", init_arg => "name", ); has version => ( is => "rw", init_arg => undef, ); sub BUILD { shift->version(3) } # load an object like so: use MooseX::YAML qw(Load -xs); my $obj = Load(<<'YAML'); --- !My::Module # this syntax requires YAML::XS name: "MooseX::YAML" YAML $obj->package; # "MooseX::YAML" $obj->version; # 3, BUILD was called =head1 DESCRIPTION This module provides DWIM loading of L based objects from YAML documents. Any hashes blessed into a L class will be replaced with a properly constructed instance (respecting init args, C, and the meta instance type). This is similar to L in that certain nodes in the loaded YAML documented are treated specially. =head1 EXPORTS All exports are setup by L using currying. C<-xs>, C<-syck> or C<-pp> can be specified to specify L, L or L on a per import basis. If no driver is explicitly chosen L will be tried first, falling back to L. =over 4 =item Load =item LoadFile =back =head1 VERSION CONTROL This module is maintained using Darcs. You can get the latest version from L, and use C to commit changes. =head1 AUTHOR Yuval Kogman Enothingmuch@woobling.orgE =head1 COPYRIGHT Copyright (c) 2008 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut