line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-Plugin-BundleInspector |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2013 by Randy Stauner. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
3
|
|
|
3
|
|
436
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
79
|
|
10
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
139
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Dist::Zilla::Config::BundleInspector; |
13
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RWSTAUNER'; |
14
|
|
|
|
|
|
|
# ABSTRACT: Give Hints to Config::MVP::BundleInspector |
15
|
|
|
|
|
|
|
$Dist::Zilla::Config::BundleInspector::VERSION = '0.004'; |
16
|
3
|
|
|
3
|
|
355
|
use Class::Load (); |
|
3
|
|
|
|
|
19329
|
|
|
3
|
|
|
|
|
43
|
|
17
|
3
|
|
|
3
|
|
1122
|
use Sub::Override (); |
|
3
|
|
|
|
|
2005
|
|
|
3
|
|
|
|
|
45
|
|
18
|
3
|
|
|
3
|
|
14
|
use Try::Tiny; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
151
|
|
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
3
|
|
427
|
use Moose; |
|
3
|
|
|
|
|
308626
|
|
|
3
|
|
|
|
|
18
|
|
21
|
|
|
|
|
|
|
extends 'Config::MVP::BundleInspector'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
around _build_bundle_method => sub { |
24
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
25
|
|
|
|
|
|
|
Class::Load::load_class($self->bundle_class); |
26
|
|
|
|
|
|
|
return $self->bundle_class->can('bundle_config') |
27
|
|
|
|
|
|
|
? 'bundle_config' |
28
|
|
|
|
|
|
|
: $self->$orig(); |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _build_bundle_name { |
32
|
10
|
|
|
10
|
|
393
|
my ($self) = @_; |
33
|
10
|
|
|
|
|
218
|
(my $name = $self->bundle_class) =~ s/.+::PluginBundle::/\@/; |
34
|
10
|
|
|
|
|
310
|
return $name; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
around _plugin_specs_from_bundle_method => sub { |
38
|
|
|
|
|
|
|
my ($orig, $self, $class, $method) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Override the add_bundle of dzil's PluginBundle::Easy to preserve the bundle spec |
41
|
|
|
|
|
|
|
# rather than expanding it to the plugins. |
42
|
|
|
|
|
|
|
# Use try {} to ignore perls < v5.10 that don't have UNIVERSAL::DOES(). |
43
|
|
|
|
|
|
|
my $over = try { |
44
|
|
|
|
|
|
|
$class->DOES('Dist::Zilla::Role::PluginBundle::Easy') && |
45
|
|
|
|
|
|
|
Sub::Override->new("${class}::add_bundle" => \&__override_dzil_add_bundle); |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return $self->$orig($class, $method); |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build_ini_opts { |
52
|
10
|
|
|
10
|
|
145893
|
my ($self) = @_; |
53
|
|
|
|
|
|
|
|
54
|
10
|
|
|
|
|
220
|
my $app = __pkg_to_app($self->bundle_class); |
55
|
10
|
|
|
|
|
44
|
my $rewriter = $self->can("__${app}_rewriter"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return { |
58
|
10
|
100
|
|
|
|
227
|
($rewriter ? (rewrite_package => $rewriter) : ()), |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# secret knowledge about dist-zilla and pod-weaver bundles |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub __override_dzil_add_bundle { |
65
|
4
|
|
|
4
|
|
715
|
my ($self, $bundle, $payload) = @_; |
66
|
4
|
|
|
|
|
44
|
my $package = $bundle; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# mimic Easy |
69
|
4
|
50
|
|
|
|
22
|
$package =~ s/^\@?/Dist::Zilla::PluginBundle::/ |
70
|
|
|
|
|
|
|
unless $package =~ /^=/; |
71
|
4
|
100
|
|
|
|
14
|
$bundle = "\@$bundle" unless $bundle =~ /^@/; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# preserve bundle spec (rather than expanding it) |
74
|
4
|
|
100
|
|
|
5
|
push @{ $self->plugins }, [ $bundle => $package, $payload || {} ]; |
|
4
|
|
|
|
|
75
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub __pkg_to_app { |
78
|
10
|
|
|
10
|
|
88
|
(my $app = $_[0]) =~ s/::PluginBundle.+$//; |
79
|
10
|
|
|
|
|
31
|
$app =~ s/::/_/g; |
80
|
10
|
|
|
|
|
23
|
return lc $app; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
use String::RewritePrefix |
84
|
3
|
|
|
|
|
42
|
rewrite => { |
85
|
|
|
|
|
|
|
-as => '__pod_weaver_rewriter', |
86
|
|
|
|
|
|
|
prefixes => { |
87
|
|
|
|
|
|
|
'Pod::Weaver::PluginBundle::' => '@', |
88
|
|
|
|
|
|
|
'Pod::Weaver::Plugin::' => '-', |
89
|
|
|
|
|
|
|
'Pod::Weaver::Section::' => '', |
90
|
|
|
|
|
|
|
'' => '=', |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
}, |
93
|
|
|
|
|
|
|
rewrite => { |
94
|
|
|
|
|
|
|
-as => '__dist_zilla_rewriter', |
95
|
|
|
|
|
|
|
prefixes => { |
96
|
|
|
|
|
|
|
'Dist::Zilla::PluginBundle::' => '@', |
97
|
|
|
|
|
|
|
'Dist::Zilla::Plugin::' => '', |
98
|
|
|
|
|
|
|
'' => '=', |
99
|
|
|
|
|
|
|
}, |
100
|
3
|
|
|
3
|
|
15685
|
}; |
|
3
|
|
|
|
|
618
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=encoding UTF-8 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=for :stopwords Randy Stauner ACKNOWLEDGEMENTS INI PluginBundles Mengué Olivier |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Dist::Zilla::Config::BundleInspector - Give Hints to Config::MVP::BundleInspector |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 VERSION |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
version 0.004 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SYNOPSIS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# exact same usage as Config::MVP::BundleInspector |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 DESCRIPTION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This is used internally by L<Dist::Zilla::Plugin::BundleInspector>. |
128
|
|
|
|
|
|
|
It extends L<Config::MVP::BundleInspector> to add specialized handling |
129
|
|
|
|
|
|
|
for L<Dist::Zilla> and L<Pod::Weaver> bundles. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SEE ALSO |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L<Config::MVP::BundleInspector> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::BundleInspector> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Randy Stauner <rwstauner@cpan.org> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Randy Stauner. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
154
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |