APISchema

 view release on metacpan or  search on metacpan

eg/bmi.psgi  view on Meta::CPAN

use strict;
use warnings;
use lib '../lib';
use lib glob '../modules/*/lib/';

use Plack::Builder;
use Plack::Request;
use APISchema::DSL;
use APISchema::Generator::Router::Simple;
use Plack::App::APISchema::Document;
use Plack::App::APISchema::MockServer;
use APISchema::Generator::Markdown;

use JSON qw(decode_json encode_json);

lib/APISchema/DSL.pm  view on Meta::CPAN

sub include ($) { $_directive->{include}->(@_) }
sub title ($) { $_directive->{title}->(@_) }
sub description ($) { $_directive->{description}->(@_) }
sub filter (&) { $_directive->{filter}->(@_) }
sub resource ($@) { $_directive->{resource}->(@_) }
for my $method (keys %METHODS) {
    no strict 'refs';
    *$method = sub ($@) { goto \&{ $_directive->{$method} } };
}

# disable the global definitions
@$_directive{@DIRECTIVES} = (sub {
    Carp::croak(sprintf(
        q(%s should be called inside 'process {}' block),
        join '/', @DIRECTIVES
    ));
}) x scalar @DIRECTIVES;

1;
__END__

t/APISchema-DSL.t  view on Meta::CPAN

use lib '.';
use t::test;
use Encode qw(decode_utf8);

sub _require : Test(startup => 1) {
    my ($self) = @_;

    BEGIN{ use_ok 'APISchema::DSL'; }
}

sub no_global : Tests {
    dies_ok {
        filter {};
    };

    dies_ok {
        title 'test';
    };

    dies_ok {
        description 'test';

t/test.pm  view on Meta::CPAN

package t::test;

use strict;
use warnings;

use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use lib lib => 't/lib' => glob 'modules/*/lib';


sub import {
    my ($class) = @_;

    strict->import;
    warnings->import;

    my ($package, $file) = caller;



( run in 0.508 second using v1.01-cache-2.11-cpan-49f99fa48dc )