File Coverage

blib/lib/Mite.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 11 100.0


line stmt bran cond sub pod time code
1 1     1   706 use 5.010001;
  1         4  
2 1     1   5 use strict;
  1         1  
  1         19  
3 1     1   5 use warnings;
  1         1  
  1         59  
4              
5             package Mite;
6              
7             our $AUTHORITY = 'cpan:TOBYINK';
8             our $VERSION = '0.012000';
9              
10             1;
11              
12             __END__
13              
14             =pod
15              
16             =head1 NAME
17              
18             Mite - Moose-like OO, fast to load, with zero dependencies.
19              
20             =head1 SYNOPSIS
21              
22             Start a project:
23              
24             $ mite init Foo
25              
26             Write a class (F<lib/Foo.pm>):
27              
28             package Foo;
29            
30             use Foo::Mite;
31            
32             has attribute => (
33             is => 'rw',
34             );
35            
36             has another_attribute => (
37             is => 'ro',
38             default => 'Hello world',
39             );
40            
41             1;
42              
43             Write another class (F<lib/Foo/Bar.pm>):
44              
45             package Foo::Bar;
46            
47             use Foo::Mite;
48             extends 'Foo';
49            
50             sub my_method {
51             my $class = shift;
52             print $class->new->another_attribute, "\n";
53             }
54            
55             1;
56              
57             Compile your project:
58              
59             $ mite compile
60              
61             Use your project:
62              
63             $ perl -Ilib -MFoo::Bar -E'Foo::Bar->my_method'
64              
65             =head1 DESCRIPTION
66              
67             Mite provides a subset of Moose features with very fast startup time
68             and zero dependencies.
69              
70             L<Moose> and L<Moo> are great... unless you can't have any dependencies
71             or compile-time is critical.
72              
73             Mite provides Moose-like functionality, but it does all the work
74             during development. New source code is written which contains the OO
75             code. Your project does not have to depend on Mite. Nor does your
76             project have to spend time during startup to build OO features.
77              
78             Mite is for a very narrow set of use cases. Unless you specifically
79             need ultra-fast startup time or zero dependencies, use L<Moose> or
80             L<Moo>.
81              
82             =head1 OPTIMIZATIONS
83              
84             Mite writes pure Perl code and your module will run with no
85             dependencies. It will also write code to use other, faster modules to
86             do the same job, if available.
87              
88             These optimizations can be turned off by setting the C<PERL_ONLY>
89             environment variable true.
90              
91             You may wish to add these as recommended dependencies.
92              
93             =head2 Class::XSAccessor
94              
95             Mite will use L<Class::XSAccessor> for accessors if available. They
96             are significantly faster than those written in Perl.
97              
98             =head1 WHY IS THIS
99              
100             This module exists for a very special set of use cases. Authors of
101             toolchain modules (Test::More, ExtUtils::MakeMaker, File::Spec,
102             etc...) who cannot easily depend on other CPAN modules. It would
103             cause a circular dependency and add instability to CPAN. These
104             authors are frustrated at not being able to use most of the advances
105             in Perl present on CPAN, such as Moose.
106              
107             To add to their burden, by being used by almost everyone, toolchain
108             modules limit how fast modules can load. So they have to compile very
109             fast. They do not have the luxury of creating attributes and
110             including roles at compile time. It must be baked in.
111              
112             Use Mite if your project cannot have non-core dependencies or needs to
113             load very quickly.
114              
115             =head1 BUGS
116              
117             Please report any bugs to L<https://github.com/tobyink/p5-mite/issues>.
118              
119             =head1 SEE ALSO
120              
121             L<Mite::Manual::Workflow> - how to develop with Mite.
122              
123             L<Mite::Manual::Keywords> - functions exported by Mite.
124              
125             L<Mite::Manual::Attributes> - options for defining attributes with Mite.
126              
127             L<Mite::Manual::Features> - other features provided by Mite.
128              
129             L<Mite::Manual::MOP> - integration with the Moose Meta-Object Protocol.
130              
131             L<Mite::Manual::Missing> - major Moose features not supported by Mite.
132              
133             L<Mite::Manual::Benchmarking> - comparing Mite with Moose, Moo, and Mouse.
134              
135             L<https://metacpan.org/dist/Acme-Mitey-Cards> - demo project.
136              
137             L<Moose> is the complete Perl 5 OO module which this is all based on.
138              
139             L<Moo> is a lighter-weight Moose-compatible module with fewer dependencies.
140              
141             L<Type::Library::Compiler> allows you to create a zero-dependency compiled
142             version of your type constraint library, which can be used by Mite.
143              
144              
145             =head1 AUTHOR
146              
147             Michael G Schwern E<lt>mschwern@cpan.orgE<gt>.
148              
149             Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
150              
151             =head1 COPYRIGHT AND LICENCE
152              
153             This software is copyright (c) 2011-2014 by Michael G Schwern.
154              
155             This software is copyright (c) 2022 by Toby Inkster.
156              
157             This is free software; you can redistribute it and/or modify it under
158             the same terms as the Perl 5 programming language system itself.
159              
160             =head1 DISCLAIMER OF WARRANTIES
161              
162             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
163             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
164             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
165              
166             =cut