line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::New::Context;
|
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
11899
|
use strict;
|
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
467
|
|
4
|
6
|
|
|
6
|
|
66
|
use warnings;
|
|
6
|
|
|
|
|
52
|
|
|
6
|
|
|
|
|
281
|
|
5
|
6
|
|
|
6
|
|
22
|
use Carp;
|
|
6
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
639
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
34
|
use Module::New::Loader;
|
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
93
|
|
8
|
6
|
|
|
6
|
|
1398
|
use Module::New::Log;
|
|
6
|
|
|
|
|
31
|
|
|
6
|
|
|
|
|
31
|
|
9
|
6
|
|
|
6
|
|
291
|
use Sub::Install 'reinstall_sub';
|
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
20
|
|
10
|
6
|
|
|
6
|
|
3448
|
use Time::Piece;
|
|
6
|
|
|
|
|
46762
|
|
|
6
|
|
|
|
|
23
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
foreach my $accessor (qw( template date path loader files )) {
|
13
|
|
|
|
|
|
|
reinstall_sub({
|
14
|
|
|
|
|
|
|
as => $accessor,
|
15
|
358
|
|
|
358
|
|
3475
|
code => sub { shift->{$accessor} },
|
|
|
|
|
2
|
|
|
|
16
|
|
|
|
|
|
|
});
|
17
|
|
|
|
|
|
|
}
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new {
|
20
|
14
|
|
|
14
|
1
|
74
|
my $class = shift;
|
21
|
|
|
|
|
|
|
|
22
|
14
|
|
|
|
|
57
|
my $loader = Module::New::Loader->new(@_);
|
23
|
14
|
|
|
|
|
47
|
my $self = bless { loader => $loader }, $class;
|
24
|
|
|
|
|
|
|
|
25
|
14
|
|
|
|
|
24
|
foreach my $name (qw( License Template )) {
|
26
|
28
|
|
|
|
|
78
|
$self->{lc $name} = $loader->load_class($name);
|
27
|
|
|
|
|
|
|
}
|
28
|
|
|
|
|
|
|
|
29
|
14
|
|
|
|
|
39
|
foreach my $name (qw( Config Path Files )) {
|
30
|
42
|
|
|
|
|
204
|
$self->{lc $name} = $loader->load($name);
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
14
|
|
|
|
|
116
|
$self->{date} = Time::Piece->new;
|
34
|
|
|
|
|
|
|
|
35
|
14
|
|
|
|
|
984
|
$self;
|
36
|
|
|
|
|
|
|
}
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub config {
|
39
|
327
|
|
|
327
|
1
|
1139
|
my $self = shift;
|
40
|
327
|
100
|
|
|
|
553
|
return $self->{config} unless @_;
|
41
|
296
|
100
|
|
|
|
900
|
return $self->{config}->get(@_) if @_ == 1;
|
42
|
4
|
|
|
|
|
12
|
$self->{config}->set(@_);
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub license {
|
46
|
20
|
|
|
20
|
1
|
1928
|
my ($self, $type, $args) = @_;
|
47
|
20
|
|
50
|
|
|
78
|
$type ||= $self->config('license') || 'perl';
|
|
|
|
33
|
|
|
|
|
48
|
20
|
|
50
|
|
|
87
|
$args ||= {};
|
49
|
20
|
|
33
|
|
|
84
|
$args->{holder} ||= $self->config('author');
|
50
|
20
|
|
33
|
|
|
83
|
$args->{year} ||= $self->date->year;
|
51
|
20
|
|
|
|
|
187
|
$self->{license}->object( $type, $args );
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub distname {
|
55
|
23
|
|
|
23
|
1
|
8185
|
my $self = shift;
|
56
|
|
|
|
|
|
|
|
57
|
23
|
100
|
|
|
|
48
|
if ( @_ ) {
|
58
|
6
|
|
|
|
|
10
|
my $module = my $dist = shift;
|
59
|
6
|
|
|
|
|
16
|
$dist =~ s/::/\-/g;
|
60
|
6
|
|
|
|
|
7
|
$module =~ s/\-/::/g;
|
61
|
|
|
|
|
|
|
|
62
|
6
|
50
|
|
|
|
16
|
croak "$dist looks weird" if $dist =~ tr/A-Za-z0-9_\-//cd;
|
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
12
|
my $distid = lc $dist;
|
65
|
6
|
|
|
|
|
6
|
$distid =~ s/\-/_/g;
|
66
|
|
|
|
|
|
|
|
67
|
6
|
|
|
|
|
19
|
$self->{distname} = $dist;
|
68
|
6
|
|
|
|
|
9
|
$self->{distid} = $distid;
|
69
|
6
|
|
|
|
|
17
|
$self->module( $module );
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
23
|
|
|
|
|
198
|
$self->{distname};
|
73
|
|
|
|
|
|
|
}
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub module {
|
76
|
38
|
|
|
38
|
1
|
21361
|
my $self = shift;
|
77
|
|
|
|
|
|
|
|
78
|
38
|
100
|
|
|
|
81
|
if ( @_ ) {
|
79
|
8
|
|
|
|
|
21
|
$self->{module} = shift;
|
80
|
8
|
|
|
|
|
12
|
my $path = $self->{module};
|
81
|
8
|
|
|
|
|
18
|
$path =~ s|::|\/|g;
|
82
|
8
|
|
|
|
|
13
|
my $id = lc $path;
|
83
|
8
|
|
|
|
|
13
|
$id =~ s|/|_|g;
|
84
|
8
|
|
|
|
|
29
|
$self->mainfile("lib/$path.pm");
|
85
|
8
|
|
|
|
|
20
|
$self->modulepath($path);
|
86
|
8
|
|
|
|
|
20
|
$self->moduleid($id);
|
87
|
|
|
|
|
|
|
}
|
88
|
38
|
|
|
|
|
435
|
$self->{module};
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub mainfile {
|
92
|
31
|
|
|
31
|
1
|
91
|
my $self = shift;
|
93
|
31
|
100
|
|
|
|
64
|
if ( @_ ) {
|
94
|
10
|
|
|
|
|
17
|
$self->{mainfile} = shift;
|
95
|
|
|
|
|
|
|
}
|
96
|
31
|
|
|
|
|
181
|
$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
|
11
|
my $self = shift;
|
108
|
8
|
50
|
|
|
|
18
|
if ( @_ ) {
|
109
|
8
|
|
|
|
|
18
|
$self->{modulepath} = shift;
|
110
|
|
|
|
|
|
|
}
|
111
|
8
|
|
|
|
|
10
|
$self->{modulepath};
|
112
|
|
|
|
|
|
|
}
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub moduleid {
|
115
|
11
|
|
|
11
|
1
|
531
|
my $self = shift;
|
116
|
11
|
100
|
|
|
|
21
|
if ( @_ ) {
|
117
|
8
|
|
|
|
|
17
|
$self->{moduleid} = shift;
|
118
|
|
|
|
|
|
|
}
|
119
|
11
|
|
|
|
|
51
|
$self->{moduleid};
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub modulebase {
|
123
|
3
|
|
|
3
|
1
|
797
|
my $self = shift;
|
124
|
3
|
|
|
|
|
10
|
my ($name) = $self->{module} =~ /(\w+)$/;
|
125
|
3
|
|
|
|
|
16
|
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
|
42
|
my $self = shift;
|
138
|
6
|
50
|
|
|
|
18
|
if ( @_ ) {
|
139
|
0
|
|
|
|
|
0
|
$self->{repository} = shift;
|
140
|
|
|
|
|
|
|
}
|
141
|
6
|
50
|
|
|
|
93
|
$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__
|