line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPVM::Builder::Resource; |
2
|
|
|
|
|
|
|
|
3
|
283
|
|
|
283
|
|
4285
|
use strict; |
|
283
|
|
|
|
|
2891
|
|
|
283
|
|
|
|
|
11730
|
|
4
|
283
|
|
|
283
|
|
2797
|
use warnings; |
|
283
|
|
|
|
|
651
|
|
|
283
|
|
|
|
|
9791
|
|
5
|
283
|
|
|
283
|
|
2425
|
use Config; |
|
283
|
|
|
|
|
619
|
|
|
283
|
|
|
|
|
11899
|
|
6
|
283
|
|
|
283
|
|
1582
|
use Carp 'confess'; |
|
283
|
|
|
|
|
2847
|
|
|
283
|
|
|
|
|
15907
|
|
7
|
283
|
|
|
283
|
|
2943
|
use File::Basename 'dirname'; |
|
283
|
|
|
|
|
1973
|
|
|
283
|
|
|
|
|
25344
|
|
8
|
|
|
|
|
|
|
|
9
|
283
|
|
|
283
|
|
2994
|
use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1; |
|
283
|
|
|
24
|
|
3014
|
|
|
283
|
|
|
16
|
|
3760
|
|
|
0
|
|
|
|
|
0
|
|
|
40
|
|
|
|
|
177
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Fields |
12
|
|
|
|
|
|
|
sub class_name { |
13
|
62
|
|
|
62
|
1
|
152
|
my $self = shift; |
14
|
62
|
50
|
|
|
|
177
|
if (@_) { |
15
|
0
|
|
|
|
|
0
|
$self->{class_name} = $_[0]; |
16
|
0
|
|
|
|
|
0
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else { |
19
|
62
|
|
|
|
|
335
|
return $self->{class_name}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub mode { |
24
|
14
|
|
|
14
|
1
|
66
|
my $self = shift; |
25
|
14
|
50
|
|
|
|
50
|
if (@_) { |
26
|
0
|
|
|
|
|
0
|
$self->{mode} = $_[0]; |
27
|
0
|
|
|
|
|
0
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
14
|
|
|
|
|
106
|
return $self->{mode}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub argv { |
35
|
35
|
|
|
35
|
1
|
67
|
my $self = shift; |
36
|
35
|
100
|
|
|
|
141
|
if (@_) { |
37
|
9
|
|
|
|
|
44
|
$self->{argv} = $_[0]; |
38
|
9
|
|
|
|
|
35
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
26
|
|
|
|
|
208
|
return $self->{argv}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub config { |
46
|
48
|
|
|
48
|
1
|
122
|
my $self = shift; |
47
|
48
|
100
|
|
|
|
179
|
if (@_) { |
48
|
12
|
|
|
|
|
30
|
$self->{config} = $_[0]; |
49
|
12
|
|
|
|
|
30
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
36
|
|
|
|
|
205
|
return $self->{config}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Methods |
57
|
|
|
|
|
|
|
sub new { |
58
|
12
|
|
|
12
|
1
|
35
|
my $class = shift; |
59
|
|
|
|
|
|
|
|
60
|
12
|
|
|
|
|
57
|
my $self = {@_}; |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
33
|
|
|
110
|
bless $self, ref $class || $class; |
63
|
|
|
|
|
|
|
|
64
|
12
|
100
|
|
|
|
71
|
unless ($self->argv) { |
65
|
9
|
|
|
|
|
52
|
$self->argv([]); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
12
|
|
|
|
|
62
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub to_string { |
72
|
40
|
|
|
40
|
1
|
101
|
my ($self) = @_; |
73
|
|
|
|
|
|
|
|
74
|
40
|
|
|
|
|
131
|
return $self->class_name; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 Name |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
SPVM::Builder::Resource - Resource |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 Description |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The SPVM::Builder::Resource class has methods to manipulate a resource. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 Usage |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $resource = SPVM::Builder::Resource->new( |
90
|
|
|
|
|
|
|
class_name => 'Resource::Zlib', |
91
|
|
|
|
|
|
|
mode => 'high_performance', |
92
|
|
|
|
|
|
|
argv => ['foo', 'bar'], |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 Fields |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 class_name |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $basic_type_name = $resource->class_name; |
100
|
|
|
|
|
|
|
$resource->class_name($basic_type_name); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Gets and sets the C field. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This field is a class name of a resource. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 mode |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $mode = $resource->mode; |
109
|
|
|
|
|
|
|
$resource->mode($mode); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Gets and sets the C field. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This field is a mode of a config file of a resource. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 argv |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $argv = $resource->argv; |
118
|
|
|
|
|
|
|
$resource->argv($argv); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Gets and sets the C field. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This field is an array reference that contains command line arguments C<@ARGV> of a config file of a resource. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 config |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $config = $resource->config; |
127
|
|
|
|
|
|
|
$resource->config($config); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Gets and sets the C field. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This field is a a L object for a resource. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 Class Methods |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 new |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $resource = SPVM::Builder::Resource->new(%fields); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Creates a L object with L"Fields">. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Default Field Values: |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
If a field is not defined, the field is set to the following default value. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=over 2 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * L"class_name"> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
undef |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * L"mode"> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
undef |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * L"argv"> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
[] |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * L"config"> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
undef |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 Instance Methods |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 to_string |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $string = $resource->to_string; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns the L"class_name"> field. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 Operators |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Overloads the following operators. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 bool |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $bool = !!$resource; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Always true. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 stringify |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
my $basic_type_name = "$resource"; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
The alias for the L"to_string"> method. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 Copyright & License |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Copyright (c) 2023 Yuki Kimoto |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
MIT License |