line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spike::Config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2
|
use feature 'state'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
221
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
10
|
0
|
|
0
|
|
|
|
my $class = ref $proto || $proto; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my %args = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $handler = sub { |
15
|
0
|
|
0
|
0
|
|
|
state $config ||= bless { %args }, "${class}::Section"; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
|
if (@_) { |
18
|
0
|
|
|
|
|
|
my $section = shift; |
19
|
0
|
|
|
|
|
|
return $config->$section(@_); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
return $config; |
23
|
0
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return bless $handler, "${class}::Accessor"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package Spike::Config::Parse; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
|
|
sub set { $_[0] = $_[1] } |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
0
|
|
|
sub defined { $_[0] // $_[1] // '' } |
|
|
|
0
|
|
|
|
|
33
|
0
|
|
0
|
0
|
|
|
sub def { $_[0] // $_[1] // '' } |
|
|
|
0
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
0
|
1
|
|
4
|
sub integer { no warnings 'numeric'; CORE::int($_[0] // $_[1] // 0) } |
|
1
|
|
0
|
0
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
|
0
|
|
|
|
|
|
|
36
|
1
|
|
0
|
1
|
|
3
|
sub int { no warnings 'numeric'; CORE::int($_[0] // $_[1] // 0) } |
|
1
|
|
0
|
0
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
0
|
1
|
|
3
|
sub number { no warnings 'numeric'; 0 + ($_[0] // $_[1] // 0) } |
|
1
|
|
0
|
0
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
|
0
|
|
|
|
|
|
|
39
|
1
|
|
0
|
1
|
|
3
|
sub num { no warnings 'numeric'; 0 + ($_[0] // $_[1] // 0) } |
|
1
|
|
0
|
0
|
|
1
|
|
|
1
|
|
|
|
|
397
|
|
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
0
|
0
|
|
|
sub boolean { !!($_[0] // $_[1]) } |
42
|
0
|
|
0
|
0
|
|
|
sub bool { !!($_[0] // $_[1]) } |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
0
|
0
|
|
|
sub string { ''.($_[0] // $_[1] // '') } |
|
|
|
0
|
|
|
|
|
45
|
0
|
|
0
|
0
|
|
|
sub str { ''.($_[0] // $_[1] // '') } |
|
|
|
0
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
package Spike::Config::Accessor; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
our $AUTOLOAD; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub AUTOLOAD { |
52
|
0
|
|
|
0
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
(my $key = $AUTOLOAD) =~ s/^.*:://; |
55
|
0
|
|
|
|
|
|
(my $class = ref $self) =~ s/::[^:]*$//; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $self->()->$key(@_); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
0
|
|
|
sub DESTROY {} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package Spike::Config::Section; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
our $AUTOLOAD; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub AUTOLOAD { |
67
|
0
|
|
|
0
|
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
(my $key = $AUTOLOAD) =~ s/^.*:://; |
70
|
0
|
|
|
|
|
|
(my $class = ref $self) =~ s/::[^:]*$//; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
0
|
|
|
|
my $section = bless $self->{$key} ||= {}, "${class}::Value"; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if (@_) { |
75
|
0
|
|
|
|
|
|
my $value = shift; |
76
|
0
|
|
|
|
|
|
return $section->$value(@_); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $section; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
0
|
|
|
sub DESTROY {} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
package Spike::Config::Value; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
130
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
our $AUTOLOAD; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub AUTOLOAD { |
91
|
0
|
|
|
0
|
|
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
(my $key = $AUTOLOAD) =~ s/^.*:://; |
94
|
0
|
|
|
|
|
|
(my $class = ref $self) =~ s/::[^:]*$//; |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if (@_) { |
97
|
0
|
|
|
|
|
|
my $format = shift; |
98
|
0
|
|
|
|
|
|
my $method = "${class}::Parse::${format}"; |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
if (defined *{$method}) { |
|
0
|
|
|
|
|
|
|
101
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
83
|
|
102
|
0
|
|
|
|
|
|
return $method->($self->{$key}, @_); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
else { |
105
|
0
|
|
|
|
|
|
carp "Unknown format: $format"; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $self->{$key}; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
0
|
|
|
sub DESTROY {} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |