| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::Declare::Syntax::OptionHandling; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Option parser dispatching |
|
3
|
|
|
|
|
|
|
$MooseX::Declare::Syntax::OptionHandling::VERSION = '0.40'; |
|
4
|
24
|
|
|
24
|
|
11776
|
use Moose::Role; |
|
|
24
|
|
|
|
|
43
|
|
|
|
24
|
|
|
|
|
143
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
93140
|
use Carp qw( croak ); |
|
|
24
|
|
|
|
|
46
|
|
|
|
24
|
|
|
|
|
1484
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
24
|
|
|
24
|
|
116
|
use namespace::clean -except => 'meta'; |
|
|
24
|
|
|
|
|
38
|
|
|
|
24
|
|
|
|
|
206
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
11
|
|
|
|
|
|
|
#pod |
|
12
|
|
|
|
|
|
|
#pod This role will call a C<add_foo_option_customization> for every C<foo> option |
|
13
|
|
|
|
|
|
|
#pod that is discovered. |
|
14
|
|
|
|
|
|
|
#pod |
|
15
|
|
|
|
|
|
|
#pod =head1 REQUIRED METHODS |
|
16
|
|
|
|
|
|
|
#pod |
|
17
|
|
|
|
|
|
|
#pod =head2 get_identifier |
|
18
|
|
|
|
|
|
|
#pod |
|
19
|
|
|
|
|
|
|
#pod Str Object->get_identifier () |
|
20
|
|
|
|
|
|
|
#pod |
|
21
|
|
|
|
|
|
|
#pod This must return the name of the current keyword's identifier. |
|
22
|
|
|
|
|
|
|
#pod |
|
23
|
|
|
|
|
|
|
#pod =cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
requires qw( get_identifier ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#pod =method ignored_options |
|
28
|
|
|
|
|
|
|
#pod |
|
29
|
|
|
|
|
|
|
#pod List[Str] Object->ignored_options () |
|
30
|
|
|
|
|
|
|
#pod |
|
31
|
|
|
|
|
|
|
#pod This method returns a list of option names that won't be dispatched. By default |
|
32
|
|
|
|
|
|
|
#pod this only contains the C<is> option. |
|
33
|
|
|
|
|
|
|
#pod |
|
34
|
|
|
|
|
|
|
#pod =cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
61
|
|
|
61
|
1
|
187
|
sub ignored_options { qw( is ) } |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#pod =head1 MODIFIED METHODS |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod =head2 add_optional_customizations |
|
42
|
|
|
|
|
|
|
#pod |
|
43
|
|
|
|
|
|
|
#pod Object->add_optional_customizations (Object $context, Str $package, HashRef $options) |
|
44
|
|
|
|
|
|
|
#pod |
|
45
|
|
|
|
|
|
|
#pod This will dispatch to the respective C<add_*_option_customization> method for option |
|
46
|
|
|
|
|
|
|
#pod handling unless the option is listed in the L</ignored_options>. |
|
47
|
|
|
|
|
|
|
#pod |
|
48
|
|
|
|
|
|
|
#pod =cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
after add_optional_customizations => sub { |
|
51
|
|
|
|
|
|
|
my ($self, $ctx, $package) = @_; |
|
52
|
|
|
|
|
|
|
my $options = $ctx->options; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# ignored options |
|
55
|
|
|
|
|
|
|
my %ignored = map { ($_ => 1) } $self->ignored_options; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# try to find a handler for each option |
|
58
|
|
|
|
|
|
|
for my $option (keys %$options) { |
|
59
|
|
|
|
|
|
|
next if $ignored{ $option }; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# call the handler with its own value and all options |
|
62
|
|
|
|
|
|
|
if (my $method = $self->can("add_${option}_option_customizations")) { |
|
63
|
|
|
|
|
|
|
$self->$method($ctx, $package, $options->{ $option }, $options); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# no handler method was found |
|
67
|
|
|
|
|
|
|
else { |
|
68
|
|
|
|
|
|
|
croak sprintf q/The '%s' keyword does not know what to do with an '%s' option/, |
|
69
|
|
|
|
|
|
|
$self->get_identifier, |
|
70
|
|
|
|
|
|
|
$option; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return 1; |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
78
|
|
|
|
|
|
|
#pod |
|
79
|
|
|
|
|
|
|
#pod =for :list |
|
80
|
|
|
|
|
|
|
#pod * L<MooseX::Declare> |
|
81
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::NamespaceHandling> |
|
82
|
|
|
|
|
|
|
#pod |
|
83
|
|
|
|
|
|
|
#pod =cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding UTF-8 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
MooseX::Declare::Syntax::OptionHandling - Option parser dispatching |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
version 0.40 |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This role will call a C<add_foo_option_customization> for every C<foo> option |
|
104
|
|
|
|
|
|
|
that is discovered. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 METHODS |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 ignored_options |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
List[Str] Object->ignored_options () |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This method returns a list of option names that won't be dispatched. By default |
|
113
|
|
|
|
|
|
|
this only contains the C<is> option. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 get_identifier |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Str Object->get_identifier () |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This must return the name of the current keyword's identifier. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 MODIFIED METHODS |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 add_optional_customizations |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Object->add_optional_customizations (Object $context, Str $package, HashRef $options) |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This will dispatch to the respective C<add_*_option_customization> method for option |
|
130
|
|
|
|
|
|
|
handling unless the option is listed in the L</ignored_options>. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<MooseX::Declare> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::NamespaceHandling> |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=back |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Florian Ragwitz. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
155
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |