prove -l t t/01_basic.t ...................... ok t/02_crud.t ....................... ok t/03_redirect_mode_list.t ......... ok t/04_redirect_mode_show.t ......... ok t/05_redirect_mode_show_parent.t .. ok t/06_sortable.t ................... ok All tests successful. Files=6, Tests=232, 18 wallclock secs ( 0.02 usr 0.21 sys + 10.34 cusr 6.65 csys = 17.22 CPU) Result: PASS
time for a devel release :) https://github.com/davewood/CatalystX-TraitFor-Controller-Resource documentation needs some cleaning up though On 6 December 2011 22:41, David Schmidt <[email protected]> wrote: > I added quite some tests and generally see good progress. > > However ... I just tried the LoadableClass thingy. > > the error message before i installed MooseX::Types::LoadableClass was > > # Failed test 'use TestApp;' > # at t/01_basic.t line 9. > # Tried to use 'TestApp'. > # Error: Couldn't instantiate component > "TestApp::Controller::Resource::Artist", "Could not find a class for > trait: Form at /usr/local/share/perl/5.10.1/CatalystX/Component/Traits.pm > line 145"Compilation failed in require at (eval 8) line 2. > # BEGIN failed--compilation aborted at (eval 8) line 2. > > > didnt really make sense to me > after installing MooseX::Types::LoadableClass > the error changed to > > # Failed test 'use TestApp;' > # at t/01_basic.t line 9. > # Tried to use 'TestApp'. > # Error: Couldn't instantiate component > "TestApp::Controller::Resource::Artist", "Attribute (form_class) does > not pass the type constraint because: Validation failed for > 'MooseX::Types::LoadableClass::LoadableClass' with value undef at > /usr/local/lib/perl/5.10.1/Moose/Meta/Attribute.pm line 1131 > # > Moose::Meta::Attribute::_coerce_and_verify('Moose::Meta::Attribute=HASH(0xb5b9960)', > 'Form::Resource::Artist', > 'Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0xb592450)') called at > /usr/local/lib/perl/5.10.1/Moose/Meta/Attribute.pm line 491 > # > Moose::Meta::Attribute::initialize_instance_slot('Moose::Meta::Attribute=HASH(0xb5b9960)', > 'Moose::Meta::Instance=HASH(0xb57c9c0)', > 'Moose::Meta::Class::__ANON__::SERIAL::11=HASH(0xb592450)', > 'HASH(0xb54e818)') called at > /usr/local/lib/perl/5.10.1/Class/MOP/Class.pm line 524 > # > Class::MOP::Class::_construct_instance('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xb59ba50)', > 'HASH(0xb54e818)') called at > /usr/local/lib/perl/5.10.1/Class/MOP/Class.pm line 497 > # > Class::MOP::Class::new_object('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xb59ba50)', > 'HASH(0xb54e818)') called at > /usr/local/lib/perl/5.10.1/Moose/Meta/Class.pm line 269 > # > Moose::Meta::Class::new_object('Moose::Meta::Class::__ANON__::SERIAL::5=HASH(0xb59ba50)', > 'HASH(0xb54e818)') called at > /usr/local/lib/perl/5.10.1/Moose/Object.pm line 28 > # Moose::Object::new('Moose::Meta::Class::__ANON__::SERIAL::11', > 'TestApp', 'HASH(0xb11d888)') called at constructor > CatalystX::Resource::Controller::Resource::new (defined at > /home/david/CatalystX-TraitFor-Controller-Resource/lib/CatalystX/Resource/Controller/Resource.pm > line 343) line 4 > # > CatalystX::Resource::Controller::Resource::new('Moose::Meta::Class::__ANON__::SERIAL::11', > 'TestApp', 'HASH(0xb11d888)') called at > /usr/local/share/perl/5.10.1/MooseX/Traits/Pluggable.pm line 139 > # > MooseX::Traits::Pluggable::_build_instance_with_traits('TestApp::Controller::Resource::Artist', > 'TestApp::Controller::Resource::Artist', 'TestApp') called at > /usr/local/share/perl/5.10.1/MooseX/Traits/Pluggable.pm line 97 > # > MooseX::Traits::Pluggable::new_with_traits('TestApp::Controller::Resource::Artist', > 'TestApp', 'HASH(0xb53c890)') called at > /usr/local/share/perl/5.10.1/CatalystX/Component/Traits.pm line 145 > # > CatalystX::Component::Traits::COMPONENT('TestApp::Controller::Resource::Artist', > 'TestApp', 'HASH(0xacb6948)') called at > /usr/local/share/perl/5.10.1/Catalyst.pm line 2525 > # eval {...} called at /usr/local/share/perl/5.10.1/Catalyst.pm line > 2525 > # Catalyst::setup_component('TestApp', > 'TestApp::Controller::Resource::Artist') called at > /usr/local/share/perl/5.10.1/CatalystX/InjectComponent.pm line 152 > # > CatalystX::InjectComponent::_setup_component('CatalystX::InjectComponent', > 'TestApp', 'TestApp::Controller::Resource::Artist') called at > /usr/local/share/perl/5.10.1/CatalystX/InjectComponent.pm line 142 > # CatalystX::InjectComponent::inject('CatalystX::InjectComponent', > 'into', 'TestApp', 'component', > 'CatalystX::Resource::Controller::Resource', 'as', > 'Controller::Resource::Artist') called at > /home/david/CatalystX-TraitFor-Controller-Resource/lib/CatalystX/Resource.pm > line 12 > # Class::MOP::Class:::after('TestApp') called at > /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 63 > # Class::MOP::Method::Wrapped::__ANON__('TestApp') called at > /usr/local/lib/perl/5.10.1/Class/MOP/Method/Wrapped.pm line 91 > # TestApp::setup_components('TestApp') called at > /usr/local/share/perl/5.10.1/Catalyst.pm line 1179 > # Catalyst::setup('TestApp') called at > /home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm > line 65 > # require TestApp.pm called at (eval 8) line 2 > # main::BEGIN() called at > /home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm > line 0 > # eval {...} called at > /home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm > line 0 > # eval 'package main; > # use TestApp @{$args[0]}; > # 1; > # > # ;' called at /usr/local/share/perl/5.10.1/Test/More.pm line 885 > # Test::More::_eval('package main;\x{a}use TestApp > @{$args[0]};\x{a}1;\x{a}', 'ARRAY(0xa01a5a0)') called at > /usr/local/share/perl/5.10.1/Test/More.pm line 860 > # Test::More::use_ok('TestApp') called at t/01_basic.t line 9 > # main::BEGIN() called at > /home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm > line 0 > # eval {...} called at > /home/david/CatalystX-TraitFor-Controller-Resource/t/lib/TestApp.pm > line 0"Compilation failed in require at (eval 8) line 2. > # BEGIN failed--compilation aborted at (eval 8) line 2. > > > > On 5 December 2011 16:04, David Schmidt <[email protected]> wrote: >> I updated my code so it does pretty much what CatalystX::SimpleLogin does. >> Namely to inject a Controller then applying or removing traits. >> Unlike SimpleLogin I want to be able to inject many Controllers. >> >> here is what I came up with: >> >> 1 use Catalyst qw/+CatalystX::Resource/; >> 2 >> 3 __PACKAGE__->config( >> 4 CatalystX::Resource => { >> 5 controllers => { >> 6 Artist => { >> 7 resultset_key => 'artists_rs', >> 8 resources_key => 'artists', >> 9 resource_key => 'artist', >> 10 model => 'DB:Artists', >> 11 traits => ['-Delete'], >> 12 }, >> 13 Song => { >> 14 parent_key => 'artist', >> 15 parents_accessor => 'songs', >> 16 resources_key => 'songs', >> 17 resource_key => 'song', >> 18 model => 'DB::Songs', >> 19 }, >> 20 }, >> 21 }, >> 22 ); >> 23 >> 24 after 'setup_components' => sub { >> 25 my $class = shift; >> 26 my $controllers >> 27 = $class->config->{'CatalystX::Resource'}{'controllers'}; >> 28 while (my ($controller, $config) = each(%$controllers)) { >> 29 CatalystX::InjectComponent->inject( >> 30 into => $class, >> 31 component => 'CatalystX::Resource::Controller::Resource', >> 32 as => 'Controller::Resource::' . $controller, >> 33 ); >> 34 } >> 35 }; >> >> I wonder if it works. will test it when i have the time. >> >> On 5 December 2011 12:51, David Schmidt <[email protected]> wrote: >>> Here is a simple testcase of what I did. Once i noticed that i >>> required a method defined in the same role it made sense. >>> >>> #!/usr/bin/env perl >>> >>> use strict; >>> use warnings; >>> use Test::More; >>> >>> { >>> package MyRole; >>> use Moose::Role; >>> >>> requires 'a'; >>> has a => (is => 'rw'); >>> } >>> >>> { >>> package MyClass; >>> use Moose; >>> with 'MyRole'; >>> } >>> >>> my $foo = MyClass->new({ a => 'foo' }); >>> can_ok ($foo, 'a'); >>> >>> done_testing; >>> >>> >>> 'MyRole' requires the method 'a' to be implemented by 'MyClass' at >>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application.pm line 53 >>> >>> Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)', >>> 'Moose::Meta::Role=HASH(0x9dc55e8)', >>> 'Moose::Meta::Class=HASH(0x9ce8170)') called at >>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role/Application/ToClass.pm line >>> 33 >>> >>> Moose::Meta::Role::Application::ToClass::apply('Moose::Meta::Role::Application::ToClass=HASH(0x9dc5a78)', >>> 'Moose::Meta::Role=HASH(0x9dc55e8)', >>> 'Moose::Meta::Class=HASH(0x9ce8170)', 'HASH(0x9c817c8)') called at >>> /usr/local/lib/perl/5.10.1/Moose/Meta/Role.pm line 482 >>> Moose::Meta::Role::apply('Moose::Meta::Role=HASH(0x9dc55e8)', >>> 'Moose::Meta::Class=HASH(0x9ce8170)') called at >>> /usr/local/lib/perl/5.10.1/Moose/Util.pm line 154 >>> Moose::Util::_apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)', >>> undef, 'MyRole') called at /usr/local/lib/perl/5.10.1/Moose/Util.pm >>> line 93 >>> Moose::Util::apply_all_roles('Moose::Meta::Class=HASH(0x9ce8170)', >>> 'MyRole') called at /usr/local/lib/perl/5.10.1/Moose.pm line 65 >>> Moose::with('Moose::Meta::Class=HASH(0x9ce8170)', 'MyRole') >>> called at /usr/local/lib/perl/5.10.1/Moose/Exporter.pm line 356 >>> Moose::with('MyRole') called at ./test.pl line 18 >>> >>> >>> >>> On 5 December 2011 11:58, Tomas Doran <[email protected]> wrote: >>>> >>>> On 4 Dec 2011, at 23:46, David Schmidt wrote: >>>> >>>>> just thought i'll keep you up to day so you dont waste time trying to >>>>> help with a problem i already solved. >>>>> >>>>> Turns out the error cause was in one of the roles. It required a >>>>> method declared in the same role. >>>> >>>> >>>> This has to be a Moose bug in some way. >>>> >>>> Moose should be able to complain that you are requiring a method you've >>>> already provided, and/or it shouldn't fail. >>>> >>>> Any chance of a small(ish) test case for this one? >>>> >>>> >>>> Cheers >>>> t0m >>>> >>>> >>>> _______________________________________________ >>>> List: [email protected] >>>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst >>>> Searchable archive: http://www.mail-archive.com/[email protected]/ >>>> Dev site: http://dev.catalyst.perl.org/ _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
