From 525b900f8cd814ea1c1294987bfbe8cd7543c040 Mon Sep 17 00:00:00 2001 From: Alexander Hartmaier Date: Tue, 19 Oct 2010 08:54:06 +0200 Subject: [PATCH] converted to Dist::Zilla --- Makefile.PL | 29 ---- README | 159 -------------------- dist.ini | 44 ++++++ lib/DBIx/Class/ResultSet/RecursiveUpdate.pm | 40 +---- 4 files changed, 45 insertions(+), 227 deletions(-) delete mode 100644 Makefile.PL delete mode 100644 README create mode 100644 dist.ini diff --git a/Makefile.PL b/Makefile.PL deleted file mode 100644 index c342803..0000000 --- a/Makefile.PL +++ /dev/null @@ -1,29 +0,0 @@ -use strict; -use warnings; -use inc::Module::Install 0.91; - -name 'DBIx-Class-ResultSet-RecursiveUpdate'; -author 'Zbigniew Lukasiak'; -all_from 'lib/DBIx/Class/ResultSet/RecursiveUpdate.pm'; -license 'perl'; - -repository 'http://github.com/zby/DBIx--Class--ResultSet--RecursiveUpdate/tree/master'; - -# prereqs -requires 'DBIx::Class' => '0.08103'; -requires 'DBIx::Class::IntrospectableM2M'; -requires 'SQL::Translator' => '0.11006'; -requires 'DateTime'; -requires 'DBD::SQLite' => '1.21'; -requires 'Readonly' => '1.03'; -requires 'List::MoreUtils' => '0.22'; - -# things the tests need -test_requires 'Test::More' => '0.88'; - -tests(); - -auto_install(); - -WriteAll(); - diff --git a/README b/README deleted file mode 100644 index 8a741c9..0000000 --- a/README +++ /dev/null @@ -1,159 +0,0 @@ -NAME - DBIx::Class::ResultSet::RecursiveUpdate - like update_or_create - but - recursive - -SYNOPSIS - The functional interface: - - my $new_item = DBIx::Class::ResultSet::RecursiveUpdate::Functions::recursive_update({ - resultset => $schema->resultset( 'Dvd' ), - updates => { - id => 1, - owned_dvds => [ - { - title => 'One Flew Over the Cuckoo's Nest' - } - ] - } - }); - - As ResultSet subclass: - - __PACKAGE__->load_namespaces( default_resultset_class => '+DBIx::Class::ResultSet::RecursiveUpdate' ); - - in the Schema file (see t/lib/DBSchema.pm). Or appriopriate 'use base' - in the ResultSet classes. - - Then: - - my $user = $user_rs->recursive_update( { - id => 1, - owned_dvds => [ - { - title => 'One Flew Over the Cuckoo's Nest' - } - ] - } - ); - -DESCRIPTION -This is still experimental. I've added a functional interface so that it can be used -in Form Processors and not require modification of the model. - You can feed the ->create method with a recursive datastructure and have - the related records created. Unfortunately you cannot do a similar thing - with update_or_create - this module tries to fill that void. - - It is a base class for ResultSets providing just one method: - recursive_update which works just like update_or_create but can - recursively update or create data objects composed of multiple rows. All - rows need to be identified by primary keys - so you need to provide them - in the update structure (unless they can be deduced from the parent row - - for example when you have a belongs_to relationship). If not all - colums comprising the primary key are specified - then a new row will be - created, with the expectation that the missing columns will be filled by - it (as in the case of auto_increment primary keys). - - If the resultset itself stores an assignement for the primary key, like - in the case of: - - my $restricted_rs = $user_rs->search( { id => 1 } ); - - then you need to inform recursive_update about additional predicate with - a second argument: - - my $user = $restricted_rs->recursive_update( { - owned_dvds => [ - { - title => 'One Flew Over the Cuckoo's Nest' - } - ] - }, - [ 'id' ] - ); - - This will work with a new DBIC release. - - For a many_to_many (pseudo) relation you can supply a list of primary - keys from the other table - and it will link the record at hand to those - and only those records identified by them. This is convenient for - handling web forms with check boxes (or a SELECT box with multiple - choice) that let you update such (pseudo) relations. - - For a description how to set up base classes for ResultSets see - load_namespaces in DBIx::Class::Schema. - -DESIGN CHOICES - Treatment of many to many pseudo relations - The function gets the information about m2m relations from - DBIx::Class::IntrospectableM2M. If it is not loaded in the ResultSource - classes - then the code relies on the fact that: if($object->can($name) - and !$object->result_source->has_relationship($name) and $object->can( - 'set_' . $name ) ) - - then $name must be a many to many pseudo relation. And that in a - similarly ugly was I find out what is the ResultSource of objects from - that many to many pseudo relation. - -INTERFACE -METHODS - recursive_update - The method that does the work here. - - is_m2m - $self->is_m2m( 'name ' ) - answers the question if 'name' is a many to - many (pseudo) relation on $self. - - get_m2m_source - $self->get_m2m_source( 'name' ) - returns the ResultSource linked to by - the many to many (pseudo) relation 'name' from $self. - -DIAGNOSTICS -CONFIGURATION AND ENVIRONMENT - DBIx::Class::RecursiveUpdate requires no configuration files or - environment variables. - -DEPENDENCIES - DBIx::Class - -INCOMPATIBILITIES - None reported. - -BUGS AND LIMITATIONS - No bugs have been reported. - - Please report any bugs or feature requests to - "bug-dbix-class-recursiveput@rt.cpan.org", or through the web interface - at . - -AUTHOR - Zbigniew Lukasiak "" Influenced by code by Pedro Melo. - -LICENCE AND COPYRIGHT - Copyright (c) 2008, Zbigniew Lukasiak "". All rights - reserved. - - This module is free software; you can redistribute it and/or modify it - under the same terms as Perl itself. See perlartistic. - -DISCLAIMER OF WARRANTY - BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY - FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN - OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES - PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER - EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH - YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL - NECESSARY SERVICING, REPAIR, OR CORRECTION. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING - WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR - REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE - TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR - CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF - SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - DAMAGES. - diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..94c9f5d --- /dev/null +++ b/dist.ini @@ -0,0 +1,44 @@ +name = DBIx-Class-ResultSet-RecursiveUpdate +author = Zbigniew Lukasiak +author = Alexander Hartmaier +license = Perl_5 +copyright_holder = Zbigniew Lukasiak, Alexander Hartmaier +copyright_year = 2010 + +version = 0.199901 + +[@Basic] + +[PodWeaver] +[PkgVersion] +[NextRelease] +[MetaConfig] +[MetaJSON] + +[MetaNoIndex] +directory = t/lib + +[MetaResources] +repository.type = git +repository.url = git://github.com/zby/DBIx--Class--ResultSet--RecursiveUpdate.git +repository.web = http://github.com/zby/DBIx--Class--ResultSet--RecursiveUpdate + +[PodSyntaxTests] +[PodCoverageTests] +[PortabilityTests] +[DistManifestTests] +[SynopsisTests] +[UnusedVarsTests] +[HasVersionTests] + +[Prereqs] +DBIx::Class = 0.08103 +DBIx::Class::IntrospectableM2M = 0 +SQL::Translator = 0.11006 +DateTime = 0 +DBD::SQLite = 1.21 +Readonly = 1.03 +List::MoreUtils = 0.22 + +[Prereqs / TestRequires] +Test::More = 0.88 \ No newline at end of file diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index c0be5cd..84b61c4 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -2,8 +2,7 @@ use strict; use warnings; package DBIx::Class::ResultSet::RecursiveUpdate; - -our $VERSION = '0.013'; +# ABSTRACT: like update_or_create - but recursive use base qw(DBIx::Class::ResultSet); @@ -776,40 +775,3 @@ No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. - - -=head1 AUTHOR - -Zbigniew Lukasiak C<< >> -Influenced by code by Pedro Melo. - -=head1 LICENCE AND COPYRIGHT - -Copyright (c) 2008, Zbigniew Lukasiak C<< >>. All rights reserved. - -This module is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. See L. - - -=head1 DISCLAIMER OF WARRANTY - -BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE -ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH -YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL -NECESSARY SERVICING, REPAIR, OR CORRECTION. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE -LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, -OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE -THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. -- 2.45.2