Path-Router-0.15/000755 000765 000024 00000000000 12665414707 014061 5ustar00neilbstaff000000 000000 Path-Router-0.15/Changes000644 000765 000024 00000011044 12665414707 015354 0ustar00neilbstaff000000 000000 Revision history for Perl extension Path::Router 0.15 2016-03-01 NEILB - Switched to Moo, done by FELLIOTT++. - Added strict and warnings to Path::Router::Types - MANWAR++ - Specified versions when use'ing any third-party modules. - Added minimal doc for route_class() method in Path::Router, and clone() method in Path::Router::Route. - Updated Stevan's email address. 0.14_01 2015-07-03 - Switched to Moo, done by FELLIOTT++. - Specified versions when use'ing any third-party modules. - Temporarily dropped NextRelease and Git::NextVersion from the @DOY bundle, so I can specify a developer release version. - Added minimal doc for route_class() method in Path::Router, and clone() method in Path::Router::Route. - Updated Stevan's email address. 0.14 2015-01-13 - localize $SIG{__DIE__} so that our exception based flow control does not mess up, or get messed up by, application exception handling - thanks to Tim Bunce for finding and reporting this issue 0.13 2014-08-24 - Allow path components to be false values (doy) - added tests for this 0.12 2012-07-16 - Fix matching on variable path components with a path where the variable part evaluated to false (for instance, matching '/blog/show/:id' against '/blog/show/0'). Reported by Clay Fouts (RT#78388). (doy) 0.11 2011-10-03 - *POSSIBLE BACKWARDS INCOMPATIBILITY* When using uri_for, a match is considered more exact if it is also missing items from the path descriptor that don't appear in the route's defaults or variables. For instance, if a router has /foo with defaults of { 'a' => 'b' } and /bar with defaults of { 'a' => 'b', 'c' => 'd' }, then ->uri_for({ 'a' => 'b' }) will always return /foo. Previously, it would return one of them arbitrarily, depending on the definition order. Also, if this new rule doesn't result in a single route being matched (for instance, if /foo had defaults of { 'a' => 'b', 'e' => 'f' }), then an exception will be thrown. - *POSSIBLE BACKWARDS INCOMPATIBILITY* When using match, a path will be considered more exact if it matches more required non-variable path components. For instance, if a router has /foo/bar and /foo/:bar, then ->match('/foo/bar') will always match /foo/bar (and not /foo/:bar). Previously, it would return one of them arbitrarily, depending on the definition order. Also, if this new rule doesn't result in a single route being matched (for instance, if the router contained /:foo/bar and /foo/:bar), then an exception will be thrown. - Warn when creating validations that don't correspond to a path element - Convert to Dist::Zilla 0.10 Wed. Jan. 12, 2011 * Path::Router - route_class attribute, to allow easy subclassing (thanks to Dylan Hardison) 0.09 Thurs. Dec. 10, 2009 * Path::Router - fixing a minor problem with the path generator and optional parts 0.08 Tues. Dec. 8, 2009 * Path::Router - added the include_router method to allow inclusion of other routers - added tests and docs for this 0.07 Tues. Mar. 10, 2009 * Path::Router::* - lots of code re-written by Daisuke Maki resulting in an 150% speed increase - matching code is now inlined by default but inlining can be turned off if needed * Path::Router - added insert_route to allow more fine grained control over route ordering (Daisuke Maki) * tests - do not run pod tests unless testing a release 0.06 Sat. January 10, 2009 * Path::Router - fix bug with >1 optional path component - simplify and completely redo uri_for matching 0.05 Sat. January 3, 2009 * Path::Router - refinements to match correctly in more uri_for edge cases * Test::Path::Router - minor display improvements 0.04 Fri. January 2, 2009 * Path::Router - fix uri_for to return undef on match failure instead of '' (empty string) 0.03 Wed. July 16, 2008 * Path::Router::Shell - fixed spelling of Term::ReadLine (RT #37693) 0.02 Mon. July 14, 2008 * Path::Router - changed DEBUG from a constant sub to $DEBUG a package variable. This is a new module and so easy debugability is important. * Path::Router::Route - silly fix to make sure exact paths will match - added tests for this 0.01 Sat. July 12, 2008 - copied Ruby on Rails Router, but make it ... better, stronger, faster Path-Router-0.15/dist.ini000644 000765 000024 00000001467 12665414707 015535 0ustar00neilbstaff000000 000000 name = Path-Router author = Stevan Little license = Perl_5 copyright_holder = Infinity Interactive [@DOY] :version = 0.15 dist = Path-Router repository = github github_user = stevan github_name = Path-Router authority = cpan:STEVAN [Prereqs] perl = 5.008 B = 0 Carp = 1.32 Clone::PP = 1.04 constant = 1.24 Data::Dumper = 2.154 Eval::Closure = 0.13 Moo = 2.000001 namespace::clean = 0.23 File::Spec::Unix = 3.40 Sub::Exporter = 0.981 Term::ReadLine = 1.11 Test::Builder = 1.001013 Test::Deep = 0.113 Try::Tiny = 0.19 Type::Tiny = 1.000005 Types::Standard = 1.000005 [Prereqs / TestRequires] Test::Fatal = 0.012 Test::More = 1.001013 Path-Router-0.15/lib/000755 000765 000024 00000000000 12665414707 014627 5ustar00neilbstaff000000 000000 Path-Router-0.15/LICENSE000644 000765 000024 00000043705 12665414707 015077 0ustar00neilbstaff000000 000000 This software is copyright (c) 2016 by Infinity Interactive. 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) 2016 by Infinity Interactive. 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, Fifth Floor, Boston, MA 02110-1301 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) 2016 by Infinity Interactive. 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 Path-Router-0.15/Makefile.PL000644 000765 000024 00000004135 12665414707 016036 0ustar00neilbstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.037. use strict; use warnings; use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "A tool for routing paths", "AUTHOR" => "Stevan Little ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Path-Router", "EXE_FILES" => [], "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008", "NAME" => "Path::Router", "PREREQ_PM" => { "B" => 0, "Carp" => "1.32", "Clone::PP" => "1.04", "Data::Dumper" => "2.154", "Eval::Closure" => "0.13", "File::Spec::Unix" => "3.40", "Moo" => "2.000001", "Sub::Exporter" => "0.981", "Term::ReadLine" => "1.11", "Test::Builder" => "1.001013", "Test::Deep" => "0.113", "Try::Tiny" => "0.19", "Type::Tiny" => "1.000005", "Types::Standard" => "1.000005", "constant" => "1.24", "namespace::clean" => "0.23" }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::Fatal" => "0.012", "Test::More" => "1.001013" }, "VERSION" => "0.15", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "B" => 0, "Carp" => "1.32", "Clone::PP" => "1.04", "Data::Dumper" => "2.154", "Eval::Closure" => "0.13", "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "File::Spec::Unix" => "3.40", "IO::Handle" => 0, "IPC::Open3" => 0, "Moo" => "2.000001", "Sub::Exporter" => "0.981", "Term::ReadLine" => "1.11", "Test::Builder" => "1.001013", "Test::Deep" => "0.113", "Test::Fatal" => "0.012", "Test::More" => "1.001013", "Try::Tiny" => "0.19", "Type::Tiny" => "1.000005", "Types::Standard" => "1.000005", "constant" => "1.24", "namespace::clean" => "0.23" ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Path-Router-0.15/MANIFEST000644 000765 000024 00000001377 12665414707 015222 0ustar00neilbstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.037. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README TODO dist.ini lib/Path/Router.pm lib/Path/Router/Route.pm lib/Path/Router/Route/Match.pm lib/Path/Router/Shell.pm lib/Path/Router/Types.pm lib/Test/Path/Router.pm t/00-compile.t t/001_basic.t t/002_w_optional.t t/003_messy_paths.t t/004_match_test.t t/005_match_test_w_optional.t t/006_match_w_targets.t t/007_match_exact_urls.t t/008_uri_for.t t/009_include_other_router.t t/010_example_cat_chained_URIs.t t/011_incorrect_validation_warning.t t/012_ambiguous_routes.t t/013_false_path_components.t t/014_test_path_router.t t/100_bug.t xt/author/no-tabs.t xt/release/eol.t xt/release/pod-coverage.t xt/release/pod-syntax.t Path-Router-0.15/META.json000644 000765 000024 00000045673 12665414707 015521 0ustar00neilbstaff000000 000000 { "abstract" : "A tool for routing paths", "author" : [ "Stevan Little " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.037, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Path-Router", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::EOL" : "0", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "B" : "0", "Carp" : "1.32", "Clone::PP" : "1.04", "Data::Dumper" : "2.154", "Eval::Closure" : "0.13", "File::Spec::Unix" : "3.40", "Moo" : "2.000001", "Sub::Exporter" : "0.981", "Term::ReadLine" : "1.11", "Test::Builder" : "1.001013", "Test::Deep" : "0.113", "Try::Tiny" : "0.19", "Type::Tiny" : "1.000005", "Types::Standard" : "1.000005", "constant" : "1.24", "namespace::clean" : "0.23", "perl" : "5.008" } }, "test" : { "requires" : { "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::Fatal" : "0.012", "Test::More" : "1.001013" } } }, "provides" : { "Path::Router" : { "file" : "lib/Path/Router.pm", "version" : "0.15" }, "Path::Router::Route" : { "file" : "lib/Path/Router/Route.pm", "version" : "0.15" }, "Path::Router::Route::Match" : { "file" : "lib/Path/Router/Route/Match.pm", "version" : "0.15" }, "Path::Router::Shell" : { "file" : "lib/Path/Router/Shell.pm", "version" : "0.15" }, "Path::Router::Types" : { "file" : "lib/Path/Router/Types.pm", "version" : "0.15" }, "Test::Path::Router" : { "file" : "lib/Test/Path/Router.pm", "version" : "0.15" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/stevan/Path-Router/issues" }, "homepage" : "http://metacpan.org/release/Path-Router", "repository" : { "type" : "git", "url" : "git://github.com/stevan/Path-Router.git", "web" : "https://github.com/stevan/Path-Router" } }, "version" : "0.15", "x_Dist_Zilla" : { "perl" : { "version" : "5.018001" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@DOY/TestMoreDoneTesting", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : "0", "include_dotfiles" : "0", "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@DOY/GatherDir", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@DOY/PruneCruft", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@DOY/ManifestSkip", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@DOY/MetaYAML", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@DOY/License", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@DOY/Readme", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DOY/RunExtraTests", "version" : "0.027" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@DOY/ExecDir", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@DOY/ShareDir", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DOY/MakeMaker", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@DOY/Manifest", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@DOY/TestRelease", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@DOY/ConfirmRelease", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@DOY/MetaConfig", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@DOY/MetaJSON", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@DOY/NextRelease", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", "name" : "@DOY/CheckChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@DOY/PkgVersion", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@DOY/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@DOY/PodCoverageTests", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@DOY/PodSyntaxTests", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ] } }, "name" : "@DOY/Test::NoTabs", "version" : "0.09" }, { "class" : "Dist::Zilla::Plugin::EOLTests", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/release/eol.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ], "trailing_whitespace" : "1" } }, "name" : "@DOY/EOLTests", "version" : "0.18" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "script_finder" : [ ":ExecFiles" ] } }, "name" : "@DOY/Test::Compile", "version" : "2.039" }, { "class" : "Dist::Zilla::Plugin::Metadata", "name" : "@DOY/Metadata", "version" : "3.03" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@DOY/MetaResources", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DOY/Git::Check", "version" : "2.028" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "changelog", "time_zone" : "local" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "dist.ini", "Changes" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DOY/Git::Commit", "version" : "2.028" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "signed" : 0, "tag" : "0.15", "tag_format" : "%v", "tag_message" : "", "time_zone" : "local" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DOY/Git::Tag", "version" : "2.028" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "config" : { "Dist::Zilla::Plugin::Git::NextVersion" : { "first_version" : "0.01", "version_by_branch" : "0", "version_regexp" : "(?^:^(\\d+\\.\\d+)$)" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DOY/Git::NextVersion", "version" : "2.028" }, { "class" : "Dist::Zilla::Plugin::ContributorsFromGit", "name" : "@DOY/ContributorsFromGit", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "5.037" } ] }, "Dist::Zilla::Role::MetaProvider::Provider" : { "inherit_missing" : "1", "inherit_version" : "1", "meta_noindex" : "1" } }, "name" : "@DOY/MetaProvides::Package", "version" : "1.15000003" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.004" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.004" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Default/SingleEncoding", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Default/Name", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Default/Version", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/prelude", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Default/Leftovers", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/postlude", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Default/Authors", "version" : "4.004" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Default/Legal", "version" : "4.004" } ] } }, "name" : "@DOY/PodWeaver", "version" : "4.006" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@DOY/UploadToCPAN", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "5.037" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.037" } }, "x_authority" : "cpan:STEVAN", "x_contributors" : [ "Daisuke Maki (lestrrat) ", "Dylan William Hardison ", "Fitz Elliott ", "Hans Dieter Pearcey ", "Jesse Luehrs ", "Mike Raynham ", "Mohammad S Anwar ", "Neil Bowers ", "Oliver Charles ", "Ricardo SIGNES ", "Stevan Little ", "Stevan Little ", "Stevan Little ", "Stevan Little ", "Tim Bunce " ] } Path-Router-0.15/META.yml000644 000765 000024 00000030174 12665414707 015337 0ustar00neilbstaff000000 000000 --- abstract: 'A tool for routing paths' author: - 'Stevan Little ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Test::Fatal: '0.012' Test::More: '1.001013' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.037, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Path-Router provides: Path::Router: file: lib/Path/Router.pm version: '0.15' Path::Router::Route: file: lib/Path/Router/Route.pm version: '0.15' Path::Router::Route::Match: file: lib/Path/Router/Route/Match.pm version: '0.15' Path::Router::Shell: file: lib/Path/Router/Shell.pm version: '0.15' Path::Router::Types: file: lib/Path/Router/Types.pm version: '0.15' Test::Path::Router: file: lib/Test/Path/Router.pm version: '0.15' requires: B: '0' Carp: '1.32' Clone::PP: '1.04' Data::Dumper: '2.154' Eval::Closure: '0.13' File::Spec::Unix: '3.40' Moo: '2.000001' Sub::Exporter: '0.981' Term::ReadLine: '1.11' Test::Builder: '1.001013' Test::Deep: '0.113' Try::Tiny: '0.19' Type::Tiny: '1.000005' Types::Standard: '1.000005' constant: '1.24' namespace::clean: '0.23' perl: '5.008' resources: bugtracker: https://github.com/stevan/Path-Router/issues homepage: http://metacpan.org/release/Path-Router repository: git://github.com/stevan/Path-Router.git version: '0.15' x_Dist_Zilla: perl: version: '5.018001' plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@DOY/TestMoreDoneTesting' version: '5.037' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: '0' include_dotfiles: '0' prefix: '' prune_directory: [] root: . name: '@DOY/GatherDir' version: '5.037' - class: Dist::Zilla::Plugin::PruneCruft name: '@DOY/PruneCruft' version: '5.037' - class: Dist::Zilla::Plugin::ManifestSkip name: '@DOY/ManifestSkip' version: '5.037' - class: Dist::Zilla::Plugin::MetaYAML name: '@DOY/MetaYAML' version: '5.037' - class: Dist::Zilla::Plugin::License name: '@DOY/License' version: '5.037' - class: Dist::Zilla::Plugin::Readme name: '@DOY/Readme' version: '5.037' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DOY/RunExtraTests' version: '0.027' - class: Dist::Zilla::Plugin::ExecDir name: '@DOY/ExecDir' version: '5.037' - class: Dist::Zilla::Plugin::ShareDir name: '@DOY/ShareDir' version: '5.037' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DOY/MakeMaker' version: '5.037' - class: Dist::Zilla::Plugin::Manifest name: '@DOY/Manifest' version: '5.037' - class: Dist::Zilla::Plugin::TestRelease name: '@DOY/TestRelease' version: '5.037' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@DOY/ConfirmRelease' version: '5.037' - class: Dist::Zilla::Plugin::MetaConfig name: '@DOY/MetaConfig' version: '5.037' - class: Dist::Zilla::Plugin::MetaJSON name: '@DOY/MetaJSON' version: '5.037' - class: Dist::Zilla::Plugin::NextRelease name: '@DOY/NextRelease' version: '5.037' - class: Dist::Zilla::Plugin::CheckChangesHasContent name: '@DOY/CheckChangesHasContent' version: '0.006' - class: Dist::Zilla::Plugin::PkgVersion name: '@DOY/PkgVersion' version: '5.037' - class: Dist::Zilla::Plugin::Authority name: '@DOY/Authority' version: '1.009' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@DOY/PodCoverageTests' version: '5.037' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@DOY/PodSyntaxTests' version: '5.037' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@DOY/Test::NoTabs' version: '0.09' - class: Dist::Zilla::Plugin::EOLTests config: Dist::Zilla::Plugin::Test::EOL: filename: xt/release/eol.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' trailing_whitespace: '1' name: '@DOY/EOLTests' version: '0.18' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: filename: t/00-compile.t module_finder: - ':InstallModules' script_finder: - ':ExecFiles' name: '@DOY/Test::Compile' version: '2.039' - class: Dist::Zilla::Plugin::Metadata name: '@DOY/Metadata' version: '3.03' - class: Dist::Zilla::Plugin::MetaResources name: '@DOY/MetaResources' version: '5.037' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: [] allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DOY/Git::Check' version: '2.028' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: changelog time_zone: local Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - dist.ini - Changes allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DOY/Git::Commit' version: '2.028' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ signed: 0 tag: '0.15' tag_format: '%v' tag_message: '' time_zone: local Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DOY/Git::Tag' version: '2.028' - class: Dist::Zilla::Plugin::Git::NextVersion config: Dist::Zilla::Plugin::Git::NextVersion: first_version: '0.01' version_by_branch: '0' version_regexp: (?^:^(\d+\.\d+)$) Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DOY/Git::NextVersion' version: '2.028' - class: Dist::Zilla::Plugin::ContributorsFromGit name: '@DOY/ContributorsFromGit' version: '0.006' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '5.037' Dist::Zilla::Role::MetaProvider::Provider: inherit_missing: '1' inherit_version: '1' meta_noindex: '1' name: '@DOY/MetaProvides::Package' version: '1.15000003' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.004' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.004' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Default/SingleEncoding' version: '4.004' - class: Pod::Weaver::Section::Name name: '@Default/Name' version: '4.004' - class: Pod::Weaver::Section::Version name: '@Default/Version' version: '4.004' - class: Pod::Weaver::Section::Region name: '@Default/prelude' version: '4.004' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.004' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.004' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.004' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.004' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.004' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.004' - class: Pod::Weaver::Section::Leftovers name: '@Default/Leftovers' version: '4.004' - class: Pod::Weaver::Section::Region name: '@Default/postlude' version: '4.004' - class: Pod::Weaver::Section::Authors name: '@Default/Authors' version: '4.004' - class: Pod::Weaver::Section::Legal name: '@Default/Legal' version: '4.004' name: '@DOY/PodWeaver' version: '4.006' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@DOY/UploadToCPAN' version: '5.037' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '5.037' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '5.037' - class: Dist::Zilla::Plugin::FinderCode name: '@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '5.037' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '5.037' x_authority: cpan:STEVAN x_contributors: - 'Daisuke Maki (lestrrat) ' - 'Dylan William Hardison ' - 'Fitz Elliott ' - 'Hans Dieter Pearcey ' - 'Jesse Luehrs ' - 'Mike Raynham ' - 'Mohammad S Anwar ' - 'Neil Bowers ' - 'Oliver Charles ' - 'Ricardo SIGNES ' - 'Stevan Little ' - 'Stevan Little ' - 'Stevan Little ' - 'Stevan Little ' - 'Tim Bunce ' Path-Router-0.15/README000644 000765 000024 00000000557 12665414707 014750 0ustar00neilbstaff000000 000000 This archive contains the distribution Path-Router, version 0.15: A tool for routing paths This software is copyright (c) 2016 by Infinity Interactive. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.037. Path-Router-0.15/t/000755 000765 000024 00000000000 12665414707 014324 5ustar00neilbstaff000000 000000 Path-Router-0.15/TODO000644 000765 000024 00000000344 12665414706 014551 0ustar00neilbstaff000000 000000 ----------------------------------------------------------- -- TODO ----------------------------------------------------------- read and steal tests/examples from : http://caboo.se/doc/classes/ActionController/Routing.htmlPath-Router-0.15/xt/000755 000765 000024 00000000000 12665414707 014514 5ustar00neilbstaff000000 000000 Path-Router-0.15/xt/author/000755 000765 000024 00000000000 12665414707 016016 5ustar00neilbstaff000000 000000 Path-Router-0.15/xt/release/000755 000765 000024 00000000000 12665414707 016134 5ustar00neilbstaff000000 000000 Path-Router-0.15/xt/release/eol.t000644 000765 000024 00000001604 12665414707 017101 0ustar00neilbstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::EOLTests 0.18 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/Path/Router.pm', 'lib/Path/Router/Route.pm', 'lib/Path/Router/Route/Match.pm', 'lib/Path/Router/Shell.pm', 'lib/Path/Router/Types.pm', 'lib/Test/Path/Router.pm', 't/00-compile.t', 't/001_basic.t', 't/002_w_optional.t', 't/003_messy_paths.t', 't/004_match_test.t', 't/005_match_test_w_optional.t', 't/006_match_w_targets.t', 't/007_match_exact_urls.t', 't/008_uri_for.t', 't/009_include_other_router.t', 't/010_example_cat_chained_URIs.t', 't/011_incorrect_validation_warning.t', 't/012_ambiguous_routes.t', 't/013_false_path_components.t', 't/014_test_path_router.t', 't/100_bug.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; Path-Router-0.15/xt/release/pod-coverage.t000644 000765 000024 00000000334 12665414707 020674 0ustar00neilbstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Path-Router-0.15/xt/release/pod-syntax.t000644 000765 000024 00000000220 12665414707 020421 0ustar00neilbstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Path-Router-0.15/xt/author/no-tabs.t000644 000765 000024 00000001553 12665414707 017552 0ustar00neilbstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.09 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/Path/Router.pm', 'lib/Path/Router/Route.pm', 'lib/Path/Router/Route/Match.pm', 'lib/Path/Router/Shell.pm', 'lib/Path/Router/Types.pm', 'lib/Test/Path/Router.pm', 't/00-compile.t', 't/001_basic.t', 't/002_w_optional.t', 't/003_messy_paths.t', 't/004_match_test.t', 't/005_match_test_w_optional.t', 't/006_match_w_targets.t', 't/007_match_exact_urls.t', 't/008_uri_for.t', 't/009_include_other_router.t', 't/010_example_cat_chained_URIs.t', 't/011_incorrect_validation_warning.t', 't/012_ambiguous_routes.t', 't/013_false_path_components.t', 't/014_test_path_router.t', 't/100_bug.t' ); notabs_ok($_) foreach @files; done_testing; Path-Router-0.15/t/00-compile.t000644 000765 000024 00000002141 12665414707 016354 0ustar00neilbstaff000000 000000 use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.039 use Test::More tests => 6 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Path/Router.pm', 'Path/Router/Route.pm', 'Path/Router/Route/Match.pm', 'Path/Router/Shell.pm', 'Path/Router/Types.pm', 'Test/Path/Router.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; Path-Router-0.15/t/001_basic.t000644 000765 000024 00000006001 12665414707 016147 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Type::Utils 1.000005 qw(subtype as where); use Types::Standard 1.000005 qw(Int); use Path::Router; my $NumericMonth = subtype as Int, where { $_ <= 12 }; my $router = Path::Router->new; isa_ok($router, 'Path::Router'); can_ok($router, 'add_route'); can_ok($router, 'match'); can_ok($router, 'uri_for'); # create some routes $router->add_route('blog/:year/:month/:day' => ( defaults => { controller => 'blog', action => 'show_date', }, validations => { year => qr/\d{4}/, month => $NumericMonth, day => subtype(Int => where { $_ <= 31 }), } )); # This used to be added at the very beginning, but we're putting it here # to test insert_route $router->insert_route('blog' => ( defaults => { controller => 'blog', action => 'index', } )); # This used to be added as the second argument, but we're... see above. $router->insert_route( 'blog/:action/:id' => ( at => 2, defaults => { controller => 'blog', }, validations => { action => qr/\D+/, id => 'Int' } )); # This used to be added as the last argument, but we're... see above. $router->insert_route('test/?:x/?:y' => ( at => 1_000_000, defaults => { controller => 'test', x => 'x', y => 'y', }, )); # create some tests # check to make sure that "blog" is at the front is( $router->routes->[0]->path, 'blog', "first route is 'blog'"); is( $router->routes->[2]->path, 'blog/:action/:id', "3rd route is 'blog/:action/:id'"); is( $router->routes->[3]->path, 'test/?:x/?:y', "4th route is 'test/?:x/?:y'"); routes_ok($router, { # blog 'blog' => { controller => 'blog', action => 'index', }, # blog/:year/:month/:day 'blog/2006/12/5' => { controller => 'blog', action => 'show_date', year => 2006, month => 12, day => 5, }, # blog/:year/:month/:day 'blog/1920/12/10' => { controller => 'blog', action => 'show_date', year => 1920, month => 12, day => 10, }, # blog/:action/:id 'blog/edit/5' => { controller => 'blog', action => 'edit', id => 5 }, 'blog/show/123' => { controller => 'blog', action => 'show', id => 123 }, 'blog/some_crazy_long_winded_action_name/12356789101112131151' => { controller => 'blog', action => 'some_crazy_long_winded_action_name', id => '12356789101112131151', }, 'blog/delete/5' => { controller => 'blog', action => 'delete', id => 5, }, 'test/x1' => { controller => 'test', x => 'x1', y => 'y', }, }, "... our routes are solid"); done_testing; Path-Router-0.15/t/002_w_optional.t000644 000765 000024 00000002544 12665414707 017252 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; my $router = Path::Router->new; isa_ok($router, 'Path::Router'); # create some routes $router->add_route(':controller/?:action' => ( defaults => { action => 'index' }, validations => { action => qr/\D+/ } )); $router->add_route(':controller/:id/?:action' => ( defaults => { action => 'show', }, validations => { id => 'Int', } )); # run it through some tests routes_ok($router, { 'people' => { controller => 'people', action => 'index', }, 'people/new' => { controller => 'people', action => 'new', }, 'people/create' => { controller => 'people', action => 'create', }, 'people/56' => { controller => 'people', action => 'show', id => 56, }, 'people/56/edit' => { controller => 'people', action => 'edit', id => 56, }, 'people/56/remove' => { controller => 'people', action => 'remove', id => 56, }, 'people/56/update' => { controller => 'people', action => 'update', id => 56, }, }, "... our routes are solid"); done_testing; Path-Router-0.15/t/003_messy_paths.t000644 000765 000024 00000003665 12665414707 017444 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; #use Data::Dumper; use Path::Router; =pod This test how the router fairs with messy URIs =cut my $router = Path::Router->new; isa_ok($router, 'Path::Router'); # create some routes $router->add_route('blog' => ( defaults => { controller => 'blog', action => 'index', } )); $router->add_route('blog/:year/:month/:day' => ( defaults => { controller => 'blog', action => 'show_date', }, validations => { year => qr/\d{4}/, month => qr/\d{1,2}/, day => qr/\d{1,2}/, } )); $router->add_route('blog/:action/:id' => ( defaults => { controller => 'blog', }, validations => { action => qr/\D+/, id => qr/\d+/ } )); # run it through some tests path_ok($router, '/blog/', '... this path is valid'); path_ok($router, './blog/', '... this path is valid'); path_ok($router, '///.///.///blog//.//', '... this path is valid'); path_ok($router, '/blog/./show/.//./20', '... this path is valid'); path_ok($router, '/blog/./2006/.//./20////////10', '... this path is valid'); path_is($router, '/blog/', { controller => 'blog', action => 'index', }, '... this path matches the mapping'); path_is($router, '///.///.///blog//.//', { controller => 'blog', action => 'index', }, '... this path matches the mapping'); path_is($router, '/blog/./show/.//./20', { controller => 'blog', action => 'show', id => 20, }, '... this path matches the mapping'); path_is($router, '/blog/./2006/.//./20////////10', { controller => 'blog', action => 'show_date', year => 2006, month => 20, day => 10, }, '... this path matches the mapping'); done_testing; Path-Router-0.15/t/004_match_test.t000644 000765 000024 00000002536 12665414707 017235 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; my $router = Path::Router->new; isa_ok($router, 'Path::Router'); # create some routes $router->add_route('blog' => ( defaults => { controller => 'blog', action => 'index', } )); $router->add_route('blog/:year/:month/:day' => ( defaults => { controller => 'blog', action => 'show_date', }, validations => { year => qr/\d{4}/, month => qr/\d{1,2}/, day => qr/\d{1,2}/, } )); $router->add_route('blog/:action/:id' => ( defaults => { controller => 'blog', }, validations => { action => qr/\D+/, id => qr/\d+/ } )); path_ok($router, $_, '... matched path (' . $_ . ')') foreach qw[ /blog/ /blog/edit/15/ /blog/2006/31/20/ /blog/2006/31/2/ /blog/2006/3/2/ /blog/2006/3/20/ ]; path_not_ok($router, $_, '... could not match path (' . $_ . ')') foreach qw[ foo/ /foo /blog/index /blog/foo /blog/foo/bar /blog/10/bar blog/10/1000 /blog/show_date/2006/31/2 /blog/06/31/2 /blog/20063/31/2 /blog/2006/31/200 /blog/2006/310/1 ]; done_testing; Path-Router-0.15/t/005_match_test_w_optional.t000644 000765 000024 00000002055 12665414707 021465 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; my $router = Path::Router->new; isa_ok($router, 'Path::Router'); # create some routes $router->add_route(':controller/?:action' => ( defaults => { action => 'index' }, validations => { controller => qr/\D+/, action => qr/\D+/ } )); $router->add_route(':controller/:id/?:action' => ( defaults => { action => 'show', }, validations => { controller => qr/\D+/, action => qr/\D+/, id => qr/\d+/, } )); path_ok($router, $_, '... matched path (' . $_ . ')') foreach qw[ /users/ /users/new/ /users/10/ /users/100000000000101010101/ /users/10/edit/ /users/1/show/ /users/100000000000101010101/show ]; path_not_ok($router, $_, '... could not match path (' . $_ . ')') foreach qw[ /10/ /20/10/ /users/10/12/ /users/edit/12/ ]; done_testing; Path-Router-0.15/t/006_match_w_targets.t000644 000765 000024 00000006026 12665414707 020255 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; for my $inline (0, 1) { my $INDEX = bless {} => 'Blog::Index'; my $SHOW_DATE = bless {} => 'Blog::ShowDate'; my $GENERAL = bless {} => 'Blog::Controller'; my $router = Path::Router->new(inline => $inline); isa_ok($router, 'Path::Router'); # create some routes $router->add_route('blog' => ( defaults => { controller => 'blog', action => 'index', }, target => $INDEX, )); $router->add_route('blog/:year/:month/:day' => ( defaults => { controller => 'blog', action => 'show_date', }, validations => { year => qr/\d{4}/, month => qr/\d{1,2}/, day => qr/\d{1,2}/, }, target => $SHOW_DATE, )); $router->add_route('blog/:action/:id' => ( defaults => { controller => 'blog', }, validations => { action => qr/\D+/, id => qr/\d+/ }, target => $GENERAL )); my $suffix = ''; $suffix = ' (inline)' if $inline; { my $match = $router->match('/blog/'); isa_ok($match, 'Path::Router::Route::Match'); is($match->route->target, $INDEX, '... got the right target' . $suffix); is_deeply( $match->mapping, { controller => 'blog', action => 'index', }, '... got the right mapping' . $suffix ); } { my $match = $router->match('/blog/2006/12/1'); isa_ok($match, 'Path::Router::Route::Match'); is($match->route->target, $SHOW_DATE, '... got the right target' . $suffix); is_deeply( $match->mapping, { controller => 'blog', action => 'show_date', year => 2006, month => 12, day => 1, }, '... got the right mapping' . $suffix ); } { my $match = $router->match('/blog/show/5'); isa_ok($match, 'Path::Router::Route::Match'); is($match->route->target, $GENERAL, '... got the right target' . $suffix); is_deeply( $match->mapping, { controller => 'blog', action => 'show', id => 5, }, '... got the right mapping' . $suffix ); } { my $match = $router->match('/blog/show/0'); isa_ok($match, 'Path::Router::Route::Match'); is($match->route->target, $GENERAL, '... got the right target' . $suffix); is_deeply( $match->mapping, { controller => 'blog', action => 'show', id => 0, }, '... got the right mapping' . $suffix ); } } done_testing; Path-Router-0.15/t/007_match_exact_urls.t000644 000765 000024 00000001355 12665414707 020430 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Path::Router; my $r = Path::Router->new; isa_ok($r, 'Path::Router'); $r->add_route('/math/simple/add', target => (bless {} => 'Math::Simple::add')); $r->add_route('/math/simple/sub', target => (bless {} => 'Math::Simple::sub')); $r->add_route('/math/simple/mul', target => (bless {} => 'Math::Simple::mul')); $r->add_route('/math/simple/div', target => (bless {} => 'Math::Simple::div')); isa_ok($r->match('math/simple/add')->target, 'Math::Simple::add'); isa_ok($r->match('math/simple/sub')->target, 'Math::Simple::sub'); isa_ok($r->match('math/simple/mul')->target, 'Math::Simple::mul'); isa_ok($r->match('math/simple/div')->target, 'Math::Simple::div'); done_testing; Path-Router-0.15/t/008_uri_for.t000644 000765 000024 00000003025 12665414707 016545 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; my $router = Path::Router->new; $router->add_route('/' => ( defaults => { controller => 'root', action => 'index', } )); $router->add_route('/name/?:first' => ( defaults => { controller => 'name', }, )); $router->add_route('/:name' => ( defaults => { controller => 'root', action => 'hello', }, )); mapping_is( $router, { controller => 'root', action => 'index', }, '', 'return "" for /', ); mapping_is( $router, { controller => 'root', action => 'bogus', }, undef, 'return undef for bogus mapping', ); mapping_is( $router, { name => 'world', }, 'world', 'match with only component variables', ); mapping_is( $router, { first => 'Sally', }, 'name/Sally', 'match with only optional component variables', ); mapping_is( $router, { controller => 'root', action => 'hello', name => 'world', }, 'world', 'match with extra variables', ); mapping_is( $router, { controller => 'root', name => 'world', }, 'world', 'match with partial defaults', ); mapping_is( $router, { controller => 'root', action => 'hello', }, undef, 'do not match with missing component variable', ); done_testing; Path-Router-0.15/t/009_include_other_router.t000644 000765 000024 00000010116 12665414707 021324 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Fatal 0.012; use Test::Path::Router; use Path::Router; my $poll_router = Path::Router->new(); isa_ok($poll_router, 'Path::Router'); # create some routes $poll_router->add_route('' => ( defaults => { controller => 'polls', action => 'index', } )); $poll_router->add_route(':id/vote' => ( defaults => { controller => 'polls', action => 'vote', }, validations => { id => qr/\d+/ } )); $poll_router->add_route(':id/results' => ( defaults => { controller => 'polls', action => 'results', }, validations => { id => qr/\d+/ } )); path_ok($poll_router, $_, '... matched path (' . $_ . ')') foreach qw[ / /15/vote /15/results ]; routes_ok($poll_router, { '' => { controller => 'polls', action => 'index', }, '15/vote' => { controller => 'polls', action => 'vote', id => 15, }, '15/results' => { controller => 'polls', action => 'results', id => 15, }, }, "... our routes are solid"); # root router my $router = Path::Router->new(); isa_ok($poll_router, 'Path::Router'); # create some routes $router->add_route('' => ( defaults => { controller => 'mysite', action => 'index', } )); $router->add_route('admin' => ( defaults => { controller => 'admin', action => 'index', } )); $router->include_router('polls/' => $poll_router); path_ok($router, $_, '... matched path (' . $_ . ')') foreach qw[ / /admin /polls/ /polls/15/vote /polls/15/results ]; routes_ok($router, { '' => { controller => 'mysite', action => 'index', }, 'admin' => { controller => 'admin', action => 'index', }, 'polls' => { controller => 'polls', action => 'index', }, 'polls/15/vote' => { controller => 'polls', action => 'vote', id => 15, }, 'polls/15/results' => { controller => 'polls', action => 'results', id => 15, }, }, "... our routes are solid"); # hmm, will this work my $test_router = Path::Router->new(); isa_ok($test_router, 'Path::Router'); # create some routes $test_router->add_route('testing' => ( defaults => { controller => 'testing', action => 'index', } )); $test_router->add_route('testing/:id' => ( defaults => { controller => 'testing', action => 'get_id', }, validations => { id => qr/\d+/ } )); $router->include_router('' => $test_router); path_ok($router, $_, '... matched path (' . $_ . ')') foreach qw[ / /admin /polls/ /polls/15/vote /polls/15/results /testing /testing/100 ]; routes_ok($router, { '' => { controller => 'mysite', action => 'index', }, 'admin' => { controller => 'admin', action => 'index', }, 'polls' => { controller => 'polls', action => 'index', }, 'polls/15/vote' => { controller => 'polls', action => 'vote', id => 15, }, 'polls/15/results' => { controller => 'polls', action => 'results', id => 15, }, 'testing' => { controller => 'testing', action => 'index', }, 'testing/1000' => { controller => 'testing', action => 'get_id', id => 1000, }, }, "... our routes are solid"); # test a few errors isnt( exception { $router->include_router('foo' => $test_router) }, undef, "... this dies correctly" ); isnt( exception { $router->include_router('/foo' => $test_router) }, undef, "... this dies correctly" ); isnt( exception { $router->include_router('/foo/1' => $test_router) }, undef, "... this dies correctly" ); done_testing; Path-Router-0.15/t/010_example_cat_chained_URIs.t000644 000765 000024 00000015425 12665414707 021737 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; =pod This is an example of using Path::Router to match the URIs from a Catalyst app we recently built at $work which used the Chained dispatch type. It is a test to see how things would translate between the two. Below is part of the Catalyst ASCII table which shows all the paths and the actions they take. Loaded Path Part actions: .-------------------------------------+--------------------------------------. | Path Spec | Private | +-------------------------------------+--------------------------------------+ | /plan/*/confirm | /plan/load_plan_from_store (1) | | | -> /plan/end_transition (0) | | | => /plan/confirm | +-------------------------------------+--------------------------------------+ | /plan/*/delete | /plan/load_plan_from_store (1) | | | => /plan/delete | +-------------------------------------+--------------------------------------+ | /plan/*/edit | /plan/load_plan_from_store (1) | | | -> /plan/edit (0) | | | => /plan/edit_next | +-------------------------------------+--------------------------------------+ | /plan/*/edit/engagement_framework | /plan/load_plan_from_store (1) | | | -> /plan/edit (0) | | | => /plan/engagement_framework | +-------------------------------------+--------------------------------------+ | /plan/*/edit/key_drivers | /plan/load_plan_from_store (1) | | | -> /plan/edit (0) | | | => /plan/key_drivers | +-------------------------------------+--------------------------------------+ | /plan/*/edit/priorities | /plan/load_plan_from_store (1) | | | -> /plan/edit (0) | | | => /plan/priorities | +-------------------------------------+--------------------------------------+ | /plan/*/submit | /plan/load_plan_from_store (1) | | | -> /plan/end_transition (0) | | | => /plan/submit | +-------------------------------------+--------------------------------------+ | /plan/*/edit/title | /plan/load_plan_from_store (1) | | | -> /plan/edit (0) | | | => /plan/title | +-------------------------------------+--------------------------------------+ | /plan/*/unsubmit | /plan/load_plan_from_store (1) | | | -> /plan/end_transition (0) | | | => /plan/unsubmit | +-------------------------------------+--------------------------------------+ | /plan/*/view | /plan/load_plan_from_store (1) | | | => /plan/view | '-------------------------------------+--------------------------------------' =cut my $router = Path::Router->new; isa_ok($router, 'Path::Router'); $router->add_route(':controller'); $router->add_route('plan/:action' => ( defaults => { controller => 'plan', }, validations => { action => qr/\D+/ } )); $router->add_route('plan/:id/edit/?:edit_action' => ( defaults => { controller => 'plan', action => 'edit', edit_action => 'edit_next' }, validations => { id => qr/\d+/, edit_action => qr/\D+/, } )); $router->add_route('plan/:id/:action' => ( defaults => { controller => 'plan' }, validations => { id => qr/\d+/, action => qr/\D+/, } )); routes_ok($router, { 'index' => { controller => 'index' }, 'access_denied' => { controller => 'access_denied' }, 'plan' => { controller => 'plan' }, # plan searching 'plan/search' => { controller => 'plan', action => 'search', }, 'plan/search_results' => { controller => 'plan', action => 'search_results', }, # plan viewing 'plan/list' => { controller => 'plan', action => 'list', }, 'plan/create' => { controller => 'plan', action => 'create', }, 'plan/not_found' => { controller => 'plan', action => 'not_found', }, 'plan/wrong_state' => { controller => 'plan', action => 'wrong_state', }, # with $id 'plan/5/view' => { controller => 'plan', action => 'view', id => 5, }, 'plan/5/delete' => { controller => 'plan', action => 'delete', id => 5, }, 'plan/5/confirm' => { controller => 'plan', action => 'confirm', id => 5, }, 'plan/5/submit' => { controller => 'plan', action => 'submit', id => 5, }, 'plan/5/unsubmit' => { controller => 'plan', action => 'unsubmit', id => 5, }, # editing 'plan/5/edit' => { controller => 'plan', action => 'edit', id => 5, edit_action => 'edit_next', }, 'plan/5/edit/title' => { controller => 'plan', action => 'edit', id => 5, edit_action => 'title', }, 'plan/5/edit/engagement_framework' => { controller => 'plan', action => 'edit', id => 5, edit_action => 'engagement_framework', }, 'plan/5/edit/key_drivers' => { controller => 'plan', action => 'edit', id => 5, edit_action => 'key_drivers', }, 'plan/5/edit/priorities' => { controller => 'plan', action => 'edit', id => 5, edit_action => 'priorities', }, }, "... our routes are solid"); path_not_ok($router, $_, '... ' . $_ . ' is not okay') for qw[ /index/edit /access_denied/5/delete /access_denied/5/delete/foo /plan/5 /plan/foo/5 /plan/5/10 /plan/5/edit/100 ]; done_testing; Path-Router-0.15/t/011_incorrect_validation_warning.t000644 000765 000024 00000001036 12665414707 023021 0ustar00neilbstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More 1.001013; use Path::Router; my $router = Path::Router->new; { my $warning; local $SIG{__WARN__} = sub { $warning .= $_[0] }; $router->add_route( '/foo/:bar' => ( validations => { baz => 'Int', }, ), ); like( $warning, qr+Validation provided for component :baz, but the path /foo/:bar doesn't contain a variable component with that name+, "got a warning" ); } done_testing; Path-Router-0.15/t/012_ambiguous_routes.t000644 000765 000024 00000005016 12665414707 020471 0ustar00neilbstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More 1.001013; use Test::Fatal 0.012; use Path::Router; { my $router = Path::Router->new; $router->add_route('/foo' => defaults => { a => 'b', c => 'd', e => 'f' } ); $router->add_route('/bar' => defaults => { a => 'b', c => 'd' } ); is($router->uri_for(a => 'b'), 'bar'); } { my $router = Path::Router->new; $router->add_route('/bar' => defaults => { a => 'b', c => 'd' } ); $router->add_route('/foo' => defaults => { a => 'b', c => 'd', e => 'f' } ); is($router->uri_for(a => 'b'), 'bar'); } { my $router = Path::Router->new; $router->add_route('/foo' => defaults => { a => 'b', c => 'd', e => 'f' } ); $router->add_route('/bar' => defaults => { a => 'b', c => 'd', g => 'h' } ); like( exception { $router->uri_for(a => 'b', c => 'd') }, qr{^\QAmbiguous path descriptor (specified keys a, c): could match paths /bar, /foo}, "error when it's actually ambiguous" ); } { my $router = Path::Router->new; $router->add_route('/foo/:bar' => (defaults => { id => 1 })); $router->add_route('/foo/bar' => (defaults => { id => 2 })); my $match = $router->match('/foo/bar'); is($match->mapping->{id}, 2); } { my $router = Path::Router->new; $router->add_route('/foo/bar' => (defaults => { id => 2 })); $router->add_route('/foo/:bar' => (defaults => { id => 1 })); my $match = $router->match('/foo/bar'); is($match->mapping->{id}, 2); } { my $router = Path::Router->new; $router->add_route('/foo/:bar' => (defaults => { id => 1 })); $router->add_route('/:foo/bar' => (defaults => { id => 2 })); like( exception { $router->match('/foo/bar') }, qr{^\QAmbiguous match: path foo/bar could match any of /:foo/bar, /foo/:bar}, "error when it's actually ambiguous" ); } { my $router = Path::Router->new; $router->add_route('/foo/bar/?:baz' => (defaults => { id => 1 })); $router->add_route('/foo/:bar' => (defaults => { id => 2 })); my $match = $router->match('/foo/bar'); is($match->mapping->{id}, 1, "optional components don't matter"); } { my $router = Path::Router->new; $router->add_route('/foo/:bar' => (defaults => { id => 2 })); $router->add_route('/foo/bar/?:baz' => (defaults => { id => 1 })); my $match = $router->match('/foo/bar'); is($match->mapping->{id}, 1, "optional components don't matter"); } done_testing; Path-Router-0.15/t/013_false_path_components.t000644 000765 000024 00000000613 12665414707 021447 0ustar00neilbstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use Test::More 1.001013; use Path::Router; for my $inline (0, 1) { for my $path ('0/1', '1/0') { my $router = Path::Router->new(inline => $inline); $router->add_route($path); my $match = $router->match($path); ok($match); is_deeply($match->route->components, [split '/', $path]); } } done_testing; Path-Router-0.15/t/014_test_path_router.t000644 000765 000024 00000007305 12665414707 020475 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router (); use Path::Router; $Test::Path::Router::Test = Test::Builder->create; my $capture = $Test::Path::Router::Test; my $test = Test::More->builder; my $router = Path::Router->new; { my $output; $capture->output(\$output); $capture->failure_output(\$output); $capture->todo_output(\$output); } $router->add_route('blog' => ( defaults => { controller => 'Blog' } )); $router->add_route('feed' => ( defaults => { controller => 'Feed' } )); my %tests = ( mapping_not_ok => { pass => { desc => 'mapping_not_ok passes when mapping not found', args => [{controller => 'Wiki'}, 'fail'], }, fail => { desc => 'mapping_not_ok fails when mapping found', args => [{controller => 'Blog'}, 'pass'], }, coderef => \&Test::Path::Router::mapping_not_ok, }, mapping_ok => { pass => { desc => 'mapping_ok passes when mapping found', args => [{controller => 'Blog'}, 'pass'], }, fail => { desc => 'mapping_ok fails when mapping not found', args => [{controller => 'Wiki'}, 'fail'], }, coderef => \&Test::Path::Router::mapping_ok, }, mapping_is => { pass => { desc => 'mapping_is passes when mapping matches path', args => [{controller => 'Blog'}, 'blog'], }, fail => { desc => 'mapping_is fails when mapping does not match path', args => [{controller => 'Wiki'}, 'blog'], }, coderef => \&Test::Path::Router::mapping_is, }, path_not_ok => { pass => { desc => 'path_not_ok passes when path not found', args => ['wiki'], }, fail => { desc => 'path_not_ok fails when path found', args => ['blog'], }, coderef => \&Test::Path::Router::path_not_ok, }, path_ok => { pass => { desc => 'path_ok passes when path found', args => ['blog'], }, fail => { desc => 'path_ok fails when path not found', args => ['wiki'], }, coderef => \&Test::Path::Router::path_ok, }, path_is => { pass => { desc => 'path_is passes when path matches mapping', args => [blog => {controller => 'Blog'}], }, fail => { desc => 'path_is fails when path does not match mapping', args => [blog => {controller => 'Wiki'}], }, coderef => \&Test::Path::Router::path_is, }, routes_ok => { pass => { desc => 'routes_ok passes when all paths and mappings match', args => [{ blog => {controller => 'Blog'}, feed => {controller => 'Feed'}, }], }, fail => { desc => 'routes_ok fails when all paths and mappings do not match', args => [{ blog => {controller => 'Blog'}, feed => {controller => 'Wiki'}, }], }, coderef => \&Test::Path::Router::routes_ok, }, ); for my $function (sort keys %tests) { my $coderef = $tests{$function}->{coderef}; for my $state (qw(pass fail)) { my $arguments = $tests{$function}->{$state}->{args}; my $description = $tests{$function}->{$state}->{desc}; $coderef->($router, @$arguments, $description); my $result = ($capture->details)[-1]->{ok}; $result = !$result if $state eq 'fail'; $test->ok($result, $description); } } $capture->done_testing; $test->done_testing; Path-Router-0.15/t/100_bug.t000644 000765 000024 00000001430 12665414707 015644 0ustar00neilbstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More 1.001013; use Test::Path::Router; use Path::Router; my $router = Path::Router->new; $router->add_route('/wiki/?:page' => ( defaults => { controller => 'wiki', page => 'HomePage', } )); $router->add_route('/css/:style' => ( defaults => { controller => 'css' } )); is( $router->uri_for(page => 'whatever'), 'wiki/whatever', '... got the right URI' ); is( $router->uri_for(style => 'mystyle'), 'css/mystyle', '... got the right URI' ); is( $router->uri_for(style => 'wiki'), 'css/wiki', '... got the right URI' ); is( $router->uri_for(controller => 'wiki'), 'wiki', 'defaults correctly excluded (no trailing slash)', ); done_testing; Path-Router-0.15/lib/Path/000755 000765 000024 00000000000 12665414707 015523 5ustar00neilbstaff000000 000000 Path-Router-0.15/lib/Test/000755 000765 000024 00000000000 12665414707 015546 5ustar00neilbstaff000000 000000 Path-Router-0.15/lib/Test/Path/000755 000765 000024 00000000000 12665414707 016442 5ustar00neilbstaff000000 000000 Path-Router-0.15/lib/Test/Path/Router.pm000644 000765 000024 00000015767 12665414707 020300 0ustar00neilbstaff000000 000000 package Test::Path::Router; our $AUTHORITY = 'cpan:STEVAN'; # ABSTRACT: A testing module for testing routes $Test::Path::Router::VERSION = '0.15'; use strict; use warnings; use Test::Builder 1.001013 (); use Test::Deep 0.113 (); use Data::Dumper 2.154 (); use Sub::Exporter 0.981; my @exports = qw/ routes_ok path_ok path_not_ok path_is mapping_ok mapping_not_ok mapping_is /; Sub::Exporter::setup_exporter({ exports => \@exports, groups => { default => \@exports } }); our $Test = Test::Builder->new; sub routes_ok { my ($router, $routes, $message) = @_; my ($passed, $reason); foreach my $path (keys %$routes) { my $mapping = $routes->{$path}; my $generated_path = $router->uri_for(%{$mapping}); $generated_path = '' unless defined $generated_path; # the path generated from the hash # is the same as the path supplied if ($path ne $generated_path) { $Test->ok(0, $message); $Test->diag("... paths do not match\n" . " got: '" . $generated_path . "'\n" . " expected: '" . $path . "'"); return; } my $match = $router->match($path); my $generated_mapping = $match && $match->mapping; $Test->ok( $match->path eq $path, "matched path (" . $match->path . ") and requested paths ($path) match" ); # the path supplied produces the # same match as the hash supplied unless (Test::Deep::eq_deeply($generated_mapping, $mapping)) { $Test->ok(0, $message); $Test->diag("... mappings do not match for '$path'\n" . " got: " . _dump_mapping_info($generated_mapping) . "\n" . " expected: " . _dump_mapping_info($mapping)); return; } } $Test->ok(1, $message); } sub path_ok { my ($router, $path, $message) = @_; if ($router->match($path)) { $Test->ok(1, $message); } else { $Test->ok(0, $message); } } sub path_not_ok { my ($router, $path, $message) = @_; unless ($router->match($path)) { $Test->ok(1, $message); } else { $Test->ok(0, $message); } } sub path_is { my ($router, $path, $expected, $message) = @_; my $generated_mapping = $router->match($path)->mapping; # the path supplied produces the # same match as the hash supplied unless (Test::Deep::eq_deeply($generated_mapping, $expected)) { $Test->ok(0, $message); $Test->diag("... mappings do not match for '$path'\n" . " got: '" . _dump_mapping_info($generated_mapping) . "'\n" . " expected: '" . _dump_mapping_info($expected) . "'"); } else { $Test->ok(1, $message); } } sub mapping_ok { my ($router, $mapping, $message) = @_; if (defined $router->uri_for(%{$mapping})) { $Test->ok(1, $message); } else { $Test->ok(0, $message); } } sub mapping_not_ok { my ($router, $mapping, $message) = @_; unless (defined $router->uri_for(%{$mapping})) { $Test->ok(1, $message); } else { $Test->ok(0, $message); } } sub mapping_is { my ($router, $mapping, $expected, $message) = @_; my $generated_path = $router->uri_for(%{$mapping}); # the path generated from the hash # is the same as the path supplied if ( (defined $generated_path and not defined $expected) or (defined $expected and not defined $generated_path) or (defined $generated_path and defined $expected and $generated_path ne $expected) ) { $_ = defined $_ ? qq{'$_'} : qq{undef} for $generated_path, $expected; $Test->ok(0, $message); $Test->diag("... paths do not match\n" . " got: $generated_path\n" . " expected: $expected"); } else { $Test->ok(1, $message); } } ## helper function sub _dump_mapping_info { my ($mapping) = @_; local $Data::Dumper::Indent = 0; my $out = Data::Dumper::Dumper($mapping); $out =~ s/\$VAR\d\s*=\s*//; return $out; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test::Path::Router - A testing module for testing routes =head1 VERSION version 0.15 =head1 SYNOPSIS use Test::More plan => 1; use Test::Path::Router; my $router = Path::Router->new; # ... define some routes path_ok($router, 'admin/remove_user/56', '... this is a valid path'); path_is($router, 'admin/edit_user/5', { controller => 'admin', action => 'edit_user', id => 5, }, '... the path and mapping match'); mapping_ok($router, { controller => 'admin', action => 'edit_user', id => 5, }, '... this maps to a valid path'); mapping_is($router, { controller => 'admin', action => 'edit_user', id => 5, }, 'admin/edit_user/5', '... the mapping and path match'); routes_ok($router, { 'admin' => { controller => 'admin', action => 'index', }, 'admin/add_user' => { controller => 'admin', action => 'add_user', }, 'admin/edit_user/5' => { controller => 'admin', action => 'edit_user', id => 5, } }, "... our routes are valid"); =head1 DESCRIPTION This module helps in testing out your path routes, to make sure they are valid. =head1 EXPORTED FUNCTIONS =over 4 =item B =item B =item B =item B =item B =item B =item B This test function will accept a set of C<%test_routes> which will get checked against your C<$router> instance. This will check to be sure that all paths in C<%test_routes> procude the expected mappings, and that all mappings also produce the expected paths. It basically assures you that your paths are roundtrippable, so that you can be confident in them. =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 AUTHOR Stevan Little Estevan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2011 Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Stevan Little =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Infinity Interactive. 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 Path-Router-0.15/lib/Path/Router/000755 000765 000024 00000000000 12665414707 017003 5ustar00neilbstaff000000 000000 Path-Router-0.15/lib/Path/Router.pm000644 000765 000024 00000033734 12665414707 017353 0ustar00neilbstaff000000 000000 package Path::Router; our $AUTHORITY = 'cpan:STEVAN'; $Path::Router::VERSION = '0.15'; use 5.008; use Carp 1.32; use Eval::Closure 0.13; use File::Spec::Unix 3.40 (); use Try::Tiny 0.19; use Types::Standard 1.000005 -types; use Path::Router::Types; use Path::Router::Route; use Path::Router::Route::Match; use Moo 2.000001; use namespace::clean 0.23; # ABSTRACT: A tool for routing paths use constant 1.24 DEBUG => exists $ENV{PATH_ROUTER_DEBUG} ? $ENV{PATH_ROUTER_DEBUG} : 0; has 'routes' => ( is => 'ro', isa => ArrayRef[InstanceOf['Path::Router::Route']], default => sub { [] }, ); has 'route_class' => ( is => 'ro', isa => ClassName, default => 'Path::Router::Route', ); has 'inline' => ( is => 'rw', isa => Bool, default => 1, trigger => sub { $_[0]->clear_match_code } ); has 'match_code' => ( is => 'rw', isa => CodeRef, lazy => 1, builder => 1, clearer => 'clear_match_code' ); sub _build_match_code { my $self = shift; my @code; my $i = 0; foreach my $route (@{$self->routes}) { push @code, $route->generate_match_code($i++); } return eval_closure( source => [ 'sub {', '#line ' . __LINE__ . ' "' . __FILE__ . '"', 'my $self = shift;', 'my $path = shift;', 'my $routes = $self->routes;', 'my @matches;', @code, '#line ' . __LINE__ . ' "' . __FILE__ . '"', 'if (@matches == 0) {', 'print STDERR "match failed\n" if Path::Router::DEBUG();', 'return;', '}', 'elsif (@matches == 1) {', 'return $matches[0];', '}', 'else {', 'return $self->_disambiguate_matches($path, @matches);', '}', '}', ] ); } sub add_route { my ($self, $path, %options) = @_; push @{$self->routes} => $self->route_class->new( path => $path, %options ); $self->clear_match_code; } sub insert_route { my ($self, $path, %options) = @_; my $at = delete $options{at} || 0; my $route = $self->route_class->new( path => $path, %options ); my $routes = $self->routes; if (! $at) { unshift @$routes, $route; } elsif ($#{$routes} < $at) { push @$routes, $route; } else { splice @$routes, $at, 0, $route; } $self->clear_match_code; } sub include_router { my ($self, $path, $router) = @_; ($path eq '' || $path =~ /\/$/) || confess "Path is either empty or does not end with /"; push @{ $self->routes } => map { $_->clone( path => ($path . $_->path) ) } @{ $router->routes }; $self->clear_match_code; } sub match { my ($self, $url) = @_; $url = File::Spec::Unix->canonpath($url); $url =~ s|^/||; # Path::Router specific. remove first / if ($self->inline) { return $self->match_code->($self, $url); } else { my @parts = split '/' => $url; my @matches; for my $route (@{$self->routes}) { my $match = $route->match(\@parts) or next; push @matches, $match; } return if @matches == 0; return $matches[0] if @matches == 1; return $self->_disambiguate_matches($url, @matches); } return; } sub _disambiguate_matches { my $self = shift; my ($path, @matches) = @_; my $min; my @found; for my $match (@matches) { my $vars = @{ $match->route->required_variable_component_names }; if (!defined($min) || $vars < $min) { @found = ($match); $min = $vars; } elsif ($vars == $min) { push @found, $match; } } confess "Ambiguous match: path $path could match any of " . join(', ', sort map { $_->route->path } @found) if @found > 1; return $found[0]; } sub uri_for { my ($self, %orig_url_map) = @_; # anything => undef is useless; ignore it and let the defaults override it for (keys %orig_url_map) { delete $orig_url_map{$_} unless defined $orig_url_map{$_}; } my @possible; foreach my $route (@{$self->routes}) { local $SIG{__DIE__}; my @url; my $url = try { my %url_map = %orig_url_map; my %required = map {( $_ => 1 )} @{ $route->required_variable_component_names }; my %optional = map {( $_ => 1 )} @{ $route->optional_variable_component_names }; my %url_defaults; my %match = %{$route->defaults || {}}; for my $component (keys(%required), keys(%optional)) { next unless exists $match{$component}; $url_defaults{$component} = delete $match{$component}; } # any remaining keys in %defaults are 'extra' -- they don't appear # in the url, so they need to match exactly rather than being # filled in %url_map = (%url_defaults, %url_map); my @keys = keys %url_map; if (DEBUG) { warn "> Attempting to match ", $route->path, " to (", (join " / " => @keys), ")"; } ( @keys >= keys(%required) && @keys <= (keys(%required) + keys(%optional) + keys(%match)) ) || die "LENGTH DID NOT MATCH\n"; if (my @missing = grep { ! exists $url_map{$_} } keys %required) { warn "missing: @missing" if DEBUG; die "MISSING ITEM [@missing]\n"; } if (my @extra = grep { ! $required{$_} && ! $optional{$_} && ! $match{$_} } keys %url_map) { warn "extra: @extra" if DEBUG; die "EXTRA ITEM [@extra]\n"; } if (my @nomatch = grep { exists $url_map{$_} and $url_map{$_} ne $match{$_} } keys %match) { warn "no match: @nomatch" if DEBUG; die "NO MATCH [@nomatch]\n"; } for my $component (@{$route->components}) { if ($route->is_component_variable($component)) { warn "\t\t... found a variable ($component)" if DEBUG; my $name = $route->get_component_name($component); push @url => $url_map{$name} unless $route->is_component_optional($component) && $route->defaults->{$name} && $route->defaults->{$name} eq $url_map{$name}; } else { warn "\t\t... found a constant ($component)" if DEBUG; push @url => $component; } warn "+++ URL so far ... ", (join "/" => @url) if DEBUG; } return join "/" => grep { defined } @url; } catch { do { warn join "/" => @url; warn "... ", $_; } if DEBUG; return; }; push @possible, [$route, $url] if defined $url; } return undef unless @possible; return $possible[0][1] if @possible == 1; my @found; my $min; for my $possible (@possible) { my ($route, $url) = @$possible; my %url_map = %orig_url_map; my %required = map {( $_ => 1 )} @{ $route->required_variable_component_names }; my %optional = map {( $_ => 1 )} @{ $route->optional_variable_component_names }; my %url_defaults; my %match = %{$route->defaults || {}}; for my $component (keys(%required), keys(%optional)) { next unless exists $match{$component}; $url_defaults{$component} = delete $match{$component}; } # any remaining keys in %defaults are 'extra' -- they don't appear # in the url, so they need to match exactly rather than being # filled in %url_map = (%url_defaults, %url_map); my %wanted = (%required, %optional, %match); delete $wanted{$_} for keys %url_map; my $extra = keys %wanted; if (!defined($min) || $extra < $min) { @found = ($possible); $min = $extra; } elsif ($extra == $min) { push @found, $possible; } } confess "Ambiguous path descriptor (specified keys " . join(', ', sort keys(%orig_url_map)) . "): could match paths " . join(', ', sort map { $_->path } map { $_->[0] } @found) if @found > 1; return $found[0][1]; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Path::Router - A tool for routing paths =head1 VERSION version 0.15 =head1 SYNOPSIS my $router = Path::Router->new; $router->add_route('blog' => ( defaults => { controller => 'blog', action => 'index', }, # you can provide a fixed "target" # for a match as well, this can be # anything you want it to be ... target => My::App->get_controller('blog')->get_action('index') )); $router->add_route('blog/:year/:month/:day' => ( defaults => { controller => 'blog', action => 'show_date', }, # validate with ... validations => { # ... raw-Regexp refs year => qr/\d{4}/, # ... custom Moose types you created month => 'NumericMonth', # ... Moose anon-subtypes created inline day => subtype('Int' => where { $_ <= 31 }), } )); $router->add_route('blog/:action/?:id' => ( defaults => { controller => 'blog', }, validations => { action => qr/\D+/, id => 'Int', # also use plain Moose types too } )); # even include other routers $router->include_router( 'polls/' => $another_router ); # ... in your dispatcher # returns a Path::Router::Route::Match object my $match = $router->match('/blog/edit/15'); # ... in your code my $uri = $router->uri_for( controller => 'blog', action => 'show_date', year => 2006, month => 10, day => 5, ); =head1 DESCRIPTION This module provides a way of deconstructing paths into parameters suitable for dispatching on. It also provides the inverse in that it will take a list of parameters, and construct an appropriate uri for it. =head2 Reversable This module places a high degree of importance on reversability. The value produced by a path match can be passed back in and you will get the same path you originally put in. The result of this is that it removes ambiguity and therefore reduces the number of possible mis-routings. =head2 Verifyable This module also provides additional tools you can use to test and verify the integrity of your router. These include: =over 4 =item * An interactive shell in which you can test various paths and see the match it will return, and also test the reversability of that match. =item * A L module which can be used in your applications test suite to easily verify the integrity of your paths. =back =head1 METHODS =over 4 =item B =item B Adds a new route to the I of the routes list. =item B Adds a new route to the routes list. You may specify an C parameter, which would indicate the position where you want to insert your newly created route. The C parameter is the C position in the list, so it starts at 0. Examples: # You have more than three paths, insert a new route at # the 4th item $router->insert_route($path => ( at => 3, %options )); # If you have less items than the index, then it's the same as # as add_route -- it's just appended to the end of the list $router->insert_route($path => ( at => 1_000_000, %options )); # If you want to prepend, omit "at", or specify 0 $router->insert_Route($path => ( at => 0, %options )); =item B These extracts all the route from C<$other_router> and includes them into the invocant router and prepends C<$path> to all their paths. It should be noted that this does B do any kind of redispatch to the C<$other_router>, it actually extracts all the paths from C<$other_router> and inserts them into the invocant router. This means any changes to C<$other_router> after inclusion will not be reflected in the invocant. =item B =item B Return a L object for the first route that matches the given C<$path>, or C if no routes match. =item B Find the path that, when passed to C<< $router->match >>, would produce the given arguments. Returns the path without any leading C. Returns C if no routes match. =item B The class to use for routes. Defaults to L. =item B =back =head1 DEBUGGING You can turn on the verbose debug logging with the C environment variable. =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 AUTHOR Stevan Little Estevan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2011 Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =for Pod::Coverage DEBUG =head1 AUTHOR Stevan Little =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Infinity Interactive. 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 Path-Router-0.15/lib/Path/Router/Route/000755 000765 000024 00000000000 12665414707 020101 5ustar00neilbstaff000000 000000 Path-Router-0.15/lib/Path/Router/Route.pm000644 000765 000024 00000023601 12665414707 020441 0ustar00neilbstaff000000 000000 package Path::Router::Route; our $AUTHORITY = 'cpan:STEVAN'; $Path::Router::Route::VERSION = '0.15'; use B; use Carp 1.32 qw(cluck); use Clone::PP 1.04 (); use Path::Router::Types qw(PathRouterRouteValidationMap); use Types::Standard 1.000005 -types; use Moo 2.000001; use namespace::clean 0.23; # ABSTRACT: An object to represent a route has 'path' => ( is => 'ro', isa => Str, required => 1 ); has 'defaults' => ( is => 'ro', isa => HashRef, default => sub { {} }, predicate => 1, ); has 'validations' => ( is => 'ro', isa => PathRouterRouteValidationMap, coerce => 1, default => sub { {} }, predicate => 1, ); has 'components' => ( is => 'ro', isa => ArrayRef[Str], lazy => 1, default => sub { [ grep {defined && length} split '/' => (shift)->path ] } ); has 'length' => ( is => 'ro', isa => Int, lazy => 1, default => sub { scalar @{(shift)->components} }, ); has 'length_without_optionals' => ( is => 'ro', isa => Int, lazy => 1, default => sub { scalar grep { ! $_[0]->is_component_optional($_) } @{ $_[0]->components } }, ); has 'required_variable_component_names' => ( is => 'ro', isa => ArrayRef[Str], lazy => 1, builder => 1, ); has 'optional_variable_component_names' => ( is => 'ro', isa => ArrayRef[Str], lazy => 1, builder => 1, ); has 'target' => ( # let this just get copied, we # assume cloning of this is not # what you would want is => 'ro', isa => Any, predicate => 'has_target' ); sub BUILD { my $self = shift; return unless $self->has_validations; my %components = map { $self->get_component_name($_) => 1 } grep { $self->is_component_variable($_) } @{ $self->components }; for my $validation (keys %{ $self->validations }) { if (!exists $components{$validation}) { cluck "Validation provided for component :$validation, but the" . " path " . $self->path . " doesn't contain a variable" . " component with that name"; } } } sub _build_required_variable_component_names { my $self = shift; return [ map { $self->get_component_name($_) } grep { $self->is_component_variable($_) && ! $self->is_component_optional($_) } @{ $self->components } ]; } sub _build_optional_variable_component_names { my $self = shift; return [ map { $self->get_component_name($_) } grep { $self->is_component_variable($_) && $self->is_component_optional($_) } @{ $self->components } ]; } # misc sub create_default_mapping { my $self = shift; +{ %{$self->defaults} } } sub has_validation_for { my ($self, $name) = @_; $self->validations->{$name}; } # component checking sub is_component_optional { my ($self, $component) = @_; $component =~ /^\?\:/; } sub is_component_variable { my ($self, $component) = @_; $component =~ /^\??\:/; } sub get_component_name { my ($self, $component) = @_; my ($name) = ($component =~ /^\??\:(.*)$/); return $name; } sub match { my ($self, $parts) = @_; return unless ( @$parts >= $self->length_without_optionals && @$parts <= $self->length ); my @parts = @$parts; # for shifting my $mapping = $self->has_defaults ? $self->create_default_mapping : {}; for my $c (@{ $self->components }) { unless (@parts) { die "should never get here: " . "no \@parts left, but more required components remain" if ! $self->is_component_optional($c); last; } my $part = shift @parts; if ($self->is_component_variable($c)) { my $name = $self->get_component_name($c); if (my $v = $self->has_validation_for($name)) { return unless $v->check($part); } $mapping->{$name} = $part; } else { return unless $c eq $part; } } return Path::Router::Route::Match->new( path => join ('/', @$parts), route => $self, mapping => $mapping, ); } sub generate_match_code { my $self = shift; my $pos = shift; my @regexp; my @variables; foreach my $c (@{$self->components}) { my $re; if ($self->is_component_variable($c)) { $re = "([^\\/]+)"; push @variables, $self->get_component_name($c); } else { $re = $c; $re =~ s/([()])/\\$1/g; } $re = "\\/$re"; if ($self->is_component_optional($c)) { $re = "(?:$re)?"; } push @regexp, $re; } $regexp[0] = '' unless defined $regexp[0]; $regexp[0] =~ s/^\\\///; my $regexp = ''; while (defined(my $piece = pop @regexp)) { $regexp = "(?:$piece$regexp)"; } my @code; push @code, ( '#line ' . __LINE__ . ' "' . __FILE__ . '"', 'printf STDERR "Attempting to match \"' . $self->path . '\" against \"$path\""', 'if Path::Router::DEBUG();', 'print STDERR " regexp is " . ' . B::perlstring($regexp), 'if Path::Router::DEBUG();', 'print STDERR "\n"', 'if Path::Router::DEBUG();', 'if ($path =~ /^' . $regexp . '$/) {', '# ' . $self->path, ); if (@variables) { push @code, ( 'my %captures = (', ); foreach my $i (0..$#variables) { my $name = $variables[$i]; $name =~ s/'/\\'/g; push @code, ( 'defined($' . ($i + 1) . ') ? ' . '(' . B::perlstring($name) . ' => $' . ($i + 1) . ') : (),', ); } push @code, ( ');', ); } push @code, ( 'my $route = $routes->[' . $pos . '];', 'my $valid = 1;', ); if ($self->has_defaults) { push @code, ( 'my $mapping = $route->create_default_mapping;', ); } else { push @code, ( 'my $mapping = {};', ); } if (@variables) { push @code, ( 'my $validations = $route->validations;', 'while (my ($key, $value) = each %captures) {', 'next unless defined $value && length $value;', ); my $if = "if"; foreach my $v (@variables) { if ($self->has_validation_for($v)) { my $vstr = B::perlstring($v); push @code, ( $if . ' ($key eq ' . $vstr . ') {', 'my $v = $validations->{' . $vstr . '};', 'if (!$v->check($value)) {', 'print STDERR ' . $vstr . ' . " failed validation\n"', 'if Path::Router::DEBUG();', '$valid = 0;', '}', '}', ); $if = "elsif"; } } push @code, ( '$mapping->{$key} = $value;', '}', ); } push @code, ( 'if ($valid) {', 'print STDERR "match success\n" if Path::Router::DEBUG();', 'push @matches, bless({', 'path => $path,', 'route => $route,', 'mapping => $mapping,', '}, "Path::Router::Route::Match")', '}', '}', ); return @code; } sub clone { my $self = shift; my %new_args = map {$_ => Clone::PP::clone($self->$_)} qw(path target); if ($self->has_defaults) { $new_args{defaults} = \%{$self->defaults}; } if ($self->has_validations) { $new_args{validations} = \%{$self->validations}; } return ref($self)->new({ %new_args, @_ }); } 1; __END__ =pod =encoding UTF-8 =head1 NAME Path::Router::Route - An object to represent a route =head1 VERSION version 0.15 =head1 DESCRIPTION This object is created by L when you call the C method. In general you won't ever create these objects directly, they will be created for you and you may sometimes introspect them. =head1 METHODS =over 4 =item B $path, ?%options)> =item B =item B =item B =item B =item B =item B =item B =item B =item B =item B =item B =back =over 4 =item B =item B =item B =back =head2 Component checks =over 4 =item B =item B =item B =back =head2 Length methods =over 4 =item B =back =head2 Introspection =over 4 =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 AUTHOR Stevan Little Estevan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2011 Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =for Pod::Coverage BUILD =head1 AUTHOR Stevan Little =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Infinity Interactive. 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 Path-Router-0.15/lib/Path/Router/Shell.pm000644 000765 000024 00000004474 12665414707 020421 0ustar00neilbstaff000000 000000 package Path::Router::Shell; our $AUTHORITY = 'cpan:STEVAN'; $Path::Router::Shell::VERSION = '0.15'; use Term::ReadLine 1.11; use Types::Standard 1.000005 qw(InstanceOf); use Data::Dumper 2.154; use Moo 2.000001; use namespace::clean 0.23; # ABSTRACT: An interactive shell for testing router configurations has 'router' => ( is => 'ro', isa => InstanceOf['Path::Router'], required => 1, ); sub shell { my $self = shift; my $term = Term::ReadLine->new(__PACKAGE__); my $OUT = $term->OUT || \*STDOUT; while ( defined ($_ = $term->readline("> ")) ) { chomp; return if /[qQ]/; my $map = $self->router->match($_); if ($map) { print $OUT Dumper $map; print $OUT "Round-trip URI is : " . $self->router->uri_for(%$map), } else { print $OUT "No match for $_\n"; } $term->addhistory($_) if /\S/; } } 1; __END__ =pod =encoding UTF-8 =head1 NAME Path::Router::Shell - An interactive shell for testing router configurations =head1 VERSION version 0.15 =head1 SYNOPSIS #!/usr/bin/perl use strict; use warnings; use My::App::Router; use Path::Router::Shell; Path::Router::Shell->new(router => My::App::Router->new)->shell; =head1 DESCRIPTION This is a tool for helping test the routing in your applications, so you simply write a small script like showing in the SYNOPSIS and then you can use it to test new routes or debug routing issues, etc etc etc. =head1 METHODS =over 4 =item B $router)> =item B =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 AUTHOR Stevan Little Estevan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2011 Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Stevan Little =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Infinity Interactive. 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 Path-Router-0.15/lib/Path/Router/Types.pm000644 000765 000024 00000004203 12665414707 020444 0ustar00neilbstaff000000 000000 package Path::Router::Types; our $AUTHORITY = 'cpan:STEVAN'; # ABSTRACT: A set of types that Path::Router uses $Path::Router::Types::VERSION = '0.15'; use strict; use warnings; use Carp 1.32 (); use Type::Library 1.000005 -base, -declare => qw(PathRouterRouteValidationMap); use Type::Utils 1.000005 -all; use Types::Standard 1.000005 -types; use Types::TypeTiny 1.000005 qw(TypeTiny); declare PathRouterRouteValidationMap, as HashRef[TypeTiny]; # NOTE: # canonicalize the route # validators into a simple # set of type constraints # - SL coerce PathRouterRouteValidationMap, from HashRef[Str | RegexpRef | TypeTiny], via { my %orig = %{ +shift }; foreach my $key (keys %orig) { my $val = $orig{$key}; if (ref $val eq 'Regexp') { $orig{$key} = declare(as Str, where{ /^$val$/ }); } elsif (TypeTiny->check($val)) { $orig{$key} = $val; } else { $orig{$key} = dwim_type($val) || Carp::confess "Could not locate type constraint named $val"; } } return \%orig; }; 1; __END__ =pod =encoding UTF-8 =head1 NAME Path::Router::Types - A set of types that Path::Router uses =head1 VERSION version 0.15 =head1 SYNOPSIS use Path::Router::Types; =head1 DESCRIPTION =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 AUTHOR Stevan Little Estevan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2011 Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Stevan Little =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Infinity Interactive. 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 Path-Router-0.15/lib/Path/Router/Route/Match.pm000644 000765 000024 00000004013 12665414707 021471 0ustar00neilbstaff000000 000000 package Path::Router::Route::Match; our $AUTHORITY = 'cpan:STEVAN'; $Path::Router::Route::Match::VERSION = '0.15'; use Types::Standard 1.000005 qw(Str HashRef InstanceOf); use Moo 2.000001; use namespace::clean 0.23; # ABSTRACT: The result of a Path::Router match has 'path' => (is => 'ro', isa => Str, required => 1); has 'mapping' => (is => 'ro', isa => HashRef, required => 1); has 'route' => ( is => 'ro', isa => InstanceOf['Path::Router::Route'], required => 1, handles => [qw[target]] ); 1; __END__ =pod =encoding UTF-8 =head1 NAME Path::Router::Route::Match - The result of a Path::Router match =head1 VERSION version 0.15 =head1 DESCRIPTION This is the object returned from calling C on a L instance. It contains all the information you would need to do any dispatching nessecary. =head1 METHODS =over 4 =item B =item B This is the path that was matched. =item B This is the mapping of your router part names to the actual parts of the path. If your route had no "variables", then this will be an empty HASH ref. =item B This is the L instance that was matched. =item B This method simply delegates to the C method of the C that was matched. =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 AUTHOR Stevan Little Estevan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 2008-2011 Infinity Interactive, Inc. L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Stevan Little =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Infinity Interactive. 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