diff options
author | Nick Morrott <nickm@debian.org> | 2020-01-02 21:37:21 +0100 |
---|---|---|
committer | Nick Morrott <nickm@debian.org> | 2020-01-02 21:37:21 +0100 |
commit | a2dd68feea86a6630a7d1ce01c38136ca62f8c65 (patch) | |
tree | c896d027a997668c98c5784cab64b2c274f31804 | |
parent | a8581ac425aff009f6225e56b909d40c1ddf1c97 (diff) | |
parent | 2bd6a3e5e9522e7910755c4d86bdaab7fa216f1a (diff) |
Record libdancer2-perl (0.300000+dfsg-1) in archive suite sid
88 files changed, 750 insertions, 378 deletions
@@ -1,3 +1,36 @@ +0.300000 2019-12-23 23:55:09-06:00 America/Chicago + + [ BUG FIXES ] + * None + + [ ENHANCEMENTS ] + * GH #1127, GH #1476: Route parameters with types (Peter Mottram - + SysPete) + + [ DOCUMENTATION ] + * None + +0.208002 2019-12-14 16:08:46-05:00 America/New_York + + [ BUG FIXES ] + * GH#1527: Update travis dist to 'trusty' (Sergiy Borodych) + + [ ENHANCEMENTS ] + * GH #1525: Remove use of Return::MultiLevel, and implement stack frame + jumping manually (Graham Knop) + + [ DOCUMENTATION ] + * GH #1505: Fix Flaskr link (Mohammad S Anwar) + * GH #1506, 1520: Explain what add_route() does with args (Tom Hukins) + * GH #1519: Fix Template Toolkit config docs (Tom Hukins) + * GH #1522: Fix itetare typo (Stefan Hornburg - Racke) + * GH #1523: Fix typo in Template Toolkit documentation (Mike Katasonov) + * GH #1524: Fix error in configuration documentation (Tom Hukins) + * GH #1526: Mention that TT2 config start_tag/end_tag need escaping + (Chris White) + * GH #1528: Note that"Engines" key must be merged in config.yml (Chris + White) + 0.208001 2019-08-04 21:06:25-04:00 America/New_York [ BUG FIXES ] @@ -269,6 +269,7 @@ t/lib/SubApp1.pm t/lib/SubApp2.pm t/lib/TestApp.pm t/lib/TestPod.pm +t/lib/TestTypeLibrary.pm t/lib/poc.pm t/lib/poc2.pm t/log_die_before_hook.t @@ -100,7 +100,6 @@ "Plack::Middleware::FixMissingBodyInRedirect" : "0", "Plack::Middleware::RemoveRedundantBody" : "0", "Ref::Util" : "0", - "Return::MultiLevel" : "0", "Role::Tiny" : "2.000000", "Safe::Isa" : "0", "Sub::Quote" : "0", @@ -142,231 +141,231 @@ "provides" : { "Dancer2" : { "file" : "lib/Dancer2.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::CLI" : { "file" : "lib/Dancer2/CLI.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::CLI::Command::gen" : { "file" : "lib/Dancer2/CLI/Command/gen.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::CLI::Command::version" : { "file" : "lib/Dancer2/CLI/Command/version.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core" : { "file" : "lib/Dancer2/Core.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::App" : { "file" : "lib/Dancer2/Core/App.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Cookie" : { "file" : "lib/Dancer2/Core/Cookie.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::DSL" : { "file" : "lib/Dancer2/Core/DSL.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Dispatcher" : { "file" : "lib/Dancer2/Core/Dispatcher.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Error" : { "file" : "lib/Dancer2/Core/Error.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Factory" : { "file" : "lib/Dancer2/Core/Factory.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::HTTP" : { "file" : "lib/Dancer2/Core/HTTP.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Hook" : { "file" : "lib/Dancer2/Core/Hook.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::MIME" : { "file" : "lib/Dancer2/Core/MIME.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Request" : { "file" : "lib/Dancer2/Core/Request.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Request::Upload" : { "file" : "lib/Dancer2/Core/Request/Upload.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Response" : { "file" : "lib/Dancer2/Core/Response.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Response::Delayed" : { "file" : "lib/Dancer2/Core/Response/Delayed.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::ConfigReader" : { "file" : "lib/Dancer2/Core/Role/ConfigReader.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::DSL" : { "file" : "lib/Dancer2/Core/Role/DSL.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::Engine" : { "file" : "lib/Dancer2/Core/Role/Engine.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::Handler" : { "file" : "lib/Dancer2/Core/Role/Handler.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::HasLocation" : { "file" : "lib/Dancer2/Core/Role/HasLocation.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::Hookable" : { "file" : "lib/Dancer2/Core/Role/Hookable.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::Logger" : { "file" : "lib/Dancer2/Core/Role/Logger.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::Serializer" : { "file" : "lib/Dancer2/Core/Role/Serializer.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::SessionFactory" : { "file" : "lib/Dancer2/Core/Role/SessionFactory.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::SessionFactory::File" : { "file" : "lib/Dancer2/Core/Role/SessionFactory/File.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::StandardResponses" : { "file" : "lib/Dancer2/Core/Role/StandardResponses.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Role::Template" : { "file" : "lib/Dancer2/Core/Role/Template.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Route" : { "file" : "lib/Dancer2/Core/Route.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Runner" : { "file" : "lib/Dancer2/Core/Runner.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Session" : { "file" : "lib/Dancer2/Core/Session.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Time" : { "file" : "lib/Dancer2/Core/Time.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Core::Types" : { "file" : "lib/Dancer2/Core/Types.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::FileUtils" : { "file" : "lib/Dancer2/FileUtils.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Handler::AutoPage" : { "file" : "lib/Dancer2/Handler/AutoPage.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Handler::File" : { "file" : "lib/Dancer2/Handler/File.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::Capture" : { "file" : "lib/Dancer2/Logger/Capture.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::Capture::Trap" : { "file" : "lib/Dancer2/Logger/Capture/Trap.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::Console" : { "file" : "lib/Dancer2/Logger/Console.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::Diag" : { "file" : "lib/Dancer2/Logger/Diag.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::File" : { "file" : "lib/Dancer2/Logger/File.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::Note" : { "file" : "lib/Dancer2/Logger/Note.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Logger::Null" : { "file" : "lib/Dancer2/Logger/Null.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Plugin" : { "file" : "lib/Dancer2/Plugin.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Serializer::Dumper" : { "file" : "lib/Dancer2/Serializer/Dumper.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Serializer::JSON" : { "file" : "lib/Dancer2/Serializer/JSON.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Serializer::Mutable" : { "file" : "lib/Dancer2/Serializer/Mutable.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Serializer::YAML" : { "file" : "lib/Dancer2/Serializer/YAML.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Session::Simple" : { "file" : "lib/Dancer2/Session/Simple.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Session::YAML" : { "file" : "lib/Dancer2/Session/YAML.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Template::Implementation::ForkedTiny" : { "file" : "lib/Dancer2/Template/Implementation/ForkedTiny.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Template::Simple" : { "file" : "lib/Dancer2/Template/Simple.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Template::TemplateToolkit" : { "file" : "lib/Dancer2/Template/TemplateToolkit.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Template::Tiny" : { "file" : "lib/Dancer2/Template/Tiny.pm", - "version" : "0.208001" + "version" : "0.300000" }, "Dancer2::Test" : { "file" : "lib/Dancer2/Test.pm", - "version" : "0.208001" + "version" : "0.300000" } }, "release_status" : "stable", @@ -383,8 +382,8 @@ "x_IRC" : "irc://irc.perl.org/#dancer", "x_WebIRC" : "https://chat.mibbit.com/#dancer@irc.perl.org" }, - "version" : "0.208001", - "x_generated_by_perl" : "v5.28.1", - "x_serialization_backend" : "Cpanel::JSON::XS version 4.12" + "version" : "0.300000", + "x_generated_by_perl" : "v5.28.2", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.18" } @@ -33,175 +33,175 @@ name: Dancer2 provides: Dancer2: file: lib/Dancer2.pm - version: '0.208001' + version: '0.300000' Dancer2::CLI: file: lib/Dancer2/CLI.pm - version: '0.208001' + version: '0.300000' Dancer2::CLI::Command::gen: file: lib/Dancer2/CLI/Command/gen.pm - version: '0.208001' + version: '0.300000' Dancer2::CLI::Command::version: file: lib/Dancer2/CLI/Command/version.pm - version: '0.208001' + version: '0.300000' Dancer2::Core: file: lib/Dancer2/Core.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::App: file: lib/Dancer2/Core/App.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Cookie: file: lib/Dancer2/Core/Cookie.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::DSL: file: lib/Dancer2/Core/DSL.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Dispatcher: file: lib/Dancer2/Core/Dispatcher.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Error: file: lib/Dancer2/Core/Error.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Factory: file: lib/Dancer2/Core/Factory.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::HTTP: file: lib/Dancer2/Core/HTTP.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Hook: file: lib/Dancer2/Core/Hook.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::MIME: file: lib/Dancer2/Core/MIME.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Request: file: lib/Dancer2/Core/Request.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Request::Upload: file: lib/Dancer2/Core/Request/Upload.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Response: file: lib/Dancer2/Core/Response.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Response::Delayed: file: lib/Dancer2/Core/Response/Delayed.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::ConfigReader: file: lib/Dancer2/Core/Role/ConfigReader.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::DSL: file: lib/Dancer2/Core/Role/DSL.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::Engine: file: lib/Dancer2/Core/Role/Engine.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::Handler: file: lib/Dancer2/Core/Role/Handler.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::HasLocation: file: lib/Dancer2/Core/Role/HasLocation.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::Hookable: file: lib/Dancer2/Core/Role/Hookable.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::Logger: file: lib/Dancer2/Core/Role/Logger.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::Serializer: file: lib/Dancer2/Core/Role/Serializer.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::SessionFactory: file: lib/Dancer2/Core/Role/SessionFactory.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::SessionFactory::File: file: lib/Dancer2/Core/Role/SessionFactory/File.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::StandardResponses: file: lib/Dancer2/Core/Role/StandardResponses.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Role::Template: file: lib/Dancer2/Core/Role/Template.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Route: file: lib/Dancer2/Core/Route.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Runner: file: lib/Dancer2/Core/Runner.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Session: file: lib/Dancer2/Core/Session.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Time: file: lib/Dancer2/Core/Time.pm - version: '0.208001' + version: '0.300000' Dancer2::Core::Types: file: lib/Dancer2/Core/Types.pm - version: '0.208001' + version: '0.300000' Dancer2::FileUtils: file: lib/Dancer2/FileUtils.pm - version: '0.208001' + version: '0.300000' Dancer2::Handler::AutoPage: file: lib/Dancer2/Handler/AutoPage.pm - version: '0.208001' + version: '0.300000' Dancer2::Handler::File: file: lib/Dancer2/Handler/File.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::Capture: file: lib/Dancer2/Logger/Capture.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::Capture::Trap: file: lib/Dancer2/Logger/Capture/Trap.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::Console: file: lib/Dancer2/Logger/Console.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::Diag: file: lib/Dancer2/Logger/Diag.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::File: file: lib/Dancer2/Logger/File.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::Note: file: lib/Dancer2/Logger/Note.pm - version: '0.208001' + version: '0.300000' Dancer2::Logger::Null: file: lib/Dancer2/Logger/Null.pm - version: '0.208001' + version: '0.300000' Dancer2::Plugin: file: lib/Dancer2/Plugin.pm - version: '0.208001' + version: '0.300000' Dancer2::Serializer::Dumper: file: lib/Dancer2/Serializer/Dumper.pm - version: '0.208001' + version: '0.300000' Dancer2::Serializer::JSON: file: lib/Dancer2/Serializer/JSON.pm - version: '0.208001' + version: '0.300000' Dancer2::Serializer::Mutable: file: lib/Dancer2/Serializer/Mutable.pm - version: '0.208001' + version: '0.300000' Dancer2::Serializer::YAML: file: lib/Dancer2/Serializer/YAML.pm - version: '0.208001' + version: '0.300000' Dancer2::Session::Simple: file: lib/Dancer2/Session/Simple.pm - version: '0.208001' + version: '0.300000' Dancer2::Session::YAML: file: lib/Dancer2/Session/YAML.pm - version: '0.208001' + version: '0.300000' Dancer2::Template::Implementation::ForkedTiny: file: lib/Dancer2/Template/Implementation/ForkedTiny.pm - version: '0.208001' + version: '0.300000' Dancer2::Template::Simple: file: lib/Dancer2/Template/Simple.pm - version: '0.208001' + version: '0.300000' Dancer2::Template::TemplateToolkit: file: lib/Dancer2/Template/TemplateToolkit.pm - version: '0.208001' + version: '0.300000' Dancer2::Template::Tiny: file: lib/Dancer2/Template/Tiny.pm - version: '0.208001' + version: '0.300000' Dancer2::Test: file: lib/Dancer2/Test.pm - version: '0.208001' + version: '0.300000' recommends: CGI::Deurl::XS: '0' Class::XSAccessor: '0' @@ -251,7 +251,6 @@ requires: Plack::Middleware::FixMissingBodyInRedirect: '0' Plack::Middleware::RemoveRedundantBody: '0' Ref::Util: '0' - Return::MultiLevel: '0' Role::Tiny: '2.000000' Safe::Isa: '0' Sub::Quote: '0' @@ -270,6 +269,6 @@ resources: bugtracker: https://github.com/PerlDancer/Dancer2/issues homepage: http://perldancer.org/ repository: git://github.com/PerlDancer/Dancer2.git -version: '0.208001' -x_generated_by_perl: v5.28.1 +version: '0.300000' +x_generated_by_perl: v5.28.2 x_serialization_backend: 'YAML::Tiny version 1.73' diff --git a/Makefile.PL b/Makefile.PL index 2c596feb..aedacf2f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -65,7 +65,6 @@ my %WriteMakefileArgs = ( "Plack::Middleware::FixMissingBodyInRedirect" => 0, "Plack::Middleware::RemoveRedundantBody" => 0, "Ref::Util" => 0, - "Return::MultiLevel" => 0, "Role::Tiny" => "2.000000", "Safe::Isa" => 0, "Sub::Quote" => 0, @@ -93,7 +92,7 @@ my %WriteMakefileArgs = ( "Test::Fatal" => 0, "Test::More" => "0.92" }, - "VERSION" => "0.208001", + "VERSION" => "0.300000", "test" => { "TESTS" => "t/*.t t/classes/Dancer2-Core-Factory/*.t t/classes/Dancer2-Core-Hook/*.t t/classes/Dancer2-Core-Request/*.t t/classes/Dancer2-Core-Response-Delayed/*.t t/classes/Dancer2-Core-Response/*.t t/classes/Dancer2-Core-Role-Engine/*.t t/classes/Dancer2-Core-Role-Handler/*.t t/classes/Dancer2-Core-Role-HasLocation/*.t t/classes/Dancer2-Core-Role-Serializer/*.t t/classes/Dancer2-Core-Role-StandardResponses/*.t t/classes/Dancer2-Core-Route/*.t t/classes/Dancer2-Core-Runner/*.t t/classes/Dancer2-Core/*.t t/classes/Dancer2/*.t t/dsl/*.t t/examples/*.t t/issues/*.t t/issues/gh-1013/*.t t/issues/gh-1046/*.t t/issues/gh-1216/*.t t/issues/gh-1226/*.t t/issues/gh-1230/*.t t/issues/gh-639/fails/*.t t/issues/gh-639/succeeds/*.t t/issues/gh-650/*.t t/issues/gh-975/*.t t/issues/memleak/*.t t/plugin2/*.t t/roles/*.t t/route-pod-coverage/*.t t/scope_problems/*.t t/template_tiny/*.t" } @@ -140,7 +139,6 @@ my %FallbackPrereqs = ( "Plack::Middleware::FixMissingBodyInRedirect" => 0, "Plack::Middleware::RemoveRedundantBody" => 0, "Ref::Util" => 0, - "Return::MultiLevel" => 0, "Role::Tiny" => "2.000000", "Safe::Isa" => 0, "Sub::Quote" => 0, @@ -32,7 +32,6 @@ requires 'Plack::Middleware::FixMissingBodyInRedirect'; requires 'Plack::Middleware::RemoveRedundantBody'; requires 'POSIX'; requires 'Ref::Util'; -requires 'Return::MultiLevel'; requires 'Role::Tiny', '2.000000'; requires 'Safe::Isa'; requires 'Sub::Quote'; diff --git a/debian/changelog b/debian/changelog index 07f60da8..5ee7386f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,39 @@ +libdancer2-perl (0.300000+dfsg-1) unstable; urgency=medium + + * Team upload + + * New upstream version 0.300000+dfsg + + -- Nick Morrott <nickm@debian.org> Thu, 02 Jan 2020 20:37:21 +0000 + +libdancer2-perl (0.208002+dfsg-1) unstable; urgency=medium + + * Team upload + + * New upstream version 0.208002+dfsg + * d/control: + - Declare compliance with Debian Policy 4.4.1 + - Add Rules-Requires-Root field + - Refresh (build) dependencies + - Annotate test-only build dependencies with <!nocheck> + - Add more test libraries to improve coverage + * d/copyright: + - Reorder header stanza + * d/docs: + - Include upstream GitGuide + * d/lintian-overrides: + - Refresh overrides for dancer2 CLI script + * d/patches: + - Refresh patches (offset) + * d/s/lintian-overrides: + - Drop unused source-contains-empty-directory override + * d/u/metadata: + - Add Bug-Submit field; drop deprecated Contact, Name fields + * d/watch: + - Migrate to version 4 watch file format + + -- Nick Morrott <nickm@debian.org> Mon, 16 Dec 2019 21:52:27 +0000 + libdancer2-perl (0.208001+dfsg-1) unstable; urgency=medium * Team upload diff --git a/debian/control b/debian/control index 03e460ab..66812844 100644 --- a/debian/control +++ b/debian/control @@ -5,51 +5,54 @@ Section: perl Testsuite: autopkgtest-pkg-perl Priority: optional Build-Depends: debhelper-compat (= 12) -Build-Depends-Indep: libapp-cmd-perl, - libcapture-tiny-perl, - libclone-perl, - libconfig-any-perl, - libcpan-meta-requirements-perl, - libcrypt-urandom-perl, - libexporter-tiny-perl, - libfile-share-perl, +Build-Depends-Indep: libanyevent-perl <!nocheck>, + libapp-cmd-perl <!nocheck>, + libcapture-tiny-perl <!nocheck>, + libclone-perl <!nocheck>, + libconfig-any-perl <!nocheck>, + libcpan-meta-requirements-perl <!nocheck>, + libcrypt-urandom-perl <!nocheck>, + libexporter-tiny-perl <!nocheck>, + libfile-share-perl <!nocheck>, libfile-sharedir-install-perl, - libhash-merge-simple-perl, - libhash-multivalue-perl, - libhttp-cookies-perl, - libhttp-date-perl, - libhttp-headers-fast-perl (>= 0.21), - libhttp-message-perl, - libimport-into-perl, - libjson-maybexs-perl, - libmath-random-isaac-xs-perl, - libmime-types-perl, - libmodule-runtime-perl, - libmoo-perl (>= 2.003000), - libplack-middleware-fixmissingbodyinredirect-perl, - libplack-middleware-removeredundantbody-perl, - libplack-perl (>= 1.0040), - libref-util-perl, - libreturn-multilevel-perl, - librole-tiny-perl (>= 2.000000), - libsafe-isa-perl, - libscalar-list-utils-perl, - libscope-upper-perl, - libsub-quote-perl, - libtemplate-perl, - libtemplate-tiny-perl, - libtest-cpan-meta-perl, - libtest-fatal-perl, - libtype-tiny-perl (>= 1.000006), - libtype-tiny-xs-perl, - liburi-perl, - libwww-perl, - libyaml-perl, + libhash-merge-simple-perl <!nocheck>, + libhash-multivalue-perl <!nocheck>, + libhttp-cookies-perl <!nocheck>, + libhttp-date-perl <!nocheck>, + libhttp-headers-fast-perl (>= 0.21) <!nocheck>, + libhttp-message-perl <!nocheck>, + libimport-into-perl <!nocheck>, + libjson-maybexs-perl <!nocheck>, + libmath-random-isaac-xs-perl <!nocheck>, + libmime-types-perl <!nocheck>, + libmodule-runtime-perl <!nocheck>, + libmoo-perl (>= 2.003000) <!nocheck>, + libplack-middleware-fixmissingbodyinredirect-perl <!nocheck>, + libplack-middleware-removeredundantbody-perl <!nocheck>, + libplack-perl (>= 1.0040) <!nocheck>, + libref-util-perl <!nocheck>, + librole-tiny-perl (>= 2.000000) <!nocheck>, + libsafe-isa-perl <!nocheck>, + libscalar-list-utils-perl <!nocheck>, + libscope-upper-perl <!nocheck>, + libsub-quote-perl <!nocheck>, + libtemplate-perl <!nocheck>, + libtemplate-tiny-perl <!nocheck>, + libtest-cpan-meta-perl <!nocheck>, + libtest-fatal-perl <!nocheck>, + libtest-memory-cycle-perl <!nocheck>, + libtest-mocktime-perl <!nocheck>, + libtype-tiny-perl (>= 1.000006) <!nocheck>, + libtype-tiny-xs-perl <!nocheck>, + liburi-perl <!nocheck>, + libwww-perl <!nocheck>, + libyaml-perl <!nocheck>, perl -Standards-Version: 4.4.0 +Standards-Version: 4.4.1 Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libdancer2-perl Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libdancer2-perl.git Homepage: https://metacpan.org/release/Dancer2 +Rules-Requires-Root: no Package: libdancer2-perl Architecture: all @@ -74,7 +77,6 @@ Depends: ${misc:Depends}, libplack-middleware-fixmissingbodyinredirect-perl, libplack-perl (>= 1.0040), libref-util-perl, - libreturn-multilevel-perl, librole-tiny-perl (>= 2.000000), libsafe-isa-perl, libscalar-list-utils-perl, diff --git a/debian/copyright b/debian/copyright index 7855c701..f3253998 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,7 +1,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: Dancer2 Source: https://metacpan.org/release/Dancer2 Upstream-Contact: Alexis Sukrieh <sukria@sukria.net>, Jason A. Crome <cromedome@cpan.org> +Upstream-Name: Dancer2 Files-Excluded: share/skel/public/javascripts/jquery.js Comment: The upstream sources were repackaged in order to: drop the minified jQuery convenience copy diff --git a/debian/libdancer2-perl.docs b/debian/libdancer2-perl.docs new file mode 100644 index 00000000..e0e57697 --- /dev/null +++ b/debian/libdancer2-perl.docs @@ -0,0 +1 @@ +GitGuide.md diff --git a/debian/libdancer2-perl.lintian-overrides b/debian/libdancer2-perl.lintian-overrides index 0d7396b5..50f28eea 100644 --- a/debian/libdancer2-perl.lintian-overrides +++ b/debian/libdancer2-perl.lintian-overrides @@ -3,3 +3,7 @@ libdancer2-perl: script-not-executable usr/share/perl5/auto/share/dist/Dancer2/s # this file is just a template libdancer2-perl: executable-not-elf-or-script usr/share/perl5/auto/share/dist/Dancer2/skel/public/+dispatch.cgi + +# this is a CLI interface to the Dancer2 libraries +libdancer2-perl: application-in-library-section perl usr/bin/dancer2 +libdancer2-perl: library-package-name-for-application usr/bin/dancer2 diff --git a/debian/patches/no-phone-home.patch b/debian/patches/no-phone-home.patch index e6604135..97137980 100644 --- a/debian/patches/no-phone-home.patch +++ b/debian/patches/no-phone-home.patch @@ -7,7 +7,7 @@ Bug-Debian: https://bugs.debian.org/883606 --- a/lib/Dancer2/CLI/Command/gen.pm +++ b/lib/Dancer2/CLI/Command/gen.pm -@@ -26,7 +26,6 @@ sub opt_spec { +@@ -26,7 +26,6 @@ [ 'path|p=s', 'application path (default: current directory)', { default => '.' } ], [ 'overwrite|o', 'overwrite existing files' ], @@ -15,7 +15,7 @@ Bug-Debian: https://bugs.debian.org/883606 [ 'skel|s=s', 'skeleton directory' ], ); } -@@ -57,7 +56,6 @@ sub validate_args { +@@ -57,7 +56,6 @@ sub execute { my ($self, $opt, $args) = @_; diff --git a/debian/patches/remove-eumm-version-req.patch b/debian/patches/remove-eumm-version-req.patch index b5379759..66bf0b7f 100644 --- a/debian/patches/remove-eumm-version-req.patch +++ b/debian/patches/remove-eumm-version-req.patch @@ -31,7 +31,7 @@ Last-Update: 2019-08-10 "File::ShareDir::Install" => "0.06", "Module::Metadata" => 0 }, -@@ -81,7 +81,7 @@ +@@ -80,7 +80,7 @@ }, "TEST_REQUIRES" => { "Capture::Tiny" => "0.12", @@ -40,7 +40,7 @@ Last-Update: 2019-08-10 "File::Spec" => 0, "HTTP::Cookies" => 0, "HTTP::Headers" => 0, -@@ -111,7 +111,7 @@ +@@ -110,7 +110,7 @@ "Encode" => 0, "Exporter" => "5.57", "Exporter::Tiny" => 0, @@ -68,7 +68,7 @@ Last-Update: 2019-08-10 "File::ShareDir::Install" : "0.06", "Module::Metadata" : "0" } -@@ -125,7 +125,7 @@ +@@ -124,7 +124,7 @@ }, "requires" : { "Capture::Tiny" : "0.12", diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides deleted file mode 100644 index b20da0db..00000000 --- a/debian/source/lintian-overrides +++ /dev/null @@ -1,3 +0,0 @@ -# we remove the shipped jquery during repackaging -# and replace it with a symlink to the packages version later -libdancer2-perl source: source-contains-empty-directory share/skel/public/javascripts/ diff --git a/debian/upstream/metadata b/debian/upstream/metadata index 1ade1ab9..87953ca9 100644 --- a/debian/upstream/metadata +++ b/debian/upstream/metadata @@ -1,6 +1,6 @@ --- Archive: CPAN Bug-Database: https://github.com/PerlDancer/Dancer2/issues -Contact: Dancer Core Developers -Name: Dancer2 -Repository: https://github.com/PerlDancer/Dancer2 +Bug-Submit: https://github.com/PerlDancer/Dancer2/issues/new +Repository: https://github.com/PerlDancer/Dancer2.git +Repository-Browse: https://github.com/PerlDancer/Dancer2 diff --git a/debian/watch b/debian/watch index 0693e5bd..b8b10971 100644 --- a/debian/watch +++ b/debian/watch @@ -1,3 +1,3 @@ -version=3 +version=4 opts="dversionmangle=s/\+dfsg//,repacksuffix=+dfsg" \ -https://metacpan.org/release/Dancer2 .*/Dancer2-v?(\d[\d.-]*)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ +https://metacpan.org/release/Dancer2 .*/Dancer2-v?@ANY_VERSION@@ARCHIVE_EXT@$ diff --git a/lib/Dancer2.pm b/lib/Dancer2.pm index 5f61a900..6ee105df 100644 --- a/lib/Dancer2.pm +++ b/lib/Dancer2.pm @@ -1,5 +1,5 @@ package Dancer2; -$Dancer2::VERSION = '0.208001'; +$Dancer2::VERSION = '0.300000'; # ABSTRACT: Lightweight yet powerful web application framework use strict; @@ -128,7 +128,7 @@ Dancer2 - Lightweight yet powerful web application framework =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION @@ -272,6 +272,7 @@ We are also on IRC: #dancer on irc.perl.org. chenchen000 Chi Trinh Christian Walde + Christopher White Colin Kuskie cym0n Dale Gallagher @@ -337,6 +338,7 @@ We are also on IRC: #dancer on irc.perl.org. Menno Blom Michael Kröll Michał Wojciechowski + Mike Katasonov Mohammad S Anwar mokko Nick Patch @@ -362,6 +364,7 @@ We are also on IRC: #dancer on irc.perl.org. Sam Kington Samit Badle Sebastien Deseille (sdeseille) + Sergiy Borodych Shlomi Fish Slava Goltser Snigdha diff --git a/lib/Dancer2/CLI.pm b/lib/Dancer2/CLI.pm index 5427b641..bc659de4 100644 --- a/lib/Dancer2/CLI.pm +++ b/lib/Dancer2/CLI.pm @@ -1,6 +1,6 @@ package Dancer2::CLI; # ABSTRACT: Dancer2 cli application -$Dancer2::CLI::VERSION = '0.208001'; +$Dancer2::CLI::VERSION = '0.300000'; use strict; use warnings; use App::Cmd::Setup -app; @@ -19,7 +19,7 @@ Dancer2::CLI - Dancer2 cli application =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/CLI/Command/gen.pm b/lib/Dancer2/CLI/Command/gen.pm index e55ff972..dd051cc6 100644 --- a/lib/Dancer2/CLI/Command/gen.pm +++ b/lib/Dancer2/CLI/Command/gen.pm @@ -1,6 +1,6 @@ # ABSTRACT: create new Dancer2 application package Dancer2::CLI::Command::gen; -$Dancer2::CLI::Command::gen::VERSION = '0.208001'; +$Dancer2::CLI::Command::gen::VERSION = '0.300000'; use strict; use warnings; @@ -305,7 +305,7 @@ Dancer2::CLI::Command::gen - create new Dancer2 application =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/CLI/Command/version.pm b/lib/Dancer2/CLI/Command/version.pm index 7bcec06c..d6c4a720 100644 --- a/lib/Dancer2/CLI/Command/version.pm +++ b/lib/Dancer2/CLI/Command/version.pm @@ -1,6 +1,6 @@ package Dancer2::CLI::Command::version; # ABSTRACT: display version -$Dancer2::CLI::Command::version::VERSION = '0.208001'; +$Dancer2::CLI::Command::version::VERSION = '0.300000'; use strict; use warnings; use App::Cmd::Setup -command; @@ -32,7 +32,7 @@ Dancer2::CLI::Command::version - display version =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Config.pod b/lib/Dancer2/Config.pod index eb03d9bb..d93eee3f 100644 --- a/lib/Dancer2/Config.pod +++ b/lib/Dancer2/Config.pod @@ -13,7 +13,7 @@ Dancer2::Config - Configure Dancer2 to suit your needs =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION @@ -55,7 +55,7 @@ is typically useful for deployment-specific configuration that should not be checked into source control. For instance, database credentials could be stored in this file. Any settings in this file are merged into the existing configuration such that those with the same name in your -global configuration file will take precedence over those settings in +local configuration file will take precedence over those settings in the global file. Next, Dancer2 will look in the F<environments> directory for a configuration diff --git a/lib/Dancer2/Cookbook.pod b/lib/Dancer2/Cookbook.pod index 0c40e19c..8fe2144b 100644 --- a/lib/Dancer2/Cookbook.pod +++ b/lib/Dancer2/Cookbook.pod @@ -13,7 +13,7 @@ Dancer2::Cookbook - Example-driven quick-start to the Dancer2 web framework =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core.pm b/lib/Dancer2/Core.pm index c21d2744..06af1a0d 100644 --- a/lib/Dancer2/Core.pm +++ b/lib/Dancer2/Core.pm @@ -1,6 +1,6 @@ package Dancer2::Core; # ABSTRACT: Core libraries for Dancer2 2.0 -$Dancer2::Core::VERSION = '0.208001'; +$Dancer2::Core::VERSION = '0.300000'; use strict; use warnings; @@ -29,7 +29,7 @@ Dancer2::Core - Core libraries for Dancer2 2.0 =head1 VERSION -version 0.208001 +version 0.300000 =head1 FUNCTIONS diff --git a/lib/Dancer2/Core/App.pm b/lib/Dancer2/Core/App.pm index 5a32da46..05a6ad90 100644 --- a/lib/Dancer2/Core/App.pm +++ b/lib/Dancer2/Core/App.pm @@ -1,11 +1,10 @@ # ABSTRACT: encapsulation of Dancer2 packages package Dancer2::Core::App; -$Dancer2::Core::App::VERSION = '0.208001'; +$Dancer2::Core::App::VERSION = '0.300000'; use Moo; use Carp qw<croak carp>; use Scalar::Util 'blessed'; use Module::Runtime 'is_module_name'; -use Return::MultiLevel (); use Safe::Isa; use Sub::Quote; use File::Spec; @@ -1223,8 +1222,11 @@ sub add_route { my $self = shift; my %route_attrs = @_; - my $route = - Dancer2::Core::Route->new( %route_attrs, prefix => $self->prefix ); + my $route = Dancer2::Core::Route->new( + type_library => $self->config->{type_library}, + %route_attrs, + prefix => $self->prefix, + ); my $method = $route->method; @@ -1467,14 +1469,23 @@ DISPATCH: } # calling the actual route - my $response = Return::MultiLevel::with_return { - my ($return) = @_; - - # stash the multilevel return coderef in the app - $self->has_with_return - or $self->set_with_return($return); - - return $self->_dispatch_route($route); + my $response; + + # this is very evil, but allows breaking out of multiple stack + # frames without throwing an exception. Avoiding exceptions means + # a naive eval won't swallow our flow control mechanisms, and + # avoids __DIE__ handlers. It also prevents some cleanup routines + # from working, since they are expecting control to return to them + # after an eval. + DANCER2_CORE_APP_ROUTE_RETURN: { + if (!$self->has_with_return) { + $self->set_with_return(sub { + $response = shift; + no warnings 'exiting'; + last DANCER2_CORE_APP_ROUTE_RETURN; + }); + } + $response = $self->_dispatch_route($route); }; # ensure we clear the with_return handler @@ -1669,7 +1680,7 @@ Dancer2::Core::App - encapsulation of Dancer2 packages =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION @@ -1693,7 +1704,8 @@ that package, thanks to that encapsulation. =head2 with_return -Used to cache the coderef from L<Return::MultiLevel> within the dispatcher. +Used to cache the coderef that will return from back to the dispatcher, across +an arbitrary number of stack frames. =head2 destroyed_session @@ -1747,6 +1759,37 @@ Just like C<with_plugin>, but for a single plugin. my $plugin = $app->with_plugin('Foo'); +=head2 add_route + +Register a new route handler. + + $app->add_route( + method => 'get', + regexp => '/somewhere', + code => sub { ... }, + options => $conditions, + ); + +Returns a new L<< Dancer2::Core::Route >> object created with the passed +arguments. + +=head2 route_exists + +Returns a true value if a route already exists, otherwise false. + + my $route = Dancer2::Core::Route->new(...); + if ($app->route_exists($route)) { + ... + } + +=head2 routes_regexps_for + +Sugar for getting the ordered list of all registered route regexps by method. + + my $regexps = $app->routes_regexps_for( 'get' ); + +Returns an ArrayRef with the results. + =head2 redirect($destination, $status) Sets a redirect in the response object. If $destination is not an absolute URI, then it will @@ -1781,45 +1824,6 @@ For example: forward '/login', { login_failed => 1 }, { method => 'GET' }); -=head2 lexical_prefix - -Allow for setting a lexical prefix - - $app->lexical_prefix('/blog', sub { - ... - }); - -All the route defined within the callback will have a prefix appended to the -current one. - -=head2 add_route - -Register a new route handler. - - $app->add_route( - method => 'get', - regexp => '/somewhere', - code => sub { ... }, - options => $conditions, - ); - -=head2 route_exists - -Check if a route already exists. - - my $route = Dancer2::Core::Route->new(...); - if ($app->route_exists($route)) { - ... - } - -=head2 routes_regexps_for - -Sugar for getting the ordered list of all registered route regexps by method. - - my $regexps = $app->routes_regexps_for( 'get' ); - -Returns an ArrayRef with the results. - =head2 app Returns itself. This is simply available as a shim to help transition from @@ -1846,6 +1850,17 @@ to make it work. my $app = $WannaBeContext->app; # works }; +=head2 lexical_prefix + +Allow for setting a lexical prefix + + $app->lexical_prefix('/blog', sub { + ... + }); + +All the route defined within the callback will have a prefix appended to the +current one. + =head2 C< $SIG{__DIE__} > Compatibility via C< $Dancer2::Core::App::EVAL_SHIM > If an installation wishes to use C< $SIG{__DIE__} > hooks to enhance diff --git a/lib/Dancer2/Core/Cookie.pm b/lib/Dancer2/Core/Cookie.pm index dbb7548b..f57dabe2 100644 --- a/lib/Dancer2/Core/Cookie.pm +++ b/lib/Dancer2/Core/Cookie.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Cookie; # ABSTRACT: A cookie representing class -$Dancer2::Core::Cookie::VERSION = '0.208001'; +$Dancer2::Core::Cookie::VERSION = '0.300000'; use Moo; use URI::Escape; use Dancer2::Core::Types; @@ -152,7 +152,7 @@ Dancer2::Core::Cookie - A cookie representing class =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/DSL.pm b/lib/Dancer2/Core/DSL.pm index b01f7343..8c3a719f 100644 --- a/lib/Dancer2/Core/DSL.pm +++ b/lib/Dancer2/Core/DSL.pm @@ -1,7 +1,7 @@ # ABSTRACT: Dancer2's Domain Specific Language (DSL) package Dancer2::Core::DSL; -$Dancer2::Core::DSL::VERSION = '0.208001'; +$Dancer2::Core::DSL::VERSION = '0.300000'; use Moo; use Carp; use Module::Runtime 'require_module'; @@ -519,7 +519,7 @@ Dancer2::Core::DSL - Dancer2's Domain Specific Language (DSL) =head1 VERSION -version 0.208001 +version 0.300000 =head1 FUNCTIONS diff --git a/lib/Dancer2/Core/Dispatcher.pm b/lib/Dancer2/Core/Dispatcher.pm index e775f913..b4db7023 100644 --- a/lib/Dancer2/Core/Dispatcher.pm +++ b/lib/Dancer2/Core/Dispatcher.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Dispatcher; # ABSTRACT: Class for dispatching request to the appropriate route handler -$Dancer2::Core::Dispatcher::VERSION = '0.208001'; +$Dancer2::Core::Dispatcher::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types; @@ -73,7 +73,7 @@ Dancer2::Core::Dispatcher - Class for dispatching request to the appropriate rou =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS @@ -112,10 +112,9 @@ object and an env as input arguments. C<dispatch> returns a response object of L<Dancer2::Core::Response>. -Any before hook and matched route code is wrapped using L<Return::MultiLevel> -to allow DSL keywords such as forward and redirect to short-circuit remaining code -without having to throw an exception. L<Return::MultiLevel> will use L<Scope::Upper> -(an XS module) if it is available. +Any before hook and matched route code is wrapped to allow DSL keywords such +as forward and redirect to short-circuit remaining code, returning across +multiple stack frames without having to throw an exception. =head2 response_internal_error diff --git a/lib/Dancer2/Core/Error.pm b/lib/Dancer2/Core/Error.pm index 40b58012..7d9f667d 100644 --- a/lib/Dancer2/Core/Error.pm +++ b/lib/Dancer2/Core/Error.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Error; # ABSTRACT: Class representing fatal errors -$Dancer2::Core::Error::VERSION = '0.208001'; +$Dancer2::Core::Error::VERSION = '0.300000'; use Moo; use Carp; use Dancer2::Core::Types; @@ -482,7 +482,7 @@ Dancer2::Core::Error - Class representing fatal errors =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/Factory.pm b/lib/Dancer2/Core/Factory.pm index 08417f4a..02874f00 100644 --- a/lib/Dancer2/Core/Factory.pm +++ b/lib/Dancer2/Core/Factory.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Factory; # ABSTRACT: Instantiate components by type and name -$Dancer2::Core::Factory::VERSION = '0.208001'; +$Dancer2::Core::Factory::VERSION = '0.300000'; use Moo; use Dancer2::Core; use Module::Runtime 'use_module'; @@ -33,7 +33,7 @@ Dancer2::Core::Factory - Instantiate components by type and name =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Core/HTTP.pm b/lib/Dancer2/Core/HTTP.pm index 28f4d2e5..ed055fca 100644 --- a/lib/Dancer2/Core/HTTP.pm +++ b/lib/Dancer2/Core/HTTP.pm @@ -1,7 +1,7 @@ # ABSTRACT: helper for rendering HTTP status codes for Dancer2 package Dancer2::Core::HTTP; -$Dancer2::Core::HTTP::VERSION = '0.208001'; +$Dancer2::Core::HTTP::VERSION = '0.300000'; use strict; use warnings; @@ -144,7 +144,7 @@ Dancer2::Core::HTTP - helper for rendering HTTP status codes for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 FUNCTIONS diff --git a/lib/Dancer2/Core/Hook.pm b/lib/Dancer2/Core/Hook.pm index 93d58f9c..a97e43b7 100644 --- a/lib/Dancer2/Core/Hook.pm +++ b/lib/Dancer2/Core/Hook.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Hook; # ABSTRACT: Manipulate hooks with Dancer2 -$Dancer2::Core::Hook::VERSION = '0.208001'; +$Dancer2::Core::Hook::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types; use Carp; @@ -51,7 +51,7 @@ Dancer2::Core::Hook - Manipulate hooks with Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/MIME.pm b/lib/Dancer2/Core/MIME.pm index d7103ea7..ca4a70a6 100644 --- a/lib/Dancer2/Core/MIME.pm +++ b/lib/Dancer2/Core/MIME.pm @@ -1,7 +1,7 @@ # ABSTRACT: Class to ease manipulation of MIME types package Dancer2::Core::MIME; -$Dancer2::Core::MIME::VERSION = '0.208001'; +$Dancer2::Core::MIME::VERSION = '0.300000'; use Moo; use Plack::MIME; @@ -91,7 +91,7 @@ Dancer2::Core::MIME - Class to ease manipulation of MIME types =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/Request.pm b/lib/Dancer2/Core/Request.pm index 63ba49dc..f789f13c 100644 --- a/lib/Dancer2/Core/Request.pm +++ b/lib/Dancer2/Core/Request.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Request; # ABSTRACT: Interface for accessing incoming requests -$Dancer2::Core::Request::VERSION = '0.208001'; +$Dancer2::Core::Request::VERSION = '0.300000'; use strict; use warnings; use parent 'Plack::Request'; @@ -623,7 +623,7 @@ Dancer2::Core::Request - Interface for accessing incoming requests =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/Request/Upload.pm b/lib/Dancer2/Core/Request/Upload.pm index ab77f2d3..43b9ab48 100644 --- a/lib/Dancer2/Core/Request/Upload.pm +++ b/lib/Dancer2/Core/Request/Upload.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Request::Upload; # ABSTRACT: Class representing file upload requests -$Dancer2::Core::Request::Upload::VERSION = '0.208001'; +$Dancer2::Core::Request::Upload::VERSION = '0.300000'; use Moo; use Carp; @@ -92,7 +92,7 @@ Dancer2::Core::Request::Upload - Class representing file upload requests =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Response.pm b/lib/Dancer2/Core/Response.pm index e15a351c..d8be82dd 100644 --- a/lib/Dancer2/Core/Response.pm +++ b/lib/Dancer2/Core/Response.pm @@ -1,7 +1,7 @@ # ABSTRACT: Response object for Dancer2 package Dancer2::Core::Response; -$Dancer2::Core::Response::VERSION = '0.208001'; +$Dancer2::Core::Response::VERSION = '0.300000'; use Moo; use Encode; @@ -276,7 +276,7 @@ Dancer2::Core::Response - Response object for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 ATTRIBUTES diff --git a/lib/Dancer2/Core/Response/Delayed.pm b/lib/Dancer2/Core/Response/Delayed.pm index 0ca5381a..55dc5bd1 100644 --- a/lib/Dancer2/Core/Response/Delayed.pm +++ b/lib/Dancer2/Core/Response/Delayed.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Response::Delayed; # ABSTRACT: Delayed responses -$Dancer2::Core::Response::Delayed::VERSION = '0.208001'; +$Dancer2::Core::Response::Delayed::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types qw<CodeRef InstanceOf>; @@ -64,7 +64,7 @@ Dancer2::Core::Response::Delayed - Delayed responses =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/Role/ConfigReader.pm b/lib/Dancer2/Core/Role/ConfigReader.pm index f4bd9e95..83d58540 100644 --- a/lib/Dancer2/Core/Role/ConfigReader.pm +++ b/lib/Dancer2/Core/Role/ConfigReader.pm @@ -1,6 +1,6 @@ # ABSTRACT: Config role for Dancer2 core objects package Dancer2::Core::Role::ConfigReader; -$Dancer2::Core::Role::ConfigReader::VERSION = '0.208001'; +$Dancer2::Core::Role::ConfigReader::VERSION = '0.300000'; use Moo::Role; use File::Spec; @@ -289,7 +289,7 @@ Dancer2::Core::Role::ConfigReader - Config role for Dancer2 core objects =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Role/DSL.pm b/lib/Dancer2/Core/Role/DSL.pm index 80e5beb8..fc6de500 100644 --- a/lib/Dancer2/Core/Role/DSL.pm +++ b/lib/Dancer2/Core/Role/DSL.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::DSL; # ABSTRACT: Role for DSL -$Dancer2::Core::Role::DSL::VERSION = '0.208001'; +$Dancer2::Core::Role::DSL::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core::Types; use Carp 'croak'; @@ -114,7 +114,7 @@ Dancer2::Core::Role::DSL - Role for DSL =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Core/Role/Engine.pm b/lib/Dancer2/Core/Role/Engine.pm index b82d7291..affd66de 100644 --- a/lib/Dancer2/Core/Role/Engine.pm +++ b/lib/Dancer2/Core/Role/Engine.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::Engine; # ABSTRACT: Role for engines -$Dancer2::Core::Role::Engine::VERSION = '0.208001'; +$Dancer2::Core::Role::Engine::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core::Types; @@ -42,7 +42,7 @@ Dancer2::Core::Role::Engine - Role for engines =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Role/Handler.pm b/lib/Dancer2/Core/Role/Handler.pm index 7e8877d8..1e55e92d 100644 --- a/lib/Dancer2/Core/Role/Handler.pm +++ b/lib/Dancer2/Core/Role/Handler.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::Handler; # ABSTRACT: Role for Handlers -$Dancer2::Core::Role::Handler::VERSION = '0.208001'; +$Dancer2::Core::Role::Handler::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core::Types; @@ -26,7 +26,7 @@ Dancer2::Core::Role::Handler - Role for Handlers =head1 VERSION -version 0.208001 +version 0.300000 =head1 ATTRIBUTES diff --git a/lib/Dancer2/Core/Role/HasLocation.pm b/lib/Dancer2/Core/Role/HasLocation.pm index 93507929..facb5c91 100644 --- a/lib/Dancer2/Core/Role/HasLocation.pm +++ b/lib/Dancer2/Core/Role/HasLocation.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::HasLocation; # ABSTRACT: Role for application location "guessing" -$Dancer2::Core::Role::HasLocation::VERSION = '0.208001'; +$Dancer2::Core::Role::HasLocation::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core::Types; use Dancer2::FileUtils; @@ -88,7 +88,7 @@ Dancer2::Core::Role::HasLocation - Role for application location "guessing" =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Core/Role/Hookable.pm b/lib/Dancer2/Core/Role/Hookable.pm index 5665599d..cfe4bade 100644 --- a/lib/Dancer2/Core/Role/Hookable.pm +++ b/lib/Dancer2/Core/Role/Hookable.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::Hookable; # ABSTRACT: Role for hookable objects -$Dancer2::Core::Role::Hookable::VERSION = '0.208001'; +$Dancer2::Core::Role::Hookable::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core; use Dancer2::Core::Types; @@ -130,7 +130,7 @@ Dancer2::Core::Role::Hookable - Role for hookable objects =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Core/Role/Logger.pm b/lib/Dancer2/Core/Role/Logger.pm index eddfed11..25b81266 100644 --- a/lib/Dancer2/Core/Role/Logger.pm +++ b/lib/Dancer2/Core/Role/Logger.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::Logger; # ABSTRACT: Role for logger engines -$Dancer2::Core::Role::Logger::VERSION = '0.208001'; +$Dancer2::Core::Role::Logger::VERSION = '0.300000'; use Dancer2::Core::Types; use Moo::Role; @@ -204,7 +204,7 @@ Dancer2::Core::Role::Logger - Role for logger engines =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Role/Serializer.pm b/lib/Dancer2/Core/Role/Serializer.pm index edb430a3..49e78300 100644 --- a/lib/Dancer2/Core/Role/Serializer.pm +++ b/lib/Dancer2/Core/Role/Serializer.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::Serializer; # ABSTRACT: Role for Serializer engines -$Dancer2::Core::Role::Serializer::VERSION = '0.208001'; +$Dancer2::Core::Role::Serializer::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core::Types; use Scalar::Util 'blessed'; @@ -88,7 +88,7 @@ Dancer2::Core::Role::Serializer - Role for Serializer engines =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Role/SessionFactory.pm b/lib/Dancer2/Core/Role/SessionFactory.pm index d458adcb..53c33157 100644 --- a/lib/Dancer2/Core/Role/SessionFactory.pm +++ b/lib/Dancer2/Core/Role/SessionFactory.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::SessionFactory; # ABSTRACT: Role for session factories -$Dancer2::Core::Role::SessionFactory::VERSION = '0.208001'; +$Dancer2::Core::Role::SessionFactory::VERSION = '0.300000'; use Moo::Role; with 'Dancer2::Core::Role::Engine'; @@ -291,7 +291,7 @@ Dancer2::Core::Role::SessionFactory - Role for session factories =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Role/SessionFactory/File.pm b/lib/Dancer2/Core/Role/SessionFactory/File.pm index 4fedcd50..dfab1a1d 100644 --- a/lib/Dancer2/Core/Role/SessionFactory/File.pm +++ b/lib/Dancer2/Core/Role/SessionFactory/File.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::SessionFactory::File; # ABSTRACT: Role for file-based session factories -$Dancer2::Core::Role::SessionFactory::File::VERSION = '0.208001'; +$Dancer2::Core::Role::SessionFactory::File::VERSION = '0.300000'; use Moo::Role; with 'Dancer2::Core::Role::SessionFactory'; @@ -125,7 +125,7 @@ Dancer2::Core::Role::SessionFactory::File - Role for file-based session factorie =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Role/StandardResponses.pm b/lib/Dancer2/Core/Role/StandardResponses.pm index 87f3ce73..ad9efa3a 100644 --- a/lib/Dancer2/Core/Role/StandardResponses.pm +++ b/lib/Dancer2/Core/Role/StandardResponses.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Role::StandardResponses; # ABSTRACT: Role to provide commonly used responses -$Dancer2::Core::Role::StandardResponses::VERSION = '0.208001'; +$Dancer2::Core::Role::StandardResponses::VERSION = '0.300000'; use Moo::Role; use Dancer2::Core::HTTP; @@ -35,7 +35,7 @@ Dancer2::Core::Role::StandardResponses - Role to provide commonly used responses =head1 VERSION -version 0.208001 +version 0.300000 =head1 METHODS diff --git a/lib/Dancer2/Core/Role/Template.pm b/lib/Dancer2/Core/Role/Template.pm index d057eb9c..0d8a86c5 100644 --- a/lib/Dancer2/Core/Role/Template.pm +++ b/lib/Dancer2/Core/Role/Template.pm @@ -1,7 +1,7 @@ # ABSTRACT: Role for template engines package Dancer2::Core::Role::Template; -$Dancer2::Core::Role::Template::VERSION = '0.208001'; +$Dancer2::Core::Role::Template::VERSION = '0.300000'; use Dancer2::Core::Types; use Dancer2::FileUtils 'path'; use Carp 'croak'; @@ -237,7 +237,7 @@ Dancer2::Core::Role::Template - Role for template engines =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Route.pm b/lib/Dancer2/Core/Route.pm index 80cec769..388bb0e1 100644 --- a/lib/Dancer2/Core/Route.pm +++ b/lib/Dancer2/Core/Route.pm @@ -1,12 +1,14 @@ package Dancer2::Core::Route; # ABSTRACT: Dancer2's route handler -$Dancer2::Core::Route::VERSION = '0.208001'; +$Dancer2::Core::Route::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types; +use Module::Runtime 'use_module'; use Carp 'croak'; use List::Util 'first'; use Scalar::Util 'blessed'; use Ref::Util qw< is_regexpref >; +use Type::Registry; our ( $REQUEST, $RESPONSE, $RESPONDER, $WRITER, $ERROR_HANDLER ); @@ -75,6 +77,12 @@ has _params => ( default => sub { [] }, ); +has _typed_params => ( + is => 'ro', + isa => ArrayRef, + default => sub { [] }, +); + sub match { my ( $self, $request ) = @_; @@ -98,15 +106,30 @@ sub match { # regex comments are how we know if we captured a token, # splat or a megasplat - my @token_or_splat = $self->regexp =~ /\(\?#(token|(?:mega)?splat)\)/g; + my @token_or_splat = + $self->regexp =~ /\(\?#((?:typed_)?token|(?:mega)?splat)\)/g; + if (@token_or_splat) { # our named tokens my @tokens = @{ $self->_params }; + my @typed_tokens = @{ $self->_typed_params }; my %params; my @splat; for ( my $i = 0; $i < @values; $i++ ) { # Is this value from a token? + if ( $token_or_splat[$i] eq 'typed_token' ) { + my ( $token, $type ) = @{ shift @typed_tokens }; + + if (defined $values[$i]) { + # undef value mean that token was marked as optional so + # we only do type check on defined value + return + unless $type->check($values[$i]); + } + $params{$token} = $values[$i]; + next; + } if ( $token_or_splat[$i] eq 'token' ) { $params{ shift @tokens } = $values[$i]; next; @@ -181,6 +204,13 @@ sub BUILDARGS { my $prefix = $args{prefix}; my $regexp = $args{regexp}; + my $type_library = delete $args{type_library}; + if ( $type_library) { + eval { use_module($type_library); 1 } + or croak "type_library $type_library cannot be loaded"; + } + $type_library ||= 'Dancer2::Core::Types'; + # init prefix if ( $prefix ) { $args{regexp} = @@ -200,22 +230,40 @@ sub BUILDARGS { $args{_should_capture} = 1; } else { - @args{qw/ regexp _params _should_capture/} = - @{ _build_regexp_from_string($regexp) }; + @args{qw/ regexp _params _typed_params _should_capture/} = + @{ _build_regexp_from_string($regexp, $type_library) }; } return \%args; } sub _build_regexp_from_string { - my ($string) = @_; + my ($string, $type_library) = @_; my $capture = 0; - my @params; + my ( @params, @typed_params ); + + my $type_registry = Type::Registry->new; + $type_registry->add_types($type_library); # look for route with tokens [aka params] (/hello/:foo) if ( $string =~ /:/ ) { - @params = $string =~ /:([^\/\.\?]+)/g; + my @found = $string =~ m|:([^/.\?]+)|g; + foreach my $token ( @found ) { + if ( $token =~ s/\[(.+)\]$// ) { + + # typed token + my $type = $type_registry->lookup($1); + push @typed_params, [ $token, $type ]; + } + else { + push @params, $token; + } + } + if (@typed_params) { + $string =~ s!(:[^/.\?]+\[[^/.\?]+\])!(?#typed_token)([^/]+)!g; + $capture = 1; + } if (@params) { first { $_ eq 'splat' } @params and warn q{Named placeholder 'splat' is deprecated}; @@ -242,7 +290,7 @@ sub _build_regexp_from_string { # escape slashes $string =~ s/\//\\\//g; - return [ "^$string\$", \@params, $capture ]; + return [ "^$string\$", \@params, \@typed_params, $capture ]; } sub validate_options { @@ -272,7 +320,7 @@ Dancer2::Core::Route - Dancer2's route handler =head1 VERSION -version 0.208001 +version 0.300000 =head1 ATTRIBUTES diff --git a/lib/Dancer2/Core/Runner.pm b/lib/Dancer2/Core/Runner.pm index f88f8a14..9f310040 100644 --- a/lib/Dancer2/Core/Runner.pm +++ b/lib/Dancer2/Core/Runner.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Runner; # ABSTRACT: Top-layer class to start a dancer app -$Dancer2::Core::Runner::VERSION = '0.208001'; +$Dancer2::Core::Runner::VERSION = '0.300000'; use Moo; use Carp 'croak'; use Module::Runtime 'require_module'; @@ -261,7 +261,7 @@ Dancer2::Core::Runner - Top-layer class to start a dancer app =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Core/Session.pm b/lib/Dancer2/Core/Session.pm index 7e1b8a02..64a24b01 100644 --- a/lib/Dancer2/Core/Session.pm +++ b/lib/Dancer2/Core/Session.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Session; # ABSTRACT: class to represent any session object -$Dancer2::Core::Session::VERSION = '0.208001'; +$Dancer2::Core::Session::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types; use Dancer2::Core::Time; @@ -68,7 +68,7 @@ Dancer2::Core::Session - class to represent any session object =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Core/Time.pm b/lib/Dancer2/Core/Time.pm index 831d5cd3..5296b0e4 100644 --- a/lib/Dancer2/Core/Time.pm +++ b/lib/Dancer2/Core/Time.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Time; # ABSTRACT: class to handle common helpers for time manipulations -$Dancer2::Core::Time::VERSION = '0.208001'; +$Dancer2::Core::Time::VERSION = '0.300000'; use Moo; has seconds => ( @@ -134,7 +134,7 @@ Dancer2::Core::Time - class to handle common helpers for time manipulations =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Core/Types.pm b/lib/Dancer2/Core/Types.pm index fc5f5f34..3133e97c 100644 --- a/lib/Dancer2/Core/Types.pm +++ b/lib/Dancer2/Core/Types.pm @@ -1,6 +1,6 @@ package Dancer2::Core::Types; # ABSTRACT: Type::Tiny types for Dancer2 core. -$Dancer2::Core::Types::VERSION = '0.208001'; +$Dancer2::Core::Types::VERSION = '0.300000'; use strict; use warnings; use Type::Library -base; @@ -90,7 +90,7 @@ Dancer2::Core::Types - Type::Tiny types for Dancer2 core. =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/FileUtils.pm b/lib/Dancer2/FileUtils.pm index 7ec291a5..9a19f71c 100644 --- a/lib/Dancer2/FileUtils.pm +++ b/lib/Dancer2/FileUtils.pm @@ -1,6 +1,6 @@ package Dancer2::FileUtils; # ABSTRACT: File utility helpers -$Dancer2::FileUtils::VERSION = '0.208001'; +$Dancer2::FileUtils::VERSION = '0.300000'; use strict; use warnings; @@ -109,7 +109,7 @@ Dancer2::FileUtils - File utility helpers =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Handler/AutoPage.pm b/lib/Dancer2/Handler/AutoPage.pm index 806e575a..220926e0 100644 --- a/lib/Dancer2/Handler/AutoPage.pm +++ b/lib/Dancer2/Handler/AutoPage.pm @@ -1,6 +1,6 @@ package Dancer2::Handler::AutoPage; # ABSTRACT: Class for handling the AutoPage feature -$Dancer2::Handler::AutoPage::VERSION = '0.208001'; +$Dancer2::Handler::AutoPage::VERSION = '0.300000'; use Moo; use Carp 'croak'; use Dancer2::Core::Types; @@ -72,7 +72,7 @@ Dancer2::Handler::AutoPage - Class for handling the AutoPage feature =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Handler/File.pm b/lib/Dancer2/Handler/File.pm index d53589d8..2dd3bbcb 100644 --- a/lib/Dancer2/Handler/File.pm +++ b/lib/Dancer2/Handler/File.pm @@ -1,6 +1,6 @@ package Dancer2::Handler::File; # ABSTRACT: class for handling file content rendering -$Dancer2::Handler::File::VERSION = '0.208001'; +$Dancer2::Handler::File::VERSION = '0.300000'; use Carp 'croak'; use Moo; use HTTP::Date; @@ -163,7 +163,7 @@ Dancer2::Handler::File - class for handling file content rendering =head1 VERSION -version 0.208001 +version 0.300000 =head1 AUTHOR diff --git a/lib/Dancer2/Logger/Capture.pm b/lib/Dancer2/Logger/Capture.pm index 96d43ceb..87c09c3b 100644 --- a/lib/Dancer2/Logger/Capture.pm +++ b/lib/Dancer2/Logger/Capture.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::Capture; # ABSTRACT: Capture dancer logs -$Dancer2::Logger::Capture::VERSION = '0.208001'; +$Dancer2::Logger::Capture::VERSION = '0.300000'; use Moo; use Dancer2::Logger::Capture::Trap; @@ -38,7 +38,7 @@ Dancer2::Logger::Capture - Capture dancer logs =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Logger/Capture/Trap.pm b/lib/Dancer2/Logger/Capture/Trap.pm index 82bc2a9a..df9eaf80 100644 --- a/lib/Dancer2/Logger/Capture/Trap.pm +++ b/lib/Dancer2/Logger/Capture/Trap.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::Capture::Trap; # ABSTRACT: a place to store captured Dancer2 logs -$Dancer2::Logger::Capture::Trap::VERSION = '0.208001'; +$Dancer2::Logger::Capture::Trap::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types; @@ -41,7 +41,7 @@ Dancer2::Logger::Capture::Trap - a place to store captured Dancer2 logs =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Logger/Console.pm b/lib/Dancer2/Logger/Console.pm index 99ca86c8..9ec24fdb 100644 --- a/lib/Dancer2/Logger/Console.pm +++ b/lib/Dancer2/Logger/Console.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::Console; # ABSTRACT: Console logger -$Dancer2::Logger::Console::VERSION = '0.208001'; +$Dancer2::Logger::Console::VERSION = '0.300000'; use Moo; with 'Dancer2::Core::Role::Logger'; @@ -24,7 +24,7 @@ Dancer2::Logger::Console - Console logger =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Logger/Diag.pm b/lib/Dancer2/Logger/Diag.pm index ff4ffd7f..be27b283 100644 --- a/lib/Dancer2/Logger/Diag.pm +++ b/lib/Dancer2/Logger/Diag.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::Diag; # ABSTRACT: Test::More diag() logging engine for Dancer2 -$Dancer2::Logger::Diag::VERSION = '0.208001'; +$Dancer2::Logger::Diag::VERSION = '0.300000'; use Moo; use Test::More; @@ -26,7 +26,7 @@ Dancer2::Logger::Diag - Test::More diag() logging engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Logger/File.pm b/lib/Dancer2/Logger/File.pm index 6819b55b..29b5790d 100644 --- a/lib/Dancer2/Logger/File.pm +++ b/lib/Dancer2/Logger/File.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::File; # ABSTRACT: file-based logging engine for Dancer2 -$Dancer2::Logger::File::VERSION = '0.208001'; +$Dancer2::Logger::File::VERSION = '0.300000'; use Carp 'carp'; use Moo; use Dancer2::Core::Types; @@ -111,7 +111,7 @@ Dancer2::Logger::File - file-based logging engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Logger/Note.pm b/lib/Dancer2/Logger/Note.pm index 5eb44ec7..fa58a862 100644 --- a/lib/Dancer2/Logger/Note.pm +++ b/lib/Dancer2/Logger/Note.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::Note; # ABSTRACT: Test::More note() logging engine for Dancer2 -$Dancer2::Logger::Note::VERSION = '0.208001'; +$Dancer2::Logger::Note::VERSION = '0.300000'; use Moo; use Test::More; @@ -26,7 +26,7 @@ Dancer2::Logger::Note - Test::More note() logging engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Logger/Null.pm b/lib/Dancer2/Logger/Null.pm index bca83adf..62d68035 100644 --- a/lib/Dancer2/Logger/Null.pm +++ b/lib/Dancer2/Logger/Null.pm @@ -1,6 +1,6 @@ package Dancer2::Logger::Null; # ABSTRACT: Blackhole-like silent logging engine for Dancer2 -$Dancer2::Logger::Null::VERSION = '0.208001'; +$Dancer2::Logger::Null::VERSION = '0.300000'; use Moo; with 'Dancer2::Core::Role::Logger'; @@ -20,7 +20,7 @@ Dancer2::Logger::Null - Blackhole-like silent logging engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Manual.pod b/lib/Dancer2/Manual.pod index 977a5144..cf35d680 100644 --- a/lib/Dancer2/Manual.pod +++ b/lib/Dancer2/Manual.pod @@ -13,7 +13,7 @@ Dancer2::Manual - A gentle introduction to Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION @@ -243,6 +243,54 @@ Tokens can be optional, for example: "Hello there, $name"; }; +=head3 Named matching with type constraints + +Type constraints can be added to tokens. + + get '/user/:id[Int]' => sub { + # matches /user/34 but not /user/jamesdean + my $user_id = route_parameters->get('id'); + }; + + get '/user/:username[Str]' => sub { + # matches /user/jamesdean but not /user/34 since that is caught + # by previous route + my $username = route_parameters->get('username'); + }; + +You can even use type constraints to add a regexp check: + + get '/book/:date[StrMatch[qr{\d\d\d\d-\d\d-\d\d}]]' => sub { + # matches /book/2014-02-04 + my $date = route_parameters->get('date'); + }; + +The default type library is L<Dancer2::Core::Types> but any type library +built using L<Type::Tiny>'s L<Type::Library> can be used instead. +If you'd like to use a different default type library you must declare it +in the configuration file, for example: + + type_library: My::Type::Library + +Alternatively you can specify the type library in which the type is defined +as part of the route definition: + + get '/user/:username[My::Type::Library::Username]' => sub { + my $username = route_parameters->get('username'); + }; + +This will load C<My::Type::Library> and from it use the type C<Username>. This +allows types to be used that are not part of the type library defined by config's +C<type_library>. + +More complex constructs are allowed such as: + + get '/some/:thing[Int|MyDate]' => sub { + ...; + }; + +See L<Type::Registry/lookup($name)> for more details. + =head3 Wildcard Matching A route can contain a wildcard (represented by a C<*>). Each wildcard match diff --git a/lib/Dancer2/Manual/Deployment.pod b/lib/Dancer2/Manual/Deployment.pod index 40155e60..ee88388e 100644 --- a/lib/Dancer2/Manual/Deployment.pod +++ b/lib/Dancer2/Manual/Deployment.pod @@ -13,7 +13,7 @@ Dancer2::Manual::Deployment - common ways to put your Dancer app into use =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Manual/Migration.pod b/lib/Dancer2/Manual/Migration.pod index 136d8025..dba84ddf 100644 --- a/lib/Dancer2/Manual/Migration.pod +++ b/lib/Dancer2/Manual/Migration.pod @@ -18,7 +18,7 @@ Dancer2::Manual::Migration - Migrating from Dancer to Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 Migration from Dancer 1 to Dancer2 diff --git a/lib/Dancer2/Manual/Testing.pod b/lib/Dancer2/Manual/Testing.pod index 330916e5..87d66aff 100644 --- a/lib/Dancer2/Manual/Testing.pod +++ b/lib/Dancer2/Manual/Testing.pod @@ -18,7 +18,7 @@ Dancer2::Manual::Testing - Writing tests for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 Basic application testing diff --git a/lib/Dancer2/Plugin.pm b/lib/Dancer2/Plugin.pm index b1674919..24f245fb 100644 --- a/lib/Dancer2/Plugin.pm +++ b/lib/Dancer2/Plugin.pm @@ -1,6 +1,6 @@ package Dancer2::Plugin; # ABSTRACT: base class for Dancer2 plugins -$Dancer2::Plugin::VERSION = '0.208001'; +$Dancer2::Plugin::VERSION = '0.300000'; use strict; use warnings; @@ -636,7 +636,7 @@ Dancer2::Plugin - base class for Dancer2 plugins =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Plugins.pod b/lib/Dancer2/Plugins.pod index badf036f..e1068b93 100644 --- a/lib/Dancer2/Plugins.pod +++ b/lib/Dancer2/Plugins.pod @@ -13,7 +13,7 @@ Dancer2::Plugins - Recommended Dancer2 plugins =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Policy.pod b/lib/Dancer2/Policy.pod index bbca2fe6..0c786c3d 100644 --- a/lib/Dancer2/Policy.pod +++ b/lib/Dancer2/Policy.pod @@ -18,7 +18,7 @@ Dancer2::Policy - Dancer core and community policy and standards of conduct =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Serializer/Dumper.pm b/lib/Dancer2/Serializer/Dumper.pm index 13a72918..87e1c968 100644 --- a/lib/Dancer2/Serializer/Dumper.pm +++ b/lib/Dancer2/Serializer/Dumper.pm @@ -1,7 +1,7 @@ # ABSTRACT: Serializer for handling Dumper data package Dancer2::Serializer::Dumper; -$Dancer2::Serializer::Dumper::VERSION = '0.208001'; +$Dancer2::Serializer::Dumper::VERSION = '0.300000'; use Moo; use Carp 'croak'; use Data::Dumper; @@ -50,7 +50,7 @@ Dancer2::Serializer::Dumper - Serializer for handling Dumper data =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Serializer/JSON.pm b/lib/Dancer2/Serializer/JSON.pm index d484cc3f..66e059ee 100644 --- a/lib/Dancer2/Serializer/JSON.pm +++ b/lib/Dancer2/Serializer/JSON.pm @@ -1,6 +1,6 @@ package Dancer2::Serializer::JSON; # ABSTRACT: Serializer for handling JSON data -$Dancer2::Serializer::JSON::VERSION = '0.208001'; +$Dancer2::Serializer::JSON::VERSION = '0.300000'; use Moo; use JSON::MaybeXS (); use Scalar::Util 'blessed'; @@ -61,7 +61,7 @@ Dancer2::Serializer::JSON - Serializer for handling JSON data =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Serializer/Mutable.pm b/lib/Dancer2/Serializer/Mutable.pm index 50e0f3f2..fc36be5f 100644 --- a/lib/Dancer2/Serializer/Mutable.pm +++ b/lib/Dancer2/Serializer/Mutable.pm @@ -1,6 +1,6 @@ package Dancer2::Serializer::Mutable; # ABSTRACT: Serialize and deserialize content based on HTTP header -$Dancer2::Serializer::Mutable::VERSION = '0.208001'; +$Dancer2::Serializer::Mutable::VERSION = '0.300000'; use Moo; use Carp 'croak'; use Encode; @@ -118,7 +118,7 @@ Dancer2::Serializer::Mutable - Serialize and deserialize content based on HTTP h =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Serializer/YAML.pm b/lib/Dancer2/Serializer/YAML.pm index bc139db6..8fe50a3f 100644 --- a/lib/Dancer2/Serializer/YAML.pm +++ b/lib/Dancer2/Serializer/YAML.pm @@ -1,6 +1,6 @@ package Dancer2::Serializer::YAML; # ABSTRACT: Serializer for handling YAML data -$Dancer2::Serializer::YAML::VERSION = '0.208001'; +$Dancer2::Serializer::YAML::VERSION = '0.300000'; use Moo; use Carp 'croak'; use Encode; @@ -42,7 +42,7 @@ Dancer2::Serializer::YAML - Serializer for handling YAML data =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Session/Simple.pm b/lib/Dancer2/Session/Simple.pm index 889a728c..616c7840 100644 --- a/lib/Dancer2/Session/Simple.pm +++ b/lib/Dancer2/Session/Simple.pm @@ -1,6 +1,6 @@ package Dancer2::Session::Simple; # ABSTRACT: in-memory session backend for Dancer2 -$Dancer2::Session::Simple::VERSION = '0.208001'; +$Dancer2::Session::Simple::VERSION = '0.300000'; use Moo; use Dancer2::Core::Types; use Carp; @@ -56,7 +56,7 @@ Dancer2::Session::Simple - in-memory session backend for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Session/YAML.pm b/lib/Dancer2/Session/YAML.pm index 111a385b..fe0ec8fc 100644 --- a/lib/Dancer2/Session/YAML.pm +++ b/lib/Dancer2/Session/YAML.pm @@ -1,5 +1,5 @@ package Dancer2::Session::YAML; -$Dancer2::Session::YAML::VERSION = '0.208001'; +$Dancer2::Session::YAML::VERSION = '0.300000'; # ABSTRACT: YAML-file-based session backend for Dancer2 use Moo; @@ -39,7 +39,7 @@ Dancer2::Session::YAML - YAML-file-based session backend for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 DESCRIPTION diff --git a/lib/Dancer2/Template/Implementation/ForkedTiny.pm b/lib/Dancer2/Template/Implementation/ForkedTiny.pm index f1c08d22..07bcb6e5 100644 --- a/lib/Dancer2/Template/Implementation/ForkedTiny.pm +++ b/lib/Dancer2/Template/Implementation/ForkedTiny.pm @@ -1,5 +1,5 @@ package Dancer2::Template::Implementation::ForkedTiny; -$Dancer2::Template::Implementation::ForkedTiny::VERSION = '0.208001'; +$Dancer2::Template::Implementation::ForkedTiny::VERSION = '0.300000'; # ABSTRACT: Dancer2 own implementation of Template::Tiny use 5.00503; @@ -225,7 +225,7 @@ Dancer2::Template::Implementation::ForkedTiny - Dancer2 own implementation of Te =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Template/Simple.pm b/lib/Dancer2/Template/Simple.pm index 8d84a572..817f9d72 100644 --- a/lib/Dancer2/Template/Simple.pm +++ b/lib/Dancer2/Template/Simple.pm @@ -1,6 +1,6 @@ package Dancer2::Template::Simple; # ABSTRACT: Pure Perl 5 template engine for Dancer2 -$Dancer2::Template::Simple::VERSION = '0.208001'; +$Dancer2::Template::Simple::VERSION = '0.300000'; use Moo; use Dancer2::FileUtils 'read_file_content'; use Ref::Util qw<is_arrayref is_coderef is_plain_hashref>; @@ -155,7 +155,7 @@ Dancer2::Template::Simple - Pure Perl 5 template engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Template/TemplateToolkit.pm b/lib/Dancer2/Template/TemplateToolkit.pm index 5c622d2f..f5ab9560 100644 --- a/lib/Dancer2/Template/TemplateToolkit.pm +++ b/lib/Dancer2/Template/TemplateToolkit.pm @@ -1,7 +1,7 @@ # ABSTRACT: Template toolkit engine for Dancer2 package Dancer2::Template::TemplateToolkit; -$Dancer2::Template::TemplateToolkit::VERSION = '0.208001'; +$Dancer2::Template::TemplateToolkit::VERSION = '0.300000'; use Moo; use Carp qw<croak>; use Dancer2::Core::Types; @@ -59,7 +59,7 @@ sub render { # # TT2 will look in a its INCLUDE_PATH for templates. # Typically $self->views is an absolute path, and we set ABSOLUTE=> 1 above. -# In that case TT2 does NOT itetare through what is set for INCLUDE_PATH +# In that case TT2 does NOT iterate through what is set for INCLUDE_PATH # However, if its not absolute, we want to allow TT2 iterate through the # its INCLUDE_PATH, which we set to be $self->views. @@ -101,7 +101,7 @@ Dancer2::Template::TemplateToolkit - Template toolkit engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS @@ -117,7 +117,7 @@ setting it manually with C<set>: Most configuration variables available when creating a new instance of a L<Template>::Toolkit object can be declared inside the template toolkit -section on the engines configuration (see your config.yml file): +section on the engines configuration in your config.yml file. For example: engines: template: @@ -125,8 +125,12 @@ section on the engines configuration (see your config.yml file): start_tag: '<%' end_tag: '%>' +(Note: C<start_tag> and C<end_tag> are regexes. If you want to use PHP-style +tags, you will need to list them as C<< <\? >> and C<< \?> >>.) +See L<Template::Manual::Config> for the configuration variables. + In addition to the standard configuration variables, the option C<show_private_variables> -is also available. Template::Toolkit, by default, do not render private variables +is also available. Template::Toolkit, by default, does not render private variables (the ones starting with an underscore). If in your project it gets easier to disable this feature than changing variable names, add this option to your configuration. @@ -144,7 +148,7 @@ This template engine allows you to use L<Template>::Toolkit in L<Dancer2>. =head2 render($template, \%tokens) Renders the template. The first arg is a filename for the template file -or a reference to a string that contains the template. The second arg +or a reference to a string that contains the template. The second arg is a hashref for the tokens that you wish to pass to L<Template::Toolkit> for rendering. @@ -207,10 +211,11 @@ template configuration settings: # in config.yml engines: - template_toolkit: - start_tag: '<%' - end_tag: '%>' - COMPILE_EXT: '.tcc' # cached file extension + template: + template_toolkit: + start_tag: '<%' + end_tag: '%>' + COMPILE_EXT: '.tcc' # cached file extension Template caching will avoid the need to re-parse template files or blocks each time they are used. Cached templates are automatically updated when you update the original template file. diff --git a/lib/Dancer2/Template/Tiny.pm b/lib/Dancer2/Template/Tiny.pm index 3bdc0555..5062e3a5 100644 --- a/lib/Dancer2/Template/Tiny.pm +++ b/lib/Dancer2/Template/Tiny.pm @@ -1,6 +1,6 @@ package Dancer2::Template::Tiny; # ABSTRACT: Template::Tiny engine for Dancer2 -$Dancer2::Template::Tiny::VERSION = '0.208001'; +$Dancer2::Template::Tiny::VERSION = '0.300000'; use Moo; use Carp qw/croak/; use Dancer2::Core::Types; @@ -50,7 +50,7 @@ Dancer2::Template::Tiny - Template::Tiny engine for Dancer2 =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Test.pm b/lib/Dancer2/Test.pm index 53815186..dfbb5002 100644 --- a/lib/Dancer2/Test.pm +++ b/lib/Dancer2/Test.pm @@ -1,6 +1,6 @@ package Dancer2::Test; # ABSTRACT: Useful routines for testing Dancer2 apps -$Dancer2::Test::VERSION = '0.208001'; +$Dancer2::Test::VERSION = '0.300000'; use strict; use warnings; @@ -629,7 +629,7 @@ Dancer2::Test - Useful routines for testing Dancer2 apps =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/lib/Dancer2/Tutorial.pod b/lib/Dancer2/Tutorial.pod index b5c9445c..870fa66d 100644 --- a/lib/Dancer2/Tutorial.pod +++ b/lib/Dancer2/Tutorial.pod @@ -13,7 +13,7 @@ Dancer2::Tutorial - An example to get you dancing =head1 VERSION -version 0.208001 +version 0.300000 =head1 What is Dancer2? @@ -44,7 +44,7 @@ explained step by step how to build an example application which was a little more involved than a trivial example. Using the -L<Flaskr|http://github.com/mitsuhiko/flask/tree/master/examples/flaskr/> +L<Flaskr|https://github.com/pallets/flask> sample application as my inspiration (OK, shamelessly plagiarised) I translated that application to the Dancer2 framework so I could better understand how Dancer2 worked. (I'm learning it too!) diff --git a/script/dancer2 b/script/dancer2 index fb31015d..503ea67a 100755 --- a/script/dancer2 +++ b/script/dancer2 @@ -33,7 +33,7 @@ dancer2 - Dancer2 command line interface =head1 VERSION -version 0.208001 +version 0.300000 =head1 SYNOPSIS diff --git a/share/skel/config.yml b/share/skel/config.yml index 7148ff13..7240c8a3 100644 --- a/share/skel/config.yml +++ b/share/skel/config.yml @@ -2,6 +2,8 @@ # env-related settings should go to environments/$env.yml # all the settings in this file will be loaded at Dancer's startup. +# === Basic configuration === + # Your application's name appname: "[d2% appname %2d]" @@ -14,6 +16,13 @@ layout: "main" # about unicode within your app when this setting is set (recommended). charset: "UTF-8" +# === Engines === +# +# NOTE: All the engine configurations need to be under a single "engines:" +# key. If you uncomment engine configurations below, make sure to delete +# all "engines:" lines except the first. Otherwise, only the last +# "engines:" block will take effect. + # template engine # simple: default and very basic template engine # template_toolkit: TT @@ -24,6 +33,7 @@ template: "simple" # engines: # template: # template_toolkit: +# # Note: start_tag and end_tag are regexes # start_tag: '<%' # end_tag: '%>' diff --git a/t/00-report-prereqs.dd b/t/00-report-prereqs.dd index f0a0b63e..70379f51 100644 --- a/t/00-report-prereqs.dd +++ b/t/00-report-prereqs.dd @@ -85,7 +85,6 @@ do { my $x = { 'Plack::Middleware::FixMissingBodyInRedirect' => '0', 'Plack::Middleware::RemoveRedundantBody' => '0', 'Ref::Util' => '0', - 'Return::MultiLevel' => '0', 'Role::Tiny' => '2.000000', 'Safe::Isa' => '0', 'Sub::Quote' => '0', diff --git a/t/author-no-tabs.t b/t/author-no-tabs.t index c3298129..9ed89298 100644 --- a/t/author-no-tabs.t +++ b/t/author-no-tabs.t @@ -248,6 +248,7 @@ my @files = ( 't/lib/SubApp2.pm', 't/lib/TestApp.pm', 't/lib/TestPod.pm', + 't/lib/TestTypeLibrary.pm', 't/lib/poc.pm', 't/lib/poc2.pm', 't/log_die_before_hook.t', diff --git a/t/classes/Dancer2-Core-Route/match.t b/t/classes/Dancer2-Core-Route/match.t index d13e4313..26520a8e 100644 --- a/t/classes/Dancer2-Core-Route/match.t +++ b/t/classes/Dancer2-Core-Route/match.t @@ -6,6 +6,7 @@ use Dancer2::Core::Request; use Dancer2::Core::Route; use Capture::Tiny 0.12 'capture_stderr'; use Ref::Util qw<is_regexpref>; +use lib 't/lib'; my @tests = ( [ [ 'get', '/', sub {11} ], '/', [ {}, 11 ] ], @@ -110,10 +111,11 @@ my @tests = ( '/foo/stuff48', [ { splat => [48] }, 44 ], ], + ); -plan tests => 110; +plan tests => 111; for my $t (@tests) { my ( $route, $path, $expected ) = @$t; @@ -268,3 +270,168 @@ note "routes with options"; { $m = $route_w_options->match($req); ok !defined $m, 'More options - Route did not match - test 2'; } + +subtest "typed route params" => sub { + my @tests = ( + { + name => "good type check", + route => { + regexp => '/some/:id[Int]', + }, + request => '/some/34', + match => { id => 34 }, + }, + { + name => "bad required type check", + route => { + regexp => '/some/:id[Int]', + }, + request => '/some/bad', + }, + { + name => "missing required type check", + route => { + regexp => '/some/:id[Int]', + }, + request => '/some/', + }, + { + name => "optional type check exists", + route => { + regexp => '/some/:id[Int]?', + }, + request => '/some/34', + match => { id => 34 }, + }, + { + name => "optional type check with bad token", + route => { + regexp => '/some/:id[Int]?', + }, + request => '/some/bad', + }, + { + name => "optional type check with empty token", + route => { + regexp => '/some/:id[Int]?', + }, + request => '/some/', + match => { id => undef }, + }, + { + name => "optional type check with empty token and optional missing trailing slash", + route => { + regexp => '/some/?:id[Int]?', + }, + request => '/some', + match => { id => undef }, + }, + { + name => "bad type", + route => { + regexp => '/some/:id[MyDate]?', + exception => qr/MyDate is not a known type constraint/, + }, + request => '/some/foo', + match => { id => undef }, + }, + { + name => "custom type with good match", + route => { + regexp => '/date/:date[MyDate]', + args => { type_library => 'TestTypeLibrary' }, + }, + request => '/date/2014-01-01', + match => { date => '2014-01-01' }, + }, + { + name => "custom type with bad match", + route => { + regexp => '/date/:date[MyDate]', + args => { type_library => 'TestTypeLibrary' }, + }, + request => '/date/X014-01-01', + }, + { + name => "type including type library but no type_library config setting", + route => { + regexp => '/date/:date[TestTypeLibrary::MyDate]', + }, + request => '/date/2014-01-01', + match => { date => '2014-01-01' }, + }, + { + name => "union of types", + route => { + regexp => '/date/:date[Int|TestTypeLibrary::MyDate]', + }, + request => '/date/2014-01-01', + match => { date => '2014-01-01' }, + }, + { + name => "union of types checking other type", + route => { + regexp => '/date/:date[Int|TestTypeLibrary::MyDate]', + }, + request => '/date/2014', + match => { date => '2014' }, + }, + { + name => "multiple typed tokens plus other tokens and splats", + route => { + regexp => '/:id[Int]/:date[MyDate]/:foo/*/**', + args => { type_library => 'TestTypeLibrary' }, + }, + request => '/42/2018-11-23/bar/dave/was/here', + match => { + id => 42, + date => '2018-11-23', + foo => 'bar', + splat => [ 'dave', [ 'was', 'here' ] ], + }, + }, + ); + + for my $test (@tests) { + my $method = $test->{route}{method} || 'get'; + + my %route_args = ( + method => $method, + regexp => $test->{route}{regexp}, + code => $test->{route}{code} || sub { 'OK' }, + $test->{route}{prefix} ? ( prefix => $test->{route}{prefix} ) : (), + $test->{route}{args} ? %{ $test->{route}{args} } : (), + ); + + if ( my $exception = $test->{route}{exception} ) { + like exception { Dancer2::Core::Route->new(%route_args) }, + $exception, + "'$test->{name}' throws expected exception in route constructor"; + next; + } + + my $route = Dancer2::Core::Route->new(%route_args); + my $request = Dancer2::Core::Request->new( + env => { + PATH_INFO => $test->{request}, + REQUEST_METHOD => $method, + } + ); + + my $match; + is exception { + $match = $route->match($request) + }, undef, "'$test->{name}' does not throw an exception"; + + my $expected = $test->{match}; + if ( defined $expected ) { + is_deeply $match, $expected, + "... and route matched with expected captures" + or diag explain $match; + } + else { + ok !defined $match, "... and route did not match" + or diag explain $match; + } + } +}; diff --git a/t/lib/TestTypeLibrary.pm b/t/lib/TestTypeLibrary.pm new file mode 100644 index 00000000..60329f0b --- /dev/null +++ b/t/lib/TestTypeLibrary.pm @@ -0,0 +1,8 @@ +package TestTypeLibrary; +use Type::Library -base, -declare => ('MyDate'); +use Type::Utils -all; +BEGIN { extends "Dancer2::Core::Types" }; + +declare MyDate, as StrMatch [qr{\d\d\d\d-\d\d-\d\d}]; + +1; |