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