line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::New::Context;
|
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1877
|
use strict;
|
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
161
|
|
4
|
6
|
|
|
6
|
|
21
|
use warnings;
|
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
158
|
|
5
|
6
|
|
|
6
|
|
19
|
use Carp;
|
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
304
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
223
|
use Module::New::Loader;
|
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
95
|
|
8
|
6
|
|
|
6
|
|
1750
|
use Module::New::Log;
|
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
23
|
|
9
|
6
|
|
|
6
|
|
280
|
use Sub::Install 'reinstall_sub';
|
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
14
|
|
10
|
6
|
|
|
6
|
|
3037
|
use Time::Piece;
|
|
6
|
|
|
|
|
45629
|
|
|
6
|
|
|
|
|
21
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
foreach my $accessor (qw( template date path loader files )) {
|
13
|
|
|
|
|
|
|
reinstall_sub({
|
14
|
|
|
|
|
|
|
as => $accessor,
|
15
|
358
|
|
|
358
|
|
3545
|
code => sub { shift->{$accessor} },
|
|
|
|
|
356
|
|
|
|
|
|
|
|
0
|
|
|
|
16
|
|
|
|
|
|
|
});
|
17
|
|
|
|
|
|
|
}
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new {
|
20
|
14
|
|
|
14
|
1
|
71
|
my $class = shift;
|
21
|
|
|
|
|
|
|
|
22
|
14
|
|
|
|
|
60
|
my $loader = Module::New::Loader->new(@_);
|
23
|
14
|
|
|
|
|
40
|
my $self = bless { loader => $loader }, $class;
|
24
|
|
|
|
|
|
|
|
25
|
14
|
|
|
|
|
25
|
foreach my $name (qw( License Template )) {
|
26
|
28
|
|
|
|
|
81
|
$self->{lc $name} = $loader->load_class($name);
|
27
|
|
|
|
|
|
|
}
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
|
|
36
|
foreach my $name (qw( Config Path Files )) {
|
30
|
42
|
|
|
|
|
220
|
$self->{lc $name} = $loader->load($name);
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
14
|
|
|
|
|
108
|
$self->{date} = Time::Piece->new;
|
34
|
|
|
|
|
|
|
|
35
|
14
|
|
|
|
|
942
|
$self;
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub config {
|
39
|
327
|
|
|
327
|
1
|
1205
|
my $self = shift;
|
40
|
327
|
100
|
|
|
|
668
|
return $self->{config} unless @_;
|
41
|
296
|
100
|
|
|
|
963
|
return $self->{config}->get(@_) if @_ == 1;
|
42
|
4
|
|
|
|
|
15
|
$self->{config}->set(@_);
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub license {
|
46
|
20
|
|
|
20
|
1
|
2235
|
my ($self, $type, $args) = @_;
|
47
|
20
|
|
50
|
|
|
82
|
$type ||= $self->config('license') || 'perl';
|
|
|
|
33
|
|
|
|
|
48
|
20
|
|
50
|
|
|
60
|
$args ||= {};
|
49
|
20
|
|
33
|
|
|
79
|
$args->{holder} ||= $self->config('author');
|
50
|
20
|
|
33
|
|
|
77
|
$args->{year} ||= $self->date->year;
|
51
|
20
|
|
|
|
|
196
|
$self->{license}->object( $type, $args );
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub distname {
|
55
|
23
|
|
|
23
|
1
|
9373
|
my $self = shift;
|
56
|
|
|
|
|
|
|
|
57
|
23
|
100
|
|
|
|
54
|
if ( @_ ) {
|
58
|
6
|
|
|
|
|
10
|
my $module = my $dist = shift;
|
59
|
6
|
|
|
|
|
14
|
$dist =~ s/::/\-/g;
|
60
|
6
|
|
|
|
|
11
|
$module =~ s/\-/::/g;
|
61
|
|
|
|
|
|
|
|
62
|
6
|
50
|
|
|
|
13
|
croak "$dist looks weird" if $dist =~ tr/A-Za-z0-9_\-//cd;
|
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
9
|
my $distid = lc $dist;
|
65
|
6
|
|
|
|
|
8
|
$distid =~ s/\-/_/g;
|
66
|
|
|
|
|
|
|
|
67
|
6
|
|
|
|
|
14
|
$self->{distname} = $dist;
|
68
|
6
|
|
|
|
|
10
|
$self->{distid} = $distid;
|
69
|
6
|
|
|
|
|
16
|
$self->module( $module );
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
23
|
|
|
|
|
228
|
$self->{distname};
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub module {
|
76
|
38
|
|
|
38
|
1
|
23321
|
my $self = shift;
|
77
|
|
|
|
|
|
|
|
78
|
38
|
100
|
|
|
|
78
|
if ( @_ ) {
|
79
|
8
|
|
|
|
|
20
|
$self->{module} = shift;
|
80
|
8
|
|
|
|
|
12
|
my $path = $self->{module};
|
81
|
8
|
|
|
|
|
17
|
$path =~ s|::|\/|g;
|
82
|
8
|
|
|
|
|
17
|
my $id = lc $path;
|
83
|
8
|
|
|
|
|
12
|
$id =~ s|/|_|g;
|
84
|
8
|
|
|
|
|
29
|
$self->mainfile("lib/$path.pm");
|
85
|
8
|
|
|
|
|
21
|
$self->modulepath($path);
|
86
|
8
|
|
|
|
|
25
|
$self->moduleid($id);
|
87
|
|
|
|
|
|
|
}
|
88
|
38
|
|
|
|
|
521
|
$self->{module};
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub mainfile {
|
92
|
31
|
|
|
31
|
1
|
86
|
my $self = shift;
|
93
|
31
|
100
|
|
|
|
62
|
if ( @_ ) {
|
94
|
10
|
|
|
|
|
29
|
$self->{mainfile} = shift;
|
95
|
|
|
|
|
|
|
}
|
96
|
31
|
|
|
|
|
206
|
$self->{mainfile};
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub maindir {
|
100
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
101
|
0
|
|
|
|
|
0
|
my $dir = $self->{mainfile};
|
102
|
0
|
|
|
|
|
0
|
$dir =~ s/\.pm$//;
|
103
|
0
|
|
|
|
|
0
|
return $dir;
|
104
|
|
|
|
|
|
|
}
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub modulepath {
|
107
|
8
|
|
|
8
|
1
|
13
|
my $self = shift;
|
108
|
8
|
50
|
|
|
|
15
|
if ( @_ ) {
|
109
|
8
|
|
|
|
|
15
|
$self->{modulepath} = shift;
|
110
|
|
|
|
|
|
|
}
|
111
|
8
|
|
|
|
|
10
|
$self->{modulepath};
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub moduleid {
|
115
|
11
|
|
|
11
|
1
|
613
|
my $self = shift;
|
116
|
11
|
100
|
|
|
|
24
|
if ( @_ ) {
|
117
|
8
|
|
|
|
|
14
|
$self->{moduleid} = shift;
|
118
|
|
|
|
|
|
|
}
|
119
|
11
|
|
|
|
|
54
|
$self->{moduleid};
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub modulebase {
|
123
|
3
|
|
|
3
|
1
|
907
|
my $self = shift;
|
124
|
3
|
|
|
|
|
13
|
my ($name) = $self->{module} =~ /(\w+)$/;
|
125
|
3
|
|
|
|
|
20
|
return $name;
|
126
|
|
|
|
|
|
|
}
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub distid {
|
129
|
0
|
|
|
0
|
1
|
0
|
my $self = shift;
|
130
|
0
|
0
|
|
|
|
0
|
if ( @_ ) {
|
131
|
0
|
|
|
|
|
0
|
$self->{distid} = shift;
|
132
|
|
|
|
|
|
|
}
|
133
|
0
|
|
|
|
|
0
|
$self->{distid};
|
134
|
|
|
|
|
|
|
}
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub repository {
|
137
|
6
|
|
|
6
|
1
|
46
|
my $self = shift;
|
138
|
6
|
50
|
|
|
|
16
|
if ( @_ ) {
|
139
|
0
|
|
|
|
|
0
|
$self->{repository} = shift;
|
140
|
|
|
|
|
|
|
}
|
141
|
6
|
50
|
|
|
|
117
|
$self->{repository} || '';
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
*dist_name = \&distname;
|
145
|
|
|
|
|
|
|
*dist_id = \&distid;
|
146
|
|
|
|
|
|
|
*main_file = \&mainfile;
|
147
|
|
|
|
|
|
|
*main_dir = \&maindir;
|
148
|
|
|
|
|
|
|
*module_path = \&modulepath;
|
149
|
|
|
|
|
|
|
*module_id = \&moduleid;
|
150
|
|
|
|
|
|
|
*module_base = \&modulebase;
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1;
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__
|