line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
56048
|
use 5.14.0; |
|
1
|
|
|
|
|
11
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package MoopsX::UsingMoose; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: A Moops that uses Moose |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $VERSION = '0.0103'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use base 'Moops'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
437
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
2
|
|
|
2
|
|
5562
|
my $class = shift; |
15
|
2
|
|
|
|
|
4
|
my %opts = @_; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
50
|
|
|
3
|
push @{ $opts{'traits'} ||= [] } => ( |
|
2
|
|
|
|
|
14
|
|
18
|
|
|
|
|
|
|
'MoopsX::TraitFor::Parser::UsingMoose', |
19
|
|
|
|
|
|
|
); |
20
|
2
|
|
|
|
|
14
|
$class->SUPER::import(%opts); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
__END__ |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=encoding UTF-8 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
MoopsX::UsingMoose - A Moops that uses Moose |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=begin html |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
<p> |
40
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/perl-5.14+-blue.svg" alt="Requires Perl 5.14+" /> |
41
|
|
|
|
|
|
|
<a href="https://travis-ci.org/Csson/p5-MoopsX-UsingMoose"><img src="https://api.travis-ci.org/Csson/p5-MoopsX-UsingMoose.svg?branch=master" alt="Travis status" /></a> |
42
|
|
|
|
|
|
|
<a href="http://cpants.cpanauthors.org/release/CSSON/MoopsX-UsingMoose-0.0103"><img src="http://badgedepot.code301.com/badge/kwalitee/CSSON/MoopsX-UsingMoose/0.0103" alt="Distribution kwalitee" /></a> |
43
|
|
|
|
|
|
|
<a href="http://matrix.cpantesters.org/?dist=MoopsX-UsingMoose%200.0103"><img src="http://badgedepot.code301.com/badge/cpantesters/MoopsX-UsingMoose/0.0103" alt="CPAN Testers result" /></a> |
44
|
|
|
|
|
|
|
<img src="https://img.shields.io/badge/coverage-97.4%-yellow.svg" alt="coverage 97.4%" /> |
45
|
|
|
|
|
|
|
</p> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=end html |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 VERSION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Version 0.0103, released 2020-07-29. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use MoopsX::UsingMoose; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
class My::Class { |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# A Moose based class |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 STATUS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Do note the inherent L<issues|Moops/"STATUS"> with using L<Moops>. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is a thin wrapper around L<Moops> that automatically adds C<using Moose> to C<role> and C<class> statements. It does this by applying the included L<MoopsX::TraitFor::Parser::UsingMoose> C<Moops::Parser> trait. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 Rationale |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
While this on the surface doesn't save any keystrokes it reduces cluttering of C<role>/C<class> statements. Consider the following: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use Moops; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
class My::Project::Class |
78
|
|
|
|
|
|
|
types Types::Standard, |
79
|
|
|
|
|
|
|
Types::Path::Tiny, |
80
|
|
|
|
|
|
|
Types::MyCustomTypes |
81
|
|
|
|
|
|
|
with This::Role |
82
|
|
|
|
|
|
|
using Moose { |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# A Moose based class |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
That is not very nice. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The first step is to get rid of C<using Moose>: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use MoopsX::UsingMoose; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
class My::Project::Class |
95
|
|
|
|
|
|
|
types Types::Standard, |
96
|
|
|
|
|
|
|
Types::Path::Tiny, |
97
|
|
|
|
|
|
|
Types::MyCustomTypes |
98
|
|
|
|
|
|
|
with This::Role { |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# A Moose based class |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
A minor improvement. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
However, create a project specific L<Moops wrapper|Moops/"Extending-Moops-via-imports">: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
package My::Project::Moops; |
109
|
|
|
|
|
|
|
use base 'MoopsX::UsingMoose'; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
use Types::Standard(); |
112
|
|
|
|
|
|
|
use Types::Path::Tiny(); |
113
|
|
|
|
|
|
|
use Types::MyCustomTypes(); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub import { |
116
|
|
|
|
|
|
|
my $class = shift; |
117
|
|
|
|
|
|
|
my %opts = @_; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
push @{ $opts{'imports'} ||= [] } => ( |
120
|
|
|
|
|
|
|
'Types::Standard' => ['-types'], |
121
|
|
|
|
|
|
|
'Types::Path::Tiny' => ['-types'], |
122
|
|
|
|
|
|
|
'Types::MyCustomTypes' => ['-types'], |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$class->SUPER::import(%opts); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
And the C<class> statement becomes: |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
use My::Project::Moops; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
class My::Project::Class with This::Role { |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# A Moose based class, still with all the types |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Happiness ensues. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SEE ALSO |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<Moops> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<Moose> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L<Moo> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=back |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SOURCE |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-MoopsX-UsingMoose> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 HOMEPAGE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L<https://metacpan.org/release/MoopsX-UsingMoose> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Erik Carlsson. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
175
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |