line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Test-Moose-More |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2017, 2016, 2015, 2014, 2013, 2012 by Chris Weyl. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Test::Moose::More::Utils; |
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RSRCHBOY'; |
12
|
|
|
|
|
|
|
$Test::Moose::More::Utils::VERSION = '0.048'; |
13
|
|
|
|
|
|
|
# ABSTRACT: Various utility functions for TMM (and maybe others!) |
14
|
|
|
|
|
|
|
|
15
|
41
|
|
|
41
|
|
264
|
use strict; |
|
41
|
|
|
|
|
92
|
|
|
41
|
|
|
|
|
1110
|
|
16
|
41
|
|
|
41
|
|
199
|
use warnings; |
|
41
|
|
|
|
|
129
|
|
|
41
|
|
|
|
|
1562
|
|
17
|
|
|
|
|
|
|
|
18
|
41
|
|
|
|
|
474
|
use Sub::Exporter::Progressive -setup => { |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
exports => [ qw{ |
21
|
|
|
|
|
|
|
get_mop_metaclass_for |
22
|
|
|
|
|
|
|
known_sugar |
23
|
|
|
|
|
|
|
} ], |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
groups => { default => [':all'] }, |
26
|
41
|
|
|
41
|
|
219
|
}; |
|
41
|
|
|
|
|
82
|
|
27
|
|
|
|
|
|
|
|
28
|
41
|
|
|
41
|
|
6589
|
use Carp 'croak'; |
|
41
|
|
|
|
|
89
|
|
|
41
|
|
|
|
|
1918
|
|
29
|
41
|
|
|
41
|
|
235
|
use List::Util 1.33 qw( first all ); |
|
41
|
|
|
|
|
947
|
|
|
41
|
|
|
|
|
2361
|
|
30
|
41
|
|
|
41
|
|
247
|
use Scalar::Util 'blessed'; |
|
41
|
|
|
|
|
92
|
|
|
41
|
|
|
|
|
7964
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_mop_metaclass_for { |
34
|
128
|
|
|
128
|
1
|
169421
|
my ($mop, $meta) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# FIXME make this less... bad |
37
|
|
|
|
|
|
|
# short-circuit! Better a special case here than *everywhere* else |
38
|
128
|
100
|
100
|
|
|
748
|
return blessed $meta |
39
|
|
|
|
|
|
|
if $mop eq 'class' || $mop eq 'role'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# this code largely lifted from Moose::Util::MetaRole |
42
|
|
|
|
|
|
|
my $attr = |
43
|
110
|
|
|
110
|
|
17069
|
first { $_ } |
44
|
110
|
|
|
|
|
529
|
map { $meta->meta->find_attribute_by_name($_) } |
|
220
|
|
|
|
|
17589
|
|
45
|
|
|
|
|
|
|
("${mop}_metaclass", "${mop}_class") |
46
|
|
|
|
|
|
|
; |
47
|
|
|
|
|
|
|
|
48
|
110
|
50
|
|
|
|
426
|
croak "Cannot find attribute storing the metaclass for $mop in " . $meta->name |
49
|
|
|
|
|
|
|
unless $attr; |
50
|
|
|
|
|
|
|
|
51
|
110
|
|
|
|
|
356
|
my $read_method = $attr->get_read_method; |
52
|
|
|
|
|
|
|
|
53
|
110
|
|
|
|
|
3134
|
return $meta->$read_method(); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
16
|
|
|
16
|
1
|
5492
|
sub known_sugar () { qw{ has around augment inner before after blessed confess } } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
!!42; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=for :stopwords Chris Weyl Chad Etheridge Granum Karen TMM |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Test::Moose::More::Utils - Various utility functions for TMM (and maybe others!) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This document describes version 0.048 of Test::Moose::More::Utils - released June 17, 2017 as part of Test-Moose-More. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 FUNCTIONS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 get_mop_metaclass_for $mop => $meta |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Given a MOP name (e.g. attribute), rummage through $meta (a metaclass) to reveal the MOP's metaclass. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
e.g. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
get_metaclass_for attribute => __PACKAGE__->meta; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 known_sugar |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returns a list of all the known standard Moose sugar (has, extends, etc). |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SEE ALSO |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<Test::Moose::More|Test::Moose::More> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L<L<Moose::Util::MetaRole> -- for much of the "find the metaclass for X mop" code|L<Moose::Util::MetaRole> -- for much of the "find the metaclass for X mop" code> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 BUGS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
110
|
|
|
|
|
|
|
L<https://github.com/RsrchBoy/Test-Moose-More/issues> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
113
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
114
|
|
|
|
|
|
|
feature. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Chris Weyl <cweyl@alumni.drew.edu> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is Copyright (c) 2017, 2016, 2015, 2014, 2013, 2012 by Chris Weyl. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software, licensed under: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |