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