libdancer2-perl-0.11+dfsg.orig/0000775000175000017500000000000012253351170015551 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/LICENSE0000644000175000017500000004366112253326150016566 0ustar gregoagregoaThis software is copyright (c) 2013 by Alexis Sukrieh. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2013 by Alexis Sukrieh. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2013 by Alexis Sukrieh. 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 libdancer2-perl-0.11+dfsg.orig/MANIFEST0000644000175000017500000001663612253351170016714 0ustar gregoagregoaAUTHORS Build.PL Changes GitGuide.md LICENSE MANIFEST META.json META.yml Makefile.PL README.md lib/Dancer2.pm lib/Dancer2/CLI.pm lib/Dancer2/CLI/Command/gen.pm lib/Dancer2/CLI/Command/version.pm lib/Dancer2/Config.pod lib/Dancer2/Cookbook.pod lib/Dancer2/Core.pm lib/Dancer2/Core/App.pm lib/Dancer2/Core/Context.pm lib/Dancer2/Core/Cookie.pm lib/Dancer2/Core/DSL.pm lib/Dancer2/Core/Dispatcher.pm lib/Dancer2/Core/Error.pm lib/Dancer2/Core/Factory.pm lib/Dancer2/Core/HTTP.pm lib/Dancer2/Core/Hook.pm lib/Dancer2/Core/MIME.pm lib/Dancer2/Core/Request.pm lib/Dancer2/Core/Request/Upload.pm lib/Dancer2/Core/Response.pm lib/Dancer2/Core/Role/Config.pm lib/Dancer2/Core/Role/DSL.pm lib/Dancer2/Core/Role/Engine.pm lib/Dancer2/Core/Role/Handler.pm lib/Dancer2/Core/Role/Headers.pm lib/Dancer2/Core/Role/Hookable.pm lib/Dancer2/Core/Role/Logger.pm lib/Dancer2/Core/Role/Serializer.pm lib/Dancer2/Core/Role/Server.pm lib/Dancer2/Core/Role/SessionFactory.pm lib/Dancer2/Core/Role/SessionFactory/File.pm lib/Dancer2/Core/Role/StandardResponses.pm lib/Dancer2/Core/Role/Template.pm lib/Dancer2/Core/Route.pm lib/Dancer2/Core/Runner.pm lib/Dancer2/Core/Server/PSGI.pm lib/Dancer2/Core/Server/Standalone.pm lib/Dancer2/Core/Session.pm lib/Dancer2/Core/Time.pm lib/Dancer2/Core/Types.pm lib/Dancer2/FileUtils.pm lib/Dancer2/Handler/AutoPage.pm lib/Dancer2/Handler/File.pm lib/Dancer2/Logger/Capture.pm lib/Dancer2/Logger/Capture/Trap.pm lib/Dancer2/Logger/Console.pm lib/Dancer2/Logger/Diag.pm lib/Dancer2/Logger/File.pm lib/Dancer2/Logger/Note.pm lib/Dancer2/Logger/Null.pm lib/Dancer2/Manual.pod lib/Dancer2/Plugin.pm lib/Dancer2/Plugin/Ajax.pm lib/Dancer2/Plugins.pod lib/Dancer2/Serializer/Dumper.pm lib/Dancer2/Serializer/JSON.pm lib/Dancer2/Serializer/YAML.pm lib/Dancer2/Session/Simple.pm lib/Dancer2/Session/YAML.pm lib/Dancer2/Template/Implementation/ForkedTiny.pm lib/Dancer2/Template/Simple.pm lib/Dancer2/Template/TemplateToolkit.pm lib/Dancer2/Template/Tiny.pm lib/Dancer2/Test.pm lib/Dancer2/Tutorial.pod script/dancer2 share/skel/MANIFEST.SKIP share/skel/Makefile.PL share/skel/bin/+app.pl share/skel/config.yml share/skel/environments/development.yml share/skel/environments/production.yml share/skel/lib/AppFile.pm share/skel/public/+dispatch.cgi share/skel/public/+dispatch.fcgi share/skel/public/404.html share/skel/public/500.html share/skel/public/css/error.css share/skel/public/css/style.css share/skel/public/favicon.ico share/skel/public/images/perldancer-bg.jpg share/skel/public/images/perldancer.jpg share/skel/t/001_base.t share/skel/t/002_index_route.t share/skel/views/index.tt share/skel/views/layouts/main.tt t/00-compile.t t/00-report-prereqs.t t/ajax_plugin.t t/any.t t/app.t t/app/t1/bin/app.psgi t/app/t1/config.yml t/app/t1/lib/App1.pm t/app/t1/lib/Sub/App2.pm t/app/t2/.dancer t/app/t2/config.yml t/app/t2/lib/App3.pm t/auto_page.t t/charset_server.t t/config.t t/config.yml t/config/config.yml t/config/environments/failure.yml t/config/environments/merging.yml t/config/environments/production.yml t/config/environments/staging.json t/config_app1.t t/config_app2.t t/config_app3.t t/config_settings.t t/context.t t/context_trigger.t t/cookie.t t/corpus/pretty/505.tt t/corpus/pretty_public/404.html t/corpus/pretty_public/510.html t/corpus/static/1x1.png t/corpus/static/index.html t/custom_dsl.t t/dancer-test.t t/deserialize.t t/dispatcher.t t/dsl.t t/dsl/halt.t t/engine.t t/error.t t/error_template.t t/factory.t t/file_utils.t t/forward.t t/forward_before_hook.t t/forward_test_tcp.t t/handler_file.t t/hooks.t t/http_methods.t t/http_status.t t/lib/App1.pm t/lib/App2.pm t/lib/DancerPlugin.pm t/lib/Foo.pm t/lib/FooPlugin.pm t/lib/Hookee.pm t/lib/MyDancerDSL.pm t/lib/PluginWithImport.pm t/lib/SubApp1.pm t/lib/SubApp2.pm t/lib/TestApp.pm t/lib/TestPod.pm t/logger.t t/logger_console.t t/mime.t t/plugin_import.t t/plugin_multiple_apps.t t/plugin_register.t t/plugin_syntax.t t/public/file.txt t/redirect.t t/release-distmeta.t t/release-no-tabs.t t/release-pod-syntax.t t/request.t t/request_params.t t/request_upload.t t/response.t t/roles/headers.t t/roles/hook.t t/roles/server.t t/route-pod-coverage/route-pod-coverage.t t/route.t t/runner.t t/serializer.t t/serializer_json.t t/server.t t/session_config.t t/session_engines.t t/session_forward.t t/session_hooks.t t/session_lifecycle.t t/session_object.t t/sessions/Uf-CrAAAdd2mP4pJAIBzc6YRqXnqeNUt.yml t/sessions/Uf-GsQAANz9OaEztWyuSfJKegUq3zD1V.yml t/sessions/Uf-HDgAAPPOeyDGX2_IgTLzBg6iBsFkk.yml t/sessions/Uf-HTQAAQOJeFHxmhw1aJKUgIkGseaAI.yml t/sessions/Uf-HZwAAQt4cqJPl7UTFUrFyY7yxYVj_.yml t/sessions/Uf-IdQAAVEongozIzRJZUxy_Q8DMaruI.yml t/sessions/Uf1awwAAXkpPhxmXEwjwLY6Oi5Dv7A8v.yml t/sessions/Uf1znwAABxlBOUOk04NfndOLhVZzIrnf.yml t/sessions/Uf61DgAAYKLILb8PdeeQV3tryrC08MvP.yml t/sessions/Uf6vLQAAA33ysk1AfxuFaITEMXY72bEI.yml t/sessions/Uf6vlwAACre4MIFKa-Jghj6q1OT9sQb_.yml t/sessions/Uf6xeQAAKIXcote58neJ3jjOIjbBlhKX.yml t/sessions/Uf6zmAAASb6UqmpBspaQIEzjLIs51E19.yml t/sessions/UfRHAQAAJsw_2oX_cvBqBtXlgre8vFiy.yml t/sessions/UfRXcwAAO8pp0bx4QwYmc73cP7UKMyY7.yml t/sessions/UfUFzgAAOBHtc6NRAKAH4xNgo-GIz8VA.yml t/sessions/Ufqu9QAAQfNUOjyt9fa2al5-bFlpbWfR.yml t/sessions/UgEFqgAAa4HX5JbR80YhN9rOBcGLG-zH.yml t/sessions/UgnzfAAAX0Gcwelnex1vHnakFt7dZMGb.yml t/sessions/UhC04wAAcgtUmse-OjZCvj1H0_I5z0pU.yml t/sessions/UhC_EwAAHS4yKDNKIO8DV-5B47BS6vWY.yml t/sessions/UhaF7gAAYpJSGqByK67_SB3A9mGE5l-s.yml t/sessions/UhaGNQAAaDVWUzXrQaDQAaQPzLEWV-4v.yml t/sessions/UiMfZwAAc4FCMkrxKK-kKyuTIDuVupPc.yml t/sessions/UiMnAgAAahCCdaVhPiVfrcwyo6sxcp7z.yml t/sessions/UiNDXgAAJ0mTXspthJgvbjShFZfcyPR3.yml t/sessions/UiNIAwAAbVyD4lIKW93APRO9IDd1K5BJ.yml t/sessions/UiNIHQAAb3tN7zHtZJRZY7ULJVTc4-bo.yml t/sessions/UjnvaAAAdx5B7BnSg2YxFz_25MpWqBwX.yml t/sessions/UjnwfgAACXJ9T98xUqd76qOfcABU4l0R.yml t/sessions/Uq2XMAAANZ8zV8FD1Emyu7XRdgIZekDJ.yml t/sessions/UqMKawAAe86AQqQeYQmzh8sUBp6GIdFY.yml t/sessions/UqMhtgAAbObthtU3fOj5q-ibplcfJI-A.yml t/sessions/UqMkygAAH92FRll2ucXas2hPHOmBwGxY.yml t/sessions/UqMo4AAAZlW25DoDlelvGZ9Mf1HPIxyI.yml t/sessions/UqMsHAAAHWKTi6hOv6wGnR-n8bIUQmYs.yml t/shared_engines.t t/splat.t t/template.t t/template_default_tokens.t t/template_ext.t t/template_name.t t/template_simple.t t/template_tiny/01_compile.t t/template_tiny/02_trivial.t t/template_tiny/03_samples.t t/template_tiny/04_compat.t t/template_tiny/05_preparse.t t/template_tiny/samples/01_hello.tt t/template_tiny/samples/01_hello.txt t/template_tiny/samples/01_hello.var t/template_tiny/samples/02_null.tt t/template_tiny/samples/02_null.txt t/template_tiny/samples/02_null.var t/template_tiny/samples/03_chomp.tt t/template_tiny/samples/03_chomp.txt t/template_tiny/samples/03_chomp.var t/template_tiny/samples/04_nested.tt t/template_tiny/samples/04_nested.txt t/template_tiny/samples/04_nested.var t/template_tiny/samples/05_condition.tt t/template_tiny/samples/05_condition.txt t/template_tiny/samples/05_condition.var t/template_tiny/samples/06_object.tt t/template_tiny/samples/06_object.txt t/template_tiny/samples/06_object.var t/template_tiny/samples/07_nesting.tt t/template_tiny/samples/07_nesting.txt t/template_tiny/samples/07_nesting.var t/template_tiny/samples/08_foreach.tt t/template_tiny/samples/08_foreach.txt t/template_tiny/samples/08_foreach.var t/template_tiny/samples/09_trim.tt t/template_tiny/samples/09_trim.txt t/template_tiny/samples/09_trim.var t/time.t t/types.t t/uri_for.t t/vars.t t/views/auto_page.tt t/views/folder/page.tt t/views/index.tt t/views/layouts/main.tt t/views/template_simple_index.tt t/views/tokens.tt xt/perlcritic.rc xt/perltidy.rc xt/whitespace.t libdancer2-perl-0.11+dfsg.orig/Changes0000644000175000017500000003371012253326150017046 0ustar gregoagregoa0.11 2013-12-15 14:19:22 Europe/Amsterdam [ ENHANCEMENTS ] * GH#481: Don't pollute @INC automatically when Dancer2 is imported, each runner is now responsible of including the local ./lib dir if needed. * GH#469, 418: Dancer2::Plugin provides a ':no_dsl' flag for modern Plugins (Pedro Melo) * GH#485: Keywords 'redirect' and 'forward' exit immediatly when executed in a route/hook. New dependency on Return::MultiLevel (Russell Jenkins). * GH#495: Use accessor and predicates instead of direct access. Addresses GH#493 too. (Russell Jenkins) * GH#502,GH#472: Rework halt to use with_return from Return::MultiLevel. (Russell Jenkins) * GH#479,GH#480,GH#508: Pass parameters to params() in the DSL. (Slava Goltser, unickuity, Russell Jenkins) * GH#505: Fix empty HTTP_REFERER in Dancer::Core::Request (Menno Blom). * GH#503: Multiple reverse proxy support (Menno Blom). * GH#371,GH#506: CLI tool rewrite (using App::Cmd, supports plugins, etc.). (Ivan Kruglov, Samit Badle, Sawyer X) * GH#498: Add some missing items in MANIFEST.SKIP (Gabor Szabo, Sawyer X). [ DOCUMENTATION ] * GH#489: Remove link to Dancer2::Deployment pod which does not exist (Sweet-kid) * GH#511: s/Deflator/Deflater/; (Cesare Gargano) * GH#491: Updated config paths for template_toolkit in cookbook. (Mark A. Stratman) * GH#494: Update session config details (Dancer2::Config), namespace fixup in Dancer2::Core::cookie. (Russell Jenkins) * GH#470: Fix Plack::Builder mount usage (Pedro Melo). * GH#507: Fix plenty of typos (David Steinbrunner). * GH#477: Document problem with Plack Shotgun on Windows (Ahmad M. Zawawi). * GH#504: Add link to Dancer2::Plugin::Sixpack (Menno Blom). * GH#490: Document Dancer2 should be FatPackable (Sawyer X). * GH#452: Make a complete authors section, clean it up (Pau Amma). * More fixes to main documentation (Pau Amma). 0.10 2013-09-28 15:26:41 Europe/Paris [ DOCUMENTATION ] * GH#431: Miscellaneous documentation fixes (Gideon D'souza) * Small POD corrections (Ashvini V) [ ENHANCEMENTS ] * GH#482: Show the startup banner when the worker starts by default (Alexis Sukrieh). * GH#481: Include local lib dir in @INC by defaults (Alexis Sukrieh). * GH#423: Remove ':tests' from Dancer.pm import (Alberto Simões). * GH#422: Get rid of core_debug method (Alberto Simões). * GH#421: Support Plugin::Ajax content_type (Russell Jenkins). * GH#428: Make default errors CSS path relocatable (Russell Jenkins). * GH#427, GH#443: Replace global warnings with lexical (Russell Jenkins). * GH#374: Don't create an app from app.psgi (Alberto Simões). * Cleanup Core::Request, Core::Request::Upload (Mickey Nasriachi). * GH#445: Test Template::Simple (Alexis Sukrieh, Russell Jenkins). * GH#449: Test Session hooks (Gideon D'souza) * GH#434,440: Imutable attributes (Mickey Nasriachi). * GH#435: Allow send_error to serialize error (Russell Jenkins). * Add more tests to session id rw (Pedro Melo). * Whitespace cleanup (Ivan Bessarabov). [ BUG FIXES ] * GH#424,425: Fix logger tests for different timezones, and close logfile before deleting it: Windows dixit. (Gideon D'souza, Russell Jenkins) 0.09 2013-09-02 00:12:58 Asia/Jerusalem [ ENHANCEMENTS ] * Rewite DSL keyword engine (Mickey Nasriachi) * Require minimum Role::Tiny 1.003000 (Alberto Simões) * GH#382: Move Request attributes to params, and fix serializers behavior (Russell Jenkins) * GH#406: Replace Dancer2::ModuleLoader with Class::Load (Alberto Simões, Sawyer X) * GH#329: Remove 'load_app' DSL keyword. Remove reference to 'load' as well. (Sawyer X) * GH#412: Autopages are now called properly with correct MIME. (Alberto Simões) [ DOCUMENTATION ] * GH#390: minor cookbook documentation fixes (Russell Jenkins) * GH#392: remove support to auto_reload and suggest alternative in Dancer2::Cookbook (Ahmad M. Zawawi) * GH#397,407: Miscellaneous documentation fixes (Andrew Solomon) * Documentation cleanups (Alex Beamish) [ BUG FIXES ] * When compiling route regex object with prefix, add the closing anchor (Mickey Nasriachi) * GH#386: honor log level defined in config file (Alberto Simões) * GH#396,409: Miscellaneous bug fixes (Russell Jenkins) * GH#403: Fix forward behavior (Russell Jenkins) 0.08 2013-08-18 15:22:45 Asia/Jerusalem [ ENHANCEMENTS ] * GH#352: Define content_type as a property for serializers. (Franck Cuny) * Cleanup duplicate HTTP status code between Core::Error and Core::HTTP (Russel Jenkins) * GH#363: Move core methods to Dancer2::Core (Alberto Simões) * GH#362: Serializers documentation and test cleanup. (Franck Cuny) * Refactoring of the engine method. (Franck Cuny) * Misc. code cleanup. (Russel Jenkins) * GH#280: Remove the unused ':syntax' importing tag (Sawyer X) * Display startup info only if environment is "development" (Franck Cuny) * Move postponed_hooks to server from runner (Sawyer X) * Provide easier access to global runner (Sawyer X) * Bunch of code cleanups which also includes speed boost (Sawyer X) * More immutability in the runner class and config role (Sawyer X) [ BUG FIXES ] * GH#85, GH#354: Fix autopages, especially in subdirs (Stefan Hornburg, Alberto Simões) * GH#365: Fix serializer settings (Steven Humphrey) * GH#333: callerstack for logger was too short (Alberto Simões) * GH#369: Move request deserialization from Dispatcher to Content & Request (Russell Jenkins) [ DOCUMENTATION ] * GH#192: Documentation the current usage of middlewares using Plack::Builder (Sawyer X) * GH#195, GH#197, GH#372: Multiple apps with Plack::Builder (Sawyer X) * GH#348: Documentation of Role::Logger (Franck Cuny) * GH#350: Move part of README.md to GitGuide.md (Franck Cuny) * GH#353: Documentation of Role::Serializer (Alberto Simões, Franck Cuny) * Misc. minor documentation tweak (Alberto Simões, Franck Cuny) 0.07 2013-08-04 01:14:59 Asia/Jerusalem [ ENHANCEMENTS ] * GH#344, GH#284: Now forward() calls preserve sessions (cym0n, Alberto Simões) * Separation of engines from triggers and configuration (Sawyer X, Franck Cuny) * GH#347: Remove old compatibility option 'log_path' (Franck Cuny) * GH#156, GH#250, GH#349: Remove unused module (Alberto Simões, mokko) * GH#331: Hook cleanups and documentation. (Franck Cuny) * GH#335: Serializing cleanup. (Franck Cuny) * GH#332: Clean up multiple definitions of core_debug (Franck Cuny) * GH#338: Clean up route builder (Mickey Nasriachi) * Clean up of the dzil configuration (Alberto Simões) [ BUG FIXES ] * GH#334: Fix for GH#86, to display custom 500 page/template on internal server errors (Russell Jenkins) * GH#346: Fix tests on 5.8.9 (Albert Simões) [ DOCUMENTATION ] * GH#345: Documentation reorganization (Alberto Simões, Franck Cuny) 0.06 2013-07-30 (Sawyer X) [ ENHANCEMENTS ] * Clean up of the dzil configuration (Alberto Simões,Franck Cuny, Russel Jenkins) * GH#327: Add support for 'info' log level (Russell Jenkins) * Remove 'for_versions' usage from tests (Alberto Simões) [ BUG FIXES ] * GH#326, GH#232: don't end up with empty views and layout (Franck Cuny) * GH#325: don't die or complain when two routes have the same path (Franck Cuny) * GH#320: fix plugin_setting deprecation warning (David Golden) [ DOCUMENTATION ] * POD cleanup (Sawyer X, Franck Cuny) 0.05 2013-07-20 18:51:53 Europe/Paris [ DEPRECATION ] * Dancer2::Plugin drops support for Dancer 1 (issue #207) a DEPRECATION notice is issued when a plugin uses the old syntax (Alexis Sukrieh, Mokko, David Golden) * Drop support for 'use Dancer2 :moose' (Franck Cuny) [ ENHANCEMENTS ] * Add support for HTTP_X_FORWARDED_PROTO (Yanick Champoux) * Don't inflate custom types (Graham Knop) * Encode UTF8 params in Dancer2::Test (Vincent Bachelier) * Make Dancer2::Core::Request more lazy (Franck Cuny) * Don't use rootdir for app location (David Golden) * Improve File logger (David Golden) * Drop body when status is 1x or [23]04 (Franck Cuny) * Add support for HTTP_X_FORWARDED_PROTO (Yanick Champoux) * Prevent duplicate routes from being created (Franck Cuny) * Add support for route options (Franck Cuny) * Add support for prefix with route defined with regex (Franck Cuny) * Methods to return path of views and layout in the Template role (Franck Cuny, Yanick Champoux). * GH#31, GH#221: Config merging support (Russell Jenkins) [ BUG FIXES ] * GH#272: test function 'route_doesnt_exist' was not handling test comment properly. (Jeff Boes, Yanick Champoux) * GH#228: handle UTF-8 correctly in JSON serializer (Steven Humphrey) * GH#270: handle correctly serializer's options (Keith Broughton) * GH#274: `dancer -v' returns the correct version (Dinis Rebolo) * GH#286: for HEAD request, drop response's body (Franck Cuny) * GH#293: fix defaults tests for a newly generated app (Franck Cuny) * GH#216: check 'show_errors' when returning an internal error (Franck Cuny) * GH#246: Add serialization of log messages (Stefan Hornburg) * GH#268: Dancer2::Core::Response->status accepts stringy HTTP codes (Franck Cuny) * GH#308: Add support for ENV{DANCER_CONFDIR} and ENV{DANCER_ENVDIR} (Franck Cuny) * GH#210: Don't print startup banner if startup_info is set to 0 (Maurice Mengel, Franck Cuny) * plugin_setting does not trigger a DEPRECATION warning anymore (Report by Alberto Simões, fix by Alexis Sukrieh) * GH#251: Support for on-the-fly changes of layouts/views (Franck Cuny) * GH#302: Avoid double encoding in Handler::File (Russell Jenkins) [ DOCUMENTATION ] * Lots of documentation cleanup (Mokko, David Precious) * Documenting Dancer2::Handler::AutoPage (Sabiha Imran, Sawyer X) * Documenting Dancer2::Core::Dispatcher (Babitha Balachandran) * Documenting Dancer2::Manual::DSL (David Precious, Franck Cuny) * Various typo (Shlomi Fish, Colin Kuskie, Stefan Hornburg, Rick Yakubowski) * Documenting some internals (Colin Kuskie) * Documenting Dancer2::Core::MIME (Babitha B.) * Documenting Manual::Developers (Maurice Mengel) * Documenting Dancer2::Core::Response (Colin Kuskie) 0.04 - 2013-04-22 (Alexis Sukrieh) [ BUG FIXES ] * Fix "Internal Sever Error" when sending a file with send_file (Dinis Rebolo) * Allow the setting of the 'views' directory, like stated in documentation (Alexander Karelas) [ ENHANCEMENTS ] * Implement Dancer2::Test file uploads (Steven Humphrey) * Give Dancer2::Test the ability to handle multiselect inputs (Steven Humphrey) * Make Cookie objects stringify to their value. (David Precious) * New routines for Dancer2::Test to check pod coverage in apps routes (Dinis Rebolo) * New script dancer2 to bootstrap an application (mokko) * Fix tests when running under Windows environments (Russell Jenkins) * Serializing modify the response's content type (Yanick Champoux) [ DOCUMENTATION ] * Make introduction more fluid in Dancer2's POD. (mokko) [ PACKAGING ] * Remove prereq Digest::SHA (mokko) * Dancer::P::Bcrypt recomends Dancer::P::Passphrase (Blabos de Blebe) 0.03 - 2013-03-07 (Alexis Sukrieh) [ ENHANCEMENTS ] * Don't create a session when just checking if a value exists (David Golden) * Only flush sessions if they are dirty (David Golden) * Allow the default template file extension to be changed. (David Precious) * Add on_plugin_import function to Dancer2::Plugin (David Golden) (Fix for issue #284) [BUG FIXES] * Dancer2::ModuleLoader now use Module::Runtime at its core (issue #166, Yanick Champoux) [ DOCUMENTATION ] * changed <% to [% in documentations (Alexander Karelas) * Improve Dancer2::Plugin documentation (David Golden) 0.02 - 2013-02-24 (Alexis Sukrieh) [ DOCUMENTATION ] * No more "TODO" tokens in the documentations * More documentation for Core classes (Alexis Sukrieh) [ ENHANCEMENTS ] * Removed the "api_version" code that is useless and was breaking some tests. (Alexis Sukrieh) 0.01 [ ENHANCEMENTS ] * Dancer::Test takes a hash instead of an array for better backward compatibility with Dancer 1. (Celogeek) * Session revamp: better decoupling between Session and SessionFactory, support for session destruction and session values deletion. Everythin regarding session settings is now configurable. (David Golden). * Add route_exists and route_doesnt_exist in Dancer::Test (Mokko) * session cookie duration can be expressed with human readable strings * instead of numeric values (Alexis Sukrieh, issue #157). [ BUG FIXES ] * The engine configuration is now passed down to Dancer::Template::Implementation::ForkedTiny (Damien Krotkine). * Dancer App lookup now try to detect the dir "bin" and "lib" or ".dancer" file. (Celogeek) * Issues #125 and #126 Support for configuration bits for session objects, possible to change the cookie name instead of the hard-coded value 'dancer.session'. (Reported by David Golden, fixed by Alexis Sukrieh). [ DOCUMENTATION ] * Add more POD in Dancer::Test (Mokko) 1.9999_02 * Fix tests for previous release, tests cannot assume we're under Dancer 2 when the version is 1.9999 (Alexis Sukrieh) 1.9999_01 * First DEVELEOPER release of Dancer 2 complete rewrite of Dancer with a Moo backend. (Alexis Sukrieh, David Precious, Damien Krotkine, SawyerX, Yanick Champoux and others, plus Matt S. Trout as a reviewer). libdancer2-perl-0.11+dfsg.orig/AUTHORS0000644000175000017500000000013112253326150016612 0ustar gregoagregoaSee perldoc Dancer2.pm, section AUTHORS, for a list of core developers and contributors. libdancer2-perl-0.11+dfsg.orig/xt/0000775000175000017500000000000012253326150016204 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/xt/perlcritic.rc0000644000175000017500000000464112253326150020675 0ustar gregoagregoa# nice output, to easily see the POD of the policy verbose = [%p] %m at %f line %l, near '%r'\n # severity of 3 is a good start (1 is very strict, 5 very tolerant) severity = 3 # we want to use // without //ms [-RegularExpressions::RequireDotMatchAnything] [-RegularExpressions::RequireLineBoundaryMatching] [-RegularExpressions::RequireExtendedFormatting] minimum_regex_length_to_complain_about = 5 [-RegularExpressions::ProhibitComplexRegexes] # we don't want these POD rules [-Documentation::RequirePodSections] # We don't care about POD links [-Documentation::RequirePodLinksIncludeText] # we use $@ and $! [-Variables::ProhibitPunctuationVars] # We want to be able to use Carp::Verbose in our tests scripts, so # we add Carp to the whitelist [Variables::ProhibitPackageVars] packages = Data::Dumper File::Find FindBin Log::Log4perl Carp [-ValuesAndExpressions::ProhibitEmptyQuotes] # I really don't think q{/} is more readable than '/'... [-ValuesAndExpressions::ProhibitNoisyQuotes] # Perl::Critic recommends Readonly, but this IS BAD! # we use Const::Fast instead, but this policy keeps poping up. [-ValuesAndExpressions::ProhibitMagicNumbers] # we want to be able to build DSLs [-Modules::ProhibitAutomaticExportation] # We only want the main module to provide $VERSION [-Modules::RequireVersionVar] # we want to be able to define short getters [-Subroutines::RequireFinalReturn] # we cant do @_ mesures with that one [-Subroutines::RequireArgUnpacking] # name is a common used name for methods # but forbidden by this policy ... [-Subroutines::ProhibitBuiltinHomonyms] # some old libs use many args, we don't want to block that for now [-Subroutines::ProhibitManyArgs] # we allo protected subs [-Subroutines::ProhibitUnusedPrivateSubroutines] # We're not under CVS! :) [-Miscellanea::RequireRcsKeywords] [TestingAndDebugging::ProhibitNoStrict] allow = refs [TestingAndDebugging::ProhibitNoWarnings] allow = redefine prototype [TestingAndDebugging::RequireUseStrict] equivalent_modules = strictures Moo Moo::Role [TestingAndDebugging::RequireUseWarnings] equivalent_modules = strictures Moo Moo::Role # we use postifx controls [-ControlStructures::ProhibitPostfixControls] [-ControlStructures::ProhibitCascadingIfElse] # We want to use croak everywhere instead of die [ErrorHandling::RequireCarping] # allow backtick if capture result [InputOutput::ProhibitBacktickOperators] only_in_void_context = 1 [-Variables::ProhibitAugmentedAssignmentInDeclaration] libdancer2-perl-0.11+dfsg.orig/xt/perltidy.rc0000644000175000017500000000224212253326150020364 0ustar gregoagregoa-l=79 # Max line width is 79 cols -i=4 # Indent level is 4 cols -ci=4 # Continuation indent is 4 cols -se # Errors to STDERR -vt=2 # Maximal vertical tightness -cti=0 # No extra indentation for closing brackets -pt=1 # Medium parenthesis tightness -bt=1 # Medium brace tightness -sbt=1 # Medium square bracket tightness -bbt=1 # Medium block brace tightness -nsfs # No space before semicolons -nolq # Don't outdent long quoted strings --break-at-old-comma-breakpoints -wbb="% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" # Break before all operators # extras/overrides/deviations from PBP --maximum-line-length=79 # be less generous --warning-output # Show warnings --maximum-consecutive-blank-lines=2 # default is 1 --nohanging-side-comments # troublesome for commented out code -isbc # block comments may only be indented if they have some space characters before the # -ci=2 # Continuation indent is 2 cols # we use version control, so just rewrite the file # -b # -- should not be active for dzil plugin ## for the up-tight folk :) #-pt=2 # High parenthesis tightness #-bt=2 # High brace tightness #-sbt=2 # High square bracket tightness libdancer2-perl-0.11+dfsg.orig/xt/whitespace.t0000644000175000017500000000031212253326150020517 0ustar gregoagregoause Test::Whitespaces { dirs => [qw( lib script t tools xt )], ignore => [ qr{t/sessions/}, qr{t/template_tiny/samples}, ], }; libdancer2-perl-0.11+dfsg.orig/Build.PL0000644000175000017500000000707212253326150017051 0ustar gregoagregoa use strict; use warnings; use Module::Build 0.3601; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.3601" }, "configure_requires" => { "ExtUtils::MakeMaker" => "6.30", "File::ShareDir::Install" => "0.03", "Module::Build" => "0.3601" }, "dist_abstract" => "Lightweight yet powerful web application framework", "dist_author" => [ "Dancer Core Developers" ], "dist_name" => "Dancer2", "dist_version" => "0.11", "license" => "perl", "module_name" => "Dancer2", "recommends" => { "CGI::Deurl::XS" => 0, "Crypt::URandom" => 0, "JSON::XS" => 0, "Math::Random::ISAAC::XS" => 0, "Plack::Request" => 0, "Pod::Simple::Search" => 0, "Pod::Simple::SimpleTree" => 0, "Scope::Upper" => 0, "Test::Builder" => 0, "Test::More" => 0, "URL::Encode::XS" => 0 }, "recursive_test_files" => 1, "requires" => { "App::Cmd::Setup" => 0, "Carp" => 0, "Class::Load" => 0, "Config::Any" => 0, "Cwd" => 0, "Data::Dumper" => 0, "Digest::SHA" => 0, "Encode" => 0, "Exporter" => "5.57", "Fcntl" => 0, "File::Basename" => 0, "File::Copy" => 0, "File::Find" => 0, "File::Path" => 0, "File::ShareDir" => 0, "File::Spec" => 0, "File::Spec::Functions" => 0, "File::Temp" => "0.22", "HTTP::Body" => 0, "HTTP::Date" => 0, "HTTP::Headers" => 0, "HTTP::Server::Simple::PSGI" => 0, "Hash::Merge::Simple" => 0, "IO::File" => 0, "JSON" => 0, "LWP::UserAgent" => 0, "List::Util" => 0, "MIME::Base64" => "3.13", "MIME::Types" => 0, "Moo" => "1.003000", "Moo::Role" => 0, "MooX::Types::MooseLike" => "0.16", "MooX::Types::MooseLike::Base" => 0, "POSIX" => 0, "Plack::Request" => 0, "Pod::Simple::Search" => 0, "Pod::Simple::SimpleTree" => 0, "Return::MultiLevel" => 0, "Role::Tiny" => "1.003000", "Scalar::Util" => 0, "Template" => 0, "Template::Tiny" => 0, "Test::Builder" => 0, "Test::More" => "0.92", "URI" => 0, "URI::Escape" => 0, "YAML::Any" => 0, "overload" => 0, "parent" => 0, "perl" => "5.00503", "strict" => 0, "warnings" => 0 }, "script_files" => [ "script/dancer2" ], "share_dir" => { "dist" => "share" }, "test_requires" => { "Capture::Tiny" => "0.12", "ExtUtils::MakeMaker" => 0, "File::Temp" => "0.22", "FindBin" => 0, "HTTP::Body" => 0, "HTTP::Request::Common" => 0, "HTTP::Server::Simple::PSGI" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "LWP::Protocol::PSGI" => "0.06", "Test::Fatal" => 0, "Test::MockTime" => 0, "Test::More" => "0.92", "Test::Script" => 0, "Test::TCP" => "1.13", "YAML" => 0, "YAML::Any" => 0, "lib" => 0, "utf8" => 0, "vars" => 0 } ); my %fallback_build_requires = ( "Capture::Tiny" => "0.12", "ExtUtils::MakeMaker" => 0, "File::Temp" => "0.22", "FindBin" => 0, "HTTP::Body" => 0, "HTTP::Request::Common" => 0, "HTTP::Server::Simple::PSGI" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "LWP::Protocol::PSGI" => "0.06", "Module::Build" => "0.3601", "Test::Fatal" => 0, "Test::MockTime" => 0, "Test::More" => "0.92", "Test::Script" => 0, "Test::TCP" => "1.13", "YAML" => 0, "YAML::Any" => 0, "lib" => 0, "utf8" => 0, "vars" => 0 ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; libdancer2-perl-0.11+dfsg.orig/t/0000775000175000017500000000000012253326150016014 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/config_settings.t0000644000175000017500000000132212253326150021362 0ustar gregoagregoause strict; use warnings; use Test::More; use Dancer2; # testing default values is( setting('port'), '3000', "default value for 'port' is OK" ); is( setting('content_type'), 'text/html', "default value for 'content_type' is OK" ); #should we test for all default values? # testing new settings ok( setting( 'foo' => '42' ), 'setting a new value' ); is( setting('foo'), 42, 'new value has been set' ); # test the alias 'set' ok( set( bar => 43 ), 'setting bar with set' ); is( setting('bar'), 43, 'new value has been set' ); #multiple values ok( setting( 'foo' => 43, bar => 44 ), 'set multiple values' ); ok( setting('foo') == 43 && setting('bar') == 44, 'set multiple values successful' ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/auto_page.t0000644000175000017500000000175012253326150020146 0ustar gregoagregoause strict; use warnings; use Test::More; { package AutoPageTest; use Dancer2; set auto_page => 1; ## HACK HACK HACK Dancer2::Handler::AutoPage->register(app); engine('template')->views('t/views'); engine('template')->layout('main'); } use Dancer2::Test apps => ['AutoPageTest']; my $r = dancer_response GET => '/auto_page'; is $r->status, 200, 'Autopage found the page'; like $r->content, qr/---\nHey! This is Auto Page working/, '...with proper content'; $r = dancer_response GET => '/folder/page'; is $r->status, 200, 'Autopage found the page under a folder'; like $r->content, qr/---\nPage under folder/, '...with proper content'; $r = dancer_response GET => '/non_existent_page'; is $r->status, 404, 'Autopage doesnt try to render nonexistent pages'; $r = dancer_response GET => '/file.txt'; is $r->status, 200, 'Found file on public with Autopage'; like $r->headers->{'content-type'}, qr!text/plain!, "Public served file as correct mime"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/custom_dsl.t0000644000175000017500000000063112253326150020353 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use FindBin qw($Bin); use lib "$Bin/lib"; use Dancer2 dsl => 'MyDancerDSL'; use Dancer2::Test; envoie '/' => sub { request->method; }; prend '/' => sub { request->method; }; { my $r = dancer_response GET => '/'; is $r->content, 'GET'; } { my $r = dancer_response POST => '/'; is $r->content, 'POST'; } done_testing; libdancer2-perl-0.11+dfsg.orig/t/views/0000775000175000017500000000000012253326150017151 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/views/index.tt0000644000175000017500000000020112253326150020620 0ustar gregoagregoa[index] var = [% var %] before_layout_render = [% before_layout_render %] before_template_render = [% before_template_render %] libdancer2-perl-0.11+dfsg.orig/t/views/auto_page.tt0000644000175000017500000000004012253326150021456 0ustar gregoagregoaHey! This is Auto Page working. libdancer2-perl-0.11+dfsg.orig/t/views/layouts/0000775000175000017500000000000012253326150020651 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/views/layouts/main.tt0000644000175000017500000000016112253326150022142 0ustar gregoagregoalayout top var = [% var %] before_layout_render = [% before_layout_render %] --- [% content %] --- layout bottom libdancer2-perl-0.11+dfsg.orig/t/views/folder/0000775000175000017500000000000012253326150020424 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/views/folder/page.tt0000644000175000017500000000002312253326150021702 0ustar gregoagregoaPage under folder. libdancer2-perl-0.11+dfsg.orig/t/views/tokens.tt0000644000175000017500000000027312253326150021025 0ustar gregoagregoaperl_version: [% perl_version %] dancer_version: [% dancer_version %] settings.foo: [% settings.foo %] params.foo: [% params.foo %] session.foo [% session.foo %] vars.foo: [% vars.foo %] libdancer2-perl-0.11+dfsg.orig/t/views/template_simple_index.tt0000644000175000017500000000015712253326150024076 0ustar gregoagregoathis is var1="<% var1 %>" and var2=<% var2 %> another line <% foo%> <%bar %> <%baz%> <% var1 %>/<% var1 %> libdancer2-perl-0.11+dfsg.orig/t/release-pod-syntax.t0000644000175000017500000000045012253326150021722 0ustar gregoagregoa#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); libdancer2-perl-0.11+dfsg.orig/t/context.t0000644000175000017500000000205112253326150017661 0ustar gregoagregoause strict; use warnings; use Test::More; use Dancer2::Core::Context; my $env = { 'psgi.url_scheme' => 'http', REQUEST_METHOD => 'GET', SCRIPT_NAME => '/foo', PATH_INFO => '/bar/baz', REQUEST_URI => '/foo/bar/baz', QUERY_STRING => 'foo=42&bar=12&bar=13&bar=14', SERVER_NAME => 'localhost', SERVER_PORT => 5000, SERVER_PROTOCOL => 'HTTP/1.1', REMOTE_ADDR => '127.0.0.1', HTTP_COOKIE => 'dancer.session=1234; fbs_102="access_token=xxxxxxxxxx%7Cffffff"', X_FORWARDED_FOR => '127.0.0.2', REMOTE_HOST => 'localhost', HTTP_USER_AGENT => 'Mozilla', REMOTE_USER => 'sukria', }; my $c = Dancer2::Core::Context->new( env => $env ); isa_ok $c->request, 'Dancer2::Core::Request'; is $c->request->method, 'GET'; isa_ok $c->cookies->{'dancer.session'}, 'Dancer2::Core::Cookie'; is $c->cookies->{'dancer.session'}->value, 1234; is $c->cookies->{'dancer.session'}->name, 'dancer.session'; is $c->cookies->{'dancer.session'}->secure, 0; done_testing; libdancer2-perl-0.11+dfsg.orig/t/app.t0000644000175000017500000001124712253326150016764 0ustar gregoagregoause strict; use warnings; use Test::More; use Test::Fatal; use Dancer2; use Dancer2::Core::App; use Dancer2::Core::Dispatcher; use Dancer2::Core::Hook; use Dancer2::FileUtils; use File::Spec; # our app/dispatcher object my $app = Dancer2::Core::App->new( name => 'main', ); my $dispatcher = Dancer2::Core::Dispatcher->new( apps => [$app] ); # first basic tests isa_ok $app, 'Dancer2::Core::App'; # some routes to play with my @routes = ( { method => 'get', regexp => '/', code => sub {'/'}, }, { method => 'get', regexp => '/blog', code => sub {'/blog'}, }, ); # testing with and without prefixes for my $p ( '/', '/mywebsite' ) { for my $r (@routes) { $app->prefix($p); $app->add_route(%$r); } } is $app->environment, 'development'; my $routes_regexps = $app->routes_regexps_for('get'); is( scalar(@$routes_regexps), 4, "route regexps are OK" ); for my $path ( '/', '/blog', '/mywebsite', '/mywebsite/blog', ) { my $env = { REQUEST_METHOD => 'GET', PATH_INFO => $path }; my $expected = { '/' => '/', '/blog' => '/blog', '/mywebsite' => '/', '/mywebsite/blog' => '/blog', }; my $resp = $dispatcher->dispatch($env)->to_psgi; is $resp->[0], 200, 'got a 200'; is $resp->[2][0], $expected->{$path}, 'got expected route'; } note "testing lexical prefixes"; # clear the prefix in $app (and by the way, makes sure it works when prefix is # undef). $app->prefix(undef); # nested prefixes bitches! $app->lexical_prefix( '/foo' => sub { $app->add_route( method => 'get', regexp => '/', code => sub {'/foo'} ); $app->add_route( method => 'get', regexp => '/second', code => sub {'/foo/second'} ); $app->lexical_prefix( '/bar' => sub { $app->add_route( method => 'get', regexp => '/', code => sub {'/foo/bar'} ); $app->add_route( method => 'get', regexp => '/second', code => sub {'/foo/bar/second'} ); } ); }, ); # to make sure the lexical prefix did not crash anything $app->add_route( method => 'get', regexp => '/root', code => sub {'/root'} ); # make sure a meaningless lexical prefix is ignored $app->lexical_prefix( '/' => sub { $app->add_route( method => 'get', regexp => '/somewhere', code => sub {'/somewhere'}, ); } ); for my $path ( '/foo', '/foo/second', '/foo/bar/second', '/root', '/somewhere' ) { my $env = { REQUEST_METHOD => 'GET', PATH_INFO => $path, }; my $resp = $dispatcher->dispatch($env)->to_psgi; is $resp->[0], 200, 'got a 200'; is $resp->[2][0], $path, 'got expected route'; } note "test a failure in the callback of a lexical prefix"; like( exception { $app->lexical_prefix( '/test' => sub { Failure->game_over() } ); }, qr{Unable to run the callback for prefix '/test': Can't locate object method "game_over" via package "Failure"}, "caught an exception in the lexical prefix callback", ); $app->add_hook( Dancer2::Core::Hook->new( name => 'before', code => sub {1}, ) ); $app->add_hook( Dancer2::Core::Hook->new( name => 'before', code => sub { Foo->failure; }, ) ); $app->compile_hooks; my $env = { REQUEST_METHOD => 'GET', PATH_INFO => '/', }; like( exception { my $resp = $dispatcher->dispatch($env)->to_psgi }, qr{Exception caught in 'core.app.before_request' filter: Hook error: Can't locate object method "failure"}, 'before filter nonexistent method failure', ); $app->replace_hook( 'core.app.before_request', [ sub {1} ] ); $app->compile_hooks; $env = { REQUEST_METHOD => 'GET', PATH_INFO => '/', }; is( exception { my $resp = $dispatcher->dispatch($env)->to_psgi }, undef, 'Successful to_psgi of response', ); # test duplicate routes when the path is a regex $app = Dancer2::Core::App->new( name => 'main', ); my $regexp_route = { method => 'get', 'regexp' => qr!/(\d+)!, code => sub {1} }; $app->add_route(%$regexp_route); # try to get an invalid engine eval {$app->engine('foo')}; ok $!, "Engine 'foo' does not exists"; my $tmpl_engine = $app->engine('template'); ok $tmpl_engine, "Template engine is defined"; my $serializer_engine = $app->engine('serializer'); ok !defined $serializer_engine, "Serializer engine is not defined"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/hooks.t0000644000175000017500000001123712253326150017326 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use File::Spec; use Carp; use Class::Load 'try_load_class'; use Capture::Tiny 0.12 'capture_stderr'; try_load_class('Template') or plan skip_all => 'Template::Toolkit not present'; my @hooks = qw( before_request after_request before_template_render after_template_render before_file_render after_file_render before_serializer after_serializer on_route_exception ); my $tests_flags = {}; { use Dancer2; for my $hook (@hooks) { hook $hook => sub { $tests_flags->{$hook} ||= 0; $tests_flags->{$hook}++; }; } # we set the engines after the hook, and that should work # thanks to the postponed hooks system set template => 'tiny'; set serializer => 'JSON'; get '/send_file' => sub { send_file( File::Spec->rel2abs(__FILE__), system_path => 1 ); }; get '/' => sub { "ok"; }; get '/template' => sub { template \"PLOP"; }; hook 'before_serializer' => sub { my $data = shift; if ( ref $data eq 'ARRAY' ) { push( @{$data}, ( added_in_hook => 1 ) ); } else { $data->{'added_in_hook'} = 1; } }; get '/json' => sub { [ foo => 42 ]; }; get '/intercepted' => sub {'not intercepted'}; get '/route_exception' => sub {die 'this is a route exception'}; get '/forward' => sub { forward '/' }; get '/redirect' => sub { redirect '/' }; hook before => sub { my $c = shift; return unless $c->request->path eq '/intercepted'; $c->response->content('halted by before'); $c->response->halt; }; hook on_route_exception => sub { my ($context, $error) = @_; is ref($context), 'Dancer2::Core::Context'; like $error, qr/this is a route exception/; }; hook init_error => sub { my ($error) = @_; is ref($error), 'Dancer2::Core::Error'; }; hook before_error => sub { my ($error) = @_; is ref($error), 'Dancer2::Core::Error'; }; hook after_error => sub { my ($response) = @_; is ref($response), 'Dancer2::Core::Response'; ok !$response->is_halted; like $response->content, qr/Internal Server Error/; }; } use Dancer2::Test; subtest 'request hooks' => sub { my $r = dancer_response get => '/'; is $tests_flags->{before_request}, 1, "before_request was called"; is $tests_flags->{after_request}, 1, "after_request was called"; is $tests_flags->{before_serializer}, undef, "before_serializer undef"; is $tests_flags->{after_serializer}, undef, "after_serializer undef"; is $tests_flags->{before_file_render}, undef, "before_file_render undef"; }; subtest 'after hook called once per request' => sub { # Get current value of the 'after_request' tests flag. my $current = $tests_flags->{after_request}; my $r = dancer_response get => '/redirect'; is $tests_flags->{after_request}, ++$current, "after_request called after redirect"; $r = dancer_response get => '/forward'; is $tests_flags->{after_request}, ++$current, "after_request called only once after forward"; }; subtest 'serializer hooks' => sub { require 'JSON.pm'; my $r = dancer_response get => '/json'; my $json = JSON::to_json( [ foo => 42, added_in_hook => 1 ] ); is $r->content, $json, 'response is serialized'; is $tests_flags->{before_serializer}, 1, 'before_serializer was called'; is $tests_flags->{after_serializer}, 1, 'after_serializer was called'; is $tests_flags->{before_file_render}, undef, "before_file_render undef"; }; subtest 'file render hooks' => sub { my $resp = dancer_response get => '/send_file'; is $tests_flags->{before_file_render}, 1, "before_file_render was called"; is $tests_flags->{after_file_render}, 1, "after_file_render was called"; $resp = dancer_response get => '/file.txt'; is $tests_flags->{before_file_render}, 2, "before_file_render was called"; is $tests_flags->{after_file_render}, 2, "after_file_render was called"; }; subtest 'template render hook' => sub { my $resp = dancer_response get => '/template'; is $tests_flags->{before_template_render}, 1, "before_template_render was called"; is $tests_flags->{after_template_render}, 1, "after_template_render was called"; }; subtest 'before can halt' => sub { my $resp = dancer_response get => '/intercepted'; is join( "\n", @{ $resp->[2] } ) => 'halted by before'; }; subtest 'route_exception' => sub { capture_stderr { dancer_response get => '/route_exception' }; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/release-distmeta.t0000644000175000017500000000045512253326150021433 0ustar gregoagregoa#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; meta_yaml_ok(); libdancer2-perl-0.11+dfsg.orig/t/serializer_json.t0000644000175000017500000000133112253326150021377 0ustar gregoagregoause strict; use warnings; use Test::More; require Dancer2::Serializer::JSON; my @tests = ( { entity => { a => 1, b => 2, }, options => { pretty => 1 }, }, { entity => { c => [ { d => 3, e => { f => 4, g => 'word', } } ], h => 6 }, options => { pretty => 1 }, } ); for my $test (@tests) { my $actual = Dancer2::Serializer::JSON::to_json( $test->{entity}, $test->{options} ); my $expected = JSON::to_json( $test->{entity}, $test->{options} ); is( $actual, $expected ); } use Dancer2::Core::Response; my $resp = Dancer2::Core::Response->new( content => '---', serializer => Dancer2::Serializer::JSON->new(), ); $resp->serialize(); done_testing(); libdancer2-perl-0.11+dfsg.orig/t/config_app2.t0000644000175000017500000000054212253326150020367 0ustar gregoagregoause strict; use warnings; use Test::More; use File::Spec; use t::app::t1::lib::Sub::App2; is( Sub::App2->runner->config->{app}->{config}, 'ok', 'config loaded properly' ); is_deeply( Sub::App2->runner->config_files, [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't1', 'config.yml' )) ], 'config files found' ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/template.t0000644000175000017500000000465412253326150020023 0ustar gregoagregoause strict; use warnings; use Test::More; use Dancer2::Core::Hook; use File::Spec; use File::Basename 'dirname'; eval { require Template; Template->import(); 1 } or plan skip_all => 'Template::Toolkit probably missing.'; use_ok('Dancer2::Template::TemplateToolkit'); my $views = File::Spec->rel2abs( File::Spec->catfile( dirname(__FILE__), 'views' ) ); my $tt = Dancer2::Template::TemplateToolkit->new( views => $views, layout => 'main.tt', ); isa_ok $tt, 'Dancer2::Template::TemplateToolkit'; ok $tt->does('Dancer2::Core::Role::Template'); $tt->add_hook( Dancer2::Core::Hook->new( name => 'engine.template.before_render', code => sub { my $tokens = shift; $tokens->{before_template_render} = 1; }, ) ); $tt->add_hook( Dancer2::Core::Hook->new( name => 'engine.template.before_layout_render', code => sub { my $tokens = shift; my $content = shift; $tokens->{before_layout_render} = 1; $$content .= "\ncontent added in before_layout_render"; }, ) ); $tt->add_hook( Dancer2::Core::Hook->new( name => 'engine.template.after_layout_render', code => sub { my $content = shift; $$content .= "\ncontent added in after_layout_render"; }, ) ); $tt->add_hook( Dancer2::Core::Hook->new( name => 'engine.template.after_render', code => sub { my $content = shift; $$content .= 'content added in after_template_render'; }, ) ); my $space = " "; my $result = $tt->process( 'index.tt', { var => 42 } ); is $result, "layout top var = 42 before_layout_render = 1 --- [index] var = 42 before_layout_render =$space before_template_render = 1 content added in after_template_render content added in before_layout_render --- layout bottom content added in after_layout_render"; { package Foo; use Dancer2; set views => '/this/is/our/path'; get '/default_views' => sub { set 'views' }; get '/set_views_via_settings' => sub { set views => '/other/path' }; get '/get_views_via_settings' => sub { set 'views' }; } use Dancer2::Test apps => ['Foo']; my $r = dancer_response GET => '/default_views'; is $r->content, '/this/is/our/path'; dancer_response GET => '/set_views_via_settings'; $r = dancer_response GET => '/get_views_via_settings'; is $r->content, '/other/path'; done_testing; libdancer2-perl-0.11+dfsg.orig/t/session_lifecycle.t0000644000175000017500000001400412253326150021700 0ustar gregoagregoause strict; use warnings; use Test::More; use YAML; use Test::TCP 1.13; use File::Temp 0.22; use LWP::UserAgent; use HTTP::Date qw/str2time/; use File::Spec; sub extract_cookie { my ($res) = @_; my @cookies = $res->header('set-cookie'); for my $c (@cookies) { next unless $c =~ /dancer\.session/; my @parts = split /;\s+/, $c; my %hash = map { my ( $k, $v ) = split /\s*=\s*/; $v ||= 1; ( lc($k), $v ) } @parts; $hash{expires} = str2time( $hash{expires} ) if $hash{expires}; return \%hash; } return; } my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); my @engines = qw(YAML Simple); if ( $ENV{DANCER_TEST_COOKIE} ) { push @engines, "cookie"; setting( session_cookie_key => "secret/foo*@!" ); } foreach my $engine (@engines) { diag "Testing engine $engine"; Test::TCP::test_tcp( client => sub { my $port = shift; my $ua = LWP::UserAgent->new; $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } ); # no session cookie set if session not referenced my $res = $ua->get("http://127.0.0.1:$port/no_session_data"); ok $res->is_success, "/no_session_data" or diag explain $res; my $cookie = extract_cookie($res); ok !$cookie, "no cookie set" or diag explain $cookie; # no empty session created if session read attempted $res = $ua->get("http://127.0.0.1:$port/read_session"); ok $res->is_success, "/read_session"; $cookie = extract_cookie($res); ok !$cookie, "no cookie set" or diag explain $cookie; # set value into session $res = $ua->get("http://127.0.0.1:$port/set_session/larry"); ok $res->is_success, "/set_session/larry"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; my $sid1 = $cookie->{"dancer.session"}; # read value back $res = $ua->get("http://127.0.0.1:$port/read_session"); ok $res->is_success, "/read_session"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; like $res->content, qr/name='larry'/, "session value looks good"; # session cookie should persist even if we don't touch sessions $res = $ua->get("http://127.0.0.1:$port/no_session_data"); ok $res->is_success, "/no_session_data"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; # destroy session and check that cookies expiration is set $res = $ua->get("http://127.0.0.1:$port/destroy_session"); ok $res->is_success, "/destroy_session"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; is $cookie->{"dancer.session"}, $sid1, "correct cookie expired"; ok $cookie->{expires} < time, "session cookie is expired"; # shouldn't be sent session cookie after session destruction $res = $ua->get("http://127.0.0.1:$port/no_session_data"); ok $res->is_success, "/no_session_data"; $cookie = extract_cookie($res); ok !$cookie, "no cookie set" or diag explain $cookie; # set value into session again $res = $ua->get("http://127.0.0.1:$port/set_session/curly"); ok $res->is_success, "/set_session/larry"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; my $sid2 = $cookie->{"dancer.session"}; isnt $sid2, $sid1, "New session has different ID"; # destroy and create a session in one request $res = $ua->get("http://127.0.0.1:$port/churn_session"); ok $res->is_success, "/churn_session"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; my $sid3 = $cookie->{"dancer.session"}; isnt $sid3, $sid2, "Changed session has different ID"; # read value back $res = $ua->get("http://127.0.0.1:$port/read_session"); ok $res->is_success, "/read_session"; $cookie = extract_cookie($res); ok $cookie, "session cookie set" or diag explain $cookie; like $res->content, qr/name='damian'/, "session value looks good"; File::Temp::cleanup(); }, server => sub { my $port = shift; use Dancer2; get '/no_session_data' => sub { return "session not modified"; }; get '/set_session/*' => sub { my ($name) = splat; session name => $name; }; get '/read_session' => sub { my $name = session('name') || ''; "name='$name'"; }; get '/destroy_session' => sub { my $name = session('name') || ''; context->destroy_session; return "destroyed='$name'"; }; get '/churn_session' => sub { context->destroy_session; session name => 'damian'; return "churned"; }; setting appdir => $tempdir; setting( engines => { session => { $engine => { session_dir => 't/sessions' } } } ); setting( session => $engine ); set(show_errors => 1, startup_info => 0, environment => 'production', port => $port ); Dancer2->runner->server->port($port); start; }, ); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/plugin_multiple_apps.t0000644000175000017500000000076512253326150022443 0ustar gregoagregoa# plugin_multiple_apps.t use strict; use warnings; use Test::More; { package App; BEGIN { use Dancer2; set session => 'Simple'; } use t::lib::SubApp1 with => { session => engine('session') }; use t::lib::SubApp2 with => { session => engine('session') }; } use Dancer2::Test apps => [ 'App', 't::lib::SubApp1', 't::lib::SubApp2' ]; # make sure both apps works as epxected response_content_is '/subapp1', 1; response_content_is '/subapp2', 2; done_testing; libdancer2-perl-0.11+dfsg.orig/t/deserialize.t0000644000175000017500000000574512253326150020512 0ustar gregoagregoause strict; use warnings; use Test::More tests => 9; { package MyApp; use Dancer2; set serializer => 'JSON'; put '/from_params' => sub { my %p = params(); return join " : ", map { $_ => $p{$_} } sort keys %p; }; put '/from_data' => sub { my $p = request->data; return join " : ", map { $_ => $p->{$_} } sort keys %$p; }; post '/from/:town' => sub { my $p = params; return $p; }; } use utf8; use JSON; use Encode; use Dancer2::Test apps => ['MyApp']; use Class::Load 'load_class'; is dancer_response( Dancer2::Core::Request->new( method => 'PUT', path => "/from_$_", content_type => 'application/json', body => '{ "foo": 1, "bar": 2 }', serializer => Dancer2::Serializer::JSON->new(), ) )->content => 'bar : 2 : foo : 1', "using $_" for qw/ params data /; note "Verify Serializers decode into characters"; { my $utf8 = '∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i)'; for my $type ( qw/Dumper JSON YAML/ ) { my $class = "Dancer2::Serializer::$type"; load_class($class); my $serializer = $class->new(); my $body = $serializer->serialize({utf8 => $utf8}); my $r = dancer_response( Dancer2::Core::Request->new( method => 'PUT', path => '/from_params', content_type => $serializer->content_type, body => $body, serializer => $serializer, ) ); my $content = Encode::decode( 'UTF-8', $r->content ); is( $content, "utf8 : $utf8", "utf-8 string returns the same using the $type serializer" ); } } note "Decoding of mixed route and deserialized body params"; { # Check integers from request body remain integers # but route params get decoded. my $r = dancer_response( Dancer2::Core::Request->new( method => 'POST', path => "/from/D\x{c3}\x{bc}sseldorf", # /from/d%C3%BCsseldorf content_type => 'application/json', body => JSON::to_json({ population => 592393 }), serializer => Dancer2::Serializer::JSON->new(), )); my $content = Encode::decode( 'UTF-8', $r->content ); # Watch out for hash order randomization.. like( $content, qr/[{,]"population":592393/, "Integer from JSON body remains integer" ); like( $content, qr/[{,]"town":"Düsseldorf"/, "Route params are decoded" ); } note 'Check serialization errors'; { my $serializer = Dancer2::Serializer::JSON->new(); my $req = Dancer2::Core::Request->new( method => 'PUT', path => '/from_params', content_type => 'application/json', body => "---", serializer => $serializer, ); ok $req->serializer->has_error, "Invalid JSON threw error in serializer"; like $req->serializer->error, qr/malformed number/, ".. of a 'malformed number'"; } libdancer2-perl-0.11+dfsg.orig/t/any.t0000644000175000017500000000106112253326150016764 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; { package App; use Dancer2; any [ 'get', 'post' ] => '/test' => sub { request->method; }; any '/all' => sub { request->method; }; } use Dancer2::Test apps => ['App']; my $r = dancer_response( POST => '/test' ); is $r->content, 'POST'; $r = dancer_response( GET => '/test' ); is $r->content, 'GET'; for my $method (qw(GET POST PUT DELETE OPTIONS PATCH)) { my $r = dancer_response( $method => '/all' ); is $r->content, $method; } done_testing; libdancer2-perl-0.11+dfsg.orig/t/file_utils.t0000644000175000017500000000335612253326150020345 0ustar gregoagregoause strict; use warnings; use Test::More tests => 14; use Test::Fatal; use File::Spec; BEGIN { @File::Spec::ISA = ("File::Spec::Unix") } use File::Temp 0.22; use Dancer2::FileUtils qw/read_file_content path_or_empty path/; sub write_file { my ( $file, $content ) = @_; open my $fh, '>', $file or die "cannot write file $file : $!"; binmode $fh, ':encoding(utf-8)'; print $fh $content; close $fh; } sub hexe { my $s = shift; $s =~ s/([\x00-\x1F])/sprintf('%#x',ord($1))/eg; return $s; } like( exception { Dancer2::FileUtils::open_file( '<', '/slfkjsdlkfjsdlf' ) }, qr{/slfkjsdlkfjsdlf' using mode '<'}, 'Failure opening nonexistent file', ); my $content = Dancer2::FileUtils::read_file_content(); is $content, undef; my $paths = [ [ undef => 'undef' ], [ '/foo/./bar/' => '/foo/bar/' ], [ '/foo/../bar' => '/bar' ], [ '/foo/bar/..' => '/foo/' ], ]; for my $case ( @$paths ) { is Dancer2::FileUtils::normalize_path( $case->[0] ), $case->[1]; } my $p = Dancer2::FileUtils::dirname('/somewhere'); is $p, '/'; my $tmp = File::Temp->new(); my $two = "²❷"; write_file( $tmp, "one$/$two" ); $content = read_file_content($tmp); is hexe($content), hexe("one$/$two"); my @content = read_file_content($tmp); is hexe( $content[0] ), hexe("one$/"); is $content[1], "$two"; # returns UNDEF on non-existant path my $path = 'bla/blah'; if ( !-e $path ) { is( path_or_empty($path), '', 'path_or_empty on non-existent path', ); } my $tmpdir = File::Temp->newdir; is( path_or_empty($tmpdir), $tmpdir, 'path_or_empty on an existing path' ); #slightly tricky paths on different platforms is( path( '/', 'b', '/c' ), '/b//c', 'path /,b,/c -> /b//c' ); is( path( '/', '/b', ), '/b', 'path /, /b -> /b' ); libdancer2-perl-0.11+dfsg.orig/t/http_status.t0000644000175000017500000000262012253326150020561 0ustar gregoagregoause strict; use warnings; use Test::More tests => 11; use Dancer2::Core::HTTP; note "HTTP status"; { my @tests = ( { status => undef, expected => undef }, { status => 200, expected => 200 }, { status => 'Not Found', expected => 404 }, { status => 'bad_request', expected => 400 }, { status => 'i_m_a_teapot', expected => 418 }, { status => 'error', expected => 500 }, { status => 911, expected => 911 }, ); for my $test (@tests) { my $status_text = defined $test->{status} ? $test->{status} : 'undef'; is( Dancer2::Core::HTTP->status( $test->{status} ), $test->{expected}, "HTTP status looks good for $status_text" ); } } note "HTTP status_message"; { my @tests = ( { status => undef, expected => undef }, { status => 200, expected => 'OK' }, { status => 'error', expected => 'Internal Server Error' }, { status => 911, expected => undef }, ); for my $test (@tests) { my $status_text = defined $test->{status} ? $test->{status} : 'undef'; is( Dancer2::Core::HTTP->status_message( $test->{status} ), $test->{expected}, "HTTP status message looks good for $status_text" ); } } libdancer2-perl-0.11+dfsg.orig/t/charset_server.t0000644000175000017500000000336112253326150021221 0ustar gregoagregoause Test::More; use strict; use warnings; use Encode; use utf8; use Test::TCP 1.13; use HTTP::Headers; use HTTP::Request::Common; use LWP::UserAgent; plan tests => 9; Test::TCP::test_tcp( client => sub { my $port = shift; my $ua = LWP::UserAgent->new; my $req = HTTP::Request::Common::POST( "http://127.0.0.1:$port/name", [ name => 'vasya' ] ); my $res = $ua->request($req); is $res->content_type, 'text/html'; ok $res->content_type_charset ; # we always have charset if the setting is set is $res->content, 'Your name: vasya'; $req = HTTP::Request::Common::GET("http://127.0.0.1:$port/unicode"); $res = $ua->request($req); is $res->content_type, 'text/html'; is $res->content_type_charset, 'UTF-8'; is $res->content, Encode::encode( 'utf-8', "cyrillic shcha \x{0429}" ); $req = HTTP::Request::Common::GET("http://127.0.0.1:$port/symbols"); $res = $ua->request($req); is $res->content_type, 'text/html'; is $res->content_type_charset, 'UTF-8'; is $res->content, Encode::encode( 'utf-8', "⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙" ); }, server => sub { my $port = shift; use Dancer2; get '/name/:name' => sub { "Your name: " . params->{name}; }; post '/name' => sub { "Your name: " . params->{name}; }; get '/unicode' => sub { "cyrillic shcha \x{0429}",; }; get '/symbols' => sub { '⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘ ⚙'; }; set charset => 'utf-8'; Dancer2->runner->server->port($port); start; }, ); libdancer2-perl-0.11+dfsg.orig/t/logger_console.t0000644000175000017500000000077112253326150021205 0ustar gregoagregoause strict; use warnings; use Test::More; use Capture::Tiny 0.12 'capture_stderr'; use Dancer2::Logger::Console; my $l = Dancer2::Logger::Console->new( app_name => 'test', log_level => 'core' ); for my $level (qw{core debug warning error}) { my $stderr = capture_stderr { $l->$level("$level") }; # Again, we are dealing directly with the logger, not through the # DSL, so the caller(6) stack has a different size like $stderr, qr{$level in -}, "$level message sent"; } done_testing; libdancer2-perl-0.11+dfsg.orig/t/route-pod-coverage/0000775000175000017500000000000012253326150021523 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/route-pod-coverage/route-pod-coverage.t0000644000175000017500000000076412253326150025424 0ustar gregoagregoause strict; use warnings; use Test::More; use t::lib::TestPod; use Dancer2::Test apps => ['t::lib::TestPod']; is_pod_covered 'is pod covered'; my $pod_structure = { 't::lib::TestPod' => { 'has_pod' => 1, 'routes' => [ "post /in_testpod/*", "post /me:id", "get /in_testpod", "get /hello", "get /me:id" ] } }; is_deeply( route_pod_coverage, $pod_structure, 'my pod looks like expected' ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/shared_engines.t0000644000175000017500000000234312253326150021157 0ustar gregoagregoause strict; use warnings; use File::Spec; use File::Temp 0.22; use LWP::UserAgent; use Test::More; use Test::TCP 1.13; use YAML; my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); Test::TCP::test_tcp( client => sub { my $port = shift; my $ua = LWP::UserAgent->new; $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } ); my $res = $ua->get("http://127.0.0.1:$port/main"); like $res->content, qr{42}, "session is set in main"; $res = $ua->get("http://127.0.0.1:$port/in_foo"); like $res->content, qr{42}, "session is set in foo"; my $engine = t::lib::Foo->dsl->engine('session'); is $engine->{__marker__}, 1, "the session engine in subapp is the same"; File::Temp::cleanup(); }, server => sub { my $port = shift; BEGIN { use Dancer2; set session => 'Simple'; engine('session')->{'__marker__'} = 1; } use t::lib::Foo with => { session => engine('session') }; get '/main' => sub { session( 'test' => 42 ); }; setting appdir => $tempdir; Dancer2->runner->server->port($port); start; }, ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/template_ext.t0000644000175000017500000000143012253326150020670 0ustar gregoagregoause strict; use warnings; use Test::More; use File::Spec; use File::Basename 'dirname'; eval { require Template; Template->import(); 1 } or plan skip_all => 'Template::Toolkit probably missing.'; use Dancer2; set engines => { template => { template_toolkit => { extension => 'foo', }, }, }; set template => 'template_toolkit'; my $views = File::Spec->rel2abs( File::Spec->catfile( dirname(__FILE__), 'views' ) ); my $tt = engine('template'); isa_ok( $tt, 'Dancer2::Template::TemplateToolkit' ); is( $tt->default_tmpl_ext, 'foo', "Template extension is 'foo' as configured", ); is( $tt->view_pathname('foo'), File::Spec->catfile( $views, 'foo.foo' ), "view('foo') gives filename with right extension as configured", ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/serializer.t0000644000175000017500000000207412253326150020353 0ustar gregoagregoause strict; use warnings; use Test::More tests => 7; use Dancer2::Serializer::Dumper; { package MyApp; use Dancer2; set serializer => 'JSON'; get '/json' => sub { return { bar => 'baz' } }; get '/to_json' => sub { to_json({bar => 'baz'}, {pretty => 1}) }; } use Dancer2::Test apps => ['MyApp']; # Response with implicit call to the serializer my $resp = dancer_response('/json'); response_status_is $resp => 200; response_content_is $resp => '{"bar":"baz"}'; response_headers_include $resp, [ 'Content-Type' => 'application/json' ]; # Response with explicit call to the serializer $resp = dancer_response('/to_json'); response_status_is $resp => 200; response_content_is $resp => "{\n \"bar\" : \"baz\"\n}\n"; # When calling `to_json', the content_type is not set, # because we can't assume we're calling it for a response response_headers_include $resp, [ 'Content-Type' => 'text/html; charset=UTF-8' ]; my $serializer = Dancer2::Serializer::Dumper->new(); is $serializer->content_type, 'text/x-data-dumper', 'content-type is set correctly'; libdancer2-perl-0.11+dfsg.orig/t/forward_test_tcp.t0000644000175000017500000000500712253326150021552 0ustar gregoagregoause strict; use warnings; use Test::More; use Test::TCP; use LWP::UserAgent; use Dancer2; test_tcp( server => sub { my $port = shift; set startup_info => 0; get '/' => sub { 'home:' . join( ',', params ); }; get '/bounce/' => sub { return forward '/'; }; get '/bounce/:withparams/' => sub { return forward '/'; }; get '/bounce2/adding_params/' => sub { return forward '/', { withparams => 'foo' }; }; post '/simple_post_route/' => sub { 'post:' . join( ',', params ); }; get '/go_to_post/' => sub { return forward '/simple_post_route/', { foo => 'bar' }, { method => 'post' }; }; post '/' => sub {'post-home'}; post '/bounce/' => sub { forward('/') }; Dancer2->runner->server->port($port); start; }, client => sub { my ( $port, $server_pid ) = @_; my $ua = LWP::UserAgent->new; my $res = $ua->get("http://127.0.0.1:$port/"); is $res->code => 200; like $res->content => qr/home:/; $res = $ua->get("http://127.0.0.1:$port/bounce/"); is $res->code => 200; like $res->content => qr/home:/; $res = $ua->get("http://127.0.0.1:$port/bounce/thesethings/"); is $res->code => 200; is $res->content => 'home:withparams,thesethings'; $res = $ua->get("http://127.0.0.1:$port/bounce2/adding_params/"); is $res->code => 200; is $res->content => 'home:withparams,foo'; $res = $ua->get("http://127.0.0.1:$port/go_to_post/"); is $res->code => 200; is $res->content => 'post:foo,bar'; $res = $ua->get("http://127.0.0.1:$port/bounce/"); is $res->header('Content-Length') => 5; is $res->header('Content-Type') => 'text/html; charset=UTF-8'; is $res->header('Server') => "Perl Dancer2 $Dancer2::VERSION"; $res = $ua->post("http://127.0.0.1:$port/"); is $res->code => 200; is $res->content => 'post-home'; $res = $ua->post("http://127.0.0.1:$port/bounce/"); is $res->code => 200; is $res->content => 'post-home'; is $res->header('Content-Length') => 9; is $res->header('Content-Type') => 'text/html; charset=UTF-8'; is $res->header('Server') => "Perl Dancer2 $Dancer2::VERSION"; } ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/redirect.t0000644000175000017500000000722612253326150020007 0ustar gregoagregoause strict; use warnings; use Test::More; subtest 'basic redirects' => sub { { package App; use Dancer2; get '/' => sub {'home'}; get '/bounce' => sub { redirect '/' }; get '/redirect' => sub { header 'X-Foo' => 'foo'; redirect '/'; }; get '/redirect_querystring' => sub { redirect '/login?failed=1' }; } use Dancer2::Test apps => ['App']; response_status_is [ GET => '/' ] => 200; response_content_is [ GET => '/' ] => "home"; response_status_is [ GET => '/bounce' ] => 302; my $expected_headers = [ 'Location' => 'http://localhost/', 'Content-Type' => 'text/html', 'X-Foo' => 'foo', ]; response_headers_include [ GET => '/redirect' ] => $expected_headers; $expected_headers = [ 'Location' => 'http://localhost/login?failed=1', 'Content-Type' => 'text/html', ]; response_headers_include [ GET => '/redirect_querystring' ] => $expected_headers; }; # redirect absolute subtest 'absolute and relative redirects' => sub { { package App; use Dancer2; get '/absolute_with_host' => sub { redirect "http://foo.com/somewhere"; }; get '/absolute' => sub { redirect "/absolute"; }; get '/relative' => sub { redirect "somewhere/else"; }; } use Dancer2::Test apps => ['App']; response_headers_include [ GET => '/absolute_with_host' ], [ Location => 'http://foo.com/somewhere' ]; response_headers_include [ GET => '/absolute' ], [ Location => 'http://localhost/absolute' ]; response_headers_include [ GET => '/relative' ], [ Location => 'http://localhost/somewhere/else' ]; }; subtest 'redirect behind a proxy' => sub { { package App; use Dancer2; prefix '/test2'; set behind_proxy => 1; get '/bounce' => sub { redirect '/test2' }; } use Dancer2::Test apps => ['App']; $ENV{X_FORWARDED_HOST} = "nice.host.name"; response_headers_include [ GET => '/test2/bounce' ], [ Location => 'http://nice.host.name/test2' ], "behind a proxy, host() is read from X_FORWARDED_HOST"; $ENV{HTTP_FORWARDED_PROTO} = "https"; response_headers_include [ GET => '/test2/bounce' ] => [ Location => 'https://nice.host.name/test2' ], "... and the scheme is read from HTTP_FORWARDED_PROTO"; $ENV{X_FORWARDED_PROTOCOL} = "ftp"; # stupid, but why not? response_headers_include [ GET => '/test2/bounce' ] => [ Location => 'ftp://nice.host.name/test2' ], "... or from X_FORWARDED_PROTOCOL"; }; subtest 'redirect behind multiple proxies' => sub { { package App; use Dancer2; prefix '/test2'; set behind_proxy => 1; get '/bounce' => sub { redirect '/test2' }; } use Dancer2::Test apps => ['App']; delete $ENV{X_FORWARDED_PROTOCOL}; delete $ENV{HTTP_FORWARDED_PROTO}; $ENV{X_FORWARDED_HOST} = "proxy1.example, proxy2.example"; response_headers_include [ GET => '/test2/bounce' ], [ Location => 'http://proxy1.example/test2' ], "behind multiple proxies, host() is read from X_FORWARDED_HOST"; $ENV{HTTP_FORWARDED_PROTO} = "https"; response_headers_include [ GET => '/test2/bounce' ] => [ Location => 'https://proxy1.example/test2' ], "... and the scheme is read from HTTP_FORWARDED_PROTO"; $ENV{X_FORWARDED_PROTOCOL} = "ftp"; # stupid, but why not? response_headers_include [ GET => '/test2/bounce' ] => [ Location => 'ftp://proxy1.example/test2' ], "... or from X_FORWARDED_PROTOCOL"; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/public/0000775000175000017500000000000012253326150017272 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/public/file.txt0000644000175000017500000000002612253326150020746 0ustar gregoagregoathis is a public file libdancer2-perl-0.11+dfsg.orig/t/plugin_register.t0000644000175000017500000000233212253326150021401 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2::Test; use Test::Fatal; subtest 'reserved keywords' => sub { use Dancer2::Plugin; like( exception { register dance => sub {1} }, qr/You can't use 'dance', this is a reserved keyword/, "Can't use Dancer2's reserved keywords", ); like( exception { register '1function' => sub {1} }, qr/You can't use '1function', it is an invalid name/, "Can't use invalid names for keywords", ); }; subtest 'plugin reserved keywords' => sub { { package Foo; use Dancer2::Plugin; Test::More::is( Test::Fatal::exception { register 'foo_method' => sub {1} }, undef, "can register a new keyword", ); } { package Bar; use Dancer2::Plugin; Test::More::like( Test::Fatal::exception { register 'foo_method' => sub {1} }, qr{can't use foo_method, this is a keyword reserved by Foo}, "cant register a keyword already registered by another plugin", ); } }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/response.t0000644000175000017500000000274512253326150020045 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2; use Dancer2::Core::Response; my $r = Dancer2::Core::Response->new( content => "hello" ); is $r->status, 200; is $r->content, 'hello'; note "content_type"; $r = Dancer2::Core::Response->new( headers => [ 'Content-Type' => 'text/html' ], content => 'foo', ); is_deeply $r->to_psgi, [ 200, [ Server => "Perl Dancer2 $Dancer2::VERSION", 'Content-Type' => 'text/html', ], ['foo'] ]; isa_ok $r->headers, 'HTTP::Headers'; is $r->content_type, 'text/html'; $r->content_type('text/plain'); is $r->content_type, 'text/plain'; ok( !$r->is_forwarded ); $r->forward('http://perldancer.org'); ok( $r->is_forwarded ); is $r->header('X-Foo'), undef; $r->header( 'X-Foo' => 42 ); is $r->header('X-Foo'), 42; $r->header( 'X-Foo' => 432 ); is $r->header('X-Foo'), 432; $r->push_header( 'X-Foo' => 777 ); is $r->header('X-Foo'), '432, 777'; $r->header( 'X-Bar' => 234 ); is $r->header('X-Bar'), '234'; is $r->push_header('X-Bar'), '234'; is scalar( @{ $r->headers_to_array } ), 10; # check that we drop the content on 204 $r = Dancer2::Core::Response->new( content => "foo" ); $r->status(204); is $r->content, ''; is $r->header('Content-Length'), 0; # stringify HTTP status $r = Dancer2::Core::Response->new( content => "foo", status => "Not Found" ); is $r->status, 404; $r = Dancer2::Core::Response->new( content => "foo", status => "not_modified" ); is $r->status, 304; done_testing; libdancer2-perl-0.11+dfsg.orig/t/cookie.t0000644000175000017500000000741112253326150017453 0ustar gregoagregoause strict; use warnings; use Test::More; BEGIN { # Freeze time at Tue, 15-Jun-2010 00:00:00 GMT *CORE::GLOBAL::time = sub { return 1276560000 } } use Dancer2::Core::Cookie; note "Constructor"; my $cookie = Dancer2::Core::Cookie->new( name => "foo" ); isa_ok $cookie => 'Dancer2::Core::Cookie'; can_ok $cookie => 'to_header'; note "Setting values"; is $cookie->value("foo") => "foo"; is $cookie->value => "foo"; is $cookie . "bar", "foobar", "Stringifies to desired value"; ok $cookie->value( [qw(a b c)] ); is $cookie->value => 'a'; is_deeply [ $cookie->value ] => [qw(a b c)]; ok $cookie->value( { x => 1, y => 2 } ); like $cookie->value => qr/^[xy]$/; # hashes doesn't store order... is_deeply [ sort $cookie->value ] => [ sort ( 1, 2, 'x', 'y' ) ]; note "accessors and defaults"; is $cookie->name => 'foo'; is $cookie->name("bar") => "bar"; is $cookie->name => 'bar'; ok !$cookie->domain; is $cookie->domain("dancer.org") => "dancer.org"; is $cookie->domain => "dancer.org"; is $cookie->domain("") => ""; ok !$cookie->domain; is $cookie->path => '/', "by default, path is /"; ok $cookie->has_path, "has_path"; is $cookie->path("/foo") => "/foo"; ok $cookie->has_path, "has_path"; is $cookie->path => "/foo"; ok !$cookie->secure; is $cookie->secure(1) => 1; is $cookie->secure => 1; is $cookie->secure(0) => 0; ok !$cookie->secure; ok !$cookie->http_only; is $cookie->http_only(1) => 1; is $cookie->http_only => 1; is $cookie->http_only(0) => 0; ok !$cookie->http_only; note "expiration strings"; my $min = 60; my $hour = 60 * $min; my $day = 24 * $hour; my $week = 7 * $day; my $mon = 30 * $day; my $year = 365 * $day; ok !$cookie->expires; my %times = ( "+2" => "Tue, 15-Jun-2010 00:00:02 GMT", "+2h" => "Tue, 15-Jun-2010 02:00:00 GMT", "-2h" => "Mon, 14-Jun-2010 22:00:00 GMT", "1 hour" => "Tue, 15-Jun-2010 01:00:00 GMT", "3 weeks 4 days 2 hours 99 min 0 secs" => "Sat, 10-Jul-2010 03:39:00 GMT", "2 months" => "Sat, 14-Aug-2010 00:00:00 GMT", "12 years" => "Sun, 12-Jun-2022 00:00:00 GMT", 1288817656 => "Wed, 03-Nov-2010 20:54:16 GMT", 1288731256 => "Tue, 02-Nov-2010 20:54:16 GMT", 1288644856 => "Mon, 01-Nov-2010 20:54:16 GMT", 1288558456 => "Sun, 31-Oct-2010 20:54:16 GMT", 1288472056 => "Sat, 30-Oct-2010 20:54:16 GMT", 1288385656 => "Fri, 29-Oct-2010 20:54:16 GMT", 1288299256 => "Thu, 28-Oct-2010 20:54:16 GMT", 1288212856 => "Wed, 27-Oct-2010 20:54:16 GMT", # Anything not understood is passed through "basset hounds got long ears" => "basset hounds got long ears", "+2 something" => "+2 something", ); for my $exp ( keys %times ) { my $want = $times{$exp}; $cookie->expires($exp); is $cookie->expires => $want; } note "to header"; my @cake = ( { cookie => { name => 'bar', value => 'foo', expires => '+2h', secure => 1 }, expected => sprintf( "bar=foo; path=/; expires=%s; Secure", $times{'+2h'} ), }, { cookie => { name => 'bar', value => 'foo', domain => 'dancer.org', path => '/dance', http_only => 1 }, expected => "bar=foo; path=/dance; domain=dancer.org; HttpOnly", }, { cookie => { name => 'bar', value => 'foo', }, expected => "bar=foo; path=/", }, ); for my $cook (@cake) { my $c = Dancer2::Core::Cookie->new( %{ $cook->{cookie} } ); is $c->to_header => $cook->{expected}; } done_testing; libdancer2-perl-0.11+dfsg.orig/t/error.t0000644000175000017500000000633712253326150017341 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2::Core::App; use Dancer2::Core::Context; use Dancer2::Core::Response; use Dancer2::Core::Request; use Dancer2::Core::Error; my $env = { 'psgi.url_scheme' => 'http', REQUEST_METHOD => 'GET', SCRIPT_NAME => '/foo', PATH_INFO => '/bar/baz', REQUEST_URI => '/foo/bar/baz', QUERY_STRING => 'foo=42&bar=12&bar=13&bar=14', SERVER_NAME => 'localhost', SERVER_PORT => 5000, SERVER_PROTOCOL => 'HTTP/1.1', REMOTE_ADDR => '127.0.0.1', HTTP_COOKIE => 'dancer.session=1234; fbs_102="access_token=xxxxxxxxxx%7Cffffff"', X_FORWARDED_FOR => '127.0.0.2', REMOTE_HOST => 'localhost', HTTP_USER_AGENT => 'Mozilla', REMOTE_USER => 'sukria', }; my $a = Dancer2::Core::App->new( name => 'main' ); my $c = Dancer2::Core::Context->new( env => $env, app => $a ); subtest 'basic defaults of Error object' => sub { my $e = Dancer2::Core::Error->new( context => $c, ); is $e->status, 500, 'code'; is $e->title, 'Error 500 - Internal Server Error', 'title'; is $e->message, undef, 'message'; like $e->content, qr!http://localhost:5000/foo/css!, "error content contains css path relative to uri_base"; }; subtest "send_error in route" => sub { { package App; use Dancer2; set serializer => 'JSON'; get '/error' => sub { send_error "This is a custom error message"; }; } use Dancer2::Test apps => ['App']; my $r = dancer_response GET => '/error'; is $r->status, 500, 'send_error sets the status to 500'; like $r->content, qr{This is a custom error message}, 'Error message looks good'; is $r->content_type, 'application/json', 'Response has appropriate content type after serialization'; }; subtest "send_error with custom stuff" => sub { { package App; use Dancer2; get '/error/:x' => sub { my $x = param('x'); send_error "Error $x", "5$x"; }; } my $r = dancer_response GET => '/error/42'; is $r->status, 542, 'send_error sets the status to 542'; like $r->content, qr{Error 42}, 'Error message looks good'; }; subtest 'Response->error()' => sub { my $resp = Dancer2::Core::Response->new; isa_ok $resp->error( message => 'oops', status => 418 ), 'Dancer2::Core::Error'; is $resp->status => 418, 'response code is 418'; like $resp->content => qr/oops/, 'response content overriden by error'; like $resp->content => qr/teapot/, 'error code title is present'; ok $resp->is_halted, 'response is halted'; }; subtest 'Error with show_errors: 0' => sub { my $err = Dancer2::Core::Error->new( context => $c, exception => 'our exception', show_errors => 0 )->throw; unlike $err->content => qr/our exception/; }; subtest 'Error with show_errors: 1' => sub { my $err = Dancer2::Core::Error->new( context => $c, exception => 'our exception', show_errors => 1 )->throw; like $err->content => qr/our exception/; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/dispatcher.t0000644000175000017500000001131512253326150020326 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Carp 'croak'; use Dancer2; use Dancer2::Test; use Dancer2::Core::App; use Dancer2::Core::Route; use Dancer2::Core::Dispatcher; use Dancer2::Core::Hook; set logger => 'Null'; # init our test fixture my $buffer = {}; my $app = Dancer2::Core::App->new( name => 'main' ); $app->setting( logger => engine('logger') ); $app->setting( show_errors => 1 ); # a simple / route $app->add_route( method => 'get', regexp => '/', code => sub {"home"}, ); # an error route $app->add_route( method => 'get', regexp => '/error', code => sub { Fail->fail; }, ); # A chain of two route for /user/$foo $app->add_route( method => 'get', regexp => '/user/:name', code => sub { my $ctx = shift; $buffer->{user} = $ctx->request->params->{'name'}; $ctx->response->has_passed(1); }, ); $app->add_route( method => 'get', regexp => '/user/*?', code => sub { my $ctx = shift; "Hello " . $ctx->request->params->{'name'}; }, ); # the tests my @tests = ( { env => { REQUEST_METHOD => 'GET', PATH_INFO => '/', }, expected => [ 200, [ 'Content-Length' => 4, 'Content-Type' => 'text/html; charset=UTF-8' ], ["home"] ] }, { env => { REQUEST_METHOD => 'GET', PATH_INFO => '/user/Johnny', }, expected => [ 200, [ 'Content-Length' => 12, 'Content-Type' => 'text/html; charset=UTF-8' ], ["Hello Johnny"] ] }, { env => { REQUEST_METHOD => 'GET', PATH_INFO => '/haltme', }, expected => [ 302, [ 'Location' => 'http://perldancer.org', 'Content-Length' => '0', 'Content-Type' => 'text/html', ], [''] ] }, # NOT SUPPORTED YET # { env => { # REQUEST_METHOD => 'GET', # PATH_INFO => '/admin', # }, # expected => [200, [], ["home"]] # }, ); # simulates a redirect with halt $app->add_hook( Dancer2::Core::Hook->new( name => 'before', code => sub { my $ctx = shift; if ( $ctx->request->path_info eq '/haltme' ) { $ctx->response->header( Location => 'http://perldancer.org' ); $ctx->response->status(302); $ctx->response->is_halted(1); } }, ) ); my $was_in_second_filter = 0; $app->add_hook( Dancer2::Core::Hook->new( name => 'before', code => sub { my $ctx = shift; if ( $ctx->request->path_info eq '/haltme' ) { $was_in_second_filter = 1; # should not happen because first filter halted the flow } }, ) ); $app->add_route( method => 'get', regexp => '/haltme', code => sub {"should not get there"}, ); $app->compile_hooks; plan tests => 13; my $dispatcher = Dancer2::Core::Dispatcher->new( apps => [$app] ); my $counter = 0; foreach my $test (@tests) { my $env = $test->{env}; my $expected = $test->{expected}; my $resp = $dispatcher->dispatch($env)->to_psgi; is $resp->[0] => $expected->[0], "Return code ok."; ok( Dancer2::Test::_include_in_headers( $resp->[1], $expected->[1] ), "expected headers are there" ); if ( ref( $expected->[2] ) eq "Regexp" ) { like $resp->[2][0] => $expected->[2], "Contents ok. (test $counter)"; } else { is_deeply $resp->[2] => $expected->[2], "Contents ok. (test $counter)"; } $counter++; } foreach my $test ( { env => { REQUEST_METHOD => 'GET', PATH_INFO => '/error', 'psgi.uri_scheme' => 'http', SERVER_NAME => 'localhost', SERVER_PORT => 5000, SERVER_PROTOCOL => 'HTTP/1.1', }, expected => [ 500, [ 'Content-Length', "Content-Type", 'text/html' ], qr{Internal Server Error.*Can't locate object method "fail" via package "Fail" \(perhaps you forgot to load "Fail"\?\) at t/dispatcher\.t line \d+.*$}ms ] } ) { my $env = $test->{env}; my $expected = $test->{expected}; my $resp = $dispatcher->dispatch($env); is $resp->status => $expected->[0], "Return code ok."; ok( $resp->header('Content-Length') >= 140, "Length ok." ); like $resp->content, $expected->[2], "contents ok"; } is $was_in_second_filter, 0, "didnt enter the second filter, because of halt"; libdancer2-perl-0.11+dfsg.orig/t/context_trigger.t0000644000175000017500000000241612253326150021411 0ustar gregoagregoause strict; use warnings; use File::Spec; use File::Temp 0.22; use LWP::UserAgent; use Test::More; use Test::TCP 1.13; use YAML; my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); Test::TCP::test_tcp( client => sub { my $port = shift; my $ua = LWP::UserAgent->new; $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } ); my $res = $ua->get("http://127.0.0.1:$port/main"); for my $type (qw/session logger serializer template/) { like $res->content, qr/^$type 1$/ms, "$type has context"; } File::Temp::cleanup(); }, server => sub { my $port = shift; BEGIN { use Dancer2; set session => 'Simple'; set logger => 'Null'; set serializer => 'JSON'; set template => 'Simple'; } get '/main' => sub { my $response = ""; for my $type (qw/session logger serializer template/) { my $defined = defined( engine("$type")->context ) ? 1 : 0; $response .= "$type $defined\n"; } return $response; }; setting appdir => $tempdir; Dancer2->runner->server->port($port); start; }, ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/route.t0000644000175000017500000000750312253326150017342 0ustar gregoagregoause strict; use warnings; use Test::More; use Test::Fatal; use Dancer2::Core::Request; use Dancer2::Core::Route; my @tests = ( [ [ 'get', '/', sub {11} ], '/', [ {}, 11 ] ], [ [ 'get', '/', sub {11} ], '/failure', [ undef, 11 ] ], [ [ 'get', '/hello/:name', sub {22} ], '/hello/sukria', [ { name => 'sukria' }, 22 ] ], [ [ 'get', '/', sub {33}, '/forum' ], '/forum', [ { splat => [1] }, 33 ] ], [ [ 'get', '/', sub {33}, '/forum' ], '/forum/', [ { splat => [1] }, 33 ] ], [ [ 'get', '/mywebsite', sub {33}, '/forum' ], '/forum/mywebsite', [ {}, 33 ] ], # splat test [ [ 'get', '/file/*.*', sub {44} ], '/file/dist.ini', [ { splat => [ 'dist', 'ini' ] }, 44 ] ], # megasplat test [ [ 'get', '/file/**/*', sub {44} ], '/file/some/where/42', [ { splat => [ [ 'some', 'where' ], '42' ] }, 44 ] ], [ [ 'get', qr{stuff(\d+)}, sub {44} ], '/stuff48', [ { splat => [48] }, 44 ] ], [ [ 'get', qr{/stuff(\d+)}, sub {44}, '/foo' ], '/foo/stuff48', [ { splat => [48] }, 44 ], ], ); plan tests => 43; for my $t (@tests) { my ( $route, $path, $expected ) = @$t; if ( ref($expected) eq 'Regexp' ) { like( exception { my $r = Dancer2::Core::Route->new( method => $route->[0], regexp => $route->[1], code => $route->[2], prefix => $route->[3], ); }, $expected, "got expected exception for $path", ); } else { my $r = Dancer2::Core::Route->new( method => $route->[0], regexp => $route->[1], code => $route->[2], prefix => $route->[3], ); isa_ok $r, 'Dancer2::Core::Route'; my $request = Dancer2::Core::Request->new( method => $route->[0], path => $path ); my $m = $r->match($request); is_deeply $m, $expected->[0], "got expected data for '$path'"; is $r->execute, $expected->[1], "got expected result for '$path'"; # failing request my $failing_request = Dancer2::Core::Request->new( method => 'get', path => '/something_that_doesnt_exist', ); $m = $r->match($failing_request); is $m, undef, "dont match failing request"; } } # captures test SKIP: { skip "Need perl >= 5.10", 1 unless $] >= 5.010; ## Regexp is parsed in compile time. So, eval with QUOTES to force to parse later. my $route_regex; eval q{ $route_regex = qr{/(? user | content | post )/(? delete | find )/(? \d+ )}x; }; my $r = Dancer2::Core::Route->new( regexp => $route_regex, code => sub { 'ok'; }, method => 'get', ); my $request = Dancer2::Core::Request->new( method => 'get', path => '/user/delete/234', ); my $m = $r->match($request); is_deeply $m, { captures => { class => 'user', action => 'delete', id => 234 } }, "named captures work"; } { my $route_w_options = Dancer2::Core::Route->new( method => 'get', regexp => '/', code => sub {'options'}, options => { 'agent' => 'cURL' }, ); my $req = Dancer2::Core::Request->new( path => '/', method => 'get', env => { 'HTTP_USER_AGENT' => 'mozilla' }, ); my $m = $route_w_options->match($req); ok !defined $m; $req = Dancer2::Core::Request->new( path => '/', method => 'get', env => { 'HTTP_USER_AGENT' => 'cURL' }, ); $m = $route_w_options->match($req); ok defined $m; } libdancer2-perl-0.11+dfsg.orig/t/config/0000775000175000017500000000000012253326150017261 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/config/environments/0000775000175000017500000000000012253326150022010 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/config/environments/staging.json0000644000175000017500000000010412253326150024330 0ustar gregoagregoa{ "main": "1", "charset": 'UTF-8', "show_errors": "1" } libdancer2-perl-0.11+dfsg.orig/t/config/environments/failure.yml0000644000175000017500000000002612253326150024156 0ustar gregoagregoanot a valid YAML file libdancer2-perl-0.11+dfsg.orig/t/config/environments/production.yml0000644000175000017500000000004112253326150024712 0ustar gregoagregoashow_errors: 0 logger: "console" libdancer2-perl-0.11+dfsg.orig/t/config/environments/merging.yml0000644000175000017500000000007012253326150024156 0ustar gregoagregoaapplication: some_feature: bar another_setting: baz libdancer2-perl-0.11+dfsg.orig/t/config/config.yml0000644000175000017500000000011312253326150021242 0ustar gregoagregoamain: 1 charset: 'UTF-8' show_errors: 1 application: some_feature: foo libdancer2-perl-0.11+dfsg.orig/t/session_hooks.t0000644000175000017500000001375412253326150021077 0ustar gregoagregoause strict; use warnings; use Test::More; use File::Temp 0.22; use YAML; use LWP::UserAgent; eval "use LWP::Protocol::PSGI"; plan skip_all => "LWP::Protocol::PSGI is needed for this test" if $@; my @engines = qw(Simple); my @hooks_to_test = qw( engine.session.before_retrieve engine.session.after_retrieve engine.session.before_create engine.session.after_create engine.session.before_destroy engine.session.after_destroy engine.session.before_flush engine.session.after_flush ); #we'll set a flag here when each hook is called. Then our test will then verify this my $test_flags = {}; my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); #I need this to make sure it works with LWP::Protocol::PSGI See GH#447 BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI'; } sub get_app_for_engine { my $engine = shift; use Dancer2; #Possibly this doesn't seem to have a real effect. See GH#447 setting apphandler => 'PSGI'; setting appdir => $tempdir; setting( engines => { #we'll need this for YAML sessions session => { engine => {session_dir => 't/sessions'}} } ); set(show_errors => 1, startup_info => 0, envoriment => 'production' ); setting(session => $engine); for my $hook (@hooks_to_test) { hook $hook => sub { $test_flags->{$hook} ||= 0; $test_flags->{$hook}++; } } get '/set_session' => sub { session foo => 'bar'; #setting causes a session flush return "ok"; }; get '/get_session' => sub { is session->read('foo'), 'bar', "Got the right session back"; return "ok"; }; get '/destroy_session' => sub { context->destroy_session; return "ok"; }; #setup each hook again and test whether they return the correct type #there is unfortunately quite some duplication here. hook 'engine.session.before_create' => sub { my ($response) = @_; is ref($response), 'Dancer2::Core::Session', 'Correct response type returned in before_create'; }; hook 'engine.session.after_create' => sub { my ($response) = @_; is ref($response), 'Dancer2::Core::Session', 'Correct response type returned in after_create'; }; hook 'engine.session.after_retrieve' => sub { my ($response) = @_; is ref($response), 'Dancer2::Core::Session', 'Correct response type returned in before_retrieve'; }; #this returns dancer app. We'll register it with LWP::Protocol::PSGI dance; } foreach my $engine (@engines) { note "Testing against $engine engine"; $test_flags = {}; #This will hijack lwp requests to localhost:3000 and send them to our dancer app LWP::Protocol::PSGI->register(get_app_for_engine($engine)); #if I set to hijack a particular the connection is refused. my $ua = LWP::UserAgent->new; $ua->cookie_jar({file => "$tempdir/.cookies.$engine.txt"}); my $r = $ua->get("http://localhost:3000/set_session"); is $r->content, "ok", "set_session ran ok"; #we verify whether the hooks were called correctly. subtest 'verify hooks for session create and session flush' => sub { is $test_flags->{'engine.session.before_create'}, 1, "session.before_create called"; is $test_flags->{'engine.session.after_create'}, 1, "session.after_create called"; is $test_flags->{'engine.session.before_flush'}, 1, "session.before_flush called"; is $test_flags->{'engine.session.after_flush'}, 1, "session.after_flush called"; is $test_flags->{'engine.session.before_retrieve'}, undef, "session.before_retrieve not called"; is $test_flags->{'engine.session.after_retrieve'}, undef, "session.after_retrieve not called"; is $test_flags->{'engine.session.before_destroy'}, undef, "session.before_destroy not called"; is $test_flags->{'engine.session.after_destroy'}, undef, "session.after_destroy not called"; }; $r = $ua->get("http://localhost:3000/get_session"); is $r->content, "ok", "get_session ran ok"; subtest 'verify hooks for session retrieve' => sub { is $test_flags->{'engine.session.before_retrieve'}, 1, "session.before_retrieve called"; is $test_flags->{'engine.session.after_retrieve'}, 1, "session.after_retrieve called"; is $test_flags->{'engine.session.before_create'}, 1, "session.before_create not called"; is $test_flags->{'engine.session.after_create'}, 1, "session.after_create not called"; is $test_flags->{'engine.session.before_flush'}, 1, "session.before_flush not called"; is $test_flags->{'engine.session.after_flush'}, 1, "session.after_flush not called"; is $test_flags->{'engine.session.before_destroy'}, undef, "session.before_destroy not called"; is $test_flags->{'engine.session.after_destroy'}, undef, "session.after_destroy not called"; }; $r = $ua->get("http://localhost:3000/destroy_session"); is $r->content, "ok", "destroy_session ran ok"; subtest 'verify session destroy hooks' => sub { is $test_flags->{'engine.session.before_destroy'}, 1, "session.before_destroy called"; is $test_flags->{'engine.session.after_destroy'}, 1, "session.after_destroy called"; #not sure if before and after retrieve should be called when the session is destroyed. But this happens. is $test_flags->{'engine.session.before_retrieve'}, 2, "session.before_retrieve called"; is $test_flags->{'engine.session.after_retrieve'}, 2, "session.after_retrieve called"; is $test_flags->{'engine.session.before_create'}, 1, "session.before_create not called"; is $test_flags->{'engine.session.after_create'}, 1, "session.after_create not called"; is $test_flags->{'engine.session.before_flush'}, 1, "session.before_flush not called"; is $test_flags->{'engine.session.after_flush'}, 1, "session.after_flush not called"; }; File::Temp::cleanup(); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/0000775000175000017500000000000012253326150020672 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/template_tiny/03_samples.t0000644000175000017500000000461312253326150023027 0ustar gregoagregoa#!/usr/bin/perl use strict; BEGIN { $| = 1; $^W = 1; } use vars qw{$VAR1 $VAR2}; use Test::More; use File::Spec::Functions ':ALL'; use Dancer2::Template::Implementation::ForkedTiny (); use FindBin qw($Bin); my $SAMPLES = catdir( $Bin, 'samples' ); unless ( -d $SAMPLES ) { die("Failed to find samples directory"); } opendir( DIR, $SAMPLES ) or die("opendir($SAMPLES): $!"); my @TEMPLATES = sort grep {/\.tt$/} readdir(DIR); closedir(DIR) or die("closedir($SAMPLES): $!"); plan( tests => scalar(@TEMPLATES) * 6 ); # Test the test classes #SCOPE: { # my $false = bless { }, 'False'; # my $string = $false . ''; # is( $string, 'Hello', 'False objects return ok as a string' ); # is( !!$false, '', 'False objects returns false during bool' ); #} ###################################################################### # Main Tests foreach my $template (@TEMPLATES) { $template =~ s/\.tt$//; my $file = catfile( $SAMPLES, $template ); my $tt_file = "$file.tt"; my $var_file = "$file.var"; my $txt_file = "$file.txt"; ok( -f $tt_file, "$template: Found $tt_file" ); ok( -f $txt_file, "$template: Found $txt_file" ); ok( -f $var_file, "$template: Found $var_file" ); # Load the resources my $tt = slurp($tt_file); my $var = slurp($var_file); my $txt = slurp($txt_file); eval $var; die $@ if $@; is( ref($VAR1), 'HASH', "$template: Loaded stash from file" ); # Create the processor normally my %params = ( INCLUDE_PATH => $SAMPLES, ); %params = ( %params, %$VAR2 ) if $VAR2; my $template = Dancer2::Template::Implementation::ForkedTiny->new(%params); isa_ok( $template, 'Dancer2::Template::Implementation::ForkedTiny' ); # Execute the template $template->process( \$tt, $VAR1, \my $out ); is( $out, $txt, "$template: Output matches expected" ); } sub slurp { my $f = shift; local $/ = undef; open( VAR, $f ) or die("open($f): $!"); my $buffer = ; close VAR; return $buffer; } ###################################################################### # Support Classes for object tests SCOPE: { package UpperCase; sub foo { uc $_[0]->{foo}; } 1; } SCOPE: { package False; use overload 'bool' => sub {0}; use overload '""' => sub {'Hello'}; 1; } SCOPE: { package Private; sub public {'foo'} sub _private {'foo'} 1; } libdancer2-perl-0.11+dfsg.orig/t/template_tiny/04_compat.t0000644000175000017500000000423512253326150022647 0ustar gregoagregoa#!/usr/bin/perl use strict; BEGIN { $| = 1; $^W = 1; } use vars qw{$VAR1 $VAR2}; use Test::More; use File::Spec::Functions ':ALL'; eval "require Template"; if ($@) { plan( skip_all => 'Template Toolkit is not installed' ); } use FindBin qw($Bin); my $SAMPLES = catdir( $Bin, 'samples' ); unless ( -d $SAMPLES ) { die("Failed to find samples directory"); } opendir( DIR, $SAMPLES ) or die("opendir($SAMPLES): $!"); my @TEMPLATES = sort grep {/\.tt$/} readdir(DIR); closedir(DIR) or die("closedir($SAMPLES): $!"); plan( tests => scalar(@TEMPLATES) * 7 ); ###################################################################### # Main Tests foreach my $name (@TEMPLATES) { $name =~ s/\.tt$//; my $file = catfile( $SAMPLES, $name ); my $tt_file = "$file.tt"; my $var_file = "$file.var"; my $txt_file = "$file.txt"; ok( -f $tt_file, "$name: Found $tt_file" ); ok( -f $txt_file, "$name: Found $txt_file" ); ok( -f $var_file, "$name: Found $var_file" ); # Load the resources my $tt = slurp($tt_file); my $var = slurp($var_file); my $txt = slurp($txt_file); eval $var; die $@ if $@; is( ref($VAR1), 'HASH', "$name: Loaded stash from file" ); # Create the template processor my %params = ( INCLUDE_PATH => $SAMPLES, ); %params = ( %params, %$VAR2 ) if $VAR2; my $template = Template->new(%params); isa_ok( $template, 'Template' ); # Execute the template my $out = ''; ok( $template->process( \$tt, $VAR1, \$out ), "$name: ->process returns true" ); is( $out, $txt, "$name: Output matches expected" ); } sub slurp { my $f = shift; local $/ = undef; open( VAR, $f ) or die("open($f): $!"); my $buffer = ; close VAR; return $buffer; } ###################################################################### # Support Classes for object tests SCOPE: { package UpperCase; sub foo { uc $_[0]->{foo}; } 1; } SCOPE: { package False; use overload 'bool' => sub {0}; use overload '""' => sub {'Hello'}; 1; } SCOPE: { package Private; sub public {'foo'} sub _private {'foo'} 1; } libdancer2-perl-0.11+dfsg.orig/t/template_tiny/01_compile.t0000644000175000017500000000022712253326150023006 0ustar gregoagregoa#!/usr/bin/perl use strict; BEGIN { $| = 1; $^W = 1; } use Test::More tests => 1; use_ok('Dancer2::Template::Implementation::ForkedTiny'); libdancer2-perl-0.11+dfsg.orig/t/template_tiny/05_preparse.t0000644000175000017500000000217512253326150023207 0ustar gregoagregoa#!/usr/bin/perl use strict; BEGIN { $| = 1; $^W = 1; } use Test::More tests => 6; use Dancer2::Template::Implementation::ForkedTiny (); sub preprocess { my $template = $_[0]; my $expected = $_[1]; my $message = $_[2] || 'Template preprocessd ok'; my $prepared = Dancer2::Template::Implementation::ForkedTiny->new->preprocess( $template); is( $prepared, $expected, $message ); is( $template, $_[0], '->proprocess does not modify original template variable' ); } ###################################################################### # Main Tests preprocess( <<'END_TEMPLATE', <<'END_EXPECTED', 'Simple IF' ); foo [% IF foo %] foobar [% END %] bar END_TEMPLATE foo [% I1 foo %] foobar [% I1 %] bar END_EXPECTED preprocess( <<'END_TEMPLATE', <<'END_EXPECTED', 'Simple UNLESS' ); foo [% UNLESS foo %] foobar [% END %] bar END_TEMPLATE foo [% U1 foo %] foobar [% U1 %] bar END_EXPECTED preprocess( <<'END_TEMPLATE', <<'END_EXPECTED', 'Simple FOREACH' ); foo [% FOREACH element IN lists %] foobar [% END %] bar END_TEMPLATE foo [% F1 element IN lists %] foobar [% F1 %] bar END_EXPECTED libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/0000775000175000017500000000000012253326150022336 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/03_chomp.tt0000644000175000017500000000015212253326150024313 0ustar gregoagregoafoo[%- a -%]bar foo [%- a -%] bar foo [% a %] bar foo [%- a %] bar foo [% a -%] bar foo [%- a -%] bar libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/02_null.tt0000644000175000017500000000004012253326150024152 0ustar gregoagregoaa[% foo %]b[% bar %]c[% foo %]d libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/07_nesting.tt0000644000175000017500000000033612253326150024664 0ustar gregoagregoa[% IF true %] one [% END %] [% IF false %] two [% END %] [% IF true %] [% IF true %] three [% END %] [% IF false %] four [% END %] [% END %] [% IF true %] five [% END %] [% IF false %] six [% END %]libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/09_trim.tt0000644000175000017500000000001612253326150024165 0ustar gregoagregoa Hello World! libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/02_null.var0000644000175000017500000000005212253326150024316 0ustar gregoagregoa$VAR1 = { 'foo' => '', }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/05_condition.txt0000644000175000017500000000005212253326150025364 0ustar gregoagregoaWorld! Hello! Hello! Hello World! foo FOO libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/01_hello.var0000644000175000017500000000006012253326150024445 0ustar gregoagregoa$VAR1 = { 'foo' => 'World' }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/02_null.txt0000644000175000017500000000000512253326150024343 0ustar gregoagregoaabcd libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/04_nested.txt0000644000175000017500000000002212253326150024654 0ustar gregoagregoab 1 2 1 4 9 bar libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/06_object.tt0000644000175000017500000000017712253326150024465 0ustar gregoagregoa[% foo.foo %] [% bar %] [% IF bar %]true[% ELSE %]false[% END %] public = '[% baz.public %]' private = '[% baz._private %]' libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/04_nested.var0000644000175000017500000000034112253326150024631 0ustar gregoagregoa$VAR1 = { a => 'b', foo => { one => 1, two => 2, three => [ 1, 4, 9 ], _private => 'secret', }, bar => [ { foo => 'bar', }, ], }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/09_trim.var0000644000175000017500000000004312253326150024326 0ustar gregoagregoa$VAR1 = {}; $VAR2 = { TRIM => 1 }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/01_hello.tt0000644000175000017500000000012712253326150024310 0ustar gregoagregoaHello [% foo %]! Hello [%foo%]! Hello [% foo %]! Hello [% foo %]! Hello [% foo %]! libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/08_foreach.txt0000644000175000017500000000014112253326150025007 0ustar gregoagregoaPeople bar: Adam Kennedy Foo Cool People: Adam Kennedy Done! libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/06_object.var0000644000175000017500000000024612253326150024623 0ustar gregoagregoa$VAR1 = { foo => bless( { foo => 'bar' }, 'UpperCase' ), bar => bless( { }, 'False' ), baz => bless( { }, 'Private' ), }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/07_nesting.var0000644000175000017500000000005512253326150025023 0ustar gregoagregoa$VAR1 = { true => 1, false => 0, }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/05_condition.var0000644000175000017500000000010112253326150025330 0ustar gregoagregoa$VAR1 = { 'foo' => 1, 'bar' => 0, }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/08_foreach.var0000644000175000017500000000044012253326150024762 0ustar gregoagregoa$VAR1 = { foo => 'bar', list => [ { name => 'Adam Kennedy', email => 'adamk@cpan.org', cool => 1, }, { name => 'Foo', email => 'No Fixed Address', cool => 0, }, ], }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/01_hello.txt0000644000175000017500000000010112253326150024470 0ustar gregoagregoaHello World! Hello World! Hello World! Hello World! Hello World! libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/07_nesting.txt0000644000175000017500000000004712253326150025053 0ustar gregoagregoa one three five libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/03_chomp.txt0000644000175000017500000000006312253326150024504 0ustar gregoagregoafoobar foo bar foo bar foo bar foo bar foobar libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/03_chomp.var0000644000175000017500000000001512253326150024452 0ustar gregoagregoa$VAR1 = { }; libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/09_trim.txt0000644000175000017500000000001412253326150024353 0ustar gregoagregoaHello World!libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/08_foreach.tt0000644000175000017500000000030512253326150024621 0ustar gregoagregoaPeople [% foo %]: [% FOREACH item IN list %] [%- item.name %] <[% item.email %]> [% END -%] Cool People: [% FOREACH item IN list %] [%- IF item.cool %] [%- item.name %] [% END %] [%- END -%] Done! libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/06_object.txt0000644000175000017500000000005512253326150024650 0ustar gregoagregoaBAR Hello false public = 'foo' private = '' libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/05_condition.tt0000644000175000017500000000034612253326150025202 0ustar gregoagregoa [%- IF foo %]World[% END %]! Hello[% IF bar %] World[% END %]! Hello[% UNLESS foo %] World[% END %]! Hello[% UNLESS bar %] World[% END %]! [% IF foo -%] foo [%- ELSE -%] bar [%- END -%] [% IF bar %] BAR [% ELSE %] FOO [% END -%] libdancer2-perl-0.11+dfsg.orig/t/template_tiny/samples/04_nested.tt0000644000175000017500000000025312253326150024472 0ustar gregoagregoa[% a %] [% foo.one %] [% foo.two %] [% foo.three.0 %] [% foo.three.1 %] [% foo.three.2 %] [% foo._private %] [% bar.0.foo %] [% bar.bad %] libdancer2-perl-0.11+dfsg.orig/t/template_tiny/02_trivial.t0000644000175000017500000000127412253326150023034 0ustar gregoagregoa#!/usr/bin/perl use strict; BEGIN { $| = 1; $^W = 1; } use Test::More tests => 1; use Dancer2::Template::Implementation::ForkedTiny (); sub process { my $stash = shift; my $input = shift; my $expected = shift; my $message = shift || 'Template processed ok'; my $output = ''; Dancer2::Template::Implementation::ForkedTiny->new->process( \$input, $stash, \$output ); is( $output, $expected, $message ); } ###################################################################### # Main Tests process( { foo => 'World' }, <<'END_TEMPLATE', <<'END_EXPECTED', 'Trivial ok' ); Hello [% foo %]! END_TEMPLATE Hello World! END_EXPECTED libdancer2-perl-0.11+dfsg.orig/t/request_params.t0000644000175000017500000001102512253326150021231 0ustar gregoagregoause Test::More; use strict; use warnings FATAL => 'all'; use Dancer2::Core::Request; diag "If you want extra speed, install URL::Encode::XS" if !$Dancer2::Core::Request::XS_URL_DECODE; diag "If you want extra speed, install CGI::Deurl::XS" if !$Dancer2::Core::Request::XS_PARSE_QUERY_STRING; sub run_test { { # 1. - get params note "get params"; $ENV{REQUEST_METHOD} = 'GET'; $ENV{PATH_INFO} = '/'; for my $separator ( '&', ';' ) { note "testing separator $separator"; $ENV{QUERY_STRING} = join( $separator, ( 'name=Alexis%20Sukrieh', 'IRC%20Nickname=sukria', 'Project=Perl+Dancer2', 'hash=2', 'hash=4', 'int1=1', 'int2=0' ) ); my $expected_params = { 'name' => 'Alexis Sukrieh', 'IRC Nickname' => 'sukria', 'Project' => 'Perl Dancer2', 'hash' => [ 2, 4 ], int1 => 1, int2 => 0, }; my $req = Dancer2::Core::Request->new( env => \%ENV ); is $req->path, '/', 'path is set'; is $req->method, 'GET', 'method is set'; ok $req->is_get, "request method is GET"; is_deeply scalar( $req->params ), $expected_params, 'params are OK'; is $req->params->{'name'}, 'Alexis Sukrieh', 'params accessor works'; my %params = $req->params; is_deeply scalar( $req->params ), \%params, 'params wantarray works'; } } { # 2. - post params note "post params"; my $body = 'foo=bar&name=john&hash=2&hash=4&hash=6&'; open my $in, '<', \$body; my $env = { CONTENT_LENGTH => length($body), CONTENT_TYPE => 'application/x-www-form-urlencoded', REQUEST_METHOD => 'POST', SCRIPT_NAME => '/', 'psgi.input' => $in, }; my $expected_params = { name => 'john', foo => 'bar', hash => [ 2, 4, 6 ], }; my $req = Dancer2::Core::Request->new( env => $env ); is $req->path, '/', 'path is set'; is $req->method, 'POST', 'method is set'; ok $req->is_post, 'method is post'; my $request_to_string = $req->to_string; like $request_to_string, qr{\[#\d+\] POST /}; is_deeply scalar( $req->params ), $expected_params, 'params are OK'; is $req->params->{'name'}, 'john', 'params accessor works'; my %params = $req->params; is_deeply scalar( $req->params ), \%params, 'params wantarray works'; } { # 3. - mixed params my $body = 'x=1&meth=post'; open my $in, '<', \$body; my $env = { CONTENT_LENGTH => length($body), CONTENT_TYPE => 'application/x-www-form-urlencoded', QUERY_STRING => 'y=2&meth=get', REQUEST_METHOD => 'POST', SCRIPT_NAME => '/', 'psgi.input' => $in, }; my $mixed_params = { meth => 'post', x => 1, y => 2, }; my $get_params = { y => 2, meth => 'get', }; my $post_params = { x => 1, meth => 'post', }; my $req = Dancer2::Core::Request->new( env => $env ); is $req->path, '/', 'path is set'; is $req->method, 'POST', 'method is set'; is_deeply scalar( $req->params ), $mixed_params, 'params are OK'; is_deeply scalar( $req->params('body') ), $post_params, 'body params are OK'; is_deeply scalar( $req->params('query') ), $get_params, 'query params are OK'; } } diag "Run test with XS_URL_DECODE" if $Dancer2::Core::Request::XS_URL_DECODE; diag "Run test with XS_PARSE_QUERY_STRING" if $Dancer2::Core::Request::XS_PARSE_QUERY_STRING; run_test(); if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) { diag "Run test without XS_PARSE_QUERY_STRING"; $Dancer2::Core::Request::XS_PARSE_QUERY_STRING = 0; $Dancer2::Core::Request::_count = 0; run_test(); } if ($Dancer2::Core::Request::XS_URL_DECODE) { diag "Run test without XS_URL_DECODE"; $Dancer2::Core::Request::XS_URL_DECODE = 0; $Dancer2::Core::Request::_count = 0; run_test(); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/config_app1.t0000644000175000017500000000051712253326150020370 0ustar gregoagregoause strict; use warnings; use Test::More; use File::Spec; use t::app::t1::lib::App1; is( App1->runner->config->{app}->{config}, 'ok', 'config loaded properly' ); is_deeply( App1->runner->config_files, [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't1', 'config.yml' )) ], 'config files found' ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/types.t0000644000175000017500000001134412253326150017346 0ustar gregoagregoause strict; use warnings; use Test::More tests => 46; use Test::Fatal; use Dancer2::Core::Types; ok( exception { Str->(undef) }, 'Str does not accept undef value', ); is( exception { Str->('something') }, undef, 'Str', ); like( exception { Str->( { foo => 'something' } ) }, qr{HASH\(\w+\) is not a string}, 'Str', ); is( exception { Num->(34) }, undef, 'Num', ); ok( exception { Num->(undef) }, 'Num does not accept undef value', ); like( exception { Num->('not a number') }, qr{(?i:not a number is not a Number)}, 'Num fail', ); is( exception { Bool->(1) }, undef, 'Bool true value', ); is( exception { Bool->(0) }, undef, 'Bool false value', ); is( exception { Bool->(undef) }, undef, 'Bool does accepts undef value', ); like( exception { Bool->('2') }, qr{2 is not a Boolean}, 'Bool fail', ); is( exception { RegexpRef->(qr{.*}) }, undef, 'Regexp', ); like( exception { RegexpRef->('/.*/') }, qr{\Q/.*/\E is not a RegexpRef}, 'Regexp fail', ); ok( exception { RegexpRef->(undef) }, 'Regexp does not accept undef value', ); is( exception { HashRef->( { goo => 'le' } ) }, undef, 'HashRef', ); like( exception { HashRef->('/.*/') }, qr{\Q/.*/\E is not a HashRef}, 'HashRef fail', ); ok( exception { HashRef->(undef) }, 'HashRef does not accept undef value', ); is( exception { ArrayRef->( [ 1, 2, 3, 4 ] ) }, undef, 'ArrayRef', ); like( exception { ArrayRef->('/.*/') }, qr{\Q/.*/\E is not an ArrayRef}, 'ArrayRef fail', ); ok( exception { ArrayRef->(undef) }, 'ArrayRef does not accept undef value', ); is( exception { CodeRef->( sub {44} ); }, undef, 'CodeRef', ); like( exception { CodeRef->('/.*/') }, qr{\Q/.*/\E is not a CodeRef}, 'CodeRef fail', ); ok( exception { CodeRef->(undef) }, 'CodeRef does not accept undef value', ); { package InstanceChecker::zad7; use Moo; use Dancer2::Core::Types; has foo => ( is => 'ro', isa => InstanceOf ['Foo'] ); } is( exception { InstanceChecker::zad7->new( foo => bless {}, 'Foo' ) }, undef, 'InstanceOf', ); like( exception { InstanceChecker::zad7->new( foo => bless {}, 'Bar' ) }, qr{Bar=HASH\(\w+\) is not an instance of the class: Foo}, 'InstanceOf fail', ); ok( exception { InstanceOf('Foo')->(undef) }, 'InstanceOf does not accept undef value', ); is( exception { Dancer2Prefix->('/foo') }, undef, 'Dancer2Prefix', ); like( exception { Dancer2Prefix->('bar/something') }, qr{bar/something is not a Dancer2Prefix}, 'Dancer2Prefix fail', ); # see Dancer2Prefix definition, undef is a valid value like( exception { Dancer2Prefix->(undef) }, qr/undef is not a Dancer2Prefix/, 'Dancer2Prefix does not accept undef value', ); is( exception { Dancer2AppName->('Foo') }, undef, 'Dancer2AppName', ); is( exception { Dancer2AppName->('Foo::Bar') }, undef, 'Dancer2AppName', ); is( exception { Dancer2AppName->('Foo::Bar::Baz') }, undef, 'Dancer2AppName', ); like( exception { Dancer2AppName->('Foo:Bar') }, qr{Foo:Bar is not a Dancer2AppName}, 'Dancer2AppName fails with single colons', ); like( exception { Dancer2AppName->('Foo:::Bar') }, qr{Foo:::Bar is not a Dancer2AppName}, 'Dancer2AppName fails with tripe colons', ); like( exception { Dancer2AppName->('7Foo') }, qr{7Foo is not a Dancer2AppName}, 'Dancer2AppName fails with beginning number', ); like( exception { Dancer2AppName->('Foo::45Bar') }, qr{Foo::45Bar is not a Dancer2AppName}, 'Dancer2AppName fails with beginning number', ); like( exception { Dancer2AppName->('-F') }, qr{-F is not a Dancer2AppName}, 'Dancer2AppName fails with special character', ); like( exception { Dancer2AppName->('Foo::-') }, qr{Foo::- is not a Dancer2AppName}, 'Dancer2AppName fails with special character', ); like( exception { Dancer2AppName->('Foo^') }, qr{\QFoo^\E is not a Dancer2AppName}, 'Dancer2AppName fails with special character', ); ok( exception { Dancer2AppName->(undef) }, 'Dancer2AppName does not accept undef value', ); like( exception { Dancer2AppName->('') }, qr{Empty string is not a Dancer2AppName}, 'Dancer2AppName fails an empty string value', ); is( exception { Dancer2Method->('post') }, undef, 'Dancer2Method', ); like( exception { Dancer2Method->('POST') }, qr{POST is not a Dancer2Method}, 'Dancer2Method fail', ); ok( exception { Dancer2Method->(undef) }, 'Dancer2Method does not accept undef value', ); is( exception { Dancer2HTTPMethod->('POST') }, undef, 'Dancer2HTTPMethod', ); like( exception { Dancer2HTTPMethod->('post') }, qr{post is not a Dancer2HTTPMethod}, 'Dancer2HTTPMethod fail', ); ok( exception { Dancer2HTTPMethod->(undef) }, 'Dancer2Method does not accept undef value', ); libdancer2-perl-0.11+dfsg.orig/t/roles/0000775000175000017500000000000012253326150017140 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/roles/hook.t0000644000175000017500000000257412253326150020273 0ustar gregoagregoause strict; use warnings; use Test::More tests => 8; use Test::Fatal; use Dancer2::Core::Hook; my $h = Dancer2::Core::Hook->new( name => 'before_template', code => sub {'BT'} ); is $h->name, 'before_template_render'; is $h->code->(), 'BT'; { package Foo; use Moo; with 'Dancer2::Core::Role::Hookable'; sub supported_hooks {'foobar'} } my $f = Foo->new; like( exception { $f->execute_hook() }, qr{execute_hook needs a hook name}, 'execute_hook needs a hook name', ); my $count = 0; my $some_hook = Dancer2::Core::Hook->new( name => 'foobar', code => sub { $count++; } ); ok( !exception { $f->add_hook($some_hook) }, 'Supported hook can be installed', ); like( exception { $f->add_hook( Dancer2::Core::Hook->new( name => 'unknown_hook', code => sub { $count++; } ) ); }, qr{Unsupported hook 'unknown_hook'}, 'Unsupported hook cannot be installed', ); $f->execute_hook('foobar'); is $count, 1; like( exception { $f->replace_hook( 'doesnotexist', [] ) }, qr{Hook 'doesnotexist' must be installed first}, 'Nonexistent hook fails', ); my $new_hooks = [ sub { $count-- }, sub { $count-- }, sub { $count-- } ]; $f->replace_hook( 'foobar', $new_hooks ); $f->execute_hook('foobar'); is $count, -2, 'replaced hooks were installed and executed'; libdancer2-perl-0.11+dfsg.orig/t/roles/server.t0000644000175000017500000000144712253326150020637 0ustar gregoagregoause Test::More; use Test::Fatal; use strict; use warnings; { package Foo; use Moo; with 'Dancer2::Core::Role::Server'; sub _build_name {'foo'} } my $s; like( exception { $s = Foo->new }, qr{required.*host}, "host is mandatory", ); like( exception { $s = Foo->new( host => 'localhost' ) }, qr{required.*port}, "port is mandatory", ); my $runner = Dancer2::Core::Runner->new( caller => $0 ); $s = Foo->new( host => 'localhost', port => 3000, runner => $runner ); my $app = Dancer2::Core::App->new( name => 'main' ); $s->register_application($app); is $s->apps->[0]->name, 'main', 'app has been registered'; isa_ok $s->dispatcher, 'Dancer2::Core::Dispatcher'; my $psgi_app = $s->psgi_app; is ref($psgi_app), 'CODE', 'got a subroutine when asked for psgi_app'; done_testing, libdancer2-perl-0.11+dfsg.orig/t/roles/headers.t0000644000175000017500000000114412253326150020736 0ustar gregoagregoa use strict; use warnings; use Test::More; { package Foo; use Moo; with 'Dancer2::Core::Role::Headers'; } my $f = Foo->new( headers => [ 'X-Foo' => 42, 'X-Bar' => 43 ] ); is $f->header('x-foo'), 42, "header can be read with lowercase"; is $f->header('X-Foo'), 42, "header can be read with original name"; $f->header( 'x-baz' => 44 ); is $f->header('x-baz'), 44, "new header is created"; $f->header( 'X-Foo' => 777 ); is $f->header('X-Foo'), 777, "existing header is replaced"; $f->push_header( 'X-Foo' => 888 ); is $f->header('X-Foo'), '777, 888', "push_header appends a value"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/template_simple.t0000644000175000017500000000526512253326150021373 0ustar gregoagregoause Test::More tests => 9; use strict; use warnings; use Dancer2::FileUtils 'path'; use Dancer2::Template::Simple; { package Foo; use Moo; has x => ( is => 'rw'); has y => ( is => 'rw'); sub method { "yeah" } } # variable interpolation, with file-based template my $engine = Dancer2::Template::Simple->new; my $template = path('t', 'views', 'template_simple_index.tt'); my $result = $engine->render( $template, { var1 => "xxx", var2 => "yyy", foo => 'one', bar => 'two', baz => 'three'}); my $expected = 'this is var1="xxx" and var2=yyy'."\n\nanother line\n\n one two three\n\nxxx/xxx\n"; is $result, $expected, "template got processed successfully"; # variable interpolation, with scalar-based template $expected = "one=1, two=2, three=3 - 77"; $template = "one=<% one %>, two=<% two %>, three=<% three %> - <% hash.key %>"; eval { $engine->render($template, { one => 1, two => 2, three => 3}) }; like $@, qr/Can't open .* using mode '<'/, "prototype failure detected"; $result = $engine->render(\$template, { one => 1, two => 2, three => 3, hash => { key => 77 }, }); is $result, $expected, "processed a template given as a scalar ref"; # complex variable interpolation (object, coderef and hash) my $foo = Foo->new; $foo->x(42); $template = 'foo->x == <% foo.x %> foo.method == <% foo.method %> foo.dumb=\'<% foo.dumb %>\''; $expected = 'foo->x == 42 foo.method == yeah foo.dumb=\'\''; $result = $engine->render(\$template, { foo => $foo }); is $result, $expected, 'object are interpolated in templates'; $template = 'code = <% code %>, code <% hash.code %>'; $expected = 'code = 42, code 42'; $result = $engine->render(\$template, { code => sub { 42 }, hash => { code => sub { 42 } } }); is $result, $expected, 'code ref are interpolated in templates'; $template = 'array: <% array %>, hash.array: <% hash.array %>'; $expected = 'array: 1 2 3 4 5, hash.array: 6 7 8'; $result = $engine->render(\$template, { array => [1, 2, 3, 4, 5], hash => { array => [6, 7, 8] }}); is $result, $expected, "arrayref are interpolated in templates"; # if-then-else $template = '<% if want %>hello<% else %>goodbye<% end %> world'; $result = $engine->render(\$template, {want => 1}); is $result, 'hello world', "true boolean condition matched"; $result = $engine->render(\$template, {want => 0}); is $result, 'goodbye world', "false boolean condition matched"; $template = 'one: 1 two: <% two %> three : <% three %>'; $result = $engine->render(\$template, {two => 2, three => 3 }); is $result, 'one: 1 two: 2 three : 3', "multiline template processed"; libdancer2-perl-0.11+dfsg.orig/t/server.t0000644000175000017500000000107712253326150017512 0ustar gregoagregoause strict; use warnings; use Test::More; { package Foo; use Moo; with 'Dancer2::Core::Role::Server'; sub _build_name {'Foo'} } use Dancer2::Core::Runner; my $runner = Dancer2::Core::Runner->new( caller => __FILE__ ); my $f = Foo->new( host => 'localhost', port => 3000, runner => $runner ); my $app = Dancer2::Core::App->new( name => 'foo' ); $f->register_application($app); is $f->apps->[0]->name, 'foo'; is $f->host, 'localhost'; is $f->port, 3000; ok( !$f->is_daemon ); ok( defined $f->dispatcher ); is ref( $f->psgi_app ), 'CODE'; done_testing; libdancer2-perl-0.11+dfsg.orig/t/dsl.t0000644000175000017500000000047512253326150016767 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2; use Dancer2::Test; any [ 'get', 'post' ], '/' => sub { request->method; }; { my $r = dancer_response GET => '/'; is $r->content, 'GET'; } { my $r = dancer_response POST => '/'; is $r->content, 'POST'; } done_testing; libdancer2-perl-0.11+dfsg.orig/t/session_forward.t0000644000175000017500000000276712253326150021422 0ustar gregoagregoause Test::More; use strict; use warnings; use LWP::UserAgent; use Test::TCP 1.13; use File::Temp; my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); my $server = sub { my $port = shift; use Dancer2; set session => 'Simple'; get '/set_chained_session' => sub { session 'zbr' => 'ugh'; forward '/set_session'; }; get '/set_session' => sub { session 'foo' => 'bar'; forward '/get_session'; }; get '/get_session' => sub { session 'more' => 'one'; sprintf("%s:%s:%s", session("more"), session('foo') , session('zbr')||"") }; get '/clear' => sub { session "foo" => undef; session "zbr" => undef; session "more" => undef; }; Dancer2->runner->server->port($port); start; }; my $client = sub { my $port = shift; my $ua = LWP::UserAgent->new; $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } ); my $res = $ua->get("http://127.0.0.1:$port/set_chained_session"); is $res->content, q{one:bar:ugh}, 'Session value preserved after chained forwards'; $res = $ua->get("http://127.0.0.1:$port/get_session"); is $res->content, q{one:bar:ugh}, 'Session values preserved between calls'; $res = $ua->get("http://127.0.0.1:$port/clear"); $res = $ua->get("http://127.0.0.1:$port/set_session"); is $res->content, q{one:bar:}, 'Session value preserved after forward from route'; }; Test::TCP::test_tcp( client => $client, server => $server); done_testing; libdancer2-perl-0.11+dfsg.orig/t/corpus/0000775000175000017500000000000012253326150017327 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/corpus/pretty/0000775000175000017500000000000012253326150020656 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/corpus/pretty/505.tt0000644000175000017500000000010012253326150021525 0ustar gregoagregoaTemplate selected. message: [% content %] status: [% status %] libdancer2-perl-0.11+dfsg.orig/t/corpus/pretty_public/0000775000175000017500000000000012253326150022214 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/corpus/pretty_public/510.html0000644000175000017500000000001512253326150023401 0ustar gregoagregoaStatic page. libdancer2-perl-0.11+dfsg.orig/t/corpus/pretty_public/404.html0000644000175000017500000000006412253326150023407 0ustar gregoagregoa

Yup, you're lost

libdancer2-perl-0.11+dfsg.orig/t/corpus/static/0000775000175000017500000000000012253326150020616 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/corpus/static/1x1.png0000644000175000017500000000013712253326150021734 0ustar gregoagregoaPNG  IHDR%VPLTEz=tRNS@f IDATc`!3IENDB`libdancer2-perl-0.11+dfsg.orig/t/corpus/static/index.html0000644000175000017500000000021312253326150022605 0ustar gregoagregoa Unicode test

Hello, UTF-8

áéíóú

libdancer2-perl-0.11+dfsg.orig/t/00-report-prereqs.t0000644000175000017500000000475012253326150021414 0ustar gregoagregoa#!perl use strict; use warnings; use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec::Functions; use List::Util qw/max/; my @modules = qw( App::Cmd::Setup CGI::Deurl::XS Capture::Tiny Carp Class::Load Class::Load::XS Config::Any Crypt::URandom Cwd Data::Dumper Digest::SHA Encode Exporter ExtUtils::MakeMaker Fcntl File::Basename File::Copy File::Find File::Path File::ShareDir File::ShareDir::Install File::Spec File::Spec::Functions File::Temp FindBin HTTP::Body HTTP::Date HTTP::Headers HTTP::Request::Common HTTP::Server::Simple::PSGI Hash::Merge::Simple IO::File IO::Handle IPC::Open3 JSON JSON::XS LWP::Protocol::PSGI LWP::UserAgent List::Util MIME::Base64 MIME::Types Math::Random::ISAAC::XS Module::Build Moo Moo::Role MooX::Types::MooseLike MooX::Types::MooseLike::Base POSIX Plack::Request Pod::Simple::Search Pod::Simple::SimpleTree Return::MultiLevel Role::Tiny Scalar::Util Scope::Upper Template Template::Tiny Test::Builder Test::Fatal Test::MockTime Test::More Test::Script Test::TCP URI URI::Escape URL::Encode::XS YAML YAML::Any lib overload parent perl strict utf8 vars warnings ); # replace modules with dynamic results from MYMETA.json if we can # (hide CPAN::Meta from prereq scanner) my $cpan_meta = "CPAN::Meta"; if ( -f "MYMETA.json" && eval "require $cpan_meta" ) { ## no critic if ( my $meta = eval { CPAN::Meta->load_file("MYMETA.json") } ) { my $prereqs = $meta->prereqs; delete $prereqs->{develop}; my %uniq = map {$_ => 1} map { keys %$_ } map { values %$_ } values %$prereqs; $uniq{$_} = 1 for @modules; # don't lose any static ones @modules = sort keys %uniq; } } my @reports = [qw/Version Module/]; for my $mod ( @modules ) { next if $mod eq 'perl'; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e catfile($_, $file) } @INC; if ( $prefix ) { my $ver = MM->parse_version( catfile($prefix, $file) ); $ver = "undef" unless defined $ver; # Newer MM should do this anyway push @reports, [$ver, $mod]; } else { push @reports, ["missing", $mod]; } } if ( @reports ) { my $vl = max map { length $_->[0] } @reports; my $ml = max map { length $_->[1] } @reports; splice @reports, 1, 0, ["-" x $vl, "-" x $ml]; diag "Prerequisite Report:\n", map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports; } pass; # vim: ts=2 sts=2 sw=2 et: libdancer2-perl-0.11+dfsg.orig/t/error_template.t0000644000175000017500000000271512253326150021230 0ustar gregoagregoause strict; use warnings; use Test::More; { package PrettyError; use Dancer2; engine('template')->views('t/corpus/pretty'); $ENV{DANCER_PUBLIC} = 't/corpus/pretty_public'; get '/error' => sub { send_error "oh my", 505; }; get '/public' => sub { send_error "static", 510; }; get '/no_template' => sub { local $ENV{DANCER_PUBLIC} = undef; send_error "oopsie", 404; }; } use Dancer2::Test apps => ['PrettyError']; subtest "/error" => sub { my $r = dancer_response GET => '/error'; is $r->status, 505, 'send_error sets the status to 505'; like $r->content, qr{Template selected}, 'Error message looks good'; like $r->content, qr{message: oh my}; like $r->content, qr{status: 505}; }; subtest "/public" => sub { my $r = dancer_response GET => '/public'; is $r->status, 510, 'send_error sets the status to 510'; like $r->content, qr{Static page}, 'Error message looks good'; }; subtest "/no_template" => sub { my $r = dancer_response GET => '/no_template'; is $r->status, 404, 'send_error sets the status to 404'; like $r->content, qr{

Error 404 - Not Found

}, 'Error message looks good'; }; subtest '404 with static template' => sub { my $r = dancer_response GET => '/middle/of/nowhere'; is $r->status, 404, 'unknown route => 404'; like $r->content, qr{you're lost}i, 'Error message looks good'; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/lib/0000775000175000017500000000000012253326150016562 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/lib/DancerPlugin.pm0000644000175000017500000000066112253326150021474 0ustar gregoagregoapackage t::lib::DancerPlugin; use strict; use warnings; use Dancer2::Plugin; my $counter = 0; register around_get => sub { my $dsl = shift; $dsl->get( '/foo/plugin' => sub { 'foo plugin'; } ); }; register install_hooks => sub { my $dsl = shift; $dsl->hook( 'before' => sub { $dsl->session( before_plugin => ++$counter ); } ); }; register_plugin; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/TestApp.pm0000644000175000017500000000471112253326150020501 0ustar gregoagregoapackage t::lib::TestApp; use Dancer2; # this app is intended to cover 100% of the DSL! # set some MIME aliases... mime->add_type( foo => 'text/foo' ); mime->add_alias( f => 'foo' ); set 'default_mime_type' => 'text/bar'; # hello route get '/' => sub { app->name }; # /haltme should bounce to / hook 'before' => sub { if ( request->path_info eq '/haltme' ) { redirect '/'; halt; } }; get '/haltme' => sub {"should not be there"}; hook 'after' => sub { my $response = shift; if ( request->path_info eq '/rewrite_me' ) { $response->content("rewritten!"); } }; get '/rewrite_me' => sub {"body should not be this one"}; # some settings set some_var => 1; setting some_other_var => 1; set multiple_vars => 4, can_be_set => 2; get '/config' => sub { return config->{some_var} . ' ' . config->{some_other_var} . ' and ' . setting('multiple_vars') . setting('can_be_set'); }; if ( $] >= 5.010 ) { # named captures get qr{/(? usr | content | post )/(? delete | find )/(? \d+ )}x => sub { join( ":", sort %{ captures() } ); }; } # chained routes with pass get '/user/**' => sub { my $user = params->{splat}; var user => $user->[0][0]; pass; }; get '/user/*/home' => sub { my $user = var('user'); # should be set by the previous route "hello $user"; }; # post & dirname post '/dirname' => sub { dirname('/etc/passwd'); }; # header get '/header/:name/:value' => sub { header param('name') => param('value'); 1; }; # push_header get '/header/:name/:valueA/:valueB' => sub { push_header param('name') => param('valueA'); push_header param('name') => param('valueB'); 1; }; # header get '/header_twice/:name/:valueA/:valueB' => sub { header param('name') => param('valueA'); header param('name') => param('valueB'); 1; }; # any any [ 'get', 'post' ], '/any' => sub { "Called with method " . request->method; }; # true and false get '/booleans' => sub { join( ":", true, false ); }; # mimes get '/mime/:name' => sub { mime->for_name( param('name') ); }; # content_type get '/content_type/:type' => sub { content_type param('type'); 1; }; # prefix prefix '/prefix' => sub { get '/bar' => sub {'/prefix/bar'}; prefix '/prefix1' => sub { get '/bar' => sub {'/prefix/prefix1/bar'}; }; prefix '/prefix2'; get '/foo' => sub {'/prefix/prefix2/foo'}; }; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/SubApp1.pm0000644000175000017500000000022112253326150020364 0ustar gregoagregoapackage t::lib::SubApp1; use strict; use warnings; use Dancer2; use t::lib::DancerPlugin; install_hooks; get '/subapp1' => sub { 1; }; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/FooPlugin.pm0000644000175000017500000000271612253326150021026 0ustar gregoagregoapackage t::lib::FooPlugin; use Dancer2::Plugin; on_plugin_import { my $dsl = shift; $dsl->get( '/sitemap' => sub { _html_sitemap($dsl) } ); }; sub _html_sitemap { join( ', ', _retrieve_get_urls(@_) ); } register foo_wrap_request => sub { my ($self) = plugin_args(@_); return $self->request; }, { is_global => 0 }; register foo_route => sub { my ($self) = plugin_args(@_); $self->get( '/foo', sub {'foo'} ); }; register p_config => sub { my $dsl = shift; my $config = plugin_setting; return $config; }; # taken from SiteMap sub _retrieve_get_urls { my $dsl = shift; my ( $route, @urls ); for my $app ( @{ $dsl->runner->server->apps } ) { my $routes = $app->routes; # push the static get routes into an array. get_route: for my $get_route ( @{ $routes->{get} } ) { my $regexp = $get_route->regexp; # If the pattern is a true comprehensive regexp or the route # has a :variable element to it, then omit it. next get_route if ( $regexp =~ m/[()[\]|]|:\w/ ); # If there is a wildcard modifier, then drop it and have the # full route. $regexp =~ s/\?//g; # Other than that, its cool to be added. push( @urls, $regexp ) if !grep { $regexp =~ m/$_/i } @$Dancer2::Plugin::SiteMap::OMIT_ROUTES; } } return sort(@urls); } register_plugin; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/Hookee.pm0000644000175000017500000000042412253326150020330 0ustar gregoagregoapackage t::lib::Hookee; use Dancer2::Plugin; register_hook 'start_hookee', 'stop_hookee'; register_hook 'third_hook'; register some_keyword => sub { execute_hook('start_hookee'); }; register some_other => sub { execute_hook('third_hook'); }; register_plugin; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/SubApp2.pm0000644000175000017500000000022112253326150020365 0ustar gregoagregoapackage t::lib::SubApp2; use strict; use warnings; use Dancer2; use t::lib::DancerPlugin; install_hooks; get '/subapp2' => sub { 2; }; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/TestPod.pm0000644000175000017500000000112712253326150020501 0ustar gregoagregoapackage t::lib::TestPod; use Dancer2; =head1 NAME TestPod =head2 ROUTES =over =cut =item get "/in_testpod" testpod =cut get '/in_testpod' => sub { # code; }; =item get "/hello" testpod =cut get '/hello' => sub { # code; }; =item post '/in_testpod/*' post in_testpod =cut post '/in_testpod/*' => sub { return 'post in_testpod'; }; =back =head2 SPECIALS =head3 PUBLIC =over =item get "/me:id" =cut get "/me:id" => sub { # code; }; =back =head3 PRIVAT =over =item post "/me:id" post /me:id =cut post "/me:id" => sub { # code; }; =back =cut 1; libdancer2-perl-0.11+dfsg.orig/t/lib/App2.pm0000644000175000017500000000024212253326150017716 0ustar gregoagregoapackage t::lib::App2; use strict; use warnings; use Dancer2; use t::lib::DancerPlugin; install_hooks; get '/app2' => sub { session 'before_plugin'; }; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/PluginWithImport.pm0000644000175000017500000000103112253326150022376 0ustar gregoagregoapackage t::lib::PluginWithImport; #ABSTRACT: a plugin that implement its own import method =head1 DESCRIPTION In order to demonstrate that Dancer2::Plugin won't loose the original import method of the plugin. =cut use strict; use warnings; use Dancer2; use Dancer2::Plugin; my $_stuff = {}; sub stuff {$_stuff} no warnings 'redefine'; sub import { my $class = shift; $_stuff->{$class} = 'imported'; } register dancer_plugin_with_import_keyword => sub { 'dancer_plugin_with_import_keyword'; }; register_plugin; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/MyDancerDSL.pm0000644000175000017500000000154712253326150021172 0ustar gregoagregoapackage MyDancerDSL; use Moo; use Dancer2::Core::Hook; use Dancer2::Core::Error; use Dancer2::FileUtils; use Carp; extends 'Dancer2::Core::DSL'; around dsl_keywords => sub { my $orig = shift; my $keywords = $orig->(@_); $keywords->{gateau} = { is_global => 0 }; # cookie $keywords->{moteur} = { is_global => 1 }; # engine $keywords->{stop} = { is_global => 0 }; # halt $keywords->{prend} = { is_global => 1 }; # post $keywords->{envoie} = { is_global => 1 }; # post $keywords->{entete} = { is_global => 0 }; #header return $keywords; }; sub gateau { goto &Dancer2::Core::DSL::cookie } sub moteur { goto &Dancer2::Core::DSL::engine } sub stop { goto &Dancer2::Core::DSL::halt } sub prend { goto &Dancer2::Core::DSL::get } sub envoie { goto &Dancer2::Core::DSL::post } sub entete { goto &Dancer2::Core::DSL::header } 1; libdancer2-perl-0.11+dfsg.orig/t/lib/App1.pm0000644000175000017500000000024212253326150017715 0ustar gregoagregoapackage t::lib::App1; use strict; use warnings; use Dancer2; use t::lib::DancerPlugin; install_hooks; get '/app1' => sub { session 'before_plugin'; }; 1; libdancer2-perl-0.11+dfsg.orig/t/lib/Foo.pm0000644000175000017500000000012612253326150017640 0ustar gregoagregoapackage t::lib::Foo; use Dancer2; get '/in_foo' => sub { session('test'); }; 1; libdancer2-perl-0.11+dfsg.orig/t/time.t0000644000175000017500000000417312253326150017142 0ustar gregoagregoa# time.t use strict; use warnings; use Test::More; use Class::Load 'try_load_class'; my $mocked_epoch = 1355676244; # "Sun, 16-Dec-2012 16:44:04 GMT" # The order is important! try_load_class('Test::MockTime') or plan skip_all => 'Test::MockTime not present'; Test::MockTime::set_fixed_time($mocked_epoch); require Dancer2::Core::Time; my @tests = ( [ "1h" => 3600 => "Sun, 16-Dec-2012 17:44:04 GMT" ], [ "1 hour" => 3600 => "Sun, 16-Dec-2012 17:44:04 GMT" ], [ "+1 hour" => 3600 => "Sun, 16-Dec-2012 17:44:04 GMT" ], [ "-1h" => -3600 => "Sun, 16-Dec-2012 15:44:04 GMT" ], [ "1 hours" => 3600 => "Sun, 16-Dec-2012 17:44:04 GMT" ], [ "1d" => ( 3600 * 24 ) => "Mon, 17-Dec-2012 16:44:04 GMT" ], [ "1 day" => ( 3600 * 24 ) => "Mon, 17-Dec-2012 16:44:04 GMT" ], ); foreach my $test (@tests) { my ( $expr, $secs, $gmt_string ) = @$test; subtest "Expression: \"$expr\"" => sub { my $t = Dancer2::Core::Time->new( expression => $expr ); is $t->seconds, $secs, "\"$expr\" is $secs seconds"; is $t->epoch, ( $t->seconds + $mocked_epoch ), "... its epoch is " . $t->epoch; is $t->gmt_string, $gmt_string, "... and its GMT string is $gmt_string"; }; } subtest "Forcing another epoch in the object should work" => sub { my $t = Dancer2::Core::Time->new( epoch => 1, expression => "1h" ); is $t->seconds, 3600, "...1h is still 3600 seconds"; is $t->epoch, 1, "... epoch is 1"; is $t->gmt_string, 'Thu, 01-Jan-1970 00:00:01 GMT', "... and is expressed as Thu, 01-Jan-1970 00:00:01 GMT"; }; subtest "unparsable strings should be kept" => sub { for my $t ( [ "something silly", "something silly", "something silly" ], [ "+2 something", "+2 something", "+2 something" ], ) { my ( $expr, $secs, $gmt ) = @$t; my $t = Dancer2::Core::Time->new( expression => $expr ); is $t->seconds, $secs, "\"$expr\" is $secs seconds"; is $t->epoch, $expr, "... its epoch is $expr"; is $t->gmt_string, $gmt, "... and its GMT string is $gmt"; } }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/engine.t0000644000175000017500000000043312253326150017444 0ustar gregoagregoause strict; use warnings; use Test::More; use Dancer2::Template::Tiny; my $f = Dancer2::Template::Tiny->new(); isa_ok $f, 'Dancer2::Template::Tiny'; ok( $f->does('Dancer2::Core::Role::Engine') ); ok( $f->does('Dancer2::Core::Role::Template') ); is $f->name, 'Tiny'; done_testing; libdancer2-perl-0.11+dfsg.orig/t/factory.t0000644000175000017500000000102012253326150017637 0ustar gregoagregoause strict; use warnings; use Test::More; use Test::Fatal; use Dancer2::Core; use Dancer2::Core::Factory; is Dancer2::Core::camelize('foo_bar_baz'), 'FooBarBaz'; is Dancer2::Core::camelize('FooBarBaz'), 'FooBarBaz'; like( exception { my $l = Dancer2::Core::Factory->create( unknown => 'stuff' ) }, qr{Unable to load class for Unknown component Stuff:}, 'Failure to load nonexistent class', ); my $l = Dancer2::Core::Factory->create( logger => 'console' ); isa_ok $l, 'Dancer2::Logger::Console'; done_testing; libdancer2-perl-0.11+dfsg.orig/t/ajax_plugin.t0000644000175000017500000000235312253326150020503 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; { package AjaxApp; use Dancer2; use Dancer2::Plugin::Ajax; set plugins => { 'Ajax' => { content_type => 'application/json' } }; ajax '/test' => sub { "{some: 'json'}"; }; get '/test' => sub { "some text"; }; ajax '/another/test' => sub { "{more: 'json'}"; }; } use Dancer2::Test apps => ['AjaxApp']; my $r = dancer_response( POST => '/test', { headers => [ [ 'X-Requested-With' => 'XMLHttpRequest' ], ], } ); is $r->content, "{some: 'json'}", "ajax works with POST"; is $r->content_type, 'application/json', "Response content type from plugin config"; $r = dancer_response( GET => '/test', { headers => [ [ 'X-Requested-With' => 'XMLHttpRequest' ], ], } ); is $r->content, "{some: 'json'}", "ajax works with GET"; $r = dancer_response( POST => '/another/test' ); is $r->status, 404, 'ajax does not match if no XMLHttpRequest'; # GitHub #143 - responst content type not munged if ajax route passes $r = dancer_response(GET => '/test'); is $r->status, 200, "ajax route passed for an non-XMLHttpRequest"; like $r->content_type, qr{^text/html}, "content type on non-XMLHttpRequest not munged"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/mime.t0000644000175000017500000000230012253326150017121 0ustar gregoagregoause strict; use warnings; use Test::More tests => 12; BEGIN { use_ok 'Dancer2::Core::MIME'; } my $mime = Dancer2::Core::MIME->new(); is_deeply( $mime->custom_types, {}, 'user defined mime_types are empty' ); $mime->add_type( foo => 'text/foo' ); is_deeply( $mime->custom_types, { foo => 'text/foo' }, 'text/foo is saved' ); is( $mime->for_name('foo'), 'text/foo', 'mime type foo is found' ); $mime->add_alias( bar => 'foo' ); is( $mime->for_name('bar'), 'text/foo', 'mime type bar is found' ); is( $mime->for_file('foo.bar'), 'text/foo', 'mime type for extension .bar is found' ); is( $mime->for_file('foobar'), $mime->default, 'mime type for no extension is the default' ); is( $mime->add_alias( xpto => 'BAR' ), 'text/foo', 'mime gets correctly lowercased for user types' ); is $mime->add_alias( xpto => 'SVG' ) => 'image/svg+xml', 'mime gets correctly lowercased for system types'; is $mime->add_alias( zbr => 'baz' ) => $mime->default, 'alias of unkown mime type gets default mime type'; is $mime->name_or_type("text/zbr") => "text/zbr", 'name_or_type does not change if it seems a mime type string'; is $mime->name_or_type("svg") => "image/svg+xml", 'name_or_type knows svg'; libdancer2-perl-0.11+dfsg.orig/t/session_engines.t0000644000175000017500000000567712253326150021411 0ustar gregoagregoause strict; use warnings; use Test::More; use YAML; use Test::TCP 1.13; use File::Temp 0.22; use LWP::UserAgent; use File::Spec; my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); my @clients = qw(one two three); my @engines = qw(YAML Simple); my $SESSION_DIR; if ( $ENV{DANCER_TEST_COOKIE} ) { push @engines, "cookie"; setting( session_cookie_key => "secret/foo*@!" ); } foreach my $engine (@engines) { note "Testing engine $engine"; Test::TCP::test_tcp( client => sub { my $port = shift; foreach my $client (@clients) { my $ua = LWP::UserAgent->new; $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } ); my $res = $ua->get("http://127.0.0.1:$port/read_session"); like $res->content, qr/name=''/, "empty session for client $client"; $res = $ua->get("http://127.0.0.1:$port/set_session/$client"); ok( $res->is_success, "set_session for client $client" ); $res = $ua->get("http://127.0.0.1:$port/read_session"); like $res->content, qr/name='$client'/, "session looks good for client $client"; $res = $ua->get("http://127.0.0.1:$port/clear_session"); like $res->content, qr/cleared/, "deleted session key"; $res = $ua->get("http://127.0.0.1:$port/cleanup"); ok( $res->is_success, "cleanup done for $client" ); ok( $res->content, "session hook triggered" ); } File::Temp::cleanup(); }, server => sub { my $port = shift; use Dancer2; my @to_destroy; hook 'engine.session.before_destroy' => sub { my $session = shift; push @to_destroy, $session; }; get '/set_session/*' => sub { my ($name) = splat; session name => $name; }; get '/read_session' => sub { my $name = session('name') || ''; "name='$name'"; }; get '/clear_session' => sub { session name => undef; return exists( session->data->{name} ) ? "failed" : "cleared"; }; get '/cleanup' => sub { context->destroy_session; return scalar(@to_destroy); }; setting appdir => $tempdir; setting( engines => { session => { $engine => { session_dir => 't/sessions' } } } ); setting( session => $engine ); set(show_errors => 1, startup_info => 0, environment => 'production', port => $port ); Dancer2->runner->server->port($port); start; }, ); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/request_upload.t0000644000175000017500000001416112253326150021236 0ustar gregoagregoause strict; use warnings FATAL => 'all'; use Test::More; use Test::Fatal; use Dancer2::Core::Request; use Carp; use File::Temp 0.22; use File::Basename qw/dirname basename/; use File::Spec; use Encode qw(encode_utf8); diag "If you want extra speed, install URL::Encode::XS" if !$Dancer2::Core::Request::XS_URL_DECODE; diag "If you want extra speed, install CGI::Deurl::XS" if !$Dancer2::Core::Request::XS_PARSE_QUERY_STRING; sub test_path { my ( $file, $dir ) = @_; is dirname($file), $dir, "dir of $file is $dir"; } sub run_test { my $filename = "some_\x{1A9}_file.txt"; my $content = qq{------BOUNDARY Content-Disposition: form-data; name="test_upload_file"; filename="$filename" Content-Type: text/plain SHOGUN ------BOUNDARY Content-Disposition: form-data; name="test_upload_file"; filename="yappo2.txt" Content-Type: text/plain SHOGUN2 ------BOUNDARY Content-Disposition: form-data; name="test_upload_file3"; filename="yappo3.txt" Content-Type: text/plain SHOGUN3 ------BOUNDARY Content-Disposition: form-data; name="test_upload_file4"; filename="yappo4.txt" Content-Type: text/plain SHOGUN4 ------BOUNDARY Content-Disposition: form-data; name="test_upload_file4"; filename="yappo5.txt" Content-Type: text/plain SHOGUN4 ------BOUNDARY Content-Disposition: form-data; name="test_upload_file6"; filename="yappo6.txt" Content-Type: text/plain SHOGUN6 ------BOUNDARY-- }; $content =~ s/\r\n/\n/g; $content =~ s/\n/\r\n/g; $content = encode_utf8($content); do { open my $in, '<', \$content; my $req = Dancer2::Core::Request->new( env => { 'psgi.input' => $in, CONTENT_LENGTH => length($content), CONTENT_TYPE => 'multipart/form-data; boundary=----BOUNDARY', REQUEST_METHOD => 'POST', SCRIPT_NAME => '/', SERVER_PORT => 80, } ); my @undef = $req->upload('undef'); is @undef, 0, 'non-existent upload as array is empty'; my $undef = $req->upload('undef'); is $undef, undef, '... and non-existent upload as scalar is undef'; my @uploads = $req->upload('test_upload_file'); like $uploads[0]->content, qr|^SHOGUN|, "content for first upload is ok, via 'upload'"; like $uploads[1]->content, qr|^SHOGUN|, "... content for second as well"; is $req->uploads->{'test_upload_file4'}[0]->content, 'SHOGUN4', "... content for other also good"; note "headers"; is_deeply $uploads[0]->headers, { 'Content-Disposition' => qq[form-data; name="test_upload_file"; filename="$filename"], 'Content-Type' => 'text/plain', }; note "type"; is $uploads[0]->type, 'text/plain'; my $test_upload_file3 = $req->upload('test_upload_file3'); is $test_upload_file3->content, 'SHOGUN3', "content for upload #3 as a scalar is good, via req->upload"; my @test_upload_file6 = $req->upload('test_upload_file6'); is $test_upload_file6[0]->content, 'SHOGUN6', "content for upload #6 is good"; is $test_upload_file6[0]->content(':raw'), 'SHOGUN6'; my $upload = $req->upload('test_upload_file6'); isa_ok $upload, 'Dancer2::Core::Request::Upload'; is $upload->filename, 'yappo6.txt', 'filename is ok'; ok $upload->file_handle, 'file handle is defined'; is $req->params->{'test_upload_file6'}, 'yappo6.txt', "filename is accessible via params"; # copy_to, link_to my $dest_dir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); my $dest_file = File::Spec->catfile( $dest_dir, $upload->basename ); $upload->copy_to($dest_file); ok( ( -f $dest_file ), "file '$dest_file' has been copied" ); my $dest_file_link = File::Spec->catfile( $dest_dir, "hardlink" ); $upload->link_to($dest_file_link); ok( ( -f $dest_file_link ), "hardlink '$dest_file_link' has been created" ); # make sure cleanup is performed when the HTTP::Body object is purged my $file = $upload->tempname; ok( ( -f $file ), 'temp file exists while HTTP::Body lives' ); undef $req->{_http_body}; SKIP: { skip "Win32 can't remove file/link while open, deadlock with HTTP::Body", 1 if ( $^O eq 'MSWin32' ); ok( ( !-f $file ), 'temp file is removed when HTTP::Body object dies' ); } note "testing failing open for tempfile"; { # mocking open_file to make it fail my $upload_file_coderef; { no strict 'refs'; $upload_file_coderef = *{"Dancer2::Core::Request::Upload::open_file"}{CODE}; no warnings 'redefine'; *{"Dancer2::Core::Request::Upload::open_file"} = sub { croak "Can't open mocked-tempfile using mode '<'"; }; } $upload->{_fh} = undef; like( exception { $upload->file_handle }, qr{Can't open.* using mode '<'}, ); # unmock open_file { no strict 'refs'; no warnings 'redefine'; *{"Dancer2::Core::Request::Upload::open_file"} = $upload_file_coderef; } } unlink($file) if ( $^O eq 'MSWin32' ); }; } diag "Run test with XS_URL_DECODE" if $Dancer2::Core::Request::XS_URL_DECODE; diag "Run test with XS_PARSE_QUERY_STRING" if $Dancer2::Core::Request::XS_PARSE_QUERY_STRING; run_test(); if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) { diag "Run test without XS_PARSE_QUERY_STRING"; $Dancer2::Core::Request::XS_PARSE_QUERY_STRING = 0; $Dancer2::Core::Request::_count = 0; run_test(); } if ($Dancer2::Core::Request::XS_URL_DECODE) { diag "Run test without XS_URL_DECODE"; $Dancer2::Core::Request::XS_URL_DECODE = 0; $Dancer2::Core::Request::_count = 0; run_test(); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/app/0000775000175000017500000000000012253326150016574 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t1/0000775000175000017500000000000012253326150017120 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t1/lib/0000775000175000017500000000000012253326150017666 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t1/lib/Sub/0000775000175000017500000000000012253326150020417 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t1/lib/Sub/App2.pm0000644000175000017500000000007612253326150021560 0ustar gregoagregoapackage Sub::App2; use strict; use warnings; use Dancer2; 1; libdancer2-perl-0.11+dfsg.orig/t/app/t1/lib/App1.pm0000644000175000017500000000007112253326150021021 0ustar gregoagregoapackage App1; use strict; use warnings; use Dancer2; 1; libdancer2-perl-0.11+dfsg.orig/t/app/t1/config.yml0000644000175000017500000000002412253326150021102 0ustar gregoagregoaapp: config: ok libdancer2-perl-0.11+dfsg.orig/t/app/t1/bin/0000775000175000017500000000000012253326150017670 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t1/bin/app.psgi0000644000175000017500000000004712253326150021333 0ustar gregoagregoa#!perl use Dancer2; use App1; start; libdancer2-perl-0.11+dfsg.orig/t/app/t2/0000775000175000017500000000000012253326150017121 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t2/.dancer0000644000175000017500000000000112253326150020343 0ustar gregoagregoa libdancer2-perl-0.11+dfsg.orig/t/app/t2/lib/0000775000175000017500000000000012253326150017667 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/app/t2/lib/App3.pm0000644000175000017500000000007012253326150021023 0ustar gregoagregoapackage App3; use strict; use warnings; use Dancer2; 1; libdancer2-perl-0.11+dfsg.orig/t/app/t2/config.yml0000644000175000017500000000002412253326150021103 0ustar gregoagregoaapp: config: ok libdancer2-perl-0.11+dfsg.orig/t/config.yml0000644000175000017500000000007412253326150020003 0ustar gregoagregoalog: "info" plugins: "t::lib::FooPlugin": plugin: 42 libdancer2-perl-0.11+dfsg.orig/t/session_object.t0000644000175000017500000000223312253326150021210 0ustar gregoagregoa# session_object.t use strict; use warnings; use Test::More; use Test::Fatal; use Dancer2::Core::Session; use Dancer2::Session::Simple; use Class::Load 'try_load_class'; my $ENGINE = Dancer2::Session::Simple->new; my $CPRNG_AVAIL = try_load_class('Math::Random::ISAAC::XS') && try_load_class('Crypt::URandom'); diag $CPRNG_AVAIL ? "Crypto strength tokens" : "Default strength tokens"; subtest 'session attributes' => sub { my $s1 = $ENGINE->create; my $id = $s1->id; ok defined($id), 'id is defined'; is(exception { $s1->id("new_$id") }, undef, 'id can be set'); is($s1->id, "new_$id", '... new value found for id'); my $s2 = $ENGINE->create; isnt($s1->id, $s2->id, "IDs are not the same"); }; my $count = 10_000; subtest "$count session IDs and no dups" => sub { my $seen = {}; my $iteration = 0; foreach my $i (1 .. $count) { my $s1 = $ENGINE->create; my $id = $s1->id; if (exists $seen->{$id}) { last; } $seen->{$id} = 1; $iteration++; } is $iteration, $count, "no duplicate ID after $count iterations (done $iteration)"; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/forward_before_hook.t0000644000175000017500000000201212253326150022200 0ustar gregoagregoause Test::More import => ['!pass'], tests => 3; use Dancer2; use Dancer2::Test; use strict; use warnings; get '/' => sub { return 'Forbidden'; }; get '/default' => sub { return 'Default'; }; get '/redirect' => sub { return 'Secret stuff never seen'; }; hook before => sub { my $context = shift; return if $context->request->dispatch_path eq '/default'; # Add some content to the response $context->response->content("SillyStringIsSilly"); # redirect - response should include the above content return redirect '/default' if $context->request->dispatch_path eq '/redirect'; # The response object will get replaced by the result of the forward. forward '/default'; }; response_content_like( [ GET => '/' ], qr{Default}, 'forward in before hook' ); # redirect in before hook my $r = dancer_response GET => '/redirect'; is $r->status, 302, "redirect in before hook"; is $r->content, "SillyStringIsSilly", ".. and the response content is correct"; done_testing(); libdancer2-perl-0.11+dfsg.orig/t/uri_for.t0000644000175000017500000000050212253326150017641 0ustar gregoagregoause Test::More import => ['!pass']; use strict; use warnings; { use Dancer2; get '/foo' => sub { return uri_for('/foo'); }; } use Dancer2::Test; response_status_is [ GET => '/foo' ], 200; response_content_is [ GET => '/foo' ], 'http://localhost/foo', "uri_for works as expected"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/00-compile.t0000644000175000017500000000653112253326150020051 0ustar gregoagregoause strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.023 use Test::More tests => 61 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Dancer2.pm', 'Dancer2/CLI.pm', 'Dancer2/CLI/Command/gen.pm', 'Dancer2/CLI/Command/version.pm', 'Dancer2/Core.pm', 'Dancer2/Core/App.pm', 'Dancer2/Core/Context.pm', 'Dancer2/Core/Cookie.pm', 'Dancer2/Core/DSL.pm', 'Dancer2/Core/Dispatcher.pm', 'Dancer2/Core/Error.pm', 'Dancer2/Core/Factory.pm', 'Dancer2/Core/HTTP.pm', 'Dancer2/Core/Hook.pm', 'Dancer2/Core/MIME.pm', 'Dancer2/Core/Request.pm', 'Dancer2/Core/Request/Upload.pm', 'Dancer2/Core/Response.pm', 'Dancer2/Core/Role/Config.pm', 'Dancer2/Core/Role/DSL.pm', 'Dancer2/Core/Role/Engine.pm', 'Dancer2/Core/Role/Handler.pm', 'Dancer2/Core/Role/Headers.pm', 'Dancer2/Core/Role/Hookable.pm', 'Dancer2/Core/Role/Logger.pm', 'Dancer2/Core/Role/Serializer.pm', 'Dancer2/Core/Role/Server.pm', 'Dancer2/Core/Role/SessionFactory.pm', 'Dancer2/Core/Role/SessionFactory/File.pm', 'Dancer2/Core/Role/StandardResponses.pm', 'Dancer2/Core/Role/Template.pm', 'Dancer2/Core/Route.pm', 'Dancer2/Core/Runner.pm', 'Dancer2/Core/Server/PSGI.pm', 'Dancer2/Core/Server/Standalone.pm', 'Dancer2/Core/Session.pm', 'Dancer2/Core/Time.pm', 'Dancer2/Core/Types.pm', 'Dancer2/FileUtils.pm', 'Dancer2/Handler/AutoPage.pm', 'Dancer2/Handler/File.pm', 'Dancer2/Logger/Capture.pm', 'Dancer2/Logger/Capture/Trap.pm', 'Dancer2/Logger/Console.pm', 'Dancer2/Logger/Diag.pm', 'Dancer2/Logger/File.pm', 'Dancer2/Logger/Note.pm', 'Dancer2/Logger/Null.pm', 'Dancer2/Plugin.pm', 'Dancer2/Plugin/Ajax.pm', 'Dancer2/Serializer/Dumper.pm', 'Dancer2/Serializer/JSON.pm', 'Dancer2/Serializer/YAML.pm', 'Dancer2/Session/Simple.pm', 'Dancer2/Session/YAML.pm', 'Dancer2/Template/Implementation/ForkedTiny.pm', 'Dancer2/Template/Simple.pm', 'Dancer2/Template/TemplateToolkit.pm', 'Dancer2/Template/Tiny.pm', 'Dancer2/Test.pm' ); my @scripts = ( 'script/dancer2' ); # no fake home requested use IPC::Open3; use IO::Handle; my @warnings; for my $lib (@module_files) { # see L my $stdin = ''; # converted to a gensym by open3 my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, qq{$^X -Mblib -e"require q[$lib]"}); waitpid($pid, 0); is($? >> 8, 0, "$lib loaded ok"); if (my @_warnings = <$stderr>) { warn @_warnings; push @warnings, @_warnings; } } foreach my $file (@scripts) { SKIP: { open my $fh, '<', $file or warn("Unable to open $file: $!"), next; my $line = <$fh>; close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!.*?\bperl\b\s*(.*)$/; my $flags = $1; my $stdin = ''; # converted to a gensym by open3 my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, qq{$^X -Mblib $flags -c $file}); waitpid($pid, 0); is($? >> 8, 0, "$file compiled ok"); if (my @_warnings = grep { !/syntax OK$/ } <$stderr>) { warn @_warnings; push @warnings, @_warnings; } } } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; libdancer2-perl-0.11+dfsg.orig/t/logger.t0000644000175000017500000000400612253326150017456 0ustar gregoagregoause Test::More; use strict; use warnings; BEGIN { # Freeze time at Tue, 15-Jun-2010 00:00:00 GMT *CORE::GLOBAL::time = sub { return 1276560000 } } my $_logs = []; { package Dancer2::Logger::Test; use Moo; with 'Dancer2::Core::Role::Logger'; sub log { my ( $self, $level, $message ) = @_; push @$_logs, $self->format_message( $level, $message ); } } my $logger = Dancer2::Logger::Test->new( app_name => 'test' ); is $logger->log_level, 'debug'; $logger->debug("foo"); # Hard to make caller(6) work when we deal with the logger directly, # so do not check for a specific filename. like $_logs->[0], qr{debug \@2010-06-1\d \d\d:\d\d:00> foo in }; subtest 'log level and capture' => sub { use Dancer2::Logger::Capture; use Dancer2; # NOTE: this will read the config.yml under t/ that defines log level as info set logger => 'capture'; warning "Danger! Warning!"; info "Tango, Foxtrot"; debug "I like pie."; my $trap = dancer_app->engine('logger')->trapper; is_deeply $trap->read, [ { level => "warning", message => "Danger! Warning!" }, { level => "info", message => "Tango, Foxtrot" }, ]; # each call to read cleans the trap is_deeply $trap->read, []; }; subtest 'logger file' => sub { use Dancer2; use File::Temp qw/tempdir/; my $dir = tempdir( CLEANUP => 1 ); set engines => { logger => { File => { log_dir => $dir, file_name => 'test', } } }; # XXX this sucks, we need to set the engine *before* the logger # - Franck, 2013/08/03 set logger => 'file'; warning "Danger! Warning!"; open my $log_file, '<', File::Spec->catfile($dir, 'test'); my $txt = <$log_file>; like $txt, qr/Danger! Warning!/; }; # Explicitly close the logger file handle for those systems that # do not allow "open" files to be unlinked (Windows). GH#424. my $log_engine = engine('logger'); close $log_engine->fh; done_testing; libdancer2-perl-0.11+dfsg.orig/t/release-no-tabs.t0000644000175000017500000000045012253326150021157 0ustar gregoagregoa BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::NoTabs'; plan skip_all => 'Test::NoTabs required' if $@; all_perl_files_ok(); libdancer2-perl-0.11+dfsg.orig/t/sessions/0000775000175000017500000000000012253326150017662 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/sessions/UhaGNQAAaDVWUzXrQaDQAaQPzLEWV-4v.yml0000644000175000017500000000002112253326150025665 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UfRHAQAAJsw_2oX_cvBqBtXlgre8vFiy.yml0000644000175000017500000000002112253326150026231 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UqMkygAAH92FRll2ucXas2hPHOmBwGxY.yml0000644000175000017500000000002112253326150026043 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf6vlwAACre4MIFKa-Jghj6q1OT9sQb_.yml0000644000175000017500000000002112253326150025666 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UjnwfgAACXJ9T98xUqd76qOfcABU4l0R.yml0000644000175000017500000000002112253326150025623 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UqMKawAAe86AQqQeYQmzh8sUBp6GIdFY.yml0000644000175000017500000000002112253326150025743 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf-GsQAANz9OaEztWyuSfJKegUq3zD1V.yml0000644000175000017500000000002112253326150026041 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf6zmAAASb6UqmpBspaQIEzjLIs51E19.yml0000644000175000017500000000002112253326150025672 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf-HDgAAPPOeyDGX2_IgTLzBg6iBsFkk.yml0000644000175000017500000000002112253326150025654 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UhC04wAAcgtUmse-OjZCvj1H0_I5z0pU.yml0000644000175000017500000000002112253326150025670 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf6xeQAAKIXcote58neJ3jjOIjbBlhKX.yml0000644000175000017500000000002112253326150026021 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf1znwAABxlBOUOk04NfndOLhVZzIrnf.yml0000644000175000017500000000002112253326150026144 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uq2XMAAANZ8zV8FD1Emyu7XRdgIZekDJ.yml0000644000175000017500000000002112253326150025573 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UfRXcwAAO8pp0bx4QwYmc73cP7UKMyY7.yml0000644000175000017500000000002112253326150025714 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf-HZwAAQt4cqJPl7UTFUrFyY7yxYVj_.yml0000644000175000017500000000002112253326150026046 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UqMo4AAAZlW25DoDlelvGZ9Mf1HPIxyI.yml0000644000175000017500000000002112253326150025653 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Ufqu9QAAQfNUOjyt9fa2al5-bFlpbWfR.yml0000644000175000017500000000002112253326150026056 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf61DgAAYKLILb8PdeeQV3tryrC08MvP.yml0000644000175000017500000000002112253326150025600 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UiNIAwAAbVyD4lIKW93APRO9IDd1K5BJ.yml0000644000175000017500000000002112253326150025277 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UgnzfAAAX0Gcwelnex1vHnakFt7dZMGb.yml0000644000175000017500000000002112253326150026213 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UhaF7gAAYpJSGqByK67_SB3A9mGE5l-s.yml0000644000175000017500000000002112253326150025433 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UiMnAgAAahCCdaVhPiVfrcwyo6sxcp7z.yml0000644000175000017500000000002112253326150026356 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UiMfZwAAc4FCMkrxKK-kKyuTIDuVupPc.yml0000644000175000017500000000002112253326150026134 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf-HTQAAQOJeFHxmhw1aJKUgIkGseaAI.yml0000644000175000017500000000002112253326150025704 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UqMsHAAAHWKTi6hOv6wGnR-n8bIUQmYs.yml0000644000175000017500000000002112253326150025727 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf-CrAAAdd2mP4pJAIBzc6YRqXnqeNUt.yml0000644000175000017500000000002112253326150025736 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UjnvaAAAdx5B7BnSg2YxFz_25MpWqBwX.yml0000644000175000017500000000002112253326150026005 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf6vLQAAA33ysk1AfxuFaITEMXY72bEI.yml0000644000175000017500000000002112253326150025524 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UiNIHQAAb3tN7zHtZJRZY7ULJVTc4-bo.yml0000644000175000017500000000002112253326150025551 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UhC_EwAAHS4yKDNKIO8DV-5B47BS6vWY.yml0000644000175000017500000000002112253326150025242 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UqMhtgAAbObthtU3fOj5q-ibplcfJI-A.yml0000644000175000017500000000002112253326150026121 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf1awwAAXkpPhxmXEwjwLY6Oi5Dv7A8v.yml0000644000175000017500000000002112253326150026125 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UfUFzgAAOBHtc6NRAKAH4xNgo-GIz8VA.yml0000644000175000017500000000002112253326150025525 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/Uf-IdQAAVEongozIzRJZUxy_Q8DMaruI.yml0000644000175000017500000000002112253326150026144 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UiNDXgAAJ0mTXspthJgvbjShFZfcyPR3.yml0000644000175000017500000000002112253326150026163 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/sessions/UgEFqgAAa4HX5JbR80YhN9rOBcGLG-zH.yml0000644000175000017500000000002112253326150025423 0ustar gregoagregoa--- name: damian libdancer2-perl-0.11+dfsg.orig/t/session_config.t0000644000175000017500000000700412253326150021210 0ustar gregoagregoause strict; use warnings; use Test::More; use YAML; use Test::TCP 1.13; use File::Temp 0.22; use LWP::UserAgent; use HTTP::Date qw/str2time/; use File::Spec; sub extract_cookie { my ($res) = @_; my @cookies = $res->header('set-cookie'); for my $c (@cookies) { next unless $c =~ /dancer\.sid/; # custom my @parts = split /;\s+/, $c; my %hash = map { my ( $k, $v ) = split /\s*=\s*/; $v ||= 1; ( lc($k), $v ) } @parts; $hash{expires} = str2time( $hash{expires} ) if $hash{expires}; return \%hash; } return; } my $tempdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); for my $session_expires ( 3600, '1h', '1 hour' ) { Test::TCP::test_tcp( client => sub { my $port = shift; my $ua = LWP::UserAgent->new; $ua->cookie_jar( { file => "$tempdir/.cookies.txt" } ); my ( $res, $cookie ); # set value into session $res = $ua->get("http://127.0.0.1:$port/foo/set_session/larry"); ok $res->is_success, "/foo/set_session/larry"; $cookie = extract_cookie($res); my $err; ok $cookie, "session cookie set" or $err++; ok $cookie->{expires} - time > 3540, "cookie expiration is in future" or $err++; is $cookie->{domain}, '127.0.0.1', "cookie domain set" or $err++; is $cookie->{path}, '/foo', "cookie path set" or $err++; is $cookie->{httponly}, undef, "cookie has not set HttpOnly"; diag explain $cookie if $err; # read value back $res = $ua->get("http://127.0.0.1:$port/foo/read_session"); ok $res->is_success, "/foo/read_session"; like $res->content, qr/name='larry'/, "session value looks good"; File::Temp::cleanup(); }, server => sub { my $port = shift; use Dancer2; get '/has_session' => sub { return context->has_session; }; get '/foo/set_session/*' => sub { my ($name) = splat; session name => $name; }; get '/foo/read_session' => sub { my $name = session('name') || ''; "name='$name'"; }; get '/foo/destroy_session' => sub { my $name = session('name') || ''; context->destroy_session; return "destroyed='$name'"; }; setting appdir => $tempdir; setting( engines => { session => { Simple => { cookie_name => 'dancer.sid', cookie_domain => '127.0.0.1', cookie_path => '/foo', cookie_duration => $session_expires, ## is_secure => 0, # can't easily test without https test server is_http_only => 0, # will not show up in cookie }, }, } ); setting( session => 'Simple' ); set(show_errors => 1, startup_info => 0, environment => 'production', port => $port ); Dancer2->runner->server->port($port); start; }, ); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/http_methods.t0000644000175000017500000000111212253326150020674 0ustar gregoagregoause strict; use warnings; use Test::More tests => 8; use Dancer2; use Dancer2::Test; my %method = ( get => 'GET', post => 'POST', del => 'DELETE', patch => 'PATCH', put => 'PUT', options => 'OPTIONS', ); while ( my ( $method, $http ) = each %method ) { eval "$method '/' => sub { '$method' }"; response_content_is [ $http => '/' ], $method, $method; } eval "get '/head' => sub {'HEAD'}"; my $resp = dancer_response( 'HEAD', '/head' ); is $resp->content, '', 'HEAD'; is $resp->header('Content-Length'), 4, 'Content-Length for HEAD'; libdancer2-perl-0.11+dfsg.orig/t/dancer-test.t0000644000175000017500000000605312253326150020414 0ustar gregoagregoa# who test the tester? We do! use strict; use warnings; use Test::More tests => 49; use Dancer2; use Dancer2::Test; use Dancer2::Core::Request; use File::Temp; use Encode; use URI::Escape; my @routes = ( '/foo', [ GET => '/foo' ], Dancer2::Core::Request->new( env => { 'psgi.url_scheme' => 'http', REQUEST_METHOD => 'GET', QUERY_STRING => '', SERVER_NAME => 'localhost', SERVER_PORT => 5000, SERVER_PROTOCOL => 'HTTP/1.1', SCRIPT_NAME => '', PATH_INFO => '/foo', REQUEST_URI => '/foo', } ), Dancer2::Core::Response->new( content => 'fighter', status => 404, ) ); route_doesnt_exist $_ for @routes; get '/foo' => sub {'fighter'}; $routes[-1]->status(200); route_exists $_, "route $_ exists" for @routes; for (@routes) { my $response = dancer_response $_; isa_ok $response => 'Dancer2::Core::Response'; is $response->content => 'fighter'; } response_content_is $_ => 'fighter', "response_content_is with $_" for @routes; response_content_isnt $_ => 'platypus', "response_content_isnt with $_" for @routes; response_content_like $_ => qr/igh/ for @routes; response_content_unlike $_ => qr/ought/ for @routes; response_status_is $_ => 200 for @routes; response_status_isnt $_ => 203 for @routes; response_headers_include $_ => [ Server => "Perl Dancer2 $Dancer2::VERSION" ] for @routes; ## Check parameters get through ok get '/param' => sub { param('test') }; my $param_response = dancer_response( GET => '/param', { params => { test => 'hello' } } ); is $param_response->content, 'hello', 'PARAMS get echoed by route'; post '/upload' => sub { my $file = upload('test'); return $file->content; }; ## Check we can upload files my $file_response = dancer_response( POST => '/upload', { files => [ { filename => 'test.txt', name => 'test', data => 'testdata' } ] } ); is $file_response->content, 'testdata', 'file uploaded with supplied data'; my $temp = File::Temp->new; print $temp 'testfile'; close($temp); $file_response = dancer_response( POST => '/upload', { files => [ { filename => $temp->filename, name => 'test' } ] } ); is $file_response->content, 'testfile', 'file uploaded with supplied filename'; ## Check multiselect/multi parameters get through ok get '/multi' => sub { my $t = param('test'); return 'bad' if ref($t) ne 'ARRAY'; my $p = join( '', @$t ); return $p; }; $param_response = dancer_response( GET => '/multi', { params => { test => [ 'foo', 'bar' ] } } ); is $param_response->content, 'foobar', 'multi values for same key get echoed back'; my $russian_test = decode( 'UTF-8', uri_unescape("%D0%B8%D1%81%D0%BF%D1%8B%D1%82%D0%B0%D0%BD%D0%B8%D0%B5") ); $param_response = dancer_response( GET => '/multi', { params => { test => [ 'test/', $russian_test ] } } ); is $param_response->content, 'test/' . encode( 'UTF-8', $russian_test ), 'multi utf8 value properly merge'; libdancer2-perl-0.11+dfsg.orig/t/handler_file.t0000644000175000017500000000152612253326150020617 0ustar gregoagregoause strict; use warnings; use Test::More; { package StaticContent; use Dancer2; engine('template')->views('t/corpus/static'); $ENV{DANCER_PUBLIC} = 't/corpus/static'; get '/' => sub { send_file 'index.html'; }; get '/image' => sub { send_file '1x1.png'; }; } use Dancer2::Test apps => ['StaticContent']; subtest "Text content" => sub { my $r = dancer_response GET => '/'; is $r->status, 200, 'send_file sets the status to 200'; my $charset = $r->headers->content_type_charset; is $charset, 'UTF-8', "Text content type has UTF-8 charset"; like $r->content, qr{áéíóú}, "Text content contains UTF-8 characters"; }; subtest "Binary content" => sub { my $r = dancer_response GET => "/image"; is $r->status, 200, 'send_file sets the status to 200'; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/plugin_import.t0000644000175000017500000000172212253326150021071 0ustar gregoagregoa# plugin_import.t use strict; use warnings; use Test::More; { use Dancer2; use t::lib::PluginWithImport; get '/test' => sub { dancer_plugin_with_import_keyword; }; } use Dancer2::Test; response_content_is '/test', 'dancer_plugin_with_import_keyword', "the plugin exported its keyword"; is_deeply( t::lib::PluginWithImport->stuff, { 't::lib::PluginWithImport' => 'imported' }, "the original import method of the plugin is still there" ); subtest 'import flags' => sub { eval " package Some::Plugin; use Dancer2::Plugin ':no_dsl'; register 'foo' => sub { request }; "; like $@, qr{Bareword "request" not allowed while "strict subs"}, "with :no_dsl, the Dancer's dsl is not imported."; eval " package Some::Plugin; use Dancer2::Plugin; register 'foo' => sub { request }; "; is $@, '', "without any import flag, the DSL is imported"; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/request.t0000644000175000017500000001733312253326150017676 0ustar gregoagregoause strict; use warnings; use Test::More; use Dancer2::Core::Request; diag "If you want extra speed, install URL::Encode::XS" if !$Dancer2::Core::Request::XS_URL_DECODE; diag "If you want extra speed, install CGI::Deurl::XS" if !$Dancer2::Core::Request::XS_PARSE_QUERY_STRING; sub run_test { my $env = { 'psgi.url_scheme' => 'http', REQUEST_METHOD => 'GET', SCRIPT_NAME => '/foo', PATH_INFO => '/bar/baz', REQUEST_URI => '/foo/bar/baz', QUERY_STRING => 'foo=42&bar=12&bar=13&bar=14', SERVER_NAME => 'localhost', SERVER_PORT => 5000, SERVER_PROTOCOL => 'HTTP/1.1', REMOTE_ADDR => '127.0.0.1', X_FORWARDED_FOR => '127.0.0.2', X_FORWARDED_HOST => 'secure.frontend', X_FORWARDED_PROTOCOL => 'https', REMOTE_HOST => 'localhost', HTTP_USER_AGENT => 'Mozilla', REMOTE_USER => 'sukria', }; my $req = Dancer2::Core::Request->new( env => $env ); note "tests for accessors"; is $req->agent, 'Mozilla'; is $req->user_agent, 'Mozilla'; is $req->remote_address, '127.0.0.1'; is $req->address, '127.0.0.1'; is $req->forwarded_for_address, '127.0.0.2'; is $req->remote_host, 'localhost'; is $req->protocol, 'HTTP/1.1'; is $req->port, 5000; is $req->request_uri, '/foo/bar/baz'; is $req->uri, '/foo/bar/baz'; is $req->user, 'sukria'; is $req->script_name, '/foo'; is $req->scheme, 'http'; is $req->referer, undef; ok( !$req->secure ); is $req->method, 'GET'; is $req->request_method, 'GET'; ok( $req->is_get ); ok( !$req->is_post ); ok( !$req->is_put ); ok( !$req->is_delete ); ok( !$req->is_patch ); ok( !$req->is_head ); is $req->id, 1; is $req->to_string, '[#1] GET /foo/bar/baz'; note "tests params"; is_deeply { $req->params }, { foo => 42, bar => [ 12, 13, 14 ] }; my $forward = $req->make_forward_to('/somewhere'); is $forward->path_info, '/somewhere'; is $forward->method, 'GET'; note "tests for uri_for"; is $req->base, 'http://localhost:5000/foo'; is $req->uri_for( 'bar', { baz => 'baz' } ), 'http://localhost:5000/foo/bar?baz=baz'; is $req->uri_for('/bar'), 'http://localhost:5000/foo/bar'; ok $req->uri_for('/bar')->isa('URI'), 'uri_for returns a URI'; ok $req->uri_for( '/bar', undef, 1 )->isa('URI'), 'uri_for returns a URI (with $dont_escape)'; is $req->request_uri, '/foo/bar/baz'; is $req->path_info, '/bar/baz'; { local $env->{SCRIPT_NAME} = ''; is $req->uri_for('/foo'), 'http://localhost:5000/foo'; } { local $env->{SERVER_NAME} = 0; is $req->base, 'http://0:5000/foo'; local $env->{HTTP_HOST} = 'oddhostname:5000'; is $req->base, 'http://oddhostname:5000/foo'; } note "testing behind proxy"; { my $req = Dancer2::Core::Request->new( env => $env, is_behind_proxy => 1 ); is $req->secure, 1; is $req->host, $env->{X_FORWARDED_HOST}; is $req->scheme, 'https'; } note "testing path, dispatch_path and uri_base"; { # Base env used for path, dispatch_path and uri_base tests my $base = { 'psgi.url_scheme' => 'http', REQUEST_METHOD => 'GET', QUERY_STRING => '', SERVER_NAME => 'localhost', SERVER_PORT => 5000, SERVER_PROTOCOL => 'HTTP/1.1', }; # PATH_INFO not set my $env = { %$base, SCRIPT_NAME => '/foo', PATH_INFO => '', REQUEST_URI => '/foo', }; my $req = Dancer2::Core::Request->new( env => $env ); is( $req->path, '/foo', 'path corrent when empty PATH_INFO' ); is( $req->uri_base, 'http://localhost:5000/foo', 'uri_base correct when empty PATH_INFO' ); is( $req->dispatch_path, '/', 'dispatch_path correct when empty PATH_INFO' ); # SCRIPT_NAME not set $env = { %$base, SCRIPT_NAME => '', PATH_INFO => '/foo', REQUEST_URI => '/foo', }; $req = Dancer2::Core::Request->new( env => $env ); is( $req->path, '/foo', 'path corrent when empty SCRIPT_NAME' ); is( $req->uri_base, 'http://localhost:5000', 'uri_base handles empty SCRIPT_NAME' ); is( $req->dispatch_path, '/foo', 'dispatch_path handles empty SCRIPT_NAME' ); # Both SCRIPT_NAME and PATH_INFO set # PSGI spec does not allow SCRIPT_NAME='/', PATH_INFO='/some/path' $env = { %$base, SCRIPT_NAME => '/foo', PATH_INFO => '/bar/baz/', REQUEST_URI => '/foo/bar/baz/', }; $req = Dancer2::Core::Request->new( env => $env ); is( $req->path, '/foo/bar/baz/', 'path corrent when both PATH_INFO and SCRIPT_NAME set' ); is( $req->uri_base, 'http://localhost:5000/foo', 'uri_base correct when both PATH_INFO and SCRIPT_NAME set', ); is( $req->dispatch_path, '/bar/baz/', 'dispatch_path correct when both PATH_INFO and SCRIPT_NAME set' ); # Neither SCRIPT_NAME or PATH_INFO set $env = { %$base, SCRIPT_NAME => '', PATH_INFO => '', REQUEST_URI => '/foo/', }; $req = Dancer2::Core::Request->new( env => $env ); is( $req->path, '/foo/', 'path corrent when calculated from REQUEST_URI' ); is( $req->uri_base, 'http://localhost:5000', 'uri_base correct when calculated from REQUEST_URI', ); is( $req->dispatch_path, '/foo/', 'dispatch_path correct when calculated from REQUEST_URI' ); } note "testing forward"; $env = { 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/', 'PATH_INFO' => '/', 'QUERY_STRING' => 'foo=bar&number=42', }; $req = Dancer2::Core::Request->new( env => $env ); is $req->path, '/', 'path is /'; is $req->method, 'GET', 'method is get'; is_deeply scalar( $req->params ), { foo => 'bar', number => 42 }, 'params are parsed'; $req = $req->make_forward_to("/new/path"); is $req->path, '/new/path', 'path is changed'; is $req->method, 'GET', 'method is unchanged'; is_deeply scalar( $req->params ), { foo => 'bar', number => 42 }, 'params are not touched'; $req = $req->make_forward_to( "/new/path", undef, { method => 'POST' } ); is $req->path, '/new/path', 'path is changed'; is $req->method, 'POST', 'method is changed'; is_deeply scalar( $req->params ), { foo => 'bar', number => 42 }, 'params are not touched'; } diag "Run test with XS_URL_DECODE" if $Dancer2::Core::Request::XS_URL_DECODE; diag "Run test with XS_PARSE_QUERY_STRING" if $Dancer2::Core::Request::XS_PARSE_QUERY_STRING; run_test(); if ($Dancer2::Core::Request::XS_PARSE_QUERY_STRING) { diag "Run test without XS_PARSE_QUERY_STRING"; $Dancer2::Core::Request::XS_PARSE_QUERY_STRING = 0; $Dancer2::Core::Request::_count = 0; run_test(); } if ($Dancer2::Core::Request::XS_URL_DECODE) { diag "Run test without XS_URL_DECODE"; $Dancer2::Core::Request::XS_URL_DECODE = 0; $Dancer2::Core::Request::_count = 0; run_test(); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/plugin_syntax.t0000644000175000017500000000431312253326150021104 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2::Test; use JSON; subtest 'global and route keywords' => sub { { use Dancer2; use t::lib::FooPlugin; sub location {'/tmp'} get '/' => sub { foo_wrap_request->env->{'PATH_INFO'}; }; get '/app' => sub { app->name }; get '/plugin_setting' => sub { to_json(p_config) }; foo_route; } my $r = dancer_response( GET => '/' ); is( $r->content, '/', 'route defined by a plugin' ); $r = dancer_response( GET => '/foo' ); is( $r->content, 'foo', 'DSL keyword wrapped by a plugin' ); $r = dancer_response( GET => '/plugin_setting' ); is( $r->content, encode_json( { plugin => "42" } ), 'plugin_setting returned the expected config' ); $r = dancer_response( GET => '/app' ); is( $r->content, 'main', 'app name is correct' ); }; subtest 'plugin old syntax' => sub { { use Dancer2; use t::lib::DancerPlugin; around_get; } my $r = dancer_response GET => '/foo/plugin'; is $r->content, 'foo plugin'; }; subtest caller_dsl => sub { { use Dancer2; use t::lib::DancerPlugin; } my $r = dancer_response GET => '/sitemap'; is $r->content, '^\/$, ^\/app$, ^\/foo$, ^\/foo\/plugin$, ^\/plugin_setting$, ^\/sitemap$'; }; subtest 'hooks in plugins' => sub { my $counter = 0; { use Dancer2; use t::lib::Hookee; hook 'third_hook' => sub { var( hook => 'third hook' ); }; hook 'start_hookee' => sub { 'hook for plugin'; }; get '/hook_with_var' => sub { some_other(); is var('hook') => 'third hook', "Vars preserved from hooks"; }; get '/hooks_plugin' => sub { $counter++; some_keyword(); }; } is $counter, 0, "the hook has not been executed"; my $r = dancer_response( GET => '/hooks_plugin' ); is( $r->content, 'hook for plugin', '... route is rendered' ); is $counter, 1, "... and the hook has been executed exactly once"; dancer_response( GET => '/hook_with_var' ); }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/config.t0000644000175000017500000000713212253326150017447 0ustar gregoagregoause strict; use warnings; use Test::More; use Test::Fatal; use Carp 'croak'; use Dancer2::Core::Runner; use Dancer2::Core::Role::Config; use Dancer2::FileUtils qw/dirname path/; use File::Spec; use File::Temp; my $runner = Dancer2::Core::Runner->new( caller => 'main' ); my $location = File::Spec->rel2abs( path( dirname(__FILE__), 'config' ) ); { package Prod; use Moo; with 'Dancer2::Core::Role::Config'; sub name {'Prod'} sub _build_environment {'production'} sub location {$location} sub default_config { $runner->default_config } package Dev; use Moo; with 'Dancer2::Core::Role::Config'; sub _build_environment {'development'} sub location {$location} sub default_config { $runner->default_config } package Failure; use Moo; with 'Dancer2::Core::Role::Config'; sub _build_environment {'failure'} sub location {$location} sub default_config { $runner->default_config } package Staging; use Moo; with 'Dancer2::Core::Role::Config'; sub _build_environment {'staging'} sub location {$location} sub default_config { $runner->default_config } package Merging; use Moo; with 'Dancer2::Core::Role::Config'; sub name {'Merging'} sub _build_environment {'merging'} sub location {$location} sub default_config { $runner->default_config } } my $d = Dev->new; is_deeply $d->config_files, [ path( $location, 'config.yml' ), ], "config_files() only sees existing files"; my $f = Prod->new; is $f->does('Dancer2::Core::Role::Config'), 1, "role Dancer2::Core::Role::Config is consumed"; is_deeply $f->config_files, [ path( $location, 'config.yml' ), path( $location, 'environments', 'production.yml' ), ], "config_files() works"; my $j = Staging->new; is_deeply $j->config_files, [ path( $location, 'config.yml' ), path( $location, 'environments', 'staging.json' ), ], "config_files() does JSON too!"; note "bad YAML file"; my $fail = Failure->new; is $fail->environment, 'failure'; is_deeply $fail->config_files, [ path( $location, 'config.yml' ), path( $location, 'environments', 'failure.yml' ), ], "config_files() works"; like( exception { $fail->config }, qr{YAML}, 'Configuration file parsing failure', ); note "config merging"; my $m = Merging->new; # Check the 'application' top-level key; its the only key that # is currently a HoH in the test configurations is_deeply $m->config->{application}, { some_feature => 'bar', another_setting => 'baz', }, "full merging of configuration hashes"; note "config parsing"; is $f->config->{show_errors}, 0; is $f->config->{main}, 1; is $f->config->{charset}, 'utf-8', "normalized UTF-8 to utf-8"; ok( $f->has_setting('charset') ); ok( !$f->has_setting('foobarbaz') ); note "default values"; is $f->setting('apphandler'), 'Standalone'; is $f->setting('content_type'), 'text/html'; like( exception { $f->_normalize_config( { charset => 'BOGUS' } ) }, qr{Charset defined in configuration is wrong : couldn't identify 'BOGUS'}, 'Configuration file charset failure', ); { package Foo; use Carp 'croak'; sub foo { croak "foo" } } is $f->setting('traces'), 0; unlike( exception { Foo->foo() }, qr{Foo::foo}, "traces are not enabled", ); $f->setting( traces => 1 ); like( exception { Foo->foo() }, qr{Foo::foo}, "traces are enabled", ); { my $tmpdir = File::Temp::tempdir( CLEANUP => 1, TMPDIR => 1 ); $ENV{DANCER_CONFDIR} = $tmpdir; my $f = Prod->new; is $f->config_location, $tmpdir; } done_testing; libdancer2-perl-0.11+dfsg.orig/t/dsl/0000775000175000017500000000000012253326150016576 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/t/dsl/halt.t0000644000175000017500000000237412253326150017717 0ustar gregoagregoause strict; use warnings; use Test::More; subtest 'halt within routes' => sub { { package App; use Dancer2; get '/' => sub { 'hello' }; get '/halt' => sub { header 'X-Foo' => 'foo'; halt; }; get '/shortcircuit' => sub { context->response->content('halted'); halt; redirect '/'; # won't get executed as halt returns immediately. }; } use Dancer2::Test apps => ['App']; response_status_is [ GET => '/shortcircuit' ] => 200; response_content_is [ GET => '/shortcircuit' ] => "halted"; my $expected_headers = [ 'X-Foo' => 'foo', 'Server' => "Perl Dancer2 $Dancer2::VERSION", ]; response_headers_include [ GET => '/halt' ] => $expected_headers; }; subtest 'halt in before halt' => sub { { package App; use Dancer2; hook before => sub { my $context = shift; $context->response->content('I was halted'); halt if $context->request->dispatch_path eq '/shortcircuit'; }; } response_status_is [ GET => '/shortcircuit' ] => 200; response_content_is [ GET => '/shortcircuit' ] => "I was halted"; }; done_testing; libdancer2-perl-0.11+dfsg.orig/t/splat.t0000644000175000017500000000070112253326150017320 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2::Test; my @splat; { use Dancer2; get '/*/*/*' => sub { @splat = splat; }; } my $resp = dancer_response( get => '/foo/bar/baz', { params => { foo => 42 }, } ); is_deeply [@splat], [qw(foo bar baz)], "splat behaves as expected"; is $resp->status, 200, "got a 200"; is_deeply $resp->content, 3, "got expected response"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/config_app3.t0000644000175000017500000000051712253326150020372 0ustar gregoagregoause strict; use warnings; use Test::More; use File::Spec; use t::app::t2::lib::App3; is( App3->runner->config->{app}->{config}, 'ok', 'config loaded properly' ); is_deeply( App3->runner->config_files, [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't2', 'config.yml' )) ], 'config files found' ); done_testing; libdancer2-perl-0.11+dfsg.orig/t/template_default_tokens.t0000644000175000017500000000160012253326150023076 0ustar gregoagregoause strict; use warnings; use File::Spec; use File::Basename 'dirname'; use Test::More; eval { require Template; Template->import(); 1 } or plan skip_all => 'Template::Toolkit probably missing.'; my $views = File::Spec->rel2abs( File::Spec->catfile( dirname(__FILE__), 'views' ) ); { package Foo; use Dancer2; set session => 'Simple'; set views => $views; set template => "template_toolkit"; set foo => "in settings"; get '/view/:foo' => sub { var foo => "in var"; session foo => "in session"; template "tokens"; }; } use Dancer2::Test apps => ['Foo']; my $expected = "perl_version: $] dancer_version: ${Dancer2::VERSION} settings.foo: in settings params.foo: 42 session.foo in session vars.foo: in var"; response_content_like "/view/42", qr{$expected}, "Response contains all expected tokens"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/template_name.t0000644000175000017500000000050712253326150021014 0ustar gregoagregoause strict; use warnings; use File::Spec; use File::Basename 'dirname'; use Test::More; { package Foo; use Dancer2; get '/template_name' => sub { return engine('template')->name; }; } use Dancer2::Test apps => ['Foo']; response_content_is "/template_name", 'Tiny', "template name"; done_testing; libdancer2-perl-0.11+dfsg.orig/t/runner.t0000644000175000017500000000232712253326150017514 0ustar gregoagregoause strict; use warnings; use Test::More; use Test::Fatal; use File::Basename 'dirname'; use Dancer2::Core::Runner; my $runner = Dancer2::Core::Runner->new( caller => __FILE__ ); isa_ok $runner, 'Dancer2::Core::Runner'; is $runner->location, File::Spec->rel2abs( dirname(__FILE__) ), "location is set correctly"; note "testing environments"; is $runner->environment, 'development'; { local $ENV{DANCER_ENVIRONMENT} = 'production'; my $runner = Dancer2::Core::Runner->new( caller => __FILE__ ); is $runner->environment, 'production'; } { local $ENV{PLACK_ENV} = 'foo'; my $runner = Dancer2::Core::Runner->new( caller => __FILE__ ); is $runner->environment, 'foo'; } is $runner->server->name, 'Standalone', "server is created and is standalone"; note "testing default config of the server"; is $runner->server->port, 3000; is $runner->server->host, '0.0.0.0'; is $runner->server->is_daemon, 0; note "testing server failure"; { $runner->config->{apphandler} = 'NotExist'; like( exception { Dancer2::Core::Runner::_build_server($runner) }, qr{Unable to load Dancer2::Core::Server::NotExist}, 'Cannot run BUILD for server that does not exist', ); } done_testing; libdancer2-perl-0.11+dfsg.orig/t/vars.t0000644000175000017500000000063712253326150017160 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; plan tests => 2; use Dancer2::Test; { use Dancer2; hook before => sub { var( "xpto" => "foo" ); vars->{zbr} = 'ugh'; }; get '/bar' => sub { var("xpto"); }; get '/baz' => sub { vars->{zbr}; }; } response_content_is [ GET => '/bar' ], 'foo'; response_content_is [ GET => '/baz' ], 'ugh'; libdancer2-perl-0.11+dfsg.orig/t/forward.t0000644000175000017500000000425012253326150017644 0ustar gregoagregoause strict; use warnings; use Test::More import => ['!pass']; use Dancer2; use Dancer2::Test; get '/' => sub { 'home:' . join( ',', params ); }; get '/bounce/' => sub { return forward '/'; }; get '/bounce/:withparams/' => sub { return forward '/'; }; get '/bounce2/adding_params/' => sub { return forward '/', { withparams => 'foo' }; }; post '/simple_post_route/' => sub { 'post:' . join( ',', params ); }; get '/go_to_post/' => sub { return forward '/simple_post_route/', { foo => 'bar' }, { method => 'post' }; }; # NOT SUPPORTED IN DANCER2 # In dancer2, vars are alive for only one request flow, a forward initiate a # new request flow, then the vars HashRef is destroyed. # # get '/b' => sub { vars->{test} = 1; forward '/a'; }; # get '/a' => sub { return "test is " . var('test'); }; response_status_is [ GET => '/' ] => 200; response_content_is [ GET => '/' ] => 'home:'; response_status_is [ GET => '/bounce/' ] => 200; response_content_is [ GET => '/bounce/' ] => 'home:'; response_status_is [ GET => '/bounce/thesethings/' ] => 200; response_content_is [ GET => '/bounce/thesethings/' ] => 'home:withparams,thesethings'; response_status_is [ GET => '/bounce2/adding_params/' ] => 200; response_content_is [ GET => '/bounce2/adding_params/' ] => 'home:withparams,foo'; response_status_is [ GET => '/go_to_post/' ] => 200; response_content_is [ GET => '/go_to_post/' ] => 'post:foo,bar'; # NOT SUPPORTED # response_status_is [ GET => '/b' ] => 200; # response_content_is [ GET => '/b' ] => 'test is 1'; my $expected_headers = [ 'Content-Length' => 5, 'Content-Type' => 'text/html; charset=UTF-8', 'Server' => "Perl Dancer2 $Dancer2::VERSION", ]; response_headers_are_deeply [ GET => '/bounce/' ], $expected_headers; # checking post post '/' => sub {'post-home'}; post '/bounce/' => sub { forward('/') }; response_status_is [ POST => '/' ] => 200; response_content_is [ POST => '/' ] => 'post-home'; response_status_is [ POST => '/bounce/' ] => 200; response_content_is [ POST => '/bounce/' ] => 'post-home'; $expected_headers->[1] = 9; response_headers_are_deeply [ POST => '/bounce/' ], $expected_headers; done_testing; libdancer2-perl-0.11+dfsg.orig/lib/0000775000175000017500000000000012253326150016317 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/lib/Dancer2.pm0000644000175000017500000001556212253326150020142 0ustar gregoagregoapackage Dancer2; { $Dancer2::VERSION = '0.11'; } # ABSTRACT: Lightweight yet powerful web application framework use strict; use warnings; use Class::Load 'load_class'; use Dancer2::Core; use Dancer2::Core::Runner; use Dancer2::Core::App; use Dancer2::FileUtils; our $AUTHORITY = 'SUKRIA'; # set version in dist.ini now # but we still need a basic version for # the tests $Dancer2::VERSION ||= '0.09'; # 2.0.9 our $runner; sub runner {$runner} sub import { my ( $class, @args ) = @_; my ( $caller, $script ) = caller; strict->import; warnings->import; utf8->import; my @final_args; my $as_script = 0; foreach (@args) { if ( $_ eq ':script' ) { $as_script = 1; } elsif ( substr( $_, 0, 1 ) eq '!' ) { push @final_args, $_, 1; } else { push @final_args, $_; } } scalar(@final_args) % 2 and die "parameters to 'use Dancer2' should be one of : 'key => value', ':script', or !, where is a DSL keyword you don't want to import"; my %final_args = @final_args; $final_args{dsl} ||= 'Dancer2::Core::DSL'; # never instantiated the runner, should do it now if ( not defined $runner ) { # TODO should support commandline options as well $runner = Dancer2::Core::Runner->new( caller => $script, ); } my $server = $runner->server; # the app object # populating with the server's postponed hooks in advance my $app = Dancer2::Core::App->new( name => $caller, environment => $runner->environment, location => $runner->location, runner_config => $runner->config, postponed_hooks => $server->postponed_hooks, ); _set_import_method_to_caller($caller); # register the app within the runner instance $server->register_application($app); # load the DSL, defaulting to Dancer2::Core::DSL load_class( $final_args{dsl} ); my $dsl = $final_args{dsl}->new( app => $app ); $dsl->export_symbols_to( $caller, \%final_args ); # # $as_script = 1 if $ENV{PLACK_ENV}; # # Dancer2::GetOpt->process_args() if !$as_script; # # If uncommenting or removing this, be sure to update the description of # :script above as well. } sub _set_import_method_to_caller { my ($caller) = @_; my $import = sub { my ( $self, %options ) = @_; my $with = $options{with}; for my $key ( keys %$with ) { $self->dancer_app->setting( $key => $with->{$key} ); } }; { no strict 'refs'; no warnings 'redefine'; *{"${caller}::import"} = $import; } } 1; __END__ =pod =head1 NAME Dancer2 - Lightweight yet powerful web application framework =head1 VERSION version 0.11 =head1 DESCRIPTION Dancer2 is the new generation of L, the lightweight web-framework for Perl. Dancer2 is a complete rewrite based on L. Dancer2 can optionally use XS modules for speed, but at its core remains fatpackable (packable by L) so you could easily deploy Dancer2 applications on hosts that do not support custom CPAN modules. Dancer2 is easy and fun: use Dancer2; get '/' => sub { "Hello World" }; dance; This is the main module for the Dancer2 distribution. It contains logic for creating a new Dancer2 application. You are welcome to joining our mailing list at dancer-users@perldancer.org, and we're also on IRC: #dancer on irc.perl.org. =head2 Documentation Index Documentation on Dancer2 is split into several manpages. Below is a complete outline on where to go for help. =over 4 =item * Dancer2 Tutorial If you are new to the Dancer approach, you should start by reading our L. =item * Dancer2 Manual L is the reference for Dancer2. Here you will find information on the concepts of Dancer2 application development and a comprehensive reference to the Dancer2 domain specific language. =item * Dancer2 Cookbook There are some situations that are common to a lot of users. For example, application deployment. in L you will find recipes for common tasks, like defining routes, storing data as sessions or cookies, using templates, configuring and logging, writing REST services, and deploying your Dancer2 application using different technologies. =item * Dancer2 Config For configuration file details refer to L. It is a complete list of all configuration options. =item * Dancer2 Plugins Refer to L for a partial list of available Dancer2 plugins. Note that although we try to keep this list up to date we expect plugin authors to tell us about new modules. =back =head1 METHODS =head2 import; If it doesn't exist already, C creates a new runner, imports strict and warnings, loads additional libraries, creates a new Dancer2 app (of type L) and exports the DSL symbols to the caller. If any additional argument processing is needed, it will be done at this point. Import gets called when you use Dancer2. You can specify import options giving you control over the keywords that will be imported into your webapp and other things: use Dancer2 ( foo => 'bar' ); # sets option foo to bar use Dancer2 '!quux'; # Don't import DSL keyword quux =head3 Import Options =over 4 =item C<:script> Not implemented yet, do not use. =back =head1 FUNCTIONS =head2 my $runner=runner(); Returns the current runner. It is of type L. =head1 AUTHORS =head2 CORE DEVELOPERS Alberto Simões Alexis Sukrieh Damien Krotkine David Golden David Precious Franck Cuny Russell Jenkins Sawyer X Stefan Hornburg (Racke) Yanick Champoux =head2 CONTRIBUTORS Ahmad M. Zawawi Alex Beamish Alexander Karelas Alexandr Ciornii ambs Andrew Grangaard Andrew Inishev andrewsolomon Ashvini V B10m Blabos de Blebe Breno G. de Oliveira Celogeek Cesare Gargano Christian Walde Colin Kuskie cym0n Dale Gallagher David Steinbrunner Dinis Rebolo geistteufel Gideon D'souza Graham Knop Hobbestigrou Ivan Bessarabov James Aitken Jason A. Crome Jonathan Scott Duff Julio Fraire Keith Broughton Mark A. Stratman Mateu X Hunter Matt Phillips Matt S Trout Maurice Mickey Nasriachi mokko Olivier Mengué Pau Amma Pedro Melo Rick Yakubowski Sam Kington Samit Badle Shlomi Fish Slava Goltser smashz Steven Humphrey Tom Hukins Upasana Shukla Vincent Bachelier =head1 AUTHOR Dancer Core Developers =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Alexis Sukrieh. 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 libdancer2-perl-0.11+dfsg.orig/lib/Dancer2/0000775000175000017500000000000012253326150017575 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/lib/Dancer2/Handler/0000775000175000017500000000000012253326150021152 5ustar gregoagregoalibdancer2-perl-0.11+dfsg.orig/lib/Dancer2/Handler/File.pm0000644000175000017500000000745412253326150022377 0ustar gregoagregoa# ABSTRACT: class for handling file content rendering package Dancer2::Handler::File; { $Dancer2::Handler::File::VERSION = '0.11'; } use Carp 'croak'; use Moo; use HTTP::Date; use Dancer2::FileUtils 'path', 'open_file', 'read_glob_content'; use Dancer2::Core::MIME; use Dancer2::Core::Types; use File::Spec; with 'Dancer2::Core::Role::Handler'; with 'Dancer2::Core::Role::StandardResponses'; with 'Dancer2::Core::Role::Hookable'; sub supported_hooks { qw( handler.file.before_render handler.file.after_render ); } has mime => ( is => 'ro', isa => InstanceOf ['Dancer2::Core::MIME'], default => sub { Dancer2::Core::MIME->new }, ); has encoding => ( is => 'ro', default => sub {'utf-8'}, ); has public_dir => ( is => 'rw', ); has regexp => ( is => 'ro', default => sub {'/**'}, ); sub BUILD { my ($self) = @_; if ( !defined $self->public_dir ) { my $public = $self->app->config->{public} || $ENV{DANCER_PUBLIC} || path( $self->app->location, 'public' ); $self->public_dir($public); } } sub register { my ( $self, $app ) = @_; # don't register the handler if no valid public dir return if !-d $self->public_dir; $app->add_route( method => $_, regexp => $self->regexp, code => $self->code( $app->prefix ), ) for $self->methods; } sub methods { ( 'head', 'get' ) } sub code { my ( $self, $prefix ) = @_; sub { my $ctx = shift; my $path = $ctx->request->path_info; if ( $path =~ /\0/ ) { return $self->response_400($ctx); } if ( $prefix && $prefix ne '/' ) { $path =~ s/^\Q$prefix\E//; } my @tokens = File::Spec->splitdir( join '', ( File::Spec->splitpath($path) )[ 1, 2 ] ); if ( grep $_ eq '..', @tokens ) { return $self->response_403($ctx); } my $file_path = path( $self->public_dir, @tokens ); if ( !-f $file_path ) { $ctx->response->has_passed(1); return; } if ( !-r $file_path ) { return $self->response_403($ctx); } # Now we are sure we can render the file... $self->execute_hook( 'handler.file.before_render', $file_path ); # Read file content as bytes my $fh = open_file( "<", $file_path ); binmode $fh; my $content = read_glob_content($fh); # Assume m/^text/ mime types are correctly encoded my $content_type = $self->mime->for_file($file_path) || 'text/plain'; if ( $content_type =~ m!^text/! ) { $content_type .= "; charset=" . ( $self->encoding || "utf-8" ); } my @stat = stat $file_path; $ctx->response->header('Content-Type') or $ctx->response->header( 'Content-Type', $content_type ); $ctx->response->header('Content-Length') or $ctx->response->header( 'Content-Length', $stat[7] ); $ctx->response->header('Last-Modified') or $ctx->response->header( 'Last-Modified', HTTP::Date::time2str( $stat[9] ) ); $ctx->response->content($content); $ctx->response->is_encoded(1); # bytes are already encoded $self->execute_hook( 'handler.file.after_render', $ctx->response ); return ( $ctx->request->method eq 'GET' ) ? $content : ''; }; } 1; __END__ =pod =head1 NAME Dancer2::Handler::File - class for handling file content rendering =head1 VERSION version 0.11 =head1 AUTHOR Dancer Core Developers =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Alexis Sukrieh. 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 libdancer2-perl-0.11+dfsg.orig/lib/Dancer2/Handler/AutoPage.pm0000644000175000017500000000451112253326150023214 0ustar gregoagregoa# ABSTRACT: Class for handling the AutoPage feature package Dancer2::Handler::AutoPage; { $Dancer2::Handler::AutoPage::VERSION = '0.11'; } use Moo; use Carp 'croak'; use Dancer2::Core::Types; with 'Dancer2::Core::Role::Handler'; with 'Dancer2::Core::Role::StandardResponses'; sub register { my ( $self, $app ) = @_; return unless $app->config->{auto_page}; $app->add_route( method => $_, regexp => $self->regexp, code => $self->code, ) for $self->methods; } sub code { sub { my $ctx = shift; my $page = $ctx->request->path_info; my $template = $ctx->app->engine('template'); if ( !defined $template ) { $ctx->response->has_passed(1); return; } my $view_path = $template->view_pathname($page); if ( !-f $view_path ) { $ctx->response->has_passed(1); return; } my $ct = $template->process($page); $ctx->response->header( 'Content-Length', length($ct) ); return ( $ctx->request->method eq 'GET' ) ? $ct : ''; }; } sub regexp {'/**'} sub methods {qw(head get)} 1; __END__ =pod =head1 NAME Dancer2::Handler::AutoPage - Class for handling the AutoPage feature =head1 VERSION version 0.11 =head1 DESCRIPTION The AutoPage feature is a Handler (turned off by default) that is responsible for serving pages that match an existing template. If a view exists with a name that matches the requested path, Dancer2 processes the request using the Autopage handler. To turn it add to your config file: auto_page: 1 This allows you to easily serve simple pages without having to write a route definition for them. If there's no view with the name request, the route passes, allowing other matching routes to be dispatched. =head1 METHODS =head2 register Creates the routes. =head2 code A code reference that processes the route request. =head2 methods The methods that should be served for autopages. Default: B, B. =head2 regexp The regexp (path) we want to match. Default: B. =head1 AUTHOR Dancer Core Developers =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Alexis Sukrieh. 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 libdancer2-perl-0.11+dfsg.orig/lib/Dancer2/CLI.pm0000644000175000017500000000075512253326150020547 0ustar gregoagregoa# ABSTRACT: Dancer2 cli application package Dancer2::CLI; { $Dancer2::CLI::VERSION = '0.11'; } use App::Cmd::Setup -app; 1; __END__ =pod =head1 NAME Dancer2::CLI - Dancer2 cli application =head1 VERSION version 0.11 =head1 AUTHOR Dancer Core Developers =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Alexis Sukrieh. 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 libdancer2-perl-0.11+dfsg.orig/lib/Dancer2/Tutorial.pod0000644000175000017500000005467512253326150022123 0ustar gregoagregoapackage Dancer2::Tutorial; # ABSTRACT: An example to get you dancing __END__ =pod =head1 NAME Dancer2::Tutorial - An example to get you dancing =head1 VERSION version 0.11 =head1 What is Dancer2? Dancer2 is a "micro" web framework which is modeled after a Ruby framework called L that constructs web applications by building a list of HTTP verbs, URLs (called routes) and methods to handle that type of traffic to that specific URL. use Dancer2; get '/' => sub { return 'Hello World!'; }; start; This example shows a single HTTP verb "GET" followed by the root URL "/" and an anonymous subroutine which returns the string C<"Hello World!"> If you were to run this example, it would display "Hello World!" when you point your browser at L. =head1 How about a little more involved example? That's the reason I wrote this tutorial. While I was investigating some Python web frameworks like L or L I enjoyed the way they explained step by step how to build an example application which was a little more involved that a trivial example. Using the L sample application as my inspiration (OK, shamelessly plagiarised) I translated that application to the Dancer2 framework so I could better understand how Dancer2 worked. (I'm learning it too!) So "Dancr" was born. Dancr is a simple "micro" blog which uses the L database engine for simplicity's sake. (You'll need to install sqlite for Dancr if you don't have it installed already.) =head1 Required perl modules Obviously you need L. You also need the L