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