Exporter-Almighty
view release on metacpan or search on metacpan
use v5.12;
use Exporter::Almighty -setup => {
tag => {
foo => [ 'foo1', 'foo2' ],
bar => [ 'bar1' ],
},
const => {
colours => { RED => 'red', BLUE => 'blue', GREEN => 'green' },
},
enum => {
Status => [ 'dead', 'alive' ],
},
also => [
'strict',
'Scalar::Util' => [ 'refaddr' ],
'warnings',
],
};
sub foo1 { ... }
sub foo2 { ... }
being a subclass of Type::Library instead of Exporter::Tiny.
(Type::Library is itself a subclass of Exporter::Tiny, so you don't miss
out on any features.)
`enum`
This is a hashref where keys are enumerated type names, and the values are
arrayrefs of strings.
use Exporter::Almighty -setup => {
enum => {
Status => [ 'dead', 'alive' ],
},
};
A user of the package defined in the "SYNOPSIS" could import:
use Your::Package qw(
Status
is_Status
assert_Status
to_Status
lib/Exporter/Almighty.pm view on Meta::CPAN
use v5.12;
use Exporter::Almighty -setup => {
tag => {
foo => [ 'foo1', 'foo2' ],
bar => [ 'bar1' ],
},
const => {
colours => { RED => 'red', BLUE => 'blue', GREEN => 'green' },
},
enum => {
Status => [ 'dead', 'alive' ],
},
also => [
'strict',
'Scalar::Util' => [ 'refaddr' ],
'warnings',
],
};
sub foo1 { ... }
sub foo2 { ... }
lib/Exporter/Almighty.pm view on Meta::CPAN
a subclass of L<Type::Library> instead of L<Exporter::Tiny>. (Type::Library is
itself a subclass of Exporter::Tiny, so you don't miss out on any features.)
=head3 C<< enum >>
This is a hashref where keys are enumerated type names, and the values are
arrayrefs of strings.
use Exporter::Almighty -setup => {
enum => {
Status => [ 'dead', 'alive' ],
},
};
A user of the package defined in the L</SYNOPSIS> could import:
use Your::Package qw(
Status
is_Status
assert_Status
to_Status
t/integration/synopsis.t view on Meta::CPAN
package Local::Package;
use Exporter::Almighty -setup => {
tag => {
foo => [ 'foo1', 'foo2' ],
bar => [ 'bar1' ],
},
const => {
colours => { RED => 'red', BLUE => 'blue', GREEN => 'green' },
},
enum => {
Status => [ 'dead', 'alive' ],
},
also => [
'strict',
'Scalar::Util' => [ 'refaddr' ],
'warnings',
],
};
sub foo1 { 'foo:foo1' }
sub foo2 { 'foo:foo2' }
sub bar1 { 'bar:bar1' }
1;
};
isa_ok( 'Local::Package', 'Type::Library' );
{
use Local::Package -all, -lexical;
is( RED, 'red' );
is( foo1(), 'foo:foo1' );
isa_ok( Status, 'Type::Tiny' );
is( STATUS_ALIVE, 'alive' );
ok( is_Status( 'dead' ) );
ok( not is_Status( 'bob' ) );
ok( refaddr( [] ) );
}
ok !eval 'my $x = STATUS_ALIVE;';
done_testing;
( run in 0.977 second using v1.01-cache-2.11-cpan-483215c6ad5 )