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