[dancer-users] Usage Of Plugins Out Of CPAN

Kadir Beyazlı kadirbeyazli at gmail.com
Mon May 25 21:57:42 BST 2015


Hi,

Now, it found Dancer2::Plugin::OnTuesday because I see different error
message when I run test.pl:

isa check for "options" failed: on_tuesday is not a HashRef! at (eval
118) line 200.
    eval {...} called at (eval 118) line 198
    Dancer2::Core::Route::new("Dancer2::Core::Route", "method", "get",
"options", "on_tuesday", "code", CODE(0x2785ad0), "regexp", "/", ...)
called at /usr/local/share/perl/5.20.1/Dancer2/Core/App.pm line 997
    Dancer2::Core::App::add_route(Dancer2::Core::App=HASH(0x1d00170),
"options", "on_tuesday", "code", CODE(0x2785ad0), "regexp", "/",
"method", "get", ...) called at
/usr/local/share/perl/5.20.1/Dancer2/Core/DSL.pm line 231
    Dancer2::Core::DSL::_normalize_route(Dancer2::Core::DSL=HASH(0x21edfd8),
ARRAY(0xc67058), "/", "on_tuesday", CODE(0x2785ad0)) called at
/usr/local/share/perl/5.20.1/Dancer2/Core/DSL.pm line 199
    Dancer2::Core::DSL::get(Dancer2::Core::DSL=HASH(0x21edfd8), "/",
"on_tuesday", CODE(0x2785ad0)) called at
/usr/local/share/perl/5.20.1/Dancer2/Core/Role/DSL.pm line 71
    Dancer2::Core::Role::DSL::__ANON__("/", "on_tuesday",
CODE(0x2785ad0)) called at test.pl line 6



On Mon, May 25, 2015 at 11:53 PM, Kadir Beyazlı <kadirbeyazli at gmail.com> wrote:
> Hi,
>
> I understood how to use plugins which are already installed to CPAN.
> I install it and use.
> But how will I test my own plugins I wrote at local?
>
> For example, I want to test following code taken from dancer manual
> (https://metacpan.org/pod/Dancer2::Manual)
>
> # Start of plugin
> package Dancer2::Plugin::OnTuesday;
> # ABSTRACT: Make sure a route only works on Tuesday
> use Dancer2::Plugin;
>
> register on_tuesday => sub {
>     my ( $dsl, $route_sub, @args ) = plugin_args(@_);
>
>     my $day = (localtime)[6];
>     $day == 2 or return pass;
>
>     return $route_sub->( $dsl, @args );
> };
>
> register_plugin;
> # End of plugin
>
> To be able to use above plugin at my local, I created .pm file at
> following folder:
>
> MyApp/lib/Dancer2/Plugin/OnTuesday.pm
>
> I wrote following code at folder MyApp/test.pl
>
> # Start of script
> use Dancer2;
> use lib "lib";
>
> use Dancer2::Plugin::OnTuesday;
>
> get '/' => on_tuesday => sub { return "tuesday" };
>
> # every other day
> get '/' => sub { return "other day" };
>
> start;
> # End of script
>
> When I rub test.pl I got following error:
>
> Can't locate Dancer2/Plugin/OnTuesday.pm in @INC
>
>
> Kadir Beyazlı
> Computer Engineer
> GSM : +90 535 821 50 00



-- 
Kadir Beyazlı
Computer Engineer
GSM : +90 535 821 50 00


More information about the dancer-users mailing list