line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::New::Command::Basic; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
419
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
94
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
67
|
|
5
|
3
|
|
|
3
|
|
10
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
161
|
|
6
|
3
|
|
|
3
|
|
19
|
use Module::New::Meta; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
13
|
|
7
|
3
|
|
|
3
|
|
150
|
use Module::New::Queue; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
4002
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
functions { |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
set_distname => sub () { Module::New::Queue->register(sub { |
12
|
6
|
|
|
6
|
|
8
|
my ($self, $name) = @_; |
13
|
6
|
50
|
|
|
|
21
|
croak "distribution/main module name is required" unless $name; |
14
|
6
|
|
|
|
|
28
|
Module::New->context->distname( $name ); |
15
|
6
|
|
|
6
|
|
45
|
})}, |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
guess_root => sub () { Module::New::Queue->register(sub { |
18
|
5
|
|
|
5
|
|
10
|
my $self = shift; |
19
|
5
|
|
|
|
|
20
|
my $context = Module::New->context; |
20
|
5
|
|
|
|
|
23
|
$context->path->guess_root( $context->config('root') ); |
21
|
5
|
|
|
5
|
|
37
|
})}, |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
set_file => sub () { Module::New::Queue->register(sub { |
24
|
4
|
|
|
4
|
|
9
|
my ($self, $name) = @_; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
11
|
croak "filename is required" unless $name; |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
12
|
my $context = Module::New->context; |
29
|
4
|
|
|
|
|
14
|
my $type = $context->config('type'); |
30
|
|
|
|
|
|
|
|
31
|
4
|
50
|
|
|
|
13
|
unless ($type) { |
32
|
4
|
100
|
66
|
|
|
68
|
if ( $name =~ /::/ or $name =~ /\.pm$/ or $name =~ m{^lib/} ) { |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
0
|
33
|
|
|
|
|
33
|
2
|
|
|
|
|
5
|
$type = 'Module'; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
elsif ( $name =~ /\.t$/ or $name =~ m{^t/} ) { |
36
|
1
|
|
|
|
|
3
|
$type = 'Test'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ( $name =~ /\.pl/ or $name =~ m{^(?:bin|scripts?)/} ) { |
39
|
1
|
|
|
|
|
3
|
$type = 'Script'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ( $name = /\./ ) { |
42
|
0
|
|
|
|
|
0
|
$type = 'Plain'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
4
|
|
50
|
|
|
13
|
$type ||= 'Module'; |
46
|
4
|
|
|
|
|
15
|
$context->config( type => $type ); |
47
|
|
|
|
|
|
|
|
48
|
4
|
100
|
|
|
|
25
|
if ( $type =~ /Module$/ ) { |
49
|
2
|
|
|
|
|
7
|
$context->module( $name ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
2
|
|
|
|
|
6
|
$context->mainfile( $name ); |
53
|
|
|
|
|
|
|
} |
54
|
4
|
|
|
4
|
|
24
|
})}, |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
create_distdir => sub () { Module::New::Queue->register(sub { |
57
|
6
|
|
|
6
|
|
10
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
17
|
my $context = Module::New->context; |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
22
|
$context->path->set_root; |
62
|
6
|
100
|
|
|
|
27
|
unless ( $context->config('no_dirs') ) { |
63
|
5
|
|
|
|
|
14
|
my $distname = $context->distname; |
64
|
5
|
|
|
|
|
14
|
my $distdir = $context->path->dir($distname); |
65
|
5
|
50
|
|
|
|
150
|
if ( $distdir->exists ) { |
66
|
0
|
0
|
|
|
|
0
|
if ( $context->config('force') ) { |
|
|
0
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
$context->path->remove_dir( $distdir, 'absolute' ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $context->config('grace') ) { |
70
|
|
|
|
|
|
|
# just skip and do nothing |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
0
|
croak "$distname already exists"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
5
|
|
|
|
|
102
|
$context->path->create_dir($distname); |
77
|
5
|
|
|
|
|
143
|
$context->path->change_dir($distname); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
1
|
|
|
|
|
4
|
$context->path->change_dir("."); |
81
|
|
|
|
|
|
|
} |
82
|
6
|
|
|
|
|
146
|
$context->path->set_root; |
83
|
6
|
|
|
6
|
|
39
|
})}, |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
create_maketool => sub (;$) { |
86
|
6
|
|
|
6
|
|
12
|
my $type = shift; |
87
|
|
|
|
|
|
|
Module::New::Queue->register(sub { |
88
|
6
|
|
|
6
|
|
14
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
6
|
|
|
|
|
18
|
my $context = Module::New->context; |
91
|
6
|
|
100
|
|
|
31
|
$type ||= $context->config('make') || 'MakeMakerCPANfile'; |
|
|
|
33
|
|
|
|
|
92
|
6
|
50
|
|
|
|
17
|
$type = 'ModuleBuild' if $type eq 'MB'; |
93
|
6
|
50
|
|
|
|
12
|
$type = 'MakeMaker' if $type eq 'EUMM'; |
94
|
|
|
|
|
|
|
|
95
|
6
|
|
|
|
|
27
|
$context->files->add( $type ); |
96
|
6
|
|
|
|
|
39
|
}); |
97
|
|
|
|
|
|
|
}, |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
create_general_files => sub () { Module::New::Queue->register(sub { |
100
|
6
|
|
|
6
|
|
9
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
6
|
|
|
|
|
18
|
Module::New->context->files->add(qw( Readme Changes ManifestSkip License )); |
103
|
6
|
|
|
6
|
|
38
|
})}, |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
create_tests => sub (;@) { |
106
|
6
|
|
|
6
|
|
14
|
my @files = @_; |
107
|
|
|
|
|
|
|
Module::New::Queue->register(sub { |
108
|
6
|
|
|
6
|
|
9
|
my $self = shift; |
109
|
|
|
|
|
|
|
|
110
|
6
|
|
|
|
|
17
|
my $context = Module::New->context; |
111
|
6
|
50
|
|
|
|
21
|
if ( ref $context->config('test') eq 'ARRAY' ) { |
|
|
50
|
|
|
|
|
|
112
|
0
|
|
|
|
|
0
|
$context->files->add( @{ Module::New->context->config('test') } ); |
|
0
|
|
|
|
|
0
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
elsif ( @files ) { |
115
|
0
|
|
|
|
|
0
|
$context->files->add( @files ); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else { |
118
|
6
|
|
|
|
|
17
|
$context->files->add(qw( LoadTest PodTest PodCoverageTest )); |
119
|
|
|
|
|
|
|
} |
120
|
6
|
|
|
|
|
41
|
}); |
121
|
|
|
|
|
|
|
}, |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
create_files => sub (;@) { |
124
|
10
|
|
|
10
|
|
21
|
my @files = @_; |
125
|
|
|
|
|
|
|
Module::New::Queue->register(sub { |
126
|
10
|
|
|
10
|
|
19
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
10
|
|
|
|
|
31
|
my $context = Module::New->context; |
129
|
10
|
|
|
|
|
30
|
$context->files->add( @files ); |
130
|
10
|
100
|
|
|
|
28
|
if ($context->config('xs')) { |
131
|
1
|
|
|
|
|
4
|
$context->files->add('XS'); |
132
|
1
|
|
|
|
|
2
|
eval { |
133
|
1
|
|
|
|
|
1386
|
require Devel::PPPort; |
134
|
1
|
|
|
|
|
359
|
Devel::PPPort::WriteFile(); |
135
|
1
|
|
|
|
|
2074
|
$context->log( info => "created ppport.h" ); |
136
|
|
|
|
|
|
|
}; |
137
|
1
|
50
|
|
|
|
54
|
$context->log( warn => $@ ) if $@; |
138
|
|
|
|
|
|
|
} |
139
|
10
|
|
|
|
|
35
|
while ( my $name = $context->files->next ) { |
140
|
59
|
100
|
|
|
|
170
|
if ( $name eq '{ANY_TYPE}' ) { |
141
|
4
|
|
50
|
|
|
14
|
$name = $context->config('type') || 'Module'; |
142
|
|
|
|
|
|
|
} |
143
|
59
|
|
|
|
|
179
|
my $file = $context->loader->reload_class( File => $name ); |
144
|
59
|
|
|
|
|
328
|
$context->path->create_file( $file->render ); |
145
|
|
|
|
|
|
|
} |
146
|
10
|
|
|
|
|
68
|
}); |
147
|
|
|
|
|
|
|
}, |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
create_manifest => sub () { Module::New::Queue->register(sub { |
150
|
10
|
|
|
10
|
|
21
|
my $self = shift; |
151
|
|
|
|
|
|
|
|
152
|
10
|
|
|
|
|
34
|
my $context = Module::New->context; |
153
|
10
|
50
|
|
|
|
39
|
$context->path->remove_file('MANIFEST') if $context->config('force'); |
154
|
|
|
|
|
|
|
|
155
|
10
|
50
|
|
|
|
38
|
local $ENV{PERL_MM_MANIFEST_VERBOSE} = 0 if $context->config('silent'); |
156
|
|
|
|
|
|
|
|
157
|
10
|
|
|
|
|
799
|
require ExtUtils::Manifest; |
158
|
10
|
|
|
|
|
8952
|
ExtUtils::Manifest::mkmanifest(); |
159
|
|
|
|
|
|
|
|
160
|
10
|
|
|
|
|
16834
|
$context->log( info => 'updated manifest' ); |
161
|
10
|
|
|
10
|
|
58
|
})}, |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
edit_mainfile => sub (;%) { |
164
|
10
|
|
|
10
|
|
27
|
my %options = @_; |
165
|
10
|
50
|
33
|
|
|
62
|
return if $ENV{HARNESS_ACTIVE} || $INC{'Test/Classy.pm'}; |
166
|
|
|
|
|
|
|
Module::New::Queue->register(sub { |
167
|
0
|
|
|
0
|
|
|
my $self = shift; |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $context = Module::New->context; |
170
|
0
|
0
|
|
|
|
|
return if $options{optional}; |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
0
|
|
|
|
my $editor = $context->config('editor') || $ENV{EDITOR}; |
173
|
0
|
0
|
|
|
|
|
unless ( $editor ) { carp 'editor is not set'; return; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
174
|
0
|
|
0
|
|
|
|
my $file = $options{file} || $context->mainfile; |
175
|
0
|
|
|
|
|
|
exec( _shell_quote($editor) => _shell_quote($file) ); |
176
|
0
|
|
|
|
|
|
}); |
177
|
|
|
|
|
|
|
}, |
178
|
|
|
|
|
|
|
}; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub _shell_quote { |
181
|
0
|
|
|
0
|
|
|
my $str = shift; |
182
|
0
|
0
|
|
|
|
|
return $str unless $str =~ /\s/; |
183
|
0
|
0
|
|
|
|
|
return ( $^O eq 'MSWin32' ) ? qq{"$str"} : qq{'$str'}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
__END__ |