line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPVM::Builder::Resource; |
2
|
|
|
|
|
|
|
|
3
|
283
|
|
|
283
|
|
4732
|
use strict; |
|
283
|
|
|
|
|
3222
|
|
|
283
|
|
|
|
|
10519
|
|
4
|
283
|
|
|
283
|
|
2816
|
use warnings; |
|
283
|
|
|
|
|
1978
|
|
|
283
|
|
|
|
|
10580
|
|
5
|
283
|
|
|
283
|
|
2653
|
use Config; |
|
283
|
|
|
|
|
1913
|
|
|
283
|
|
|
|
|
12133
|
|
6
|
283
|
|
|
283
|
|
1766
|
use Carp 'confess'; |
|
283
|
|
|
|
|
1913
|
|
|
283
|
|
|
|
|
17029
|
|
7
|
283
|
|
|
283
|
|
3049
|
use File::Basename 'dirname'; |
|
283
|
|
|
|
|
2919
|
|
|
283
|
|
|
|
|
25102
|
|
8
|
|
|
|
|
|
|
|
9
|
283
|
|
|
283
|
|
4425
|
use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1; |
|
283
|
|
|
40
|
|
688
|
|
|
283
|
|
|
0
|
|
5013
|
|
|
0
|
|
|
|
|
0
|
|
|
40
|
|
|
|
|
177
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Fields |
12
|
|
|
|
|
|
|
sub class_name { |
13
|
62
|
|
|
62
|
1
|
152
|
my $self = shift; |
14
|
62
|
50
|
|
|
|
167
|
if (@_) { |
15
|
0
|
|
|
|
|
0
|
$self->{class_name} = $_[0]; |
16
|
0
|
|
|
|
|
0
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else { |
19
|
62
|
|
|
|
|
450
|
return $self->{class_name}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub mode { |
24
|
14
|
|
|
14
|
1
|
43
|
my $self = shift; |
25
|
14
|
50
|
|
|
|
43
|
if (@_) { |
26
|
0
|
|
|
|
|
0
|
$self->{mode} = $_[0]; |
27
|
0
|
|
|
|
|
0
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
14
|
|
|
|
|
114
|
return $self->{mode}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub argv { |
35
|
35
|
|
|
35
|
1
|
78
|
my $self = shift; |
36
|
35
|
100
|
|
|
|
89
|
if (@_) { |
37
|
9
|
|
|
|
|
48
|
$self->{argv} = $_[0]; |
38
|
9
|
|
|
|
|
30
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
26
|
|
|
|
|
215
|
return $self->{argv}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub config { |
46
|
48
|
|
|
48
|
1
|
164
|
my $self = shift; |
47
|
48
|
100
|
|
|
|
178
|
if (@_) { |
48
|
12
|
|
|
|
|
35
|
$self->{config} = $_[0]; |
49
|
12
|
|
|
|
|
37
|
return $self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
36
|
|
|
|
|
222
|
return $self->{config}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Methods |
57
|
|
|
|
|
|
|
sub new { |
58
|
12
|
|
|
12
|
1
|
42
|
my $class = shift; |
59
|
|
|
|
|
|
|
|
60
|
12
|
|
|
|
|
48
|
my $self = {@_}; |
61
|
|
|
|
|
|
|
|
62
|
12
|
|
33
|
|
|
132
|
bless $self, ref $class || $class; |
63
|
|
|
|
|
|
|
|
64
|
12
|
100
|
|
|
|
82
|
unless ($self->argv) { |
65
|
9
|
|
|
|
|
67
|
$self->argv([]); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
12
|
|
|
|
|
58
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub to_string { |
72
|
40
|
|
|
40
|
1
|
113
|
my ($self) = @_; |
73
|
|
|
|
|
|
|
|
74
|
40
|
|
|
|
|
199
|
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 |