Array-To-Moose
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
module_name => 'Array::To::Moose',
license => 'perl',
dist_author => 'Sam Brain <samb@stanford.edu>',
dist_version_from => 'lib/Array/To/Moose.pm',
requires => {
'Array::GroupBy' => 0,
'Moose' => 0,
'MooseX::StrictConstructor' => 0,
'Params::Validate::Array' => 0,
'Carp' => 0,
'namespace::autoclean' => 0,
'Test::More' => 0,
'Data::Dumper' => 0,
'version' => 0,
},
configure_requires => {
'Module::Build' => 0.38
},
add_to_cleanup => [ 'Array-To-Moose-*' ],
},
"runtime" : {
"requires" : {
"Array::GroupBy" : "0",
"Carp" : "0",
"Data::Dumper" : "0",
"Moose" : "0",
"MooseX::StrictConstructor" : "0",
"Params::Validate::Array" : "0",
"Test::More" : "0",
"namespace::autoclean" : "0",
"version" : "0"
}
}
},
"provides" : {
"Array::To::Moose" : {
"file" : "lib/Array/To/Moose.pm",
"version" : "v0.0.9"
}
},
file: lib/Array/To/Moose.pm
version: v0.0.9
requires:
Array::GroupBy: 0
Carp: 0
Data::Dumper: 0
Moose: 0
MooseX::StrictConstructor: 0
Params::Validate::Array: 0
Test::More: 0
namespace::autoclean: 0
version: 0
resources:
license: http://dev.perl.org/licenses/
version: v0.0.9
./Build test
./Build install
DEPENDENCIES
Moose
MooseX::StrictConstructor
Params::Validate
Carp
namespace::autoclean
Test::More
Data::Dumper
TODO
(1) Smarten up type contstraint handling a la Moose::Util::TypeConstraints
Currently only handles 'Str', 'Int', etc.
COPYRIGHT AND LICENCE
Copyright (C) 2012, Sam Brain <samb@stanford.edu>
my $n1 = [ 1, 1, 1 ];
my $n2 = [ 2, 2, 2 ];
my $n3 = [ 3, 3, 3 ];
my $n4 = [ 4, 4, 4 ];
my $data = [ $n1, $n2, $n3, $n4 ];
#----------------------------------------
package Person;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has [ qw( last first gender ) ] => (is => 'rw', isa => 'Str');
__PACKAGE__->meta->make_immutable;
#----------------------------------------
package Person_w_Aliases;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
extends 'Person';
has 'aliases' => (is => 'ro', isa => 'ArrayRef[Str]');
__PACKAGE__->meta->make_immutable;
#----------------------------------------
package Person_w_Visit;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
extends 'Person';
has 'Visits' => (is => 'ro', isa => 'ArrayRef[Visit]');
__PACKAGE__->meta->make_immutable;
#----------------------------------------
package Person_w_Aliases_n_Visit;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
extends 'Person_w_Visit';
has 'aliases' => (is => 'ro', isa => 'ArrayRef[Str]');
__PACKAGE__->meta->make_immutable;
package main;
BEGIN {
eval "use Test::Exception";
plan skip_all => "Test::Exception needed" if $@;
}
plan tests => 11;
#----------------------------------------
package Sibling;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has [ qw( name sex ) ] => (is => 'rw', isa => 'Str' );
__PACKAGE__->meta->make_immutable;
#----------------------------------------
package Cousin;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has [ qw( name sex ) ] => (is => 'rw', isa => 'Str' );
__PACKAGE__->meta->make_immutable;
#----------------------------------------
package Person;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has [ qw( name sex ) ] => (is => 'rw', isa => 'Str' );
has SibH => (is => 'rw', isa => 'HashRef[Sibling]' );
has SibA => (is => 'rw', isa => 'ArrayRef[Sibling]');
has SibB => (is => 'rw', isa => 'Sibling'); # (B)are
__PACKAGE__->meta->make_immutable;
BEGIN {
eval "use Test::Exception";
plan skip_all => "Test::Exception needed" if $@;
}
plan tests => 1;
#----------------------------------------
package Person;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has 'name' => (is => 'rw', isa => 'Str' );
has 'sibling' => (is => 'rw', isa => 'Maybe[Str]' );
__PACKAGE__->meta->make_immutable;
package main;
BEGIN {
eval "use Test::Exception";
plan skip_all => "Test::Exception needed" if $@;
}
plan tests => 12;
#----------------------------------------
package Person;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has [ qw( name gender ) ] => (is => 'rw', isa => 'Str' );
has hobbies => (is => 'rw', isa => 'ArrayRef[Str]');
__PACKAGE__->meta->make_immutable;
package main;
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Array::To::Moose qw (:ALL :TESTING);
package Patient;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has [ qw(last first) ] => (is => 'ro', isa => 'Str');
__PACKAGE__->meta->make_immutable;
package main;
sub Npat { Patient->new(last => $_[0], first => $_[1] ) }
# patients
use Array::To::Moose qw (:ALL :TESTING);
# change keywords "class" to "_CLASS_" and "key" to "_KEY_"
set_class_ind('_CLASS_');
set_key_ind('_KEY_');
package Patient;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has [ qw(last first) ] => (is => 'ro', isa => 'Str');
__PACKAGE__->meta->make_immutable;
package main;
sub Npat { Patient->new(last => $_[0], first => $_[1] ) }
# patients
use Array::To::Moose qw (:ALL);
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Carp;
package Person;
use Moose;
use namespace::autoclean;
use MooseX::StrictConstructor;
has last => (is => 'ro', isa => 'Str');
has first => (is => 'ro', isa => 'Str');
has hobbies => (is => 'ro', isa => 'ArrayRef[Str]');
__PACKAGE__->meta->make_immutable;
package main;
sub Npat { Person->new(last => $_[0], first => $_[1], hobbies => $_[2] ) }
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Carp;
#------------
package Test;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has 'name' => (is => 'rw', isa => 'Str');
has 'result' => (is => 'rw', isa => 'Str');
#------------
package Visit;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has 'date' => (is => 'rw', isa => 'Str' );
has 'md' => (is => 'rw', isa => 'Str' );
has 'diagnosis' => (is => 'rw', isa => 'Str' );
has 'Tests' => (is => 'rw', isa => 'HashRef[Test]' );
#------------
package Patient;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has 'last' => (is => 'rw', isa => 'Str' );
has 'first' => (is => 'rw', isa => 'Str' );
has 'Visits' => (is => 'rw', isa => 'ArrayRef[Visit]' );
Test ->meta->make_immutable;
Visit ->meta->make_immutable;
Patient->meta->make_immutable;
package main;
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Carp;
#------------
package Test;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has 'name' => (is => 'rw', isa => 'Str');
has 'result' => (is => 'rw', isa => 'Num');
#------------
package Visit;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has 'date' => (is => 'rw', isa => 'Str' );
has 'md' => (is => 'rw', isa => 'Str' );
has 'Tests' => (is => 'rw', isa => 'ArrayRef[Test]' );
#------------
package Patient;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has 'last' => (is => 'rw', isa => 'Str' );
has 'first' => (is => 'rw', isa => 'Str' );
has 'Visits' => (is => 'rw', isa => 'ArrayRef[Visit]' );
Test ->meta->make_immutable;
Visit ->meta->make_immutable;
Patient->meta->make_immutable;
package main;
eval "use Test::Exception";
plan skip_all => "Test::Exception needed" if $@;
}
plan tests => 11;
#----------------------------------------
package Patient;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has [ qw(last first gender) ] => (is => 'rw', isa => 'Str');
__PACKAGE__->meta->make_immutable;
package main;
my $data = [ [1, 2, 3, 4] ];
throws_ok { array_to_moose ( data => $data,
desc => { class => 'Patient' }
)
} qr/no attributes with column numbers in descriptor:/,
"no numeric attributes";
#----------------------------------------
# using set_class_ind()
package ObjWclass;
use Moose;
use MooseX::StrictConstructor;
use namespace::autoclean;
has [ qw(class other) ] => (is => 'rw', isa => 'Str');
__PACKAGE__->meta->make_immutable;
package main;
throws_ok { array_to_moose ( data => $data,
desc => { class => 'ObjWclass', other => 0 }
)
plan tests => 3;
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Carp;
package Employer;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has 'year' => (is => 'rw', isa => 'Str');
has 'name' => (is => 'rw', isa => 'Str');
__PACKAGE__->meta->make_immutable;
package Person;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has 'name' => (is => 'rw', isa => 'Str' );
has 'Employers' => (is => 'rw', isa => 'HashRef[Employer]');
__PACKAGE__->meta->make_immutable;
package main;
plan tests => 3;
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Carp;
package Salary;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has 'year' => (is => 'rw', isa => 'Str');
has 'amount' => (is => 'rw', isa => 'Int');
__PACKAGE__->meta->make_immutable;
package Person;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has 'name' => (is => 'rw', isa => 'Str' );
has 'Salary' => (is => 'rw', isa => 'Salary'); # a single object
__PACKAGE__->meta->make_immutable;
package main;
plan tests => 2;
eval 'use VarianReportsMoose qw(print_obj)';
use Data::Dumper;
use Carp;
package Point;
use namespace::autoclean;
use Moose;
use MooseX::StrictConstructor;
has 'x' => (is => 'ro', isa => 'Int');
has 'y' => (is => 'ro', isa => 'Int');
__PACKAGE__->meta->make_immutable;
package main;
sub Npt { Point->new(x => $_[0], y => $_[1]) }
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.002 second using v1.00-cache-2.02-grep-82fe00e-cpan-c98054f2a92 )