line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
1239267
|
use 5.006; # our |
|
5
|
|
|
|
|
14
|
|
2
|
5
|
|
|
5
|
|
19
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
100
|
|
3
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
445
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Bootstrap::ShareDir::Module; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.001002'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Use a share directory on your dist for a module during bootstrap |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
473
|
use Moose qw( with has around ); |
|
5
|
|
|
|
|
286117
|
|
|
5
|
|
|
|
|
44
|
|
14
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::Bootstrap'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has module_map => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'HashRef', |
32
|
|
|
|
|
|
|
lazy_build => 1, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
|
0
|
sub _build_module_map { return {} } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
around 'dump_config' => sub { |
38
|
|
|
|
|
|
|
my ( $orig, $self, @args ) = @_; |
39
|
|
|
|
|
|
|
my $config = $self->$orig(@args); |
40
|
|
|
|
|
|
|
my $localconf = $config->{ +__PACKAGE__ } = {}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if ( $self->meta->find_attribute_by_name('module_map')->has_value($self) ) { |
43
|
|
|
|
|
|
|
$localconf->{module_map} = $self->module_map; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
$localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION |
46
|
|
|
|
|
|
|
unless __PACKAGE__ eq ref $self; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return $config; |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
around 'plugin_from_config' => sub { |
52
|
|
|
|
|
|
|
my ( $orig, $self, $name, $payload, $section ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $special_fields = [qw( try_built fallback )]; |
55
|
|
|
|
|
|
|
my $module_map = { %{$payload} }; |
56
|
|
|
|
|
|
|
my $new = {}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
for my $field ( @{$special_fields} ) { |
59
|
|
|
|
|
|
|
$new->{$field} = delete $module_map->{$field} if exists $module_map->{$field}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
$new->{module_map} = $module_map; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $self->$orig( $name, $new, $section ); |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub bootstrap { |
67
|
4
|
|
|
4
|
|
26
|
my $self = shift; |
68
|
4
|
|
|
|
|
179
|
my $root = $self->_bootstrap_root; |
69
|
|
|
|
|
|
|
|
70
|
4
|
50
|
|
|
|
2555
|
if ( not defined $root ) { |
71
|
0
|
|
|
|
|
0
|
$self->log( ['Not bootstrapping'] ); |
72
|
0
|
|
|
|
|
0
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
4
|
|
|
|
|
8
|
my $resolved_map = {}; |
75
|
|
|
|
|
|
|
|
76
|
4
|
|
|
|
|
6
|
for my $key ( keys %{ $self->module_map } ) { |
|
4
|
|
|
|
|
145
|
|
77
|
4
|
|
|
|
|
24
|
require Path::Tiny; |
78
|
4
|
|
|
|
|
144
|
$resolved_map->{$key} = Path::Tiny::path( $self->module_map->{$key} )->absolute($root); |
79
|
|
|
|
|
|
|
} |
80
|
4
|
|
|
|
|
2745
|
require Test::File::ShareDir::Object::Module; |
81
|
4
|
|
|
|
|
11723
|
my $share_object = Test::File::ShareDir::Object::Module->new( modules => $resolved_map ); |
82
|
4
|
|
|
|
|
287
|
for my $module ( $share_object->module_names ) { |
83
|
4
|
|
|
|
|
139
|
$self->log( [ 'Bootstrapped sharedir for %s -> %s', $module, $resolved_map->{$module}->relative(q[.])->stringify ] ); |
84
|
4
|
|
|
|
|
2855
|
$self->log_debug( |
85
|
|
|
|
|
|
|
[ |
86
|
|
|
|
|
|
|
'Installing module %s sharedir ( %s => %s )', |
87
|
|
|
|
|
|
|
"$module", |
88
|
|
|
|
|
|
|
$share_object->module_share_source_dir($module) . q{}, |
89
|
|
|
|
|
|
|
$share_object->module_share_target_dir($module) . q{}, |
90
|
|
|
|
|
|
|
], |
91
|
|
|
|
|
|
|
); |
92
|
4
|
|
|
|
|
10657
|
$share_object->install_module($module); |
93
|
|
|
|
|
|
|
} |
94
|
4
|
|
|
|
|
5155
|
$self->_add_inc( $share_object->inc->tempdir . q{} ); |
95
|
4
|
|
|
|
|
585
|
$self->log_debug( [ 'Sharedir for %s installed to %s', $self->distname, $share_object->inc->module_tempdir . q{} ] ); |
96
|
4
|
|
|
|
|
608
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
100
|
5
|
|
|
5
|
|
22595
|
no Moose; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
20
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=pod |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=encoding UTF-8 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Bootstrap::ShareDir::Module - Use a share directory on your dist for a module during bootstrap |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 VERSION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
version 1.001002 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This module allows one to load a C<Module> styled C<ShareDir> using a C<Bootstrap> |
121
|
|
|
|
|
|
|
mechanism so a distribution can use files in its own source tree when building with itself. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is very much like the C<Bootstrap::lib> plugin in that it injects libraries into |
124
|
|
|
|
|
|
|
C<@INC> based on your existing source tree, or a previous build you ran. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
And it is syntactically like the C<ModuleShareDirs> plugin. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
B<Note> that this is really only useful for self consuming I<plugins> and will have no effect |
129
|
|
|
|
|
|
|
on the C<test> or C<run> phases of your dist. ( For that, you'll need C<Test::File::ShareDir> ). |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=begin MetaPOD::JSON v1.1.0 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
{ |
134
|
|
|
|
|
|
|
"namespace":"Dist::Zilla::Plugin::Bootstrap::ShareDir::Module", |
135
|
|
|
|
|
|
|
"interface":"class", |
136
|
|
|
|
|
|
|
"does":"Dist::Zilla::Role::Bootstrap", |
137
|
|
|
|
|
|
|
"inherits":"Moose::Object" |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=end MetaPOD::JSON |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 USAGE |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
[Bootstrap::lib] |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
[Bootstrap::ShareDir::Module] |
148
|
|
|
|
|
|
|
Foo::Bar = shares/foo_bar |
149
|
|
|
|
|
|
|
Foo::Baz = shares/foo_baz |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
[ModuleShareDirs] |
152
|
|
|
|
|
|
|
Foo::Bar = shares/foo_bar |
153
|
|
|
|
|
|
|
Foo::Baz = shares/foo_baz |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The only significant difference between this module and C<ModuleShareDirs> is this module exists to |
156
|
|
|
|
|
|
|
make a C<share> visible to plugins for the distribution being built, while C<ModuleShareDirs> exists |
157
|
|
|
|
|
|
|
to export a C<share> directory visible after install time. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Additionally, there are two primary attributes that are provided by |
160
|
|
|
|
|
|
|
L<< C<Dist::Zilla::Role::Bootstrap>|Dist::Zilla::Role::Bootstrap >>, See |
161
|
|
|
|
|
|
|
L<< Dist::Zilla::Role::Bootstrap/ATTRIBUTES >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
For instance, this bootstraps C<ROOT/Your-Dist-Name-$VERSION/shares/foo_bar> if it exists and |
164
|
|
|
|
|
|
|
there's only one C<$VERSION>, otherwise it falls back to simply bootstrapping C<ROOT/shares/foo_bar> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
[Bootstrap::ShareDir::Module] |
167
|
|
|
|
|
|
|
Foo::Bar = shares/foo_bar |
168
|
|
|
|
|
|
|
Foo::Baz = shares/foo_baz |
169
|
|
|
|
|
|
|
; These are special cased |
170
|
|
|
|
|
|
|
dir = share |
171
|
|
|
|
|
|
|
try_built = 1 |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHOR |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
182
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |