line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
14360
|
use 5.14.0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.0101'; # VERSION: |
6
|
|
|
|
|
|
|
# ABSTRACT: A Moops that uses Moose |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package MoopsX::UsingMoose { |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3
|
use base 'Moops'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
409
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
2
|
|
|
2
|
|
2539
|
my $class = shift; |
14
|
2
|
|
|
|
|
4
|
my %opts = @_; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
50
|
|
|
2
|
push @{ $opts{'traits'} ||= [] } => ( |
|
2
|
|
|
|
|
20
|
|
17
|
|
|
|
|
|
|
'MoopsX::TraitFor::Parser::UsingMoose', |
18
|
|
|
|
|
|
|
); |
19
|
2
|
|
|
|
|
11
|
$class->SUPER::import(%opts); |
20
|
|
|
|
|
|
|
} |
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
|
|
|
|
|
|
|
=head1 VERSION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Version 0.0101, released 2015-03-19. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use MoopsX::UsingMoose; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
class My::Class { |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# A Moose based class |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
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. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Rationale |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
While this on the surface doesn't save any keystrokes it reduces cluttering of C<role>/C<class> statements. Consider the following: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use Moops; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
class My::Project::Class |
60
|
|
|
|
|
|
|
types Types::Standard, |
61
|
|
|
|
|
|
|
Types::Path::Tiny, |
62
|
|
|
|
|
|
|
Types::MyCustomTypes |
63
|
|
|
|
|
|
|
with This::Role |
64
|
|
|
|
|
|
|
using Moose { |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# A Moose based class |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
That is not very nice. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The first step is to get rid of C<using Moose>: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
use MoopsX::UsingMoose; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
class My::Project::Class |
77
|
|
|
|
|
|
|
types Types::Standard, |
78
|
|
|
|
|
|
|
Types::Path::Tiny, |
79
|
|
|
|
|
|
|
Types::MyCustomTypes |
80
|
|
|
|
|
|
|
with This::Role { |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# A Moose based class |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
A minor improvement. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
However, create a project specific L<Moops wrapper|Moops/"Extending-Moops-via-imports">: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
package My::Project::Moops; |
91
|
|
|
|
|
|
|
use base 'MoopsX::UsingMoose'; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use Types::Standard(); |
94
|
|
|
|
|
|
|
use Types::Path::Tiny(); |
95
|
|
|
|
|
|
|
use Types::MyCustomTypes(); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub import { |
98
|
|
|
|
|
|
|
my $class = shift; |
99
|
|
|
|
|
|
|
my %opts = @_; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
push @{ $opts{'imports'} ||= [] } => ( |
102
|
|
|
|
|
|
|
'Types::Standard' => ['-types'], |
103
|
|
|
|
|
|
|
'Types::Path::Tiny' => ['-types'], |
104
|
|
|
|
|
|
|
'Types::MyCustomTypes' => ['-types'], |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$class->SUPER::import(%opts); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
And the C<class> statement becomes: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use My::Project::Moops; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
class My::Project::Class with This::Role { |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# A Moose based class, still with all the types |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Happiness ensues. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<Moops> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L<Moose> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<Moo> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 SOURCE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-MoopsX-UsingMoose> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 HOMEPAGE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<https://metacpan.org/release/MoopsX-UsingMoose> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Erik Carlsson <info@code301.com>. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |