DBIx-Class-Candy-0.002104000755001750001750 012144174323 13717 5ustar00frewfrew000000000000README100644001750001750 1644012144174323 14705 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104NAME DBIx::Class::Candy - Sugar for your favorite ORM, DBIx::Class SYNOPSIS package MyApp::Schema::Result::Artist; use DBIx::Class::Candy -autotable => v1; primary_column id => { data_type => 'int', is_auto_increment => 1, }; column name => { data_type => 'varchar', size => 25, is_nullable => 1, }; has_many albums => 'A::Schema::Result::Album', 'artist_id'; 1; DESCRIPTION "DBIx::Class::Candy" is a simple sugar layer for definition of DBIx::Class results. Note that it may later be expanded to add sugar for more "DBIx::Class" related things. By default "DBIx::Class::Candy": * turns on strict and warnings * sets your parent class * exports a bunch of the package methods that you normally use to define your DBIx::Class results * makes a few aliases to make some of the original method names a shorter or more clear * defines very few new subroutines that transform the arguments passed to them It assumes a DBIx::Class::Core-like API, but you can tailor it to suit your needs. IMPORT OPTIONS See "SETTING DEFAULT IMPORT OPTIONS" for information on setting these schema wide. -base use DBIx::Class::Candy -base => 'MyApp::Schema::Result'; The first thing you can do to customize your usage of "DBIx::Class::Candy" is change the parent class. Do that by using the "-base" import option. -autotable use DBIx::Class::Candy -autotable => v1; Don't waste your precious keystrokes typing "table 'buildings'", let "DBIx::Class::Candy" do that for you! See "AUTOTABLE VERSIONS" for what the existing versions will generate for you. -components use DBIx::Class::Candy -components => ['FilterColumn']; "DBIx::Class::Candy" allows you to set which components you are using at import time so that the components can define their own sugar to export as well. See DBIx::Class::Candy::Exports for details on how that works. -perl5 use DBIx::Class::Candy -perl5 => v10; I love the new features in Perl 5.10 and 5.12, so I felt that it would be nice to remove the boiler plate of doing "use feature ':5.10'" and add it to my sugar importer. Feel free not to use this. IMPORTED SUBROUTINES Most of the imported subroutines are the same as what you get when you use the normal interface for result definition: they have the same names and take the same arguments. In general write the code the way you normally would, leaving out the "__PACKAGE__->" part. The following are methods that are exported with the same name and arguments: belongs_to has_many has_one inflate_column many_to_many might_have remove_column remove_columns resultset_attributes resultset_class sequence source_name table There are some exceptions though, which brings us to: IMPORTED ALIASES These are merely renamed versions of the functions you know and love. The idea is to make your result classes a tiny bit prettier by aliasing some methods. If you know your "DBIx::Class" API you noticed that in the "SYNOPSIS" I used "column" instead of "add_columns" and "primary_key" instead of "set_primary_key". The old versions work, this is just nicer. A list of aliases are as follows: column => 'add_columns', primary_key => 'set_primary_key', unique_constraint => 'add_unique_constraint', relationship => 'add_relationship', SETTING DEFAULT IMPORT OPTIONS Eventually you will get tired of writing the following in every single one of your results: use DBIx::Class::Candy -base => 'MyApp::Schema::Result', -perl5 => v12, -autotable => v1; You can set all of these for your whole schema if you define your own "Candy" subclass as follows: package MyApp::Schema::Candy; use base 'DBIx::Class::Candy'; sub base { $_[1] || 'MyApp::Schema::Result' } sub perl_version { 12 } sub autotable { 1 } Note the "$_[1] ||" in "base". All of these methods are passed the values passed in from the arguments to the subclass, so you can either throw them away, honor them, die on usage, or whatever. To be clear, if you define your subclass, and someone uses it as follows: use MyApp::Schema::Candy -base => 'MyApp::Schema::Result', -perl5 => v18, -autotable => v1; Your "base" method will get "MyApp::Schema::Result", your "perl_version" will get 18, and your "autotable" will get 1. SECONDARY API has_column There is currently a single "transformer" for "add_columns", so that people used to the Moose api will feel more at home. Note that this may go into a "Candy Component" at some point. Example usage: has_column foo => ( data_type => 'varchar', size => 25, is_nullable => 1, ); primary_column Another handy little feature that allows you to define a column and set it as the primary key in a single call: primary_column id => { data_type => 'int', is_auto_increment => 1, }; If your table has multiple columns in its primary key, merely call this method for each column: primary_column person_id => { data_type => 'int' }; primary_column friend_id => { data_type => 'int' }; unique_column This allows you to define a column and set it as unique in a single call: unique_column name => { data_type => 'varchar', size => 30, }; AUTOTABLE VERSIONS Currently there is a single version, "v1", which looks at your class name, grabs everything after "::Schema::Result::" (or "::Result::"), removes the "::"'s, converts it to underscores instead of camel-case, and pluralizes it. Here are some examples if that's not clear: MyApp::Schema::Result::Cat -> cats MyApp::Schema::Result::Software::Building -> software_buildings MyApp::Schema::Result::LonelyPerson -> lonely_people MyApp::DB::Result::FriendlyPerson -> friendly_people MyApp::DB::Result::Dog -> dogs Also, if you just want to be different, you can easily set up your own naming scheme. Just add a "gen_table" method to your candy subclass. The method gets passed the class name and the autotable version, which of course you may ignore. For example, one might just do the following: sub gen_table { my ($self, $class) = @_; $class =~ s/::/_/g; lc $class; } Which would tranform "MyApp::Schema::Result::Foo" into "myapp_schema_result_foo". Or maybe instead of using the standard "MyApp::Schema::Result" namespace you decided to be different and do "MyApp::DB::Table" or something silly like that. You could pre-process your class name so that the default "gen_table" will still work: sub gen_table { my $self = shift; my $class = $_[0]; $class =~ s/::DB::Table::/::Schema::Result::/; return $self->next::method(@_); } AUTHOR Arthur Axel "fREW" Schmidt COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes100644001750001750 315212144174323 15274 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104Revision history for DBIx-Class-Candy 0.002104 2013-05-13 09:29:37 CST6CDT - Fix stupid doc examples 0.002103 2012-12-23 17:42:36 CST6CDT - Lazily load deps for autotable - Remove HERE BE DRAGONS warning, this module is totally stable \o/ 0.002102 2012-11-17 15:43:18 CST6CDT - Put MetaYAML back in dist 0.002101 2012-08-21 17:47:50 America/Chicago - remove VERSION from pod because yuck - fix repo url 0.002100 2012-03-13 20:31:45 America/Chicago - primary_column may be called multiple times to define a multicolumn pk 0.002001 2011-08-10 20:03:18 CST6CDT - autotable v1 now dies on unrecognized naming scheme - autotable v1 works with simply ::Result:: and not just ::Schema::Result:: 0.002000 2011-03-09 12:03:50 CST6CDT - Add unique_column sugar - Allow Candy to automatically set table name - Allow Candy subclass to define default base and default perl version - Add missing docs for primary_column sugar 0.001006 2011-03-01 22:44:45 CST6CDT - Add primary_column sugar - Fix incorrectly named export (inflate_colum .= n) 0.001005 2010-12-25 10:06:15 CST6CDT - Initial sketches of "Moosey" API - Merry Christmas!!! 0.001004 2010-07-31 01:46:04 CST6CDT - Fix a bug that only appears in perl 5.8 0.001003 2010-07-29 20:20:14 CST6CDT - Fix more bugs, this time the are from inheriting from other other results - Make ::Exports actually work 0.001002 2010-07-24 01:21:49 CST6CDT - Fix bug uncovered by doing belongs_to twice in a class 0.001001 2010-07-21 17:48:14 CST6CDT - Don't require parent for tests 0.001000 2010-07-21 00:18:10 CST6CDT - Initial Release LICENSE100644001750001750 4372512144174323 15040 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644001750001750 127512144174323 15451 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104name = DBIx-Class-Candy author = Arthur Axel "fREW" Schmidt license = Perl_5 copyright_holder = Arthur Axel "fREW" Schmidt version = 0.002104 [NextRelease] [@Git] [@Basic] [MetaResources] repository.url = git://github.com/frioux/DBIx-Class-Candy.git repository.web = http://github.com/frioux/DBIx-Class-Candy repository.type = git [MetaJSON] [PodWeaver] [OurPkgVersion] [ReadmeFromPod] [PodSyntaxTests] [Prereqs] DBIx::Class = 0.08123 Sub::Exporter = 0.982 Test::More = 0.94 Test::Fatal = 0 Test::Deep = 0 namespace::clean = 0.18 MRO::Compat = 0.11 String::CamelCase = 0 Lingua::EN::Inflect = 0 META.yml100644001750001750 130512144174323 15250 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104--- abstract: 'Sugar for your favorite ORM, DBIx::Class' author: - "Arthur Axel \"fREW\" Schmidt " build_requires: {} configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300034, CPAN::Meta::Converter version 2.130880' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: DBIx-Class-Candy requires: DBIx::Class: 0.08123 Lingua::EN::Inflect: 0 MRO::Compat: 0.11 String::CamelCase: 0 Sub::Exporter: 0.982 Test::Deep: 0 Test::Fatal: 0 Test::More: 0.94 namespace::clean: 0.18 resources: repository: git://github.com/frioux/DBIx-Class-Candy.git version: 0.002104 MANIFEST100644001750001750 126312144174323 15133 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/DBIx/Class/Candy.pm lib/DBIx/Class/Candy/Exports.pm t/autotable.t t/imports.t t/irc-schema.t t/lib/A/Component.pm t/lib/A/Schema.pm t/lib/A/Schema/Candy.pm t/lib/A/Schema/Result.pm t/lib/A/Schema/Result/Album.pm t/lib/A/Schema/Result/Artist.pm t/lib/A/Schema/Result/Song.pm t/lib/A/Schema/Result/Statistic.pm t/lib/IRC/Schema.pm t/lib/IRC/Schema/Candy.pm t/lib/IRC/Schema/Result.pm t/lib/IRC/Schema/Result/Channel.pm t/lib/IRC/Schema/Result/Message.pm t/lib/IRC/Schema/Result/Mode.pm t/lib/IRC/Schema/Result/Network.pm t/lib/IRC/Schema/Result/User.pm t/lib/IRC/Schema/ResultSet.pm t/release-pod-syntax.t weaver.ini META.json100644001750001750 247212144174323 15426 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104{ "abstract" : "Sugar for your favorite ORM, DBIx::Class", "author" : [ "Arthur Axel \"fREW\" Schmidt " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300034, CPAN::Meta::Converter version 2.130880", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "DBIx-Class-Candy", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "DBIx::Class" : "0.08123", "Lingua::EN::Inflect" : "0", "MRO::Compat" : "0.11", "String::CamelCase" : "0", "Sub::Exporter" : "0.982", "Test::Deep" : "0", "Test::Fatal" : "0", "Test::More" : "0.94", "namespace::clean" : "0.18" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "git://github.com/frioux/DBIx-Class-Candy.git", "web" : "http://github.com/frioux/DBIx-Class-Candy" } }, "version" : "0.002104" } weaver.ini100644001750001750 24212144174323 15750 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104[@CorePrep] [Name] [Region / prelude] [Generic / SYNOPSIS] [Generic / DESCRIPTION] [Generic / OVERVIEW] [Leftovers] [Region / postlude] [Authors] [Legal] t000755001750001750 012144174323 14103 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104imports.t100644001750001750 137512144174323 16133 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/tuse strict; use warnings; use Test::More; use lib 't/lib'; use A::Schema; use A::Schema::Result::Album; use A::Schema::Result::Statistic; my $result_class = A::Schema->resultset('Album')->result_class; isa_ok $result_class, 'DBIx::Class::Core'; is( $result_class->table, 'albums', 'table set correctly' ); my @cols = $result_class->columns; is( $cols[0], 'id', 'id column set correctly' ); is( $cols[1], 'name', 'name column set correctly' ); A::Schema::Result::Album::test_strict; ok( !$result_class->can('column'), 'namespace gets cleaned'); my $artist_result = A::Schema->resultset('Artist')->result_class; isa_ok( $artist_result, 'A::Schema::Result'); is_deeply( [ A::Schema->source('Statistic')->primary_columns ], [qw(song_id playtime)]); done_testing; Makefile.PL100644001750001750 315012144174323 15751 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Sugar for your favorite ORM, DBIx::Class", "AUTHOR" => "Arthur Axel \"fREW\" Schmidt ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "DBIx-Class-Candy", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "DBIx::Class::Candy", "PREREQ_PM" => { "DBIx::Class" => "0.08123", "Lingua::EN::Inflect" => 0, "MRO::Compat" => "0.11", "String::CamelCase" => 0, "Sub::Exporter" => "0.982", "Test::Deep" => 0, "Test::Fatal" => 0, "Test::More" => "0.94", "namespace::clean" => "0.18" }, "TEST_REQUIRES" => {}, "VERSION" => "0.002104", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); autotable.t100644001750001750 132112144174323 16405 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/tuse strict; use warnings; use Test::More; use Test::Fatal; use lib 't/lib'; require DBIx::Class::Candy; subtest v1 => sub { # {{{ is( DBIx::Class::Candy->gen_table('MyApp::Schema::Result::Cat', 1), 'cats', 'simple name' ); is( DBIx::Class::Candy->gen_table('MyApp::Schema::Result::Traffic::Ticket', 1), 'traffic_tickets', 'name with ::' ); is( DBIx::Class::Candy->gen_table('MyApp::DB::Result::Dog', 1), 'dogs', 'simple no ::Schema' ); like( exception { DBIx::Class::Candy->gen_table('MyApp::DB::Pal', 1) }, qr(^unrecognized naming scheme! at t/autotable\.t), 'unknown naming scheme' ); }; done_testing; irc-schema.t100644001750001750 1237212144174323 16470 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/tuse strict; use warnings; use Test::More; use Test::Deep; use lib 't/lib'; use IRC::Schema; subtest Channel => sub { # {{{ my $result_class = IRC::Schema->resultset('Channel')->result_class; isa_ok $result_class, 'IRC::Schema::Result'; cmp_set [$result_class->columns], [qw(id name network_id)], 'columns get set correctly'; cmp_deeply $result_class->column_info('name'), { data_type => 'varchar', size => 100, }, 'name metadata set'; cmp_deeply $result_class->column_info('id'), { data_type => 'int', is_auto_increment => 1, }, 'id metadata set'; cmp_deeply $result_class->column_info('network_id'), { data_type => 'int', }, 'network_id metadata set'; ok $result_class->has_relationship('network'), 'network relationship works'; cmp_deeply([$result_class->primary_columns], [ 'id' ], 'id gets set to pk'); cmp_deeply({ $result_class->unique_constraints }, { Channels_name => [ 'name' ], primary => [ 'id' ], }, 'unqiue constraints get set correctly'); is( $result_class->table, 'Channels', 'table gets set correctly'); is( $result_class->test_perl_version, 'station', 'perl version gets set from base class') if $] >= 5.010; }; # }}} subtest Message => sub { # {{{ my $result_class = IRC::Schema->resultset('Message')->result_class; isa_ok $result_class, 'DBIx::Class::Core'; ok(!$result_class->isa('IRC::Schema::Result'), 'Not a ::Result'); cmp_set [$result_class->columns], [qw(id user_id mode_id channel_id value when_said)], 'columns get set correctly'; cmp_deeply $result_class->column_info('id'), { data_type => 'int', is_auto_increment => 1, }, 'id metadata set'; cmp_deeply $result_class->column_info('user_id'), { data_type => 'int', }, 'user_id metadata set'; cmp_deeply $result_class->column_info('mode_id'), { data_type => 'int', }, 'mode_id metadata set'; cmp_deeply $result_class->column_info('channel_id'), { data_type => 'int', }, 'channel_id metadata set'; cmp_deeply $result_class->column_info('value'), { data_type => 'varchar', size => 100, }, 'value metadata set'; cmp_deeply $result_class->column_info('when_said'), { data_type => 'datetime', }, 'when_said metadata set'; ok $result_class->has_relationship('user'), 'user relationship works'; ok $result_class->has_relationship('channel'), 'channel relationship works'; ok $result_class->has_relationship('mode'), 'mode relationship works'; cmp_deeply([$result_class->primary_columns], [ 'id' ], 'id gets set to pk'); is( $result_class->table, 'Messages', 'table gets set correctly'); }; # }}} subtest Mode => sub { # {{{ my $result_class = IRC::Schema->resultset('Mode')->result_class; isa_ok $result_class, 'IRC::Schema::Result'; cmp_set [$result_class->columns], [qw(id name code)], 'columns get set correctly'; cmp_deeply $result_class->column_info('id'), { data_type => 'int', is_auto_increment => 1, }, 'id metadata set'; cmp_deeply $result_class->column_info('name'), { data_type => 'varchar', size => 30, }, 'name metadata set'; cmp_deeply $result_class->column_info('code'), { data_type => 'char', size => 1, }, 'code metadata set'; cmp_deeply([$result_class->primary_columns], [ 'id' ], 'id gets set to pk'); cmp_deeply({ $result_class->unique_constraints }, { Modes_name => [ 'name' ], Modes_code => [ 'code' ], primary => [ 'id' ], }, 'unqiue constraints get set correctly'); is( $result_class->table, 'Modes', 'table gets set correctly'); }; # }}} subtest Network => sub { # {{{ my $result_class = IRC::Schema->resultset('Network')->result_class; isa_ok $result_class, 'IRC::Schema::Result'; cmp_set [$result_class->columns], [qw(id name)], 'columns get set correctly'; cmp_deeply $result_class->column_info('id'), { data_type => 'int', is_auto_increment => 1, }, 'id metadata set'; cmp_deeply $result_class->column_info('name'), { data_type => 'varchar', size => 100, }, 'name metadata set'; cmp_deeply([$result_class->primary_columns], [ 'id' ], 'id gets set to pk'); cmp_deeply({ $result_class->unique_constraints }, { Networks_name => [ 'name' ], primary => [ 'id' ], }, 'unqiue constraints get set correctly'); is( $result_class->table, 'Networks', 'table gets set correctly'); }; # }}} subtest User => sub { # {{{ my $result_class = IRC::Schema->resultset('User')->result_class; isa_ok $result_class, 'IRC::Schema::Result'; cmp_set [$result_class->columns], [qw(id handle)], 'columns get set correctly'; cmp_deeply $result_class->column_info('id'), { data_type => 'int', is_auto_increment => 1, }, 'id metadata set'; cmp_deeply $result_class->column_info('handle'), { data_type => 'varchar', size => 30, }, 'handle metadata set'; ok $result_class->has_relationship('messages'), 'messages relationship works'; cmp_deeply([$result_class->primary_columns], [ 'id' ], 'id gets set to pk'); cmp_deeply({ $result_class->unique_constraints }, { users_handle => [ 'handle' ], primary => [ 'id' ], }, 'unqiue constraints get set correctly'); is( $result_class->table, 'users', 'table gets set correctly'); }; # }}} done_testing; # vim: foldmethod=marker A000755001750001750 012144174323 15031 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/libSchema.pm100644001750001750 13112144174323 16702 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/Apackage A::Schema; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces(); 1; IRC000755001750001750 012144174323 15266 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/libSchema.pm100644001750001750 24212144174323 17142 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRCpackage IRC::Schema; use strict; use warnings; use base 'DBIx::Class::Schema'; __PACKAGE__->load_namespaces( default_resultset_class => 'ResultSet', ); 1; Component.pm100644001750001750 16112144174323 17447 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/Apackage A::Result; use DBIx::Class::Candy::Exports; sub giant_robot { 1 } export_methods ['giant_robot']; 1; release-pod-syntax.t100644001750001750 45012144174323 20133 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Class000755001750001750 012144174323 16241 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/lib/DBIxCandy.pm100644001750001750 3241312144174323 20020 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/lib/DBIx/Classpackage DBIx::Class::Candy; use strict; use warnings; our $VERSION = '0.002104'; # VERSION use namespace::clean; require DBIx::Class::Candy::Exports; use MRO::Compat; use Sub::Exporter 'build_exporter'; use Carp 'croak'; # ABSTRACT: Sugar for your favorite ORM, DBIx::Class my %aliases = ( column => 'add_columns', primary_key => 'set_primary_key', unique_constraint => 'add_unique_constraint', relationship => 'add_relationship', ); my @methods = qw( resultset_class resultset_attributes remove_columns remove_column table source_name inflate_column belongs_to has_many might_have has_one many_to_many sequence ); sub base { return $_[1] || 'DBIx::Class::Core' } sub perl_version { return $_[1] } sub autotable { $_[1] } sub gen_table { my ( $self, $class, $version ) = @_; if ($version == 1) { if (my ( $part ) = $class =~ /(?:::Schema)?::Result::(.+)$/) { require Lingua::EN::Inflect; require String::CamelCase; $part =~ s/:://g; $part = String::CamelCase::decamelize($part); return join q{_}, split /\s+/, Lingua::EN::Inflect::PL(join q{ }, split /_/, $part); } else { croak 'unrecognized naming scheme!' } } } sub import { my $self = shift; my $inheritor = caller(0); my $args = $self->parse_arguments(\@_); my $perl_version = $self->perl_version($args->{perl_version}); my @rest = @{$args->{rest}}; $self->set_base($inheritor, $args->{base}); $inheritor->load_components(@{$args->{components}}); my @custom_methods; my %custom_aliases; { my @custom = $self->gen_custom_imports($inheritor); @custom_methods = @{$custom[0]}; %custom_aliases = %{$custom[1]}; } my $set_table = sub {}; if (my $v = $self->autotable($args->{autotable})) { my $table_name = $self->gen_table($inheritor, $v); $set_table = sub { $inheritor->table($table_name); $set_table = sub {} } } @_ = ($self, @rest); my $import = build_exporter({ exports => [ has_column => $self->gen_has_column($inheritor, $set_table), primary_column => $self->gen_primary_column($inheritor, $set_table), unique_column => $self->gen_unique_column($inheritor, $set_table), (map { $_ => $self->gen_proxy($inheritor, $set_table) } @methods, @custom_methods), (map { $_ => $self->gen_rename_proxy($inheritor, $set_table, \%aliases, \%custom_aliases) } keys %aliases, keys %custom_aliases), ], groups => { default => [ qw(has_column primary_column unique_column), @methods, @custom_methods, keys %aliases, keys %custom_aliases ], }, installer => $self->installer($inheritor), collectors => [ INIT => $self->gen_INIT($perl_version, \%custom_aliases, \@custom_methods, $inheritor), ], }); goto $import } sub gen_custom_imports { my ($self, $inheritor) = @_; my @methods; my %aliases; for (@{mro::get_linear_isa($inheritor)}) { if (my $a = $DBIx::Class::Candy::Exports::aliases{$_}) { %aliases = (%aliases, %$a) } if (my $m = $DBIx::Class::Candy::Exports::methods{$_}) { @methods = (@methods, @$m) } } return(\@methods, \%aliases) } sub parse_arguments { my $self = shift; my @args = @{shift @_}; my $skipnext; my $base; my @rest; my $perl_version = undef; my $components = []; my $autotable = 0; for my $idx ( 0 .. $#args ) { my $val = $args[$idx]; next unless defined $val; if ($skipnext) { $skipnext--; next; } if ( $val eq '-base' ) { $base = $args[$idx + 1]; $skipnext = 1; } elsif ( $val eq '-autotable' ) { $autotable = ord $args[$idx + 1]; $skipnext = 1; } elsif ( $val eq '-perl5' ) { $perl_version = ord $args[$idx + 1]; $skipnext = 1; } elsif ( $val eq '-components' ) { $components = $args[$idx + 1]; $skipnext = 1; } else { push @rest, $val; } } return { autotable => $autotable, base => $base, perl_version => $perl_version, components => $components, rest => \@rest, }; } sub gen_primary_column { my ($self, $inheritor, $set_table) = @_; sub { my $i = $inheritor; sub { my $column = shift; my $info = shift; $set_table->(); $i->add_columns($column => $info); $i->set_primary_key($i->primary_columns, $column); } } } sub gen_unique_column { my ($self, $inheritor, $set_table) = @_; sub { my $i = $inheritor; sub { my $column = shift; my $info = shift; $set_table->(); $i->add_columns($column => $info); $i->add_unique_constraint([ $column ]); } } } sub gen_has_column { my ($self, $inheritor, $set_table) = @_; sub { my $i = $inheritor; sub { my $column = shift; $set_table->(); $i->add_columns($column => { @_ }) } } } sub gen_rename_proxy { my ($self, $inheritor, $set_table, $aliases, $custom_aliases) = @_; sub { my ($class, $name) = @_; my $meth = $aliases->{$name} || $custom_aliases->{$name}; my $i = $inheritor; sub { $set_table->(); $i->$meth(@_) } } } sub gen_proxy { my ($self, $inheritor, $set_table) = @_; sub { my ($class, $name) = @_; my $i = $inheritor; sub { $set_table->(); $i->$name(@_) } } } sub installer { my ($self, $inheritor) = @_; sub { Sub::Exporter::default_installer @_; namespace::clean->import( -cleanee => $inheritor ) } } sub set_base { my ($self, $inheritor, $base) = @_; # inlined from parent.pm for ( my @useless = $self->base($base) ) { s{::|'}{/}g; require "$_.pm"; # dies if the file is not found } { no strict 'refs'; # This is more efficient than push for the new MRO # at least until the new MRO is fixed @{"$inheritor\::ISA"} = (@{"$inheritor\::ISA"} , $self->base($base)); } } sub gen_INIT { my ($self, $perl_version, $custom_aliases, $custom_methods, $inheritor) = @_; sub { my $orig = $_[1]->{import_args}; $_[1]->{import_args} = []; %$custom_aliases = (); @$custom_methods = (); if ($perl_version) { require feature; feature->import(":5.$perl_version") } strict->import; warnings->import; 1; } } 1; __END__ =pod =head1 NAME DBIx::Class::Candy - Sugar for your favorite ORM, DBIx::Class =head1 SYNOPSIS package MyApp::Schema::Result::Artist; use DBIx::Class::Candy -autotable => v1; primary_column id => { data_type => 'int', is_auto_increment => 1, }; column name => { data_type => 'varchar', size => 25, is_nullable => 1, }; has_many albums => 'A::Schema::Result::Album', 'artist_id'; 1; =head1 DESCRIPTION C is a simple sugar layer for definition of L results. Note that it may later be expanded to add sugar for more C related things. By default C: =over =item * turns on strict and warnings =item * sets your parent class =item * exports a bunch of the package methods that you normally use to define your L results =item * makes a few aliases to make some of the original method names a shorter or more clear =item * defines very few new subroutines that transform the arguments passed to them =back It assumes a L-like API, but you can tailor it to suit your needs. =head1 IMPORT OPTIONS See L for information on setting these schema wide. =head2 -base use DBIx::Class::Candy -base => 'MyApp::Schema::Result'; The first thing you can do to customize your usage of C is change the parent class. Do that by using the C<-base> import option. =head2 -autotable use DBIx::Class::Candy -autotable => v1; Don't waste your precious keystrokes typing C<< table 'buildings' >>, let C do that for you! See L for what the existing versions will generate for you. =head2 -components use DBIx::Class::Candy -components => ['FilterColumn']; C allows you to set which components you are using at import time so that the components can define their own sugar to export as well. See L for details on how that works. =head2 -perl5 use DBIx::Class::Candy -perl5 => v10; I love the new features in Perl 5.10 and 5.12, so I felt that it would be nice to remove the boiler plate of doing C<< use feature ':5.10' >> and add it to my sugar importer. Feel free not to use this. =head1 IMPORTED SUBROUTINES Most of the imported subroutines are the same as what you get when you use the normal interface for result definition: they have the same names and take the same arguments. In general write the code the way you normally would, leaving out the C<< __PACKAGE__-> >> part. The following are methods that are exported with the same name and arguments: belongs_to has_many has_one inflate_column many_to_many might_have remove_column remove_columns resultset_attributes resultset_class sequence source_name table There are some exceptions though, which brings us to: =head1 IMPORTED ALIASES These are merely renamed versions of the functions you know and love. The idea is to make your result classes a tiny bit prettier by aliasing some methods. If you know your C API you noticed that in the L I used C instead of C and C instead of C. The old versions work, this is just nicer. A list of aliases are as follows: column => 'add_columns', primary_key => 'set_primary_key', unique_constraint => 'add_unique_constraint', relationship => 'add_relationship', =head1 SETTING DEFAULT IMPORT OPTIONS Eventually you will get tired of writing the following in every single one of your results: use DBIx::Class::Candy -base => 'MyApp::Schema::Result', -perl5 => v12, -autotable => v1; You can set all of these for your whole schema if you define your own C subclass as follows: package MyApp::Schema::Candy; use base 'DBIx::Class::Candy'; sub base { $_[1] || 'MyApp::Schema::Result' } sub perl_version { 12 } sub autotable { 1 } Note the C<< $_[1] || >> in C. All of these methods are passed the values passed in from the arguments to the subclass, so you can either throw them away, honor them, die on usage, or whatever. To be clear, if you define your subclass, and someone uses it as follows: use MyApp::Schema::Candy -base => 'MyApp::Schema::Result', -perl5 => v18, -autotable => v1; Your C method will get C, your C will get C<18>, and your C will get C<1>. =head1 SECONDARY API =head2 has_column There is currently a single "transformer" for C, so that people used to the L api will feel more at home. Note that this B go into a "Candy Component" at some point. Example usage: has_column foo => ( data_type => 'varchar', size => 25, is_nullable => 1, ); =head2 primary_column Another handy little feature that allows you to define a column and set it as the primary key in a single call: primary_column id => { data_type => 'int', is_auto_increment => 1, }; If your table has multiple columns in its primary key, merely call this method for each column: primary_column person_id => { data_type => 'int' }; primary_column friend_id => { data_type => 'int' }; =head2 unique_column This allows you to define a column and set it as unique in a single call: unique_column name => { data_type => 'varchar', size => 30, }; =head1 AUTOTABLE VERSIONS Currently there is a single version, C, which looks at your class name, grabs everything after C<::Schema::Result::> (or C<::Result::>), removes the C<::>'s, converts it to underscores instead of camel-case, and pluralizes it. Here are some examples if that's not clear: MyApp::Schema::Result::Cat -> cats MyApp::Schema::Result::Software::Building -> software_buildings MyApp::Schema::Result::LonelyPerson -> lonely_people MyApp::DB::Result::FriendlyPerson -> friendly_people MyApp::DB::Result::Dog -> dogs Also, if you just want to be different, you can easily set up your own naming scheme. Just add a C method to your candy subclass. The method gets passed the class name and the autotable version, which of course you may ignore. For example, one might just do the following: sub gen_table { my ($self, $class) = @_; $class =~ s/::/_/g; lc $class; } Which would tranform C into C. Or maybe instead of using the standard C namespace you decided to be different and do C or something silly like that. You could pre-process your class name so that the default C will still work: sub gen_table { my $self = shift; my $class = $_[0]; $class =~ s/::DB::Table::/::Schema::Result::/; return $self->next::method(@_); } =head1 AUTHOR Arthur Axel "fREW" Schmidt =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Schema000755001750001750 012144174323 16231 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/ACandy.pm100644001750001750 14012144174323 17740 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/Schemapackage A::Schema::Candy; use base 'DBIx::Class::Candy'; sub base { 'A::Schema::Result' } 1; Result.pm100644001750001750 7612144174323 20150 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/Schemapackage A::Schema::Result; use base 'DBIx::Class::Core'; 1; Schema000755001750001750 012144174323 16466 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRCCandy.pm100644001750001750 42512144174323 20203 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schemapackage IRC::Schema::Candy; use base 'DBIx::Class::Candy'; sub base() { $_[1] || 'IRC::Schema::Result' } sub perl_version() { return 10 if $] >= 5.010 } sub autotable() { 1 } sub gen_table { my $self = shift; my $ret = $self->next::method(@_); ucfirst $ret } 1; Result.pm100644001750001750 52712144174323 20426 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schemapackage IRC::Schema::Result; use strict; use warnings; use base 'DBIx::Class::Core'; __PACKAGE__->load_components('Candy'); sub base() { $_[1] || 'IRC::Schema::Result' } sub perl_version() { return 10 if $] >= 5.010 } sub autotable() { 1 } sub gen_table { my $self = shift; my $ret = $self->next::method(@_); ucfirst $ret } 1; ResultSet.pm100644001750001750 14312144174323 21074 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schemapackage IRC::Schema::ResultSet; use strict; use warnings; use base 'DBIx::Class::ResultSet'; 1; Result000755001750001750 012144174323 17507 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/SchemaSong.pm100644001750001750 63212144174323 21074 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/Schema/Resultpackage A::Schema::Result::Song; use DBIx::Class::Candy -base => 'A::Schema::Result'; table 'songs'; column id => { data_type => 'int', is_auto_increment => 1, }; column name => { data_type => 'varchar', size => 25, is_nullable => 1, }; column album_id => { data_type => 'int', is_nullable => 0, }; primary_key 'id'; belongs_to album => 'A::Schema::Result::Album', 'album_id'; 1; Album.pm100644001750001750 102312144174323 21241 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/Schema/Resultpackage A::Schema::Result::Album; use DBIx::Class::Candy -base => 'A::Schema::Result'; table 'albums'; primary_column id => { data_type => 'int', is_auto_increment => 1, is_numeric => 1, }; has_column name => ( data_type => 'varchar', size => 25, is_nullable => 1, ); column artist_id => { data_type => 'int', is_nullable => 0, }; has_many songs => 'A::Schema::Result::Song', 'album_id'; sub test_strict { require Test::More; eval '$foo = 1'; Test::More::ok($@, 'strict mode is on'); } 1; Candy000755001750001750 012144174323 17277 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/lib/DBIx/ClassExports.pm100644001750001750 373712144174323 21453 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/lib/DBIx/Class/Candypackage DBIx::Class::Candy::Exports; # ABSTRACT: Create sugar for your favorite ORM, DBIx::Class use strict; use warnings; our $VERSION = '0.002104'; # VERSION our %methods; our %aliases; sub export_methods { $methods{scalar caller(0)} = $_[0] } sub export_method_aliases { $aliases{scalar caller(0)} = $_[0] } use Sub::Exporter -setup => { exports => [ qw(export_methods export_method_aliases) ], groups => { default => [ qw(export_methods export_method_aliases) ] }, }; 1; __END__ =pod =head1 NAME DBIx::Class::Candy::Exports - Create sugar for your favorite ORM, DBIx::Class =head1 SYNOPSIS package DBIx::Class::Widget; sub create_a_widget { ... } # so you don't depend on ::Candy eval { require DBIx::Class::Candy::Exports; DBIx::Class::Candy::Exports->import; export_methods ['create_a_widget']; export_method_aliases { widget => 'create_a_widget' }; } 1; The above will make it such that users of your component who use it with L will have the methods you designate exported into their namespace. =head1 DESCRIPTION The whole point of this module is to make sugar a first class citizen in the component world that dominates L. I make enough components and like this sugar idea enough that I want to be able to have both at the same time. =head1 IMPORTED SUBROUTINES =head2 export_methods export_methods [qw( foo bar baz )]; Use this subroutine to define methods that get exported as subroutines of the same name. =head2 export_method_aliases export_method_aliases { old_method_name => 'new_sub_name', }; Use this subroutine to define methods that get exported as subroutines of a different name. =head1 AUTHOR Arthur Axel "fREW" Schmidt =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Result000755001750001750 012144174323 17744 5ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/SchemaUser.pm100644001750001750 52212144174323 21337 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schema/Resultpackage IRC::Schema::Result::User; use DBIx::Class::Candy -autotable => v1, -base => 'IRC::Schema::Result'; column id => { data_type => 'int', is_auto_increment => 1, }; unique_column handle => { data_type => 'varchar', size => 30, }; primary_key 'id'; has_many messages => 'IRC::Schema::Result::Message', 'user_id'; 1; Mode.pm100644001750001750 45112144174323 21306 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schema/Resultpackage IRC::Schema::Result::Mode; use IRC::Schema::Candy; primary_column id => { data_type => 'int', is_auto_increment => 1, }; unique_column name => { data_type => 'varchar', size => 30, }; unique_column code => { data_type => 'char', size => '1', }; 1; Artist.pm100644001750001750 46312144174323 21436 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/Schema/Resultpackage A::Schema::Result::Artist; use A::Schema::Candy; table 'artists'; primary_column id => { data_type => 'int', is_auto_increment => 1, }; has_column name => ( data_type => 'varchar', size => 25, is_nullable => 1, ); has_many albums => 'A::Schema::Result::Album', 'artist_id'; 1; Network.pm100644001750001750 37012144174323 22053 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schema/Resultpackage IRC::Schema::Result::Network; use IRC::Schema::Result; primary_column id => { data_type => 'int', is_auto_increment => 1, }; column name => { data_type => 'varchar', size => 100, }; unique_constraint [qw( name )]; 1; Channel.pm100644001750001750 67312144174323 22000 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schema/Resultpackage IRC::Schema::Result::Channel; use IRC::Schema::Candy; primary_column id => { data_type => 'int', is_auto_increment => 1, }; column name => { data_type => 'varchar', size => 100, }; column network_id => { data_type => 'int', }; belongs_to network => 'IRC::Schema::Result::Network', 'network_id'; unique_constraint [qw( name )]; sub test_perl_version { eval "given (1) { when (1) { return 'station' } }" } 1; Message.pm100644001750001750 121012144174323 22020 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/IRC/Schema/Resultpackage IRC::Schema::Result::Message; use IRC::Schema::Candy -base => 'DBIx::Class::Core'; table 'Messages'; primary_column id => { data_type => 'int', is_auto_increment => 1, }; column user_id => { data_type => 'int', }; column mode_id => { data_type => 'int', }; column channel_id => { data_type => 'int', }; column value => { data_type => 'varchar', size => 100, }; column when_said => { data_type => 'datetime', }; belongs_to user => 'IRC::Schema::Result::User', 'user_id'; belongs_to mode => 'IRC::Schema::Result::Mode', 'mode_id'; belongs_to channel => 'IRC::Schema::Result::Channel', 'channel_id'; 1; Statistic.pm100644001750001750 42612144174323 22136 0ustar00frewfrew000000000000DBIx-Class-Candy-0.002104/t/lib/A/Schema/Resultpackage A::Schema::Result::Statistic; use DBIx::Class::Candy -base => 'A::Schema::Result'; table 'statistics'; primary_column song_id => { data_type => 'int' }; primary_column playtime => { data_type => 'int' }; belongs_to song => 'A::Schema::Result::Song', 'song_id'; 1;