From: Stevan Little Date: Fri, 23 Nov 2007 21:22:26 +0000 (+0000) Subject: cleanup some stuff before release X-Git-Tag: 0_32~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1edfdf1c2c930faea9d3b5e9fed40928fec420b0;p=gitmo%2FMoose.git cleanup some stuff before release --- diff --git a/Changes b/Changes index 96bd331..5f44414 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,6 @@ Revision history for Perl extension Moose -0.30 +0.30 Fri. Nov. 23, 2007 * Moose::Meta::Method::Constructor -builder related bug in inlined constructor. (groditi) @@ -15,6 +15,10 @@ Revision history for Perl extension Moose with work correctly. - added tests for this + * Moose::Cookbook + - adding the link to Recipie 11 (written by Sartak) + - adding test for SYNOPSIS code + * t/ - New tests for builder bug. Upon instantiation, if an attribute had a builder, no value and was not lazy the diff --git a/MANIFEST b/MANIFEST index d43b1b1..067e78c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -56,6 +56,7 @@ t/000_recipes/004_recipe.t t/000_recipes/005_recipe.t t/000_recipes/006_recipe.t t/000_recipes/007_recipe.t +t/000_recipes/011_recipe.t t/010_basics/001_basic_class_setup.t t/010_basics/002_require_superclasses.t t/010_basics/003_super_and_override.t diff --git a/Makefile.PL b/Makefile.PL index b43cdca..cb6139f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -12,13 +12,13 @@ my $win32 = !! ( $^O eq 'Win32' or $^O eq 'cygwin' ); # prereqs requires 'Scalar::Util' => $win32 ? '1.17' : '1.18'; requires 'Carp'; -requires 'Class::MOP' => '0.43'; -requires 'Sub::Name' => '0.02'; +requires 'Class::MOP' => '0.46'; +requires 'Sub::Name' => '0.02'; requires 'Sub::Exporter' => '0.972'; requires 'B'; # things the tests need -build_requires 'Test::More' => '0.62'; +build_requires 'Test::More' => '0.62'; build_requires 'Test::Exception' => '0.21'; build_requires 'Test::LongString'; diff --git a/lib/Moose.pm b/lib/Moose.pm index b3073c4..f251bcf 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -14,7 +14,7 @@ use B 'svref_2object'; use Sub::Exporter; -use Class::MOP 0.43; +use Class::MOP 0.46; use Moose::Meta::Class; use Moose::Meta::TypeConstraint; @@ -52,8 +52,7 @@ use Moose::Util::TypeConstraints; # override a specific class $meta = $class->meta(); ( blessed($meta) && $meta->isa('Moose::Meta::Class') ) - || confess -"You already have a &meta function, but it does not return a Moose::Meta::Class"; + || confess "You already have a &meta function, but it does not return a Moose::Meta::Class"; } else { # NOTE: @@ -162,32 +161,6 @@ use Moose::Util::TypeConstraints; $class->meta->add_augment_method_modifier( $name => $method ); }; }, - - # NOTE: - # this is experimental, but I am not - # happy with it. If you want to try - # it, you will have to uncomment it - # yourself. - # There is a really good chance that - # this will be deprecated, dont get - # too attached - # self => sub { - # return subname 'Moose::self' => sub {}; - # }, - # method => sub { - # my $class = $CALLER; - # return subname 'Moose::method' => sub { - # my ($name, $method) = @_; - # $class->meta->add_method($name, sub { - # my $self = shift; - # no strict 'refs'; - # no warnings 'redefine'; - # local *{$class->meta->name . '::self'} = sub { $self }; - # $method->(@_); - # }); - # }; - # }, - confess => sub { return \&Carp::confess; }, diff --git a/lib/Moose/Cookbook.pod b/lib/Moose/Cookbook.pod index a705f0d..d986a7f 100644 --- a/lib/Moose/Cookbook.pod +++ b/lib/Moose/Cookbook.pod @@ -33,6 +33,8 @@ for common questions and problems people have with Moose. =item L - The augment/inner example +=item L - The meta-attribute example + =back =head1 SEE ALSO diff --git a/lib/Moose/Cookbook/Recipe11.pod b/lib/Moose/Cookbook/Recipe11.pod index cb0aa35..c24c422 100644 --- a/lib/Moose/Cookbook/Recipe11.pod +++ b/lib/Moose/Cookbook/Recipe11.pod @@ -1,3 +1,6 @@ + +=pod + =head1 NAME Moose::Cookbook::Recipe11 - The meta-attribute example @@ -304,5 +307,3 @@ it under the same terms as Perl itself. =cut -1; - diff --git a/t/000_recipes/007_recipe.t b/t/000_recipes/007_recipe.t index 3b62cca..53d2b75 100644 --- a/t/000_recipes/007_recipe.t +++ b/t/000_recipes/007_recipe.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More no_plan => 1; +use Test::More tests => 3; use Test::Exception; BEGIN { diff --git a/t/000_recipes/011_recipe.t b/t/000_recipes/011_recipe.t new file mode 100644 index 0000000..b71ac11 --- /dev/null +++ b/t/000_recipes/011_recipe.t @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More no_plan => 1; +use Test::Exception; + +BEGIN { + use_ok('Moose'); +} + +## meta-attribute example +{ + + package MyApp::Meta::Attribute::Labeled; + use Moose; + extends 'Moose::Meta::Attribute'; + + has label => ( + is => 'rw', + isa => 'Str', + predicate => 'has_label', + ); + + package Moose::Meta::Attribute::Custom::Labeled; + sub register_implementation { 'MyApp::Meta::Attribute::Labeled' } + + package MyApp::Website; + use Moose; + + has url => ( + metaclass => 'Labeled', + isa => 'Str', + is => 'rw', + label => "The site's URL", + ); + + has name => ( + is => 'rw', + isa => 'Str', + ); + + sub dump { + my $self = shift; + + my $dump_value = ''; + + # iterate over all the attributes in $self + my %attributes = %{ $self->meta->get_attribute_map }; + while (my ($name, $attribute) = each %attributes) { + + # print the label if available + if ($attribute->isa('MyApp::Meta::Attribute::Labeled') + && $attribute->has_label) { + $dump_value .= $attribute->label; + } + # otherwise print the name + else { + $dump_value .= $name; + } + + # print the attribute's value + my $reader = $attribute->get_read_method; + $dump_value .= ": " . $self->$reader . "\n"; + } + + return $dump_value; + } + +} + +my $app = MyApp::Website->new(url => "http://google.com", name => "Google"); +is($app->dump, q{The site's URL: http://google.com +name: Google +}, '... got the expected dump value'); + +