r37127 - in /branches/upstream/libmoosex-yaml-perl: ./ current/ current/lib/ current/lib/MooseX/ current/t/

franck-guest at users.alioth.debian.org franck-guest at users.alioth.debian.org
Mon Jun 1 09:04:03 UTC 2009


Author: franck-guest
Date: Mon Jun  1 09:03:58 2009
New Revision: 37127

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=37127
Log:
[svn-inject] Installing original source of libmoosex-yaml-perl

Added:
    branches/upstream/libmoosex-yaml-perl/
    branches/upstream/libmoosex-yaml-perl/current/
    branches/upstream/libmoosex-yaml-perl/current/Changes
    branches/upstream/libmoosex-yaml-perl/current/MANIFEST
    branches/upstream/libmoosex-yaml-perl/current/MANIFEST.SKIP
    branches/upstream/libmoosex-yaml-perl/current/META.yml
    branches/upstream/libmoosex-yaml-perl/current/Makefile.PL
    branches/upstream/libmoosex-yaml-perl/current/SIGNATURE
    branches/upstream/libmoosex-yaml-perl/current/lib/
    branches/upstream/libmoosex-yaml-perl/current/lib/MooseX/
    branches/upstream/libmoosex-yaml-perl/current/lib/MooseX/YAML.pm
    branches/upstream/libmoosex-yaml-perl/current/t/
    branches/upstream/libmoosex-yaml-perl/current/t/basic.t
    branches/upstream/libmoosex-yaml-perl/current/t/fq.t

Added: branches/upstream/libmoosex-yaml-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/Changes?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/Changes (added)
+++ branches/upstream/libmoosex-yaml-perl/current/Changes Mon Jun  1 09:03:58 2009
@@ -1,0 +1,8 @@
+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

Added: branches/upstream/libmoosex-yaml-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/MANIFEST?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/MANIFEST (added)
+++ branches/upstream/libmoosex-yaml-perl/current/MANIFEST Mon Jun  1 09:03:58 2009
@@ -1,0 +1,9 @@
+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)

Added: branches/upstream/libmoosex-yaml-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/MANIFEST.SKIP?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libmoosex-yaml-perl/current/MANIFEST.SKIP Mon Jun  1 09:03:58 2009
@@ -1,0 +1,44 @@
+# 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)$

Added: branches/upstream/libmoosex-yaml-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/META.yml?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/META.yml (added)
+++ branches/upstream/libmoosex-yaml-perl/current/META.yml Mon Jun  1 09:03:58 2009
@@ -1,0 +1,23 @@
+--- #YAML:1.0
+name:               MooseX-YAML
+version:            0.03
+abstract:           ~
+author:  []
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    MooseX::Blessed::Reconstruct:  0
+    namespace::clean:     0
+    Sub::Exporter:        0.982
+    Test::use::ok:        0
+    YAML:                 0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.48
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Added: branches/upstream/libmoosex-yaml-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/Makefile.PL?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/Makefile.PL (added)
+++ branches/upstream/libmoosex-yaml-perl/current/Makefile.PL Mon Jun  1 09:03:58 2009
@@ -1,0 +1,21 @@
+#!/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,
+		'Sub::Exporter' => 0.982,
+		'namespace::clean' => 0,
+	},
+);
+

Added: branches/upstream/libmoosex-yaml-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/SIGNATURE?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/SIGNATURE (added)
+++ branches/upstream/libmoosex-yaml-perl/current/SIGNATURE Mon Jun  1 09:03:58 2009
@@ -1,0 +1,31 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.55.
+
+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 d150b1fce68dacdb15c95a7a9335f7af888245c1 Changes
+SHA1 6d448889cdc6d56d1965525392a55ca3fef72213 MANIFEST
+SHA1 190e9058eb9c6446a1a3f3ddf15b082f1ecde152 MANIFEST.SKIP
+SHA1 97cff5e31d04f9f5f8e7d141acf1ec660a7dc19b META.yml
+SHA1 7978103c7f0ba50780de658ad7e7b75e46d9c54d Makefile.PL
+SHA1 6dd1bd4d9ba1c8203495dba7d8877dcd062166a6 lib/MooseX/YAML.pm
+SHA1 0fc8dd58ff1e1354f1c769d318420362a191e50c t/basic.t
+SHA1 cc6fe78f3c240e5053fdf833180755398b8825cb t/fq.t
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.7 (Darwin)
+
+iD8DBQFJ+vHOVCwRwOvSdBgRAuoBAJ9+AlGB6V4Op2oD9pDN8gqLXbm5jwCfdgIJ
+sLiO2XLnYkJErLf7lZfYN9I=
+=9s9r
+-----END PGP SIGNATURE-----

Added: branches/upstream/libmoosex-yaml-perl/current/lib/MooseX/YAML.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/lib/MooseX/YAML.pm?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/lib/MooseX/YAML.pm (added)
+++ branches/upstream/libmoosex-yaml-perl/current/lib/MooseX/YAML.pm Mon Jun  1 09:03:58 2009
@@ -1,0 +1,158 @@
+#!/usr/bin/perl
+
+package MooseX::YAML;
+
+use strict;
+use warnings;
+
+our $VERSION = "0.03";
+
+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<Moose> based objects from YAML
+documents.
+
+Any hashes blessed into a L<Moose> class will be replaced with a properly
+constructed instance (respecting init args, C<BUILDALL>, and the meta instance
+type).
+
+This is similar to L<YAML::Active> in that certain nodes in the loaded YAML
+documented are treated specially.
+
+=head1 EXPORTS
+
+All exports are setup by L<Sub::Exporter> using currying.
+
+C<-xs>, C<-syck> or C<-pp> can be specified to specify L<YAML::XS>,
+L<YAML::Syck> or L<YAML> on a per import basis.
+
+If no driver is explicitly chosen L<YAML::XS> will be tried first, falling back
+to L<YAML>.
+
+=over 4
+
+=item Load
+
+=item LoadFile
+
+=back
+
+=head1 VERSION CONTROL
+
+This module is maintained using Darcs. You can get the latest version from
+L<http://nothingmuch.woobling.org/code>, and use C<darcs send> to commit
+changes.
+
+=head1 AUTHOR
+
+Yuval Kogman E<lt>nothingmuch at woobling.orgE<gt>
+
+=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

Added: branches/upstream/libmoosex-yaml-perl/current/t/basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/t/basic.t?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/t/basic.t (added)
+++ branches/upstream/libmoosex-yaml-perl/current/t/basic.t Mon Jun  1 09:03:58 2009
@@ -1,0 +1,79 @@
+#!/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 = <<YAML;
+--- !!perl/hash:Foo
+oh: hai
+YAML
+
+{
+	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::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" );
+}

Added: branches/upstream/libmoosex-yaml-perl/current/t/fq.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmoosex-yaml-perl/current/t/fq.t?rev=37127&op=file
==============================================================================
--- branches/upstream/libmoosex-yaml-perl/current/t/fq.t (added)
+++ branches/upstream/libmoosex-yaml-perl/current/t/fq.t Mon Jun  1 09:03:58 2009
@@ -1,0 +1,34 @@
+#!/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 = <<YAML;
+--- !!perl/hash:Foo
+oh: hai
+YAML
+
+{
+	my $obj = MooseX::YAML::Load($yml);
+
+	isa_ok( $obj, "Foo" );
+
+	is( $obj->oh, "hai", "simple attr" );
+	is( $obj->blah, 3, "default" );
+	is( $obj->extra, "yatta", "BUILD" );
+}




More information about the Pkg-perl-cvs-commits mailing list