From: Stevan Little Date: Sat, 4 Mar 2006 18:08:56 +0000 (+0000) Subject: moooooose X-Git-Tag: 0_05~113 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fcd84ca90cb39d34c25a5731fecb919b19c46afa;p=gitmo%2FMoose.git moooooose --- fcd84ca90cb39d34c25a5731fecb919b19c46afa diff --git a/Build.PL b/Build.PL new file mode 100644 index 0000000..1a4116b --- /dev/null +++ b/Build.PL @@ -0,0 +1,27 @@ +use Module::Build; + +use strict; + +my $build = Module::Build->new( + module_name => 'Moose', + license => 'perl', + requires => { + 'Scalar::Util' => '1.18', + 'Carp' => '0.01', + 'Class::MOP' => '0.20', + }, + optional => { + }, + build_requires => { + 'Test::More' => '0.47', + 'Test::Exception' => '0.21', + }, + create_makefile_pl => 'traditional', + recursive_test_files => 1, + add_to_cleanup => [ + 'META.yml', '*.bak', '*.gz', 'Makefile.PL', + ], +); + +$build->create_build_script; + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..96270c5 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,5 @@ +Revision history for Perl extension Moose + +0.01 + - Møøse + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..e69de29 diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..795aeb0 --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,18 @@ +^_build +^Build$ +^blib +~$ +\.bak$ +^MANIFEST\.SKIP$ +CVS +\.svn +\.DS_Store +cover_db +\..*\.sw.?$ +^Makefile$ +^pm_to_blib$ +^MakeMaker-\d +^blibdirs$ +\.old$ +^#.*#$ +^\.# \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..d05173f --- /dev/null +++ b/README @@ -0,0 +1,29 @@ +Moose version 0.01 +=========================== + +See the individual module documentation for more information + +INSTALLATION + +To install this module type the following: + + perl Makefile.PL + make + make test + make install + +DEPENDENCIES + +This module requires these other modules and libraries: + + None + +COPYRIGHT AND LICENCE + +Copyright (C) 2006 Infinity Interactive, Inc. + +http://www.iinteractive.com + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + diff --git a/lib/Moose.pm b/lib/Moose.pm new file mode 100644 index 0000000..ab122e3 --- /dev/null +++ b/lib/Moose.pm @@ -0,0 +1,108 @@ + +package Moose; + +use strict; +use warnings; + +our $VERSION = '0.01'; + +use Scalar::Util 'blessed'; +use Carp 'confess'; + +use Class::MOP; +use Moose::Object; + +sub import { + shift; + my $pkg = caller(); + + my $meta; + if ($pkg->can('meta')) { + $meta = $pkg->meta(); + (blessed($meta) && $meta->isa('Class::MOP::Class')) + || confess "Whoops, not møøsey enough"; + } + else { + $meta = Class::MOP::Class->initialize($pkg); + } + + $meta->alias_method('has' => sub { + my ($name, %options) = @_; + my ($init_arg) = ($name =~ /^[\$\@\%][\.\:](.*)$/); + $meta->add_attribute($name => ( + init_arg => $init_arg, + %options, + )); + }); + + $meta->superclasses('Moose::Object') + unless $meta->superclasses(); +} + +1; + +__END__ + +=pod + +=head1 NAME + +Moose - + +=head1 SYNOPSIS + + package Point; + use Moose; + + has '$.x'; + has '$.y' => (is => 'rw'); + + sub clear { + my $self = shift; + $self->x(0); + $self->y(0); + } + + package Point::3D; + use Moose; + + use base 'Point'; + + has '$:z'; + + sub clear : After { + my $self = shift; + $self->{'$:z'} = 0; + } + +=head1 DESCRIPTION + +=head1 OTHER NAMES + +=head1 BUGS + +All complex software has bugs lurking in it, and this module is no +exception. If you find a bug please either email me, or add the bug +to cpan-RT. + +=head1 CODE COVERAGE + +I use L to test the code coverage of my tests, below is the +L report on this module's test suite. + +=head1 ACKNOWLEDGEMENTS + +=head1 AUTHOR + +Stevan Little Estevan@iinteractive.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright 2006 by Infinity Interactive, Inc. + +L + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut \ No newline at end of file diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm new file mode 100644 index 0000000..6835bd2 --- /dev/null +++ b/lib/Moose/Object.pm @@ -0,0 +1,63 @@ + +package Moose::Object; + +use strict; +use warnings; +use metaclass; + +sub new { + my $class = shift; + $class->meta->new_object(@_); +} + +1; + +__END__ + +=pod + +=head1 NAME + +Moose::Object - + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=over 4 + +=item B + +=item B + +=back + +=head1 BUGS + +All complex software has bugs lurking in it, and this module is no +exception. If you find a bug please either email me, or add the bug +to cpan-RT. + +=head1 CODE COVERAGE + +I use L to test the code coverage of my tests, below is the +L report on this module's test suite. + +=head1 ACKNOWLEDGEMENTS + +=head1 AUTHOR + +Stevan Little Estevan@iinteractive.comE + +=head1 COPYRIGHT AND LICENSE + +Copyright 2006 by Infinity Interactive, Inc. + +L + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut \ No newline at end of file diff --git a/t/000_load.t b/t/000_load.t new file mode 100644 index 0000000..298e89c --- /dev/null +++ b/t/000_load.t @@ -0,0 +1,10 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 1; + +BEGIN { + use_ok('Moose'); +} \ No newline at end of file diff --git a/t/001_basic.t b/t/001_basic.t new file mode 100644 index 0000000..6bf6887 --- /dev/null +++ b/t/001_basic.t @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 15; + +BEGIN { + use_ok('Moose'); +} + +{ + package Point; + use Moose; + + has '$.x' => (reader => 'x'); + has '$.y' => (accessor => 'y'); + + sub clear { + my $self = shift; + $self->{'$.x'} = 0; + $self->y(0); + } + + package Point3D; + use Moose; + + use base 'Point'; + + has '$:z'; + + sub clear { + my $self = shift; + $self->SUPER::clear(); + $self->{'$:z'} = 0; + } + +} + +my $point = Point->new(x => 1, y => 2); +isa_ok($point, 'Point'); + +is($point->x, 1, '... got the right value for x'); +is($point->y, 2, '... got the right value for y'); + +$point->y(10); + +is($point->y, 10, '... got the right (changed) value for y'); + +$point->clear(); + +is($point->x, 0, '... got the right (cleared) value for x'); +is($point->y, 0, '... got the right (cleared) value for y'); + +my $point3d = Point3D->new(x => 10, y => 15, z => 3); +isa_ok($point3d, 'Point3D'); +isa_ok($point3d, 'Point'); + +is($point3d->x, 10, '... got the right value for x'); +is($point3d->y, 15, '... got the right value for y'); +is($point3d->{'$:z'}, 3, '... got the right value for z'); + +$point3d->clear(); + +is($point3d->x, 0, '... got the right (cleared) value for x'); +is($point3d->y, 0, '... got the right (cleared) value for y'); +is($point3d->{'$:z'}, 0, '... got the right (cleared) value for z'); diff --git a/t/pod.t b/t/pod.t new file mode 100644 index 0000000..4ae1af3 --- /dev/null +++ b/t/pod.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; + +eval "use Test::Pod 1.14"; +plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; + +all_pod_files_ok(); diff --git a/t/pod_coverage.t b/t/pod_coverage.t new file mode 100644 index 0000000..7569358 --- /dev/null +++ b/t/pod_coverage.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; + +eval "use Test::Pod::Coverage 1.04"; +plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; + +all_pod_coverage_ok();