From 33dcd0ab40dd0f1668a144eef71f57ffac85470c Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sat, 12 Oct 2024 19:26:59 +0200 Subject: [PATCH] convert to Dist::Zilla --- .editorconfig | 18 ++ .github/workflows/test.yml | 177 +++++++++++++ .gitignore | 13 + .perlcriticrc | 81 ++++++ Changes | 60 +++-- LICENSE | 412 ++++++++++++++++++++++++++++++ META.json | 89 +++++++ Makefile.PL | 66 +++-- README.md | 108 ++++++++ dist.ini | 108 ++++++++ lib/Catalyst/Action/RenderView.pm | 61 ++--- prereqs.yml | 9 + t/02pod.t | 7 - t/03podcoverage.t | 7 - t/04live.t | 148 +++++------ t/lib/TestApp.pm | 24 +- t/lib/TestApp/View/TestView.pm | 18 +- weaver.ini | 12 + 18 files changed, 1228 insertions(+), 190 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 .perlcriticrc create mode 100644 LICENSE create mode 100644 META.json create mode 100644 README.md create mode 100644 dist.ini create mode 100644 prereqs.yml delete mode 100644 t/02pod.t delete mode 100644 t/03podcoverage.t create mode 100644 weaver.ini diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c0afb70 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +indent_style = space +indent_size = 4 + +end_of_line = lf +charset = utf-8 + +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{yml,yaml}] +indent_size = 2 +quote_type = single + +[Changes] +indent_size = 2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b8df8da --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,177 @@ +name: Test +on: + push: ~ + pull_request: ~ + +jobs: + perl-versions: + runs-on: ubuntu-latest + name: Calculate Perl Versions + outputs: + versions: ${{ steps.perl-versions.outputs.perl-versions }} + steps: + - uses: actions/checkout@v4 + - id: perl-versions + uses: perl-actions/perl-versions@v1 + with: + since-perl: v5.14 + with-devel: true + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: ~/.perl-cpm + key: cpm-${{ runner.os }} + - name: Setup local::lib + run: | + echo "$RUNNER_TEMP/perl5/bin" >> "$GITHUB_PATH" + echo "PERL5LIB=$RUNNER_TEMP/perl5/lib/perl5:$PERL5LIB" >> "$GITHUB_ENV" + echo "PERL_MB_OPT=--install_base $RUNNER_TEMP/perl5" >> "$GITHUB_ENV" + echo "PERL_MM_OPT=INSTALL_BASE=$RUNNER_TEMP/perl5" >> "$GITHUB_ENV" + - name: Extract Dist::Zilla dependencies + id: authordeps + uses: perl-actions/get-prereqs@v1 + with: + sources: dist.ini + phases: author + - name: Install authordeps + uses: perl-actions/install-with-cpm@v1 + with: + sudo: false + install: ${{ steps.authordeps.outputs.prereqs }} + - name: Build + id: build + run: | + DZIL_COLOR=1 dzil build --no-tgz | tee "/tmp/dzil-build.log" + echo build="$(grep --only-matching 'built in .*' "/tmp/dzil-build.log" | tail -1 | cut -c10-)" >> "$GITHUB_OUTPUT" + - name: Upload build + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.build.outputs.build }} + path: ${{ steps.build.outputs.build }} + include-hidden-files: true + outputs: + name: ${{ steps.build.outputs.build }} + + test: + needs: + - perl-versions + - build + + strategy: + fail-fast: false + matrix: + perl-version: ${{ fromJson(needs.perl-versions.outputs.versions) }} + + runs-on: ubuntu-latest + container: + image: perl:${{ matrix.perl-version }}-buster + + env: + AUTOMATED_TESTING: 1 + PERL_USE_UNSAFE_INC: 0 + + steps: + - name: Download build + uses: actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.name }} + - uses: actions/cache@v4 + with: + path: ~/.perl-cpm + key: cpm-perl:${{ matrix.perl-version }}-buster + - name: Setup local::lib + run: | + echo "$RUNNER_TEMP/perl5/bin" >> "$GITHUB_PATH" + echo "PERL5LIB=$RUNNER_TEMP/perl5/lib/perl5:$PERL5LIB" >> "$GITHUB_ENV" + echo "PERL_MB_OPT=--install_base $RUNNER_TEMP/perl5" >> "$GITHUB_ENV" + echo "PERL_MM_OPT=INSTALL_BASE=$RUNNER_TEMP/perl5" >> "$GITHUB_ENV" + - name: Extract configure dependecies + id: configure + uses: perl-actions/get-prereqs@v1 + with: + phases: configure + - name: Install configure deps + uses: perl-actions/install-with-cpm@v1 + with: + sudo: false + install: ${{ steps.configure.outputs.prereqs }} + - name: Run Makefile.PL + run: perl Makefile.PL + - name: Extract dependecies + id: prereqs + uses: perl-actions/get-prereqs@v1 + with: + phases: build test runtime + relationships: requires recommends suggests + - name: Install deps + uses: perl-actions/install-with-cpm@v1 + with: + sudo: false + install: ${{ steps.prereqs.outputs.prereqs }} + - name: Run the tests + run: make test + env: + AUTHOR_TESTING: 1 + + test-xt: + needs: + - perl-versions + - build + + runs-on: ubuntu-latest + container: + image: perl:5.36-buster + + env: + AUTOMATED_TESTING: 1 + + steps: + - name: Download build + uses: actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.name }} + - uses: actions/cache@v4 + with: + path: ~/.perl-cpm + key: cpm-perl:5.36-buster + - name: Setup local::lib + run: | + echo "$RUNNER_TEMP/perl5/bin" >> "$GITHUB_PATH" + echo "PERL5LIB=$RUNNER_TEMP/perl5/lib/perl5:$PERL5LIB" >> "$GITHUB_ENV" + echo "PERL_MB_OPT=--install_base $RUNNER_TEMP/perl5" >> "$GITHUB_ENV" + echo "PERL_MM_OPT=INSTALL_BASE=$RUNNER_TEMP/perl5" >> "$GITHUB_ENV" + - name: Extract configure dependecies + id: configure + uses: perl-actions/get-prereqs@v1 + with: + phases: configure + - name: Install configure deps + uses: perl-actions/install-with-cpm@v1 + with: + sudo: false + install: ${{ steps.configure.outputs.prereqs }} + - name: Run Makefile.PL + run: perl Makefile.PL + - name: Extract dependecies + id: prereqs + uses: perl-actions/get-prereqs@v1 + with: + phases: build test runtime develop + relationships: requires recommends suggests + - name: Install deps + uses: perl-actions/install-with-cpm@v1 + with: + sudo: false + install: ${{ steps.prereqs.outputs.prereqs }} + - name: Run the xt tests + run: prove -l xt + env: + AUTHOR_TESTING: 1 + - name: Run the xt/author tests + run: prove -lr xt/author + env: + AUTHOR_TESTING: 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..829b42f --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/MANIFEST.bak +/Makefile.old +/Makefile +/blib/ +/pm_to_blib +/MYMETA.json +/MYMETA.yml +/cover_db/ +/MYMETA.json.lock +/MANIFEST +/.build/ +/Catalyst-Action-RenderView-*.tar.gz +/Catalyst-Action-RenderView-*/ diff --git a/.perlcriticrc b/.perlcriticrc new file mode 100644 index 0000000..faea4f1 --- /dev/null +++ b/.perlcriticrc @@ -0,0 +1,81 @@ +severity = 1 +verbose = 9 +only = 1 + +[BuiltinFunctions::ProhibitLvalueSubstr] +[BuiltinFunctions::ProhibitShiftRef] +[BuiltinFunctions::ProhibitSleepViaSelect] +[BuiltinFunctions::ProhibitStringyEval] +[BuiltinFunctions::ProhibitUniversalCan] +[BuiltinFunctions::ProhibitUniversalIsa] +[BuiltinFunctions::ProhibitVoidGrep] +[BuiltinFunctions::ProhibitVoidMap] +[BuiltinFunctions::RequireGlobFunction] +[BuiltinFunctions::RequireSimpleSortBlock] +[ClassHierarchies::ProhibitOneArgBless] +[CodeLayout::ProhibitHardTabs] +[CodeLayout::RequireConsistentNewlines] +[ControlStructures::ProhibitCascadingIfElse] +[ControlStructures::ProhibitDeepNests] +[ControlStructures::ProhibitLabelsWithSpecialBlockNames] +[ControlStructures::ProhibitMutatingListFunctions] +[ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions] +[ControlStructures::ProhibitUnreachableCode] +[ControlStructures::ProhibitYadaOperator] +[ErrorHandling::RequireCheckingReturnValueOfEval] +[InputOutput::ProhibitBacktickOperators] +[InputOutput::ProhibitBarewordFileHandles] +[InputOutput::ProhibitExplicitStdin] +[InputOutput::ProhibitInteractiveTest] +[InputOutput::ProhibitJoinedReadline] +[InputOutput::ProhibitOneArgSelect] +[InputOutput::ProhibitReadlineInForLoop] +[InputOutput::ProhibitTwoArgOpen] +[InputOutput::RequireCheckedOpen] +[InputOutput::RequireEncodingWithUTF8Layer] +[Miscellanea::ProhibitFormats] +[Miscellanea::ProhibitUnrestrictedNoCritic] +[Modules::ProhibitAutomaticExportation] +[Modules::ProhibitConditionalUseStatements] +[Modules::ProhibitEvilModules] +[Modules::ProhibitExcessMainComplexity] +[Modules::RequireBarewordIncludes] +[Modules::RequireEndWithOne] +[Modules::RequireFilenameMatchesPackage] +[NamingConventions::ProhibitAmbiguousNames] +[Objects::ProhibitIndirectSyntax] +[RegularExpressions::ProhibitCaptureWithoutTest] +[RegularExpressions::ProhibitComplexRegexes] +[RegularExpressions::ProhibitUnusedCapture] +[Subroutines::ProhibitBuiltinHomonyms] +[Subroutines::ProhibitExcessComplexity] +max_mccabe = 30 +[Subroutines::ProhibitExplicitReturnUndef] +[Subroutines::ProhibitManyArgs] +[Subroutines::ProhibitNestedSubs] +[Subroutines::ProhibitReturnSort] +[Subroutines::ProhibitUnusedPrivateSubroutines] +[Subroutines::ProtectPrivateSubs] +[TestingAndDebugging::ProhibitProlongedStrictureOverride] +[TestingAndDebugging::RequireTestLabels] +[TestingAndDebugging::RequireUseStrict] +[TestingAndDebugging::RequireUseWarnings] +[ValuesAndExpressions::ProhibitCommaSeparatedStatements] +[ValuesAndExpressions::ProhibitComplexVersion] +[ValuesAndExpressions::ProhibitImplicitNewlines] +[ValuesAndExpressions::ProhibitLeadingZeros] +[ValuesAndExpressions::ProhibitMismatchedOperators] +[ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters] +[ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator] +[ValuesAndExpressions::RequireQuotedHeredocTerminator] +[Variables::ProhibitAugmentedAssignmentInDeclaration] +allow_our = 1 +[Variables::ProhibitConditionalDeclarations] +[Variables::ProhibitMatchVars] +[Variables::ProhibitReusedNames] +[Variables::ProhibitUnusedVariables] +[Variables::ProtectPrivateVars] +[Variables::RequireInitializationForLocalVars] +[Variables::RequireLexicalLoopIterators] +[Variables::RequireLocalizedPunctuationVars] +[Variables::RequireNegativeIndices] diff --git a/Changes b/Changes index 9557bd5..398fe60 100644 --- a/Changes +++ b/Changes @@ -1,59 +1,63 @@ +Revision history for Perl extension Catalyst-Action-RenderView + +{{ $NEXT }} + 0.16 2011-01-05 19:28:00 GMT - - Fix bug accidentally introduced in the last version with response - 3xx statuses. + - Fix bug accidentally introduced in the last version with response + 3xx statuses. 0.15 2011-01-04 14:19:36 CET - - Don't delegate to a view if the response body is set to `undef'. - - Make sure a Test::More with done_testing support is available. + - Don't delegate to a view if the response body is set to `undef'. + - Make sure a Test::More with done_testing support is available. 0.14 2009-12-03 03:13:23 GMT - - Remove warnings from tests about actions in the app root + - Remove warnings from tests about actions in the app root 0.13 2009-10-24 04:48:03 PDT - - Re-release 0.12 without changes for reindexing by CPAN/PAUSE. + - Re-release 0.12 without changes for reindexing by CPAN/PAUSE. 0.12 2009-10-18 19:10:00 BST - - Fixup copyright information + - Fixup copyright information 0.11 2009-06-28 19:29:16 - - Update Module::Install to 0.87 to unbreak auto_install. - No functional changes. + - Update Module::Install to 0.87 to unbreak auto_install. + No functional changes. 0.10 2009-04-29 18:24:50 - - Depend on Data::Visitor 0.24 to avoid Class::MOP deprecation - warnings. (Florian Ragwitz) + - Depend on Data::Visitor 0.24 to avoid Class::MOP deprecation + warnings. (Florian Ragwitz) 0.09 2009-02-18 21:32:00 - - Store config in $c->config->{'Action::RenderView'} - instead of $c->config->{debug}. - Config from $c->config->{debug} is deprecated, but - still supported. - - Switch from NEXT to next::method + - Store config in $c->config->{'Action::RenderView'} + instead of $c->config->{debug}. + Config from $c->config->{debug} is deprecated, but + still supported. + - Switch from NEXT to next::method 0.08 2008-05-02 19:40:00 - - Add AsCGI to list of test requirements. - - Check for defined()ness of $c->res->body so "0" is valid. (RT #30564) + - Add AsCGI to list of test requirements. + - Check for defined()ness of $c->res->body so "0" is valid. (RT #30564) 0.07 2007-09-01 11:03:00 - - Add DateTime to default list of scrubbed objects - - Stringify rather than ref by default , - more explicit message + - Add DateTime to default list of scrubbed objects + - Stringify rather than ref by default , + more explicit message 0.06 2007-08-29 16:35:00 - - Add support for scrubbing stash objects. - - Remove undef warning + - Add support for scrubbing stash objects. + - Remove undef warning 0.05 2007-04-26 - - switch to Module::Install + - switch to Module::Install 0.04 2006-07-04 09:21:00 - - That debug code wasn't quite production ready : / + - That debug code wasn't quite production ready : / 0.03 2006-07-02 11:26:00 - - Forgot to update use test as well, silly git. + - Forgot to update use test as well, silly git. 0.02 2006-06-29 14:59:00 - - Oops, moved content check ending brace up. + - Oops, moved content check ending brace up. 0.01 2006-06-26 17:14:00 - - Initial release + - Initial release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1a6577b --- /dev/null +++ b/LICENSE @@ -0,0 +1,412 @@ +This software is copyright (c) 2006 - 2009 by Marcus Ramberg and Florian Ragwitz. + +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) 2006 - 2009 by Marcus Ramberg and Florian Ragwitz. + +This is free software, licensed under: + + The GNU General Public License, Version 1, February 1989 + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + +--- The Perl Artistic License 1.0 --- + +This software is Copyright (c) 2006 - 2009 by Marcus Ramberg and Florian Ragwitz. + +This is free software, licensed under: + + The Perl 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 as specified below. + + "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 uunet.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) give non-standard executables non-standard names, and clearly + document 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. You may embed this Package's interpreter within +an executable of yours (by linking); this shall be construed as a mere +form of aggregation, provided that the complete Standard Version of the +interpreter is so embedded. + +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 whoever generated +them, and may be sold commercially, and may be aggregated with this +Package. If such scripts or library files are aggregated with this +Package via the so-called "undump" or "unexec" methods of producing a +binary executable image, then distribution of such an image shall +neither be construed as a distribution of this Package nor shall it +fall under the restrictions of Paragraphs 3 and 4, provided that you do +not represent such an executable image as a Standard Version of this +Package. + +7. C subroutines (or comparably compiled subroutines in other +languages) supplied by you and linked into this Package in order to +emulate subroutines and variables of the language defined by this +Package shall not be considered part of this Package, but are the +equivalent of input as in Paragraph 6, provided these subroutines do +not change the language in any way that would cause it to fail the +regression tests for the language. + +8. Aggregation of this Package with a commercial distribution is always +permitted provided that the use of this Package is embedded; that is, +when no overt attempt is made to make this Package's interfaces visible +to the end user of the commercial distribution. Such use shall not be +construed as a distribution of this Package. + +9. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End + diff --git a/META.json b/META.json new file mode 100644 index 0000000..92eb928 --- /dev/null +++ b/META.json @@ -0,0 +1,89 @@ +{ + "abstract" : "Sensible default end action.", + "author" : [ + "Marcus Ramberg ", + "Florian Ragwitz " + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "name" : "Catalyst-Action-RenderView", + "prereqs" : { + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "develop" : { + "requires" : { + "Test::CPAN::Changes" : "0.19", + "Test::CPAN::Meta" : "0", + "Test::EOL" : "0", + "Test::Kwalitee" : "1.21", + "Test::MinimumVersion" : "0", + "Test::Mojibake" : "0", + "Test::More" : "0.88", + "Test::NoTabs" : "0", + "Test::Perl::Critic" : "0", + "Test::Pod" : "1.41", + "Test::Pod::Coverage::TrustMe" : "0", + "Test::Portability::Files" : "0", + "Test::Spelling" : "0.12", + "Test::Version" : "1" + } + }, + "runtime" : { + "requires" : { + "Catalyst::Runtime" : "5.80030", + "Data::Visitor" : "0.24", + "MRO::Compat" : "0", + "perl" : "5.008005" + } + }, + "test" : { + "recommends" : { + "CPAN::Meta" : "2.120900" + }, + "requires" : { + "ExtUtils::MakeMaker" : "0", + "File::Spec" : "0", + "IO::Handle" : "0", + "IPC::Open3" : "0", + "Test::More" : "0.88" + } + } + }, + "provides" : { + "Catalyst::Action::RenderView" : { + "file" : "lib/Catalyst/Action/RenderView.pm", + "version" : "0.17" + } + }, + "release_status" : "stable", + "resources" : { + "bugtracker" : { + "x_url" : "https://github.com/perl-catalyst/Catalyst-Action-RenderView/issues" + }, + "repository" : { + "type" : "git", + "url" : "https://github.com/perl-catalyst/Catalyst-Action-RenderView.git", + "web" : "https://github.com/perl-catalyst/Catalyst-Action-RenderView" + } + }, + "version" : "0.17", + "x_contributors" : [ + "Graham Knop " + ], + "x_generated_by_perl" : "v5.38.2", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.37", + "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", + "x_static_install" : 1, + "x_use_unsafe_inc" : 0 +} + diff --git a/Makefile.PL b/Makefile.PL index fe46182..792abda 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,23 +1,59 @@ +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032. use strict; use warnings; -use inc::Module::Install 0.91; -if ( $Module::Install::AUTHOR ) { - system( 'pod2text lib/Catalyst/Action/RenderView.pm > README' ) - and die $!; -} +use 5.008005; + +use ExtUtils::MakeMaker; + +my %WriteMakefileArgs = ( + "ABSTRACT" => "Sensible default end action.", + "AUTHOR" => "Marcus Ramberg , Florian Ragwitz ", + "CONFIGURE_REQUIRES" => { + "ExtUtils::MakeMaker" => 0 + }, + "DISTNAME" => "Catalyst-Action-RenderView", + "LICENSE" => "perl", + "MIN_PERL_VERSION" => "5.008005", + "NAME" => "Catalyst::Action::RenderView", + "PREREQ_PM" => { + "Catalyst::Runtime" => "5.80030", + "Data::Visitor" => "0.24", + "MRO::Compat" => 0 + }, + "TEST_REQUIRES" => { + "ExtUtils::MakeMaker" => 0, + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Test::More" => "0.88" + }, + "VERSION" => "0.17", + "test" => { + "TESTS" => "t/*.t" + } +); -name 'Catalyst-Action-RenderView'; -all_from 'lib/Catalyst/Action/RenderView.pm'; -requires 'Catalyst::Runtime' => '5.80030'; -requires 'Test::More'; -requires 'Data::Visitor' => '0.24'; -requires 'MRO::Compat'; +my %FallbackPrereqs = ( + "Catalyst::Runtime" => "5.80030", + "Data::Visitor" => "0.24", + "ExtUtils::MakeMaker" => 0, + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "MRO::Compat" => 0, + "Test::More" => "0.88" +); -test_requires 'HTTP::Request::AsCGI'; -test_requires 'Test::More' => '0.88'; -resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Action-RenderView/trunk/'; +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; +} + +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} + unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; -WriteAll; +WriteMakefile(%WriteMakefileArgs); diff --git a/README.md b/README.md new file mode 100644 index 0000000..bd9d3d2 --- /dev/null +++ b/README.md @@ -0,0 +1,108 @@ +# NAME + +Catalyst::Action::RenderView - Sensible default end action. + +# SYNOPSIS + +```perl +sub end : ActionClass('RenderView') {} +``` + +# DESCRIPTION + +This action implements a sensible default end action, which will forward +to the first available view, unless `$c->res->status` is a 3xx code +(redirection, not modified, etc.), 204 (no content), or `$c->res->body` has +already been set. It also allows you to pass `dump_info=1` to the url in +order to force a debug screen, while in debug mode. + +If you have more than one view, you can specify which one to use with +the `default_view` config setting and the `current_view` and +`current_view_instance` stash keys (see [Catalyst](https://metacpan.org/pod/Catalyst)'s `$c->view($name)` +method -- this module simply calls `$c->view` with no argument). + +# METHODS + +## end + +The default `end` action. You can override this as required in your +application class; normal inheritance applies. + +# INTERNAL METHODS + +## execute + +Dispatches control to superclasses, then forwards to the default View. + +See ["METHODS/action" in Catalyst::Action](https://metacpan.org/pod/Catalyst%3A%3AAction#METHODS-action). + +# SCRUBBING OUTPUT + +When you force debug with dump\_info=1, RenderView is capable of removing +classes from the objects in your stash. By default it will replace any +DBIx::Class ResultSource objects with the class name, which cleans up the +debug output considerably, but you can change what gets scrubbed by +setting a list of classes in +$c->config->{'Action::RenderView'}->{ignore\_classes}. +For instance: + +``` +$c->config->{'Action::RenderView'}->{ignore_classes} = []; +``` + +To disable the functionality. You can also set +config->{'Action::RenderView'}->{scrubber\_func} to change what it does with the +classes. For instance, this will undef it instead of putting in the +class name: + +```perl +$c->config->{'Action::RenderView'}->{scrubber_func} = sub { undef $_ }; +``` + +## Deprecation notice + +This plugin used to be configured by setting `$c->config->{debug}`. +That configuration key is still supported in this release, but is +deprecated, please use the ` 'Action::RenderView' ` namespace as shown +above for configuration in new code. + +# EXTENDING + +To add something to an `end` action that is called before rendering, +simply place it in the `end` method: + +```perl +sub end : ActionClass('RenderView') { + my ( $self, $c ) = @_; + # do stuff here; the RenderView action is called afterwards +} +``` + +To add things to an `end` action that are called _after_ rendering, +you can set it up like this: + +```perl +sub render : ActionClass('RenderView') { } + +sub end : Private { + my ( $self, $c ) = @_; + $c->forward('render'); + # do stuff here +} +``` + +# AUTHORS + +- Marcus Ramberg +- Florian Ragwitz + +# CONTRIBUTOR + +Graham Knop + +# COPYRIGHT AND LICENSE + +This software is copyright (c) 2006 - 2009 by Marcus Ramberg and Florian Ragwitz. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..4eed661 --- /dev/null +++ b/dist.ini @@ -0,0 +1,108 @@ +name = Catalyst-Action-RenderView +copyright_year = 2006 - 2009 +license = Perl_5 +author = Marcus Ramberg +author = Florian Ragwitz +copyright_holder = Marcus Ramberg and Florian Ragwitz + +;;; Gather +[Git::GatherDir] +exclude_filename = Makefile.PL +exclude_filename = META.json +exclude_filename = LICENSE +exclude_filename = README.md + +[GatherFile] +filename = .perlcriticrc + +;;; Metadata +[Git::Contributors] + +[MetaProvides::Package] + +[MetaResources] +bugtracker.url = https://github.com/perl-catalyst/Catalyst-Action-RenderView/issues +repository.url = https://github.com/perl-catalyst/Catalyst-Action-RenderView.git +repository.web = https://github.com/perl-catalyst/Catalyst-Action-RenderView +repository.type = git + +[PrereqsFile] + +[UseUnsafeInc] +dot_in_INC = 0 + +;;; Modification +[PodWeaver] +; authordep Pod::Weaver::Section::Contributors +; authordep Pod::Weaver::Plugin::StopWords + +;;; Extra Files +[License] +[MetaJSON] +[MetaYAML] +[Manifest] +[Pod2Readme] + +;;; Installer +[MakeMaker] + +[StaticInstall] +mode = on + +;;; Tests +[MetaTests] +[MojibakeTests] +[PodSyntaxTests] +[Test::CPAN::Changes] +[Substitute / RenameTestCPANChanges] +-version = 0.008 +file = xt/release/cpan-changes.t +filename_code = s{release}{author}; +[Test::ChangesHasContent] +[Test::Compile] +[Test::EOL] +[Test::Kwalitee] +filename = xt/author/kwalitee.t +[Test::MinimumVersion] +[Test::NoTabs] +[Test::Perl::Critic] +critic_config = .perlcriticrc +[Substitute / VerboseCritic] +file = xt/author/critic.t +code = s/ x!!.*;/;/; s/(-profile)/-verbose => 8, $1/; +[Test::Pod::Coverage::TrustMe] +[Test::PodSpelling] +[Test::Portability] +options = test_one_dot = 0 +[Test::ReportPrereqs] +[Test::Version] + +;;; Repo files +[CopyFilesFromRelease] +filename = Makefile.PL +filename = META.json +filename = LICENSE +[ReadmeAnyFromPod / ReadmeGFMInRoot] +phase = release + +[Regenerate::AfterReleasers] +plugin = CopyFilesFromRelease +plugin = ReadmeGFMInRoot + +;;; Release +[TestRelease] +[RunExtraTests] +[ConfirmRelease] +[UploadToCPAN] + +[Git::Check] +[Git::Remote::Check] +branch = master +[@Git::VersionManager] +-remove = Prereqs +commit_files_after_release = Makefile.PL +commit_files_after_release = META.json +commit_files_after_release = LICENSE +commit_files_after_release = README.md +NextRelease.format = %-6v %{yyyy-MM-dd}d%{ (TRIAL RELEASE)}T +[Git::Push] diff --git a/lib/Catalyst/Action/RenderView.pm b/lib/Catalyst/Action/RenderView.pm index 5de16ed..e167184 100644 --- a/lib/Catalyst/Action/RenderView.pm +++ b/lib/Catalyst/Action/RenderView.pm @@ -3,7 +3,7 @@ package Catalyst::Action::RenderView; use strict; use warnings; -our $VERSION = '0.16'; +our $VERSION = '0.17'; use base 'Catalyst::Action'; @@ -20,7 +20,7 @@ sub execute { $c->config->{'Action::RenderView'}->{ignore_classes} = ( ref($c->config->{'debug'}) eq 'HASH' ? $c->config->{'debug'}->{ignore_classes} : undef ) || [ qw/ - DBIx::Class::ResultSource::Table + DBIx::Class::ResultSource::Table DBIx::Class::ResultSourceHandle DateTime / ] unless exists $c->config->{'Action::RenderView'}->{ignore_classes}; @@ -58,6 +58,11 @@ sub execute { }; 1; +__END__ + +=pod + +=for stopwords 3xx ResultSource =head1 NAME @@ -99,17 +104,17 @@ See L. When you force debug with dump_info=1, RenderView is capable of removing classes from the objects in your stash. By default it will replace any -DBIx::Class resultsource objects with the class name, which cleans up the -debug output considerably, but you can change what gets scrubbed by -setting a list of classes in +DBIx::Class ResultSource objects with the class name, which cleans up the +debug output considerably, but you can change what gets scrubbed by +setting a list of classes in $c->config->{'Action::RenderView'}->{ignore_classes}. For instance: - $c->config->{'Action::RenderView'}->{ignore_classes} = []; - -To disable the functionality. You can also set -config->{'Action::RenderView'}->{scrubber_func} to change what it does with the -classes. For instance, this will undef it instead of putting in the + $c->config->{'Action::RenderView'}->{ignore_classes} = []; + +To disable the functionality. You can also set +config->{'Action::RenderView'}->{scrubber_func} to change what it does with the +classes. For instance, this will undef it instead of putting in the class name: $c->config->{'Action::RenderView'}->{scrubber_func} = sub { undef $_ }; @@ -117,8 +122,8 @@ class name: =head2 Deprecation notice This plugin used to be configured by setting C<< $c->config->{debug} >>. -That configuration key is still supported in this release, but is -deprecated, please use the C< 'Action::RenderView' > namespace as shown +That configuration key is still supported in this release, but is +deprecated, please use the C< 'Action::RenderView' > namespace as shown above for configuration in new code. =head1 EXTENDING @@ -127,8 +132,8 @@ To add something to an C action that is called before rendering, simply place it in the C method: sub end : ActionClass('RenderView') { - my ( $self, $c ) = @_; - # do stuff here; the RenderView action is called afterwards + my ( $self, $c ) = @_; + # do stuff here; the RenderView action is called afterwards } To add things to an C action that are called I rendering, @@ -136,28 +141,8 @@ you can set it up like this: sub render : ActionClass('RenderView') { } - sub end : Private { - my ( $self, $c ) = @_; - $c->forward('render'); - # do stuff here + sub end : Private { + my ( $self, $c ) = @_; + $c->forward('render'); + # do stuff here } - -=head1 AUTHORS - -Marcus Ramberg - -Florian Ragwitz Erafl@debian.orgE - -=head1 COPYRIGHT - -Copyright (c) 2006 - 2009 -the Catalyst::Action::RenderView L -as listed above. - -=head1 LICENSE - -This library is free software. You can redistribute it and/or modify it -under the same terms as Perl itself. - -=cut - diff --git a/prereqs.yml b/prereqs.yml new file mode 100644 index 0000000..d8bf018 --- /dev/null +++ b/prereqs.yml @@ -0,0 +1,9 @@ +runtime: + requires: + perl: 5.008005 + Catalyst::Runtime: 5.80030 + Data::Visitor: 0.24 + MRO::Compat: 0 +test: + requires: + Test::More: 0.88 diff --git a/t/02pod.t b/t/02pod.t deleted file mode 100644 index 1647794..0000000 --- a/t/02pod.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; - -eval "use Test::Pod 1.14"; -plan skip_all => 'Test::Pod 1.14 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; - -all_pod_files_ok(); diff --git a/t/03podcoverage.t b/t/03podcoverage.t deleted file mode 100644 index d91be5e..0000000 --- a/t/03podcoverage.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; - -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; - -all_pod_coverage_ok(); diff --git a/t/04live.t b/t/04live.t index 0e4d539..d8f9d95 100644 --- a/t/04live.t +++ b/t/04live.t @@ -1,74 +1,74 @@ -#!perl - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -use Test::More 0.88; -use Catalyst::Test 'TestApp'; - -run_tests(); - -done_testing; - -sub run_tests { - - # test first available view - { - my $expected = 'View'; - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_firstview' ); - - ok( my $response = request($request), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); - is( $response->code, 200, 'Response Code' ); - - is( $response->content, $expected, 'Content OK' ); - } - - # test view - { - my $expected = 'View'; - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_view' ); - - ok( my $response = request($request), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); - is( $response->code, 200, 'Response Code' ); - - is( $response->content, $expected, 'Content OK' ); - } - - # test skip view - { - my $expected = 'Skipped View'; - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_skipview' ); - - ok( my $response = request($request), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); - is( $response->code, 200, 'Response Code' ); - - is( $response->content, $expected, 'Content OK' ); - } - - # test X-Sendfile case - { - my $request = - HTTP::Request->new( GET => 'http://localhost:3000/test_definedbody_skipsview' ); - - ok( my $response = request($request), 'Request' ); - ok( $response->is_success, 'Response Successful 2xx' ); - is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); - is( $response->code, 200, 'Response Code' ); - - is( $response->content, '', 'Content OK' ); - is( $response->header('X-Sendfile'), '/some/file/path', 'X-Sendfile header present' ); - } - -} +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/lib"; + +use Test::More 0.88; +use Catalyst::Test 'TestApp'; + +run_tests(); + +done_testing; + +sub run_tests { + + # test first available view + { + my $expected = 'View'; + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_firstview' ); + + ok( my $response = request($request), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + is( $response->code, 200, 'Response Code' ); + + is( $response->content, $expected, 'Content OK' ); + } + + # test view + { + my $expected = 'View'; + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_view' ); + + ok( my $response = request($request), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + is( $response->code, 200, 'Response Code' ); + + is( $response->content, $expected, 'Content OK' ); + } + + # test skip view + { + my $expected = 'Skipped View'; + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_skipview' ); + + ok( my $response = request($request), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + is( $response->code, 200, 'Response Code' ); + + is( $response->content, $expected, 'Content OK' ); + } + + # test X-Sendfile case + { + my $request = + HTTP::Request->new( GET => 'http://localhost:3000/test_definedbody_skipsview' ); + + ok( my $response = request($request), 'Request' ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->header( 'Content-Type' ), 'text/html; charset=utf-8', 'Content Type' ); + is( $response->code, 200, 'Response Code' ); + + is( $response->content, '', 'Content OK' ); + is( $response->header('X-Sendfile'), '/some/file/path', 'X-Sendfile header present' ); + } + +} diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index 452e312..8463a89 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -1,12 +1,12 @@ -package TestApp; -use strict; -use warnings; -use Catalyst; - -use base qw/Catalyst/; - -__PACKAGE__->config( name => 'TestApp', root => '/some/dir' ); - -__PACKAGE__->setup; - -1; +package TestApp; +use strict; +use warnings; +use Catalyst; + +use base qw/Catalyst/; + +__PACKAGE__->config( name => 'TestApp', root => '/some/dir' ); + +__PACKAGE__->setup; + +1; diff --git a/t/lib/TestApp/View/TestView.pm b/t/lib/TestApp/View/TestView.pm index d596e15..e834045 100644 --- a/t/lib/TestApp/View/TestView.pm +++ b/t/lib/TestApp/View/TestView.pm @@ -1,10 +1,10 @@ -package TestApp::View::TestView; - -use base qw( Catalyst::View ); - -sub process { - my( $self, $c ) = @_; - $c->res->body( 'View' ); -} - +package TestApp::View::TestView; + +use base qw( Catalyst::View ); + +sub process { + my( $self, $c ) = @_; + $c->res->body( 'View' ); +} + 1; \ No newline at end of file diff --git a/weaver.ini b/weaver.ini new file mode 100644 index 0000000..e535f8e --- /dev/null +++ b/weaver.ini @@ -0,0 +1,12 @@ +[@CorePrep] +[-SingleEncoding] +[-StopWords] + +[Generic / NAME] + +[Leftovers] + +[Bugs] +[Authors] +[Contributors] +[Legal]