NAME

Stencil::Source::Role

ABSTRACT

Perl 5 role source code generator

SYNOPSIS

use Stencil::Source::Role;

my $source = Stencil::Source::Role->new;

DESCRIPTION

This package provides a Perl 5 role source code generator, using this specification.

# package name
name: MyApp

# package roles
integrates:
- MyApp::Role::Doable

# package attributes
attributes:
- is: ro
  name: name
  type: Str
  required: 1

# generator operations
operations:
- from: class
  make: lib/MyApp.pm
- from: class-test
  make: t/MyApp.t

# package routines
routines:
- name: execute
  args: "(Str $key) : Any"
  desc: executes something which triggers something else

LIBRARIES

This package uses type constraints from:

Types::Standard

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues

name: MyApp

integrates: - MyApp::Role::Doable

attributes: - is: ro name: name type: Str required: 1

operations: - from: role make: lib/MyApp.pm - from: role-test make: t/MyApp.t

routines: - name: execute args: "(Str $key) : Any" desc: executes something which triggers something else

package [% data.name %];

use 5.014;

use strict; use warnings;

use Moo;

[%- IF data.integrates %] [%- FOR item IN data.integrates %] with '[% item %]'; [%- END %] [% END -%]

# VERSION

[%- IF data.attributes %] # ATTRIBUTES [% FOR item IN data.attributes %] has '[% item.name %]' => ( is => '[% item.is %]', isa => '[% item.type %]', required => [% item.required %], ); [% END -%] [% END -%]

[%- IF data.routines %] # ROUTINES [% FOR item IN data.routines %] sub [% item.name %] { my ($self) = @_;

# do something ...

return $self;
}
[% END -%]
[% END -%]

1;

=role-test

use 5.014;

use strict; use warnings;

use Test::More;

use_ok '[% data.name %]';

[%- IF data.integrates %] [%- FOR item IN data.integrates %] use_ok '[% item %]'; [%- END %] [% END -%]

subtest 'synopsis', sub {

# do something ...

};

[%- IF data.routines %] [%- FOR item IN data.routines %] subtest 'routine: [% item.name %]', sub {

# do something ...

}; [% END -%] [% END -%]

done_testing;

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 111:

Unknown directive: =spec

Around line 135:

Unknown directive: =role