1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package Exporter::Shiny;
use 5.006001;
use strict;
use warnings;
use Exporter::Tiny ();
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.042';
sub import {
my $me = shift;
my $caller = caller;
(my $nominal_file = $caller) =~ s(::)(/)g;
$INC{"$nominal_file\.pm"} ||= __FILE__;
if (@_ == 2 and $_[0] eq -setup)
{
my (undef, $opts) = @_;
@_ = @{ delete($opts->{exports}) || [] };
if (%$opts) {
Exporter::Tiny::_croak(
'Unsupported Sub::Exporter-style options: %s',
join(q[, ], sort keys %$opts),
);
}
}
ref($_) && Exporter::Tiny::_croak('Expected sub name, got ref %s', $_) for @_;
no strict qw(refs);
push @{"$caller\::ISA"}, 'Exporter::Tiny';
push @{"$caller\::EXPORT_OK"}, @_;
}
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Exporter::Shiny - shortcut for Exporter::Tiny
=head1 SYNOPSIS
use Exporter::Shiny qw( foo bar );
Is a shortcut for:
use base "Exporter::Tiny";
push our(@EXPORT_OK), qw( foo bar );
For compatibility with L<Sub::Exporter>, the following longer syntax is
also supported:
use Exporter::Shiny -setup => {
exports => [qw( foo bar )],
};
=head1 DESCRIPTION
This is a very small wrapper to simplify using L<Exporter::Tiny>.
It does the following:
=over
=item * Marks your package as loaded in C<< %INC >>;
=item * Pushes any function names in the import list onto your C<< @EXPORT_OK >>; and
=item * Pushes C<< "Exporter::Tiny" >> onto your C<< @ISA >>.
=back
It doesn't set up C<< %EXPORT_TAGS >> or C<< @EXPORT >>, but there's
nothing stopping you doing that yourself.
=head1 BUGS
Please report any bugs to
L<http://rt.cpan.org/Dist/Display.html?Queue=Exporter-Tiny>.
=head1 SEE ALSO
L<Exporter::Tiny>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT AND LICENCE
This software is copyright (c) 2014 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=head1 DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|