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