diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0169799..0000000 --- a/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -pm_to_blib -t/logs -*.old -Makefile -MANIFEST.bak -cover_db -blib -MYMETA.json -MYMETA.yml -Dancer2-Plugin-REST-* -.watsonrc diff --git a/.perlcriticrc b/.perlcriticrc deleted file mode 100644 index ff69073..0000000 --- a/.perlcriticrc +++ /dev/null @@ -1,57 +0,0 @@ -verbose = [%p] %m at %f line %l, near '%r'\n -severity = 2 - -# we don't want these POD rules -[-Documentation::RequirePodSections] - -# we want to be able to define short getters -[-Subroutines::RequireFinalReturn] - -# we use eval strings in Dancer for dynamic loading -[-BuiltinFunctions::ProhibitStringyEval] - -# we use magic closure bindings in some places -[-TestingAndDebugging::ProhibitNoStrict] -[-TestingAndDebugging::ProhibitNoWarnings] - -# We're not under CVS! :) -[-Miscellanea::RequireRcsKeywords] - -# only Dancer.pm matters here -[-Modules::RequireVersionVar] - -# we use postifx controls -[-ControlStructures::ProhibitPostfixControls] - -# we provide syntactic sugar, so we need them -[-Subroutines::ProhibitSubroutinePrototypes] - -# we check $@ -[-ErrorHandling::RequireCheckingReturnValueOfEval] - -# we use $@ and $! -[-Variables::ProhibitPunctuationVars] - -# we don't check close -[-InputOutput::RequireCheckedClose] - -# I really don't think q{/} is more readable than '/'... -[-ValuesAndExpressions::ProhibitNoisyQuotes] - -# We don't care about POD links for now -[-Documentation::RequirePodLinksIncludeText] - -[-RegularExpressions::RequireExtendedFormatting] -minimum_regex_length_to_complain_about = 5 - -# we have name and log here -[-Subroutines::ProhibitBuiltinHomonyms] - -[-ValuesAndExpressions::ProhibitMagicNumbers] - -[-Subroutines::RequireArgUnpacking] - -[-Modules::ProhibitAutomaticExportation] - -[-ValuesAndExpressions::ProhibitCommaSeparatedStatements] -[-ControlStructures::ProhibitUnlessBlocks] diff --git a/.perltidyrc b/.perltidyrc deleted file mode 100644 index 5866d16..0000000 --- a/.perltidyrc +++ /dev/null @@ -1,34 +0,0 @@ --l=79 # Max line width is 79 cols --i=4 # Indent level is 4 cols --ci=4 # Continuation indent is 4 cols - --b --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 --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 - -# for the up-tight folk :) --pt=2 # High parenthesis tightness --bt=2 # High brace tightness --sbt=2 # High square bracket tightness - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64242b8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: perl - -perl: - - "5.18" - - "5.14" - - "5.10" - -notifications: - irc: - channels: - - "irc.perl.org#dancer" - template: - - "%{branch}#%{build_number} by %{author}: %{message} (%{build_url})" - on_success: change - on_failure: always - use_notice: true - -install: - - cpanm . - -script: - - make test diff --git a/Build.PL b/Build.PL new file mode 100644 index 0000000..551e33c --- /dev/null +++ b/Build.PL @@ -0,0 +1,75 @@ + +# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.020. +use strict; +use warnings; + +use Module::Build 0.28; + + +my %module_build_args = ( + "build_requires" => { + "Module::Build" => "0.28" + }, + "configure_requires" => { + "Module::Build" => "0.28" + }, + "dist_abstract" => "A plugin for writing RESTful apps with Dancer2", + "dist_author" => [ + "Dancer Core Developers" + ], + "dist_name" => "Dancer2-Plugin-REST", + "dist_version" => "0.25", + "license" => "perl", + "module_name" => "Dancer2::Plugin::REST", + "recommends" => {}, + "recursive_test_files" => 1, + "requires" => { + "Carp" => 0, + "Class::Load" => 0, + "Dancer2" => "0.149000_01", + "Dancer2::Plugin" => 0, + "Moo::Role" => 0, + "strict" => 0, + "warnings" => 0 + }, + "script_files" => [], + "test_requires" => { + "Dancer2::Core::Request" => 0, + "Data::Dumper" => 0, + "File::Spec" => 0, + "HTTP::Request::Common" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "JSON" => 0, + "Module::Runtime" => 0, + "Plack::Test" => 0, + "Test::More" => "0.88", + "perl" => "5.006" + } +); + + +my %fallback_build_requires = ( + "Dancer2::Core::Request" => 0, + "Data::Dumper" => 0, + "File::Spec" => 0, + "HTTP::Request::Common" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "JSON" => 0, + "Module::Build" => "0.28", + "Module::Runtime" => 0, + "Plack::Test" => 0, + "Test::More" => "0.88", + "perl" => "5.006" +); + + +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; diff --git a/Changes b/Changes index c4e8c48..be132d8 100644 --- a/Changes +++ b/Changes @@ -1,19 +1,12 @@ Revision history for Dancer2-Plugin-REST -{{$NEXT}} - [API CHANGES] - +0.25 2014-11-01 [BUG FIXES] - - Change tests to use Pack::Test instead of - the deprecated Dancer2::Test. (GH#3, Davs) - - [DOCUMENTATION] - - [ENHANCEMENTS] - - [NEW FEATURES] + - Change tests to use Pack::Test instead of the deprecated Dancer2::Test. + (GH#3, Davs) [STATISTICS] + - code churn: 4 files changed, 62 insertions(+), 41 deletions(-) 0.24 2014-09-01 [MISC] diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..176be07 --- /dev/null +++ b/INSTALL @@ -0,0 +1,44 @@ + +This is the Perl distribution Dancer2-Plugin-REST. + +Installing Dancer2-Plugin-REST is straightforward. + +## Installation with cpanm + +If you have cpanm, you only need one line: + + % cpanm Dancer2::Plugin::REST + +If you are installing into a system-wide directory, you may need to pass the +"-S" flag to cpanm, which uses sudo to install the module: + + % cpanm -S Dancer2::Plugin::REST + +## Installing with the CPAN shell + +Alternatively, if your CPAN shell is set up, you should just be able to do: + + % cpan Dancer2::Plugin::REST + +## Manual installation + +As a last resort, you can manually install it. Download the tarball, untar it, +then build it: + + % perl Build.PL + % ./Build && ./Build test + +Then install it: + + % ./Build install + +If you are installing into a system-wide directory, you may need to run: + + % sudo ./Build install + +## Documentation + +Dancer2-Plugin-REST documentation is available as POD. +You can run perldoc from a shell to read the documentation: + + % perldoc Dancer2::Plugin::REST diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5fe3728 --- /dev/null +++ b/LICENSE @@ -0,0 +1,379 @@ +This software is copyright (c) 2010 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) 2010 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, Fifth Floor, Boston, MA 02110-1301 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + +--- The Artistic License 1.0 --- + +This software is Copyright (c) 2010 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 + diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP deleted file mode 100644 index 30a1bd3..0000000 --- a/MANIFEST.SKIP +++ /dev/null @@ -1,15 +0,0 @@ -Dancer2-.* -t\/logs\/.*log -cover_db -\.git -blib -pm_to_blib -\.old$ -^Makefile$ -MANIFEST.bak -MANIFEST.SKIP -.perlcriticrc -.perltidyrc -MYMETA.* -dist.ini -.travis.yml diff --git a/META.json b/META.json new file mode 100644 index 0000000..e7f67a3 --- /dev/null +++ b/META.json @@ -0,0 +1,80 @@ +{ + "abstract" : "A plugin for writing RESTful apps with Dancer2", + "author" : [ + "Dancer Core Developers" + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.140640", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Dancer2-Plugin-REST", + "prereqs" : { + "build" : { + "requires" : { + "Module::Build" : "0.28" + } + }, + "configure" : { + "requires" : { + "Module::Build" : "0.28" + } + }, + "develop" : { + "requires" : { + "version" : "0.9901" + } + }, + "runtime" : { + "requires" : { + "Carp" : "0", + "Class::Load" : "0", + "Dancer2" : "0.149000_01", + "Dancer2::Plugin" : "0", + "Moo::Role" : "0", + "strict" : "0", + "warnings" : "0" + } + }, + "test" : { + "requires" : { + "Dancer2::Core::Request" : "0", + "Data::Dumper" : "0", + "File::Spec" : "0", + "HTTP::Request::Common" : "0", + "IO::Handle" : "0", + "IPC::Open3" : "0", + "JSON" : "0", + "Module::Runtime" : "0", + "Plack::Test" : "0", + "Test::More" : "0.88", + "perl" : "5.006" + } + } + }, + "provides" : { + "Dancer2::Plugin::REST" : { + "file" : "lib/Dancer2/Plugin/REST.pm", + "version" : "0.25" + } + }, + "release_status" : "stable", + "resources" : { + "bugtracker" : { + "web" : "https://github.com/perldancer/Dancer2-Plugin-REST/issues" + }, + "homepage" : "http://search.cpan.org/dist/Dancer2-Plugin-REST/", + "repository" : { + "type" : "git", + "url" : "https://github.com/perldancer/Dancer2-Plugin-REST.git", + "web" : "https://github.com/perldancer/Dancer2-Plugin-REST" + } + }, + "version" : "0.25", + "x_authority" : "cpan:SUKRIA" +} + diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..0f6d934 --- /dev/null +++ b/META.yml @@ -0,0 +1,44 @@ +--- +abstract: 'A plugin for writing RESTful apps with Dancer2' +author: + - 'Dancer Core Developers' +build_requires: + Dancer2::Core::Request: '0' + Data::Dumper: '0' + File::Spec: '0' + HTTP::Request::Common: '0' + IO::Handle: '0' + IPC::Open3: '0' + JSON: '0' + Module::Build: '0.28' + Module::Runtime: '0' + Plack::Test: '0' + Test::More: '0.88' + perl: '5.006' +configure_requires: + Module::Build: '0.28' +dynamic_config: 0 +generated_by: 'Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.140640' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Dancer2-Plugin-REST +provides: + Dancer2::Plugin::REST: + file: lib/Dancer2/Plugin/REST.pm + version: '0.25' +requires: + Carp: '0' + Class::Load: '0' + Dancer2: 0.149000_01 + Dancer2::Plugin: '0' + Moo::Role: '0' + strict: '0' + warnings: '0' +resources: + bugtracker: https://github.com/perldancer/Dancer2-Plugin-REST/issues + homepage: http://search.cpan.org/dist/Dancer2-Plugin-REST/ + repository: https://github.com/perldancer/Dancer2-Plugin-REST.git +version: '0.25' +x_authority: cpan:SUKRIA diff --git a/README b/README index e1c8f7b..7d80759 100644 --- a/README +++ b/README @@ -1,5 +1,129 @@ -Dancer::Plugin::REST +NAME + Dancer2::Plugin::REST - A plugin for writing RESTful apps with Dancer2 -A Dancer plugin to transform your Dancer app in a RESTful -webservice. +VERSION + version 0.25 + +DESCRIPTION + This plugin helps you write a RESTful webservice with Dancer2. + +SYNOPSYS + package MyWebService; + + use Dancer2; + use Dancer2::Plugin::REST; + + prepare_serializer_for_format; + + get '/user/:id.:format' => sub { + User->find(params->{id}); + }; + + get qr{^/user/(?\d+)\.(?\w+)} => sub { + User->find(captures->{id}); + }; + + # curl http://mywebservice/user/42.json + { "id": 42, "name": "John Foo", email: "john.foo@example.com"} + + # curl http://mywebservice/user/42.yml + -- + id: 42 + name: "John Foo" + email: "john.foo@example.com" + +CONFIGURATION + serializers + The default format serializer hash which maps a given ":format" to a + "Dancer2::Serializer::*" serializer. Unless overriden in the + configuration, it defaults to: + + serializers: + json: JSON + yml: YAML + dump: Dumper + +KEYWORDS + prepare_serializer_for_format + When this pragma is used, a before filter is set by the plugin to + automatically change the serializer when a format is detected in the + URI. + + That means that each route you define with a :format param or captures + token will trigger a serializer definition, if the format is known. + + This lets you define all the REST actions you like as regular Dancer2 + route handlers, without explicitly handling the outgoing data format. + + Regexp routes will use the file-extension from captures->{'format'} to + determine the serialization format. + + resource + This keyword lets you declare a resource your application will handle. + + resource user => + get => sub { # return user where id = params->{id} }, + create => sub { # create a new user with params->{user} }, + delete => sub { # delete user where id = params->{id} }, + update => sub { # update user with params->{user} }; + + # this defines the following routes: + # GET /user/:id + # GET /user/:id.:format + # POST /user + # POST /user.:format + # DELETE /user/:id + # DELETE /user/:id.:format + # PUT /user/:id + # PUT /user/:id.:format + + helpers + Some helpers are available. This helper will set an appropriate HTTP + status for you. + + status_ok + status_ok({users => {...}}); + + Set the HTTP status to 200 + + status_created + status_created({users => {...}}); + + Set the HTTP status to 201 + + status_accepted + status_accepted({users => {...}}); + + Set the HTTP status to 202 + + status_bad_request + status_bad_request("user foo can't be found"); + + Set the HTTP status to 400. This function as for argument a scalar that + will be used under the key error. + + status_not_found + status_not_found("users doesn't exists"); + + Set the HTTP status to 404. This function as for argument a scalar that + will be used under the key error. + +LICENCE + This module is released under the same terms as Perl itself. + +AUTHORS + This module has been written by Alexis Sukrieh "" and + Franck Cuny. + +SEE ALSO + Dancer2 + +AUTHOR + Dancer Core Developers + +COPYRIGHT AND LICENSE + This software is copyright (c) 2010 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. diff --git a/README.mkdn b/README.mkdn new file mode 100644 index 0000000..dbf4084 --- /dev/null +++ b/README.mkdn @@ -0,0 +1,144 @@ +# NAME + +Dancer2::Plugin::REST - A plugin for writing RESTful apps with Dancer2 + +# VERSION + +version 0.25 + +# DESCRIPTION + +This plugin helps you write a RESTful webservice with Dancer2. + +# SYNOPSYS + + package MyWebService; + + use Dancer2; + use Dancer2::Plugin::REST; + + prepare_serializer_for_format; + + get '/user/:id.:format' => sub { + User->find(params->{id}); + }; + + get qr{^/user/(?\d+)\.(?\w+)} => sub { + User->find(captures->{id}); + }; + + # curl http://mywebservice/user/42.json + { "id": 42, "name": "John Foo", email: "john.foo@example.com"} + + # curl http://mywebservice/user/42.yml + -- + id: 42 + name: "John Foo" + email: "john.foo@example.com" + +# CONFIGURATION + +## serializers + +The default format serializer hash which maps a given `:format` to +a `Dancer2::Serializer::*` serializer. Unless overriden in the +configuration, it defaults to: + + serializers: + json: JSON + yml: YAML + dump: Dumper + +# KEYWORDS + +## prepare\_serializer\_for\_format + +When this pragma is used, a before filter is set by the plugin to automatically +change the serializer when a format is detected in the URI. + +That means that each route you define with a **:format** param or captures token +will trigger a serializer definition, if the format is known. + +This lets you define all the REST actions you like as regular Dancer2 route +handlers, without explicitly handling the outgoing data format. + +Regexp routes will use the file-extension from captures->{'format'} to determine +the serialization format. + +## resource + +This keyword lets you declare a resource your application will handle. + + resource user => + get => sub { # return user where id = params->{id} }, + create => sub { # create a new user with params->{user} }, + delete => sub { # delete user where id = params->{id} }, + update => sub { # update user with params->{user} }; + + # this defines the following routes: + # GET /user/:id + # GET /user/:id.:format + # POST /user + # POST /user.:format + # DELETE /user/:id + # DELETE /user/:id.:format + # PUT /user/:id + # PUT /user/:id.:format + +## helpers + +Some helpers are available. This helper will set an appropriate HTTP status for you. + +### status\_ok + + status_ok({users => {...}}); + +Set the HTTP status to 200 + +### status\_created + + status_created({users => {...}}); + +Set the HTTP status to 201 + +### status\_accepted + + status_accepted({users => {...}}); + +Set the HTTP status to 202 + +### status\_bad\_request + + status_bad_request("user foo can't be found"); + +Set the HTTP status to 400. This function as for argument a scalar that will be used under the key **error**. + +### status\_not\_found + + status_not_found("users doesn't exists"); + +Set the HTTP status to 404. This function as for argument a scalar that will be used under the key **error**. + +# LICENCE + +This module is released under the same terms as Perl itself. + +# AUTHORS + +This module has been written by Alexis Sukrieh `` and Franck +Cuny. + +# SEE ALSO + +[Dancer2](https://metacpan.org/pod/Dancer2) [http://en.wikipedia.org/wiki/Representational\_State\_Transfer](http://en.wikipedia.org/wiki/Representational_State_Transfer) + +# AUTHOR + +Dancer Core Developers + +# COPYRIGHT AND LICENSE + +This software is copyright (c) 2010 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. diff --git a/SIGNATURE b/SIGNATURE new file mode 100644 index 0000000..e69de29 diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..41d4992 --- /dev/null +++ b/cpanfile @@ -0,0 +1,33 @@ +requires "Carp" => "0"; +requires "Class::Load" => "0"; +requires "Dancer2" => "0.149000_01"; +requires "Dancer2::Plugin" => "0"; +requires "Moo::Role" => "0"; +requires "strict" => "0"; +requires "warnings" => "0"; + +on 'build' => sub { + requires "Module::Build" => "0.28"; +}; + +on 'test' => sub { + requires "Dancer2::Core::Request" => "0"; + requires "Data::Dumper" => "0"; + requires "File::Spec" => "0"; + requires "HTTP::Request::Common" => "0"; + requires "IO::Handle" => "0"; + requires "IPC::Open3" => "0"; + requires "JSON" => "0"; + requires "Module::Runtime" => "0"; + requires "Plack::Test" => "0"; + requires "Test::More" => "0.88"; + requires "perl" => "5.006"; +}; + +on 'configure' => sub { + requires "Module::Build" => "0.28"; +}; + +on 'develop' => sub { + requires "version" => "0.9901"; +}; diff --git a/dist.ini b/dist.ini deleted file mode 100644 index 67a63e2..0000000 --- a/dist.ini +++ /dev/null @@ -1,14 +0,0 @@ -name = Dancer2-Plugin-REST -author = Dancer Core Developers -license = Perl_5 -copyright_holder = Alexis Sukrieh -copyright_year = 2010 -main_module = lib/Dancer2/Plugin/REST.pm - -[@Filter] --bundle=@YANICK --remove=ContributorsFromGit --remove=ContributorsFile --remove=Covenant -authority = cpan:SUKRIA -NextVersion::Semantic.format=%d.%02d diff --git a/doap.xml b/doap.xml new file mode 100644 index 0000000..1710aee --- /dev/null +++ b/doap.xml @@ -0,0 +1,102 @@ + + + Dancer2-Plugin-REST + A plugin for writing RESTful apps with Dancer2 + + + + + + + + + + + + + + + 0.05 + 2011-03-04 + + + + + 0.06 + 2011-05-28 + + + + + 0.07 + 2011-11-01 + + + + + 0.08 + 2013-02-24 + + + + + 0.09 + 2013-02-25 + + + + + 0.10 + 2013-07-03 + + + + + 0.11 + 2013-07-03 + + + + + 0.12 + 2013-07-06 + + + + + 0.20 + 2013-10-03 + + + + + 0.21 + 2013-12-07 + + + + + 0.22 + 2014-06-05 + + + + + 0.23_00 + 2014-08-13 + + + + + 0.24 + 2014-09-01 + + + Perl + diff --git a/lib/Dancer2/Plugin/REST.pm b/lib/Dancer2/Plugin/REST.pm index 7df596d..bd63e98 100644 --- a/lib/Dancer2/Plugin/REST.pm +++ b/lib/Dancer2/Plugin/REST.pm @@ -1,6 +1,9 @@ package Dancer2::Plugin::REST; +BEGIN { + $Dancer2::Plugin::REST::AUTHORITY = 'cpan:SUKRIA'; +} # ABSTRACT: A plugin for writing RESTful apps with Dancer2 - +$Dancer2::Plugin::REST::VERSION = '0.25'; use strict; use warnings; @@ -182,6 +185,19 @@ __END__ =pod +=encoding UTF-8 + +=head1 NAME + +Dancer2::Plugin::REST - A plugin for writing RESTful apps with Dancer2 + +=head1 VERSION + +version 0.25 + +=head1 DESCRIPTION + +This plugin helps you write a RESTful webservice with Dancer2. =head1 SYNOPSYS @@ -209,10 +225,6 @@ __END__ name: "John Foo" email: "john.foo@example.com" -=head1 DESCRIPTION - -This plugin helps you write a RESTful webservice with Dancer2. - =head1 CONFIGURATION =head2 serializers @@ -309,4 +321,15 @@ Cuny. L L +=head1 AUTHOR + +Dancer Core Developers + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2010 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 diff --git a/t/00-compile.t b/t/00-compile.t new file mode 100644 index 0000000..115f68b --- /dev/null +++ b/t/00-compile.t @@ -0,0 +1,50 @@ +use 5.006; +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.046 + +use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); + + + +my @module_files = ( + 'Dancer2/Plugin/REST.pm' +); + + + +# no fake home requested + +my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; + +use File::Spec; +use IPC::Open3; +use IO::Handle; + +open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; + +my @warnings; +for my $lib (@module_files) +{ + # see L + my $stderr = IO::Handle->new; + + my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); + binmode $stderr, ':crlf' if $^O eq 'MSWin32'; + my @_warnings = <$stderr>; + waitpid($pid, 0); + is($?, 0, "$lib loaded ok"); + + if (@_warnings) + { + warn @_warnings; + push @warnings, @_warnings; + } +} + + + +is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', explain \@warnings if $ENV{AUTHOR_TESTING}; + + diff --git a/t/000-report-versions-tiny.t b/t/000-report-versions-tiny.t new file mode 100644 index 0000000..a5d4877 --- /dev/null +++ b/t/000-report-versions-tiny.t @@ -0,0 +1,87 @@ +use strict; +use warnings; +use Test::More 0.88; +# This is a relatively nice way to avoid Test::NoWarnings breaking our +# expectations by adding extra tests, without using no_plan. It also helps +# avoid any other test module that feels introducing random tests, or even +# test plans, is a nice idea. +our $success = 0; +END { $success && done_testing; } + +# List our own version used to generate this +my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n"; + +eval { # no excuses! + # report our Perl details + my $want = '5.006'; + $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; +}; +defined($@) and diag("$@"); + +# Now, our module version dependencies: +sub pmver { + my ($module, $wanted) = @_; + $wanted = " (want $wanted)"; + my $pmver; + eval "require $module;"; + if ($@) { + if ($@ =~ m/Can't locate .* in \@INC/) { + $pmver = 'module not found.'; + } else { + diag("${module}: $@"); + $pmver = 'died during require.'; + } + } else { + my $version; + eval { $version = $module->VERSION; }; + if ($@) { + diag("${module}: $@"); + $pmver = 'died during VERSION check.'; + } elsif (defined $version) { + $pmver = "$version"; + } else { + $pmver = ''; + } + } + + # So, we should be good, right? + return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); +} + +eval { $v .= pmver('Carp','any version') }; +eval { $v .= pmver('Class::Load','any version') }; +eval { $v .= pmver('Dancer2','0.149000_01') }; +eval { $v .= pmver('Dancer2::Core::Request','any version') }; +eval { $v .= pmver('Dancer2::Plugin','any version') }; +eval { $v .= pmver('Data::Dumper','any version') }; +eval { $v .= pmver('File::Spec','any version') }; +eval { $v .= pmver('HTTP::Request::Common','any version') }; +eval { $v .= pmver('IO::Handle','any version') }; +eval { $v .= pmver('IPC::Open3','any version') }; +eval { $v .= pmver('JSON','any version') }; +eval { $v .= pmver('Module::Build','0.28') }; +eval { $v .= pmver('Module::Runtime','any version') }; +eval { $v .= pmver('Moo::Role','any version') }; +eval { $v .= pmver('Plack::Test','any version') }; +eval { $v .= pmver('Test::More','0.88') }; +eval { $v .= pmver('strict','any version') }; +eval { $v .= pmver('warnings','any version') }; + + +# All done. +$v .= <<'EOT'; + +Thanks for using my code. I hope it works for you. +If not, please try and include this output in the bug report. +That will help me reproduce the issue and solve your problem. + +EOT + +diag($v); +ok(1, "we really didn't test anything, just reporting data"); +$success = 1; + +# Work around another nasty module on CPAN. :/ +no warnings 'once'; +$Template::Test::NO_FLUSH = 1; +exit 0; diff --git a/xt/release/unused-vars.t b/xt/release/unused-vars.t new file mode 100644 index 0000000..e601076 --- /dev/null +++ b/xt/release/unused-vars.t @@ -0,0 +1,14 @@ +#!perl + +use Test::More 0.96 tests => 1; +eval { require Test::Vars }; + +SKIP: { + skip 1 => 'Test::Vars required for testing for unused vars' + if $@; + Test::Vars->import; + + subtest 'unused vars' => sub { +all_vars_ok(); + }; +};