ouse.pm!
[gitmo/Mouse.git] / lib / ouse.pm
CommitLineData
b0e7066c 1package ouse;
2
3use strict;
4use warnings;
5
6our $VERSION = '0.59';
7
8BEGIN {
9 my $package;
10 sub import {
11 $package = $_[1] || 'Class';
12 if ($package =~ /^\+/) {
13 $package =~ s/^\+//;
14 eval "require $package; 1" or die;
15 }
16 }
17 use Filter::Simple sub { s/^/package $package;\nuse Mouse;\n/; }
18}
19
201;
21
22__END__
23
24=pod
25
26=head1 NAME
27
28ouse - syntactic sugar to make Mouse one-liners easier
29
30=head1 SYNOPSIS
31
32 # create a Mouse class on the fly ...
33 perl -Mouse=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz
34
35 # loads an existing class (Mouse or non-Mouse)
36 # and re-"opens" the package definition to make
37 # debugging/introspection easier
38 perl -Mouse=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
39
40=head1 DESCRIPTION
41
42ouse.pm is a simple source filter that adds C<package $name; use Mouse;>
43to the beginning of your script and was entirely created because typing
44perl -e'package Foo; use Mouse; ...' was annoying me... especially after
45getting used to having C<-Moose> for Moose.
46
47=head1 INTERFACE
48
49ouse provides exactly one method and it's automically called by perl:
50
51=over 4
52
53=item B<import($package)>
54
55Pass a package name to import to be used by the source filter.
56
57=back
58
59=head1 DEPENDENCIES
60
61You will need L<Filter::Simple> and eventually L<Mouse>
62
63=head1 INCOMPATIBILITIES
64
65None reported. But it is a source filter and might have issues there.
66
67=head1 BUGS
68
69All complex software has bugs lurking in it, and this module is no
70exception. If you find a bug please either email me, or add the bug
71to cpan-RT.
72
73=head1 AUTHOR
74
75For all intents and purposes, blame:
76
77Chris Prather C<< <perigrin@cpan.org> >>
78
79...who wrote ouse.pm, which was adapted for use by Mouse by:
80
81Ricardo SIGNES C<< <rjbs@cpan.org> >>
82
83=head1 COPYRIGHT AND LICENSE
84
85Copyright 2008 Shawn M Moore.
86
87This program is free software; you can redistribute it and/or modify it
88under the same terms as Perl itself.
89
90=cut