line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sphinx::Config::Builder; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
40078
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
69
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3466
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
2
|
|
|
2
|
1
|
80
|
my $pkg = shift; |
10
|
2
|
|
|
|
|
18
|
my $self = { |
11
|
|
|
|
|
|
|
indexes => [], # container of ::Index references |
12
|
|
|
|
|
|
|
sources => [], # container of ::Source references |
13
|
|
|
|
|
|
|
indexer => Sphinx::Config::Entry::Indexer->new(), |
14
|
|
|
|
|
|
|
searchd => Sphinx::Config::Entry::Searchd->new(), |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
|
|
4
|
bless $self, $pkg; |
18
|
2
|
|
|
|
|
6
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub push_index { |
22
|
6
|
|
|
6
|
1
|
9
|
my $self = shift; |
23
|
6
|
|
|
|
|
7
|
push @{ $self->{indexes} }, @_; |
|
6
|
|
|
|
|
14
|
|
24
|
6
|
|
|
|
|
18
|
return 1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub pop_index { |
28
|
7
|
|
|
7
|
1
|
1633
|
my $self = shift; |
29
|
7
|
|
|
|
|
9
|
return pop @{ $self->{indexes} }; |
|
7
|
|
|
|
|
24
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub push_source { |
33
|
6
|
|
|
6
|
1
|
10
|
my $self = shift; |
34
|
6
|
|
|
|
|
7
|
push @{ $self->{sources} }, @_; |
|
6
|
|
|
|
|
15
|
|
35
|
6
|
|
|
|
|
19
|
return 1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub pop_source { |
39
|
7
|
|
|
7
|
1
|
1694
|
my $self = shift; |
40
|
7
|
|
|
|
|
10
|
return pop @{ $self->{sources} }; |
|
7
|
|
|
|
|
20
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub index_list { |
44
|
3
|
|
|
3
|
1
|
300
|
my $self = shift; |
45
|
3
|
|
|
|
|
14
|
return $self->{indexes}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub source_list { |
49
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
50
|
3
|
|
|
|
|
12
|
return $self->{sources}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub indexer { |
54
|
4
|
|
|
4
|
1
|
785
|
my $self = shift; |
55
|
4
|
|
|
|
|
31
|
return $self->{indexer}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub searchd { |
59
|
4
|
|
|
4
|
1
|
10
|
my $self = shift; |
60
|
4
|
|
|
|
|
43
|
return $self->{searchd}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub as_string { |
64
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
65
|
1
|
|
|
|
|
3
|
my $ret = q{}; |
66
|
1
|
|
|
|
|
2
|
foreach my $source ( @{ $self->source_list } ) { |
|
1
|
|
|
|
|
4
|
|
67
|
6
|
|
|
|
|
15
|
$ret .= $source->as_string(); |
68
|
|
|
|
|
|
|
} |
69
|
1
|
|
|
|
|
2
|
foreach my $index ( @{ $self->index_list } ) { |
|
1
|
|
|
|
|
11
|
|
70
|
6
|
|
|
|
|
15
|
$ret .= $index->as_string(); |
71
|
|
|
|
|
|
|
} |
72
|
1
|
|
|
|
|
3
|
$ret .= $self->indexer->as_string(); |
73
|
1
|
|
|
|
|
3
|
$ret .= $self->searchd->as_string(); |
74
|
1
|
|
|
|
|
5
|
return $ret; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# bless array of singleton key/value hash refs |
78
|
|
|
|
|
|
|
package Sphinx::Config::Entry; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub new { |
81
|
20
|
|
|
20
|
|
6122
|
my $pkg = shift; |
82
|
20
|
|
|
|
|
52
|
my $self = { kv_pairs => [], }; |
83
|
|
|
|
|
|
|
|
84
|
20
|
|
|
|
|
49
|
bless $self, $pkg; |
85
|
20
|
|
|
|
|
55
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub kv_push { |
89
|
14
|
|
|
14
|
|
23
|
my $self = shift; |
90
|
14
|
|
|
|
|
18
|
return push @{ $self->{kv_pairs} }, @_; |
|
14
|
|
|
|
|
76
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub kv_pop { |
94
|
12
|
|
|
12
|
|
13263
|
my $self = shift; |
95
|
12
|
|
|
|
|
18
|
return pop @{ $self->{kv_pairs} }; |
|
12
|
|
|
|
|
37
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
|
0
|
sub as_string { |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
package Sphinx::Config::Entry::Source; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
our @ISA = q{Sphinx::Config::Entry}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub name { |
107
|
6
|
|
|
6
|
|
1845
|
my $self = shift; |
108
|
6
|
50
|
|
|
|
28
|
$self->{name} = $_[0] if $_[0]; |
109
|
6
|
|
|
|
|
22
|
return $self->{name}; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub as_string { |
113
|
12
|
|
|
12
|
|
4847
|
my $self = shift; |
114
|
12
|
|
|
|
|
28
|
my $name = $self->{name}; |
115
|
12
|
|
|
|
|
24
|
my $ret = qq/ |
116
|
|
|
|
|
|
|
source $name |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
/; |
119
|
12
|
|
|
|
|
16
|
foreach my $kv_pair ( @{ $self->{kv_pairs} } ) { |
|
12
|
|
|
|
|
41
|
|
120
|
24
|
|
|
|
|
69
|
my @k = keys %$kv_pair; |
121
|
24
|
|
|
|
|
41
|
my $k = pop @k; |
122
|
24
|
|
|
|
|
42
|
my $v = $kv_pair->{$k}; |
123
|
24
|
|
|
|
|
80
|
$ret .= qq{ $k = $v\n}; |
124
|
|
|
|
|
|
|
} |
125
|
12
|
|
|
|
|
22
|
$ret .= qq/ |
126
|
|
|
|
|
|
|
}/; |
127
|
12
|
|
|
|
|
45
|
return $ret; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
package Sphinx::Config::Entry::Index; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
our @ISA = q{Sphinx::Config::Entry}; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub name { |
135
|
6
|
|
|
6
|
|
9
|
my $self = shift; |
136
|
6
|
50
|
|
|
|
26
|
$self->{name} = $_[0] if $_[0]; |
137
|
6
|
|
|
|
|
29
|
return $self->{name}; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub as_string { |
141
|
12
|
|
|
12
|
|
4546
|
my $self = shift; |
142
|
12
|
|
|
|
|
23
|
my $name = $self->{name}; |
143
|
12
|
|
|
|
|
23
|
my $ret = qq/ |
144
|
|
|
|
|
|
|
index $name |
145
|
|
|
|
|
|
|
{ |
146
|
|
|
|
|
|
|
/; |
147
|
12
|
|
|
|
|
13
|
foreach my $kv_pair ( @{ $self->{kv_pairs} } ) { |
|
12
|
|
|
|
|
30
|
|
148
|
36
|
|
|
|
|
80
|
my @k = keys %$kv_pair; |
149
|
36
|
|
|
|
|
45
|
my $k = pop @k; |
150
|
36
|
|
|
|
|
56
|
my $v = $kv_pair->{$k}; |
151
|
36
|
|
|
|
|
189
|
$ret .= qq{ $k = $v\n}; |
152
|
|
|
|
|
|
|
} |
153
|
12
|
|
|
|
|
18
|
$ret .= qq/ |
154
|
|
|
|
|
|
|
}/; |
155
|
12
|
|
|
|
|
40
|
return $ret; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
package Sphinx::Config::Entry::Indexer; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
our @ISA = q{Sphinx::Config::Entry}; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub as_string { |
163
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
164
|
2
|
|
|
|
|
4
|
my $ret = qq/ |
165
|
|
|
|
|
|
|
indexer |
166
|
|
|
|
|
|
|
{ |
167
|
|
|
|
|
|
|
/; |
168
|
2
|
|
|
|
|
634
|
foreach my $kv_pair ( @{ $self->{kv_pairs} } ) { |
|
2
|
|
|
|
|
8
|
|
169
|
2
|
|
|
|
|
7
|
my @k = keys %$kv_pair; |
170
|
2
|
|
|
|
|
4
|
my $k = pop @k; |
171
|
2
|
|
|
|
|
3
|
my $v = $kv_pair->{$k}; |
172
|
2
|
|
|
|
|
11
|
$ret .= qq{ $k = $v\n}; |
173
|
|
|
|
|
|
|
} |
174
|
2
|
|
|
|
|
4
|
$ret .= qq/ |
175
|
|
|
|
|
|
|
}/; |
176
|
2
|
|
|
|
|
7
|
return $ret; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
package Sphinx::Config::Entry::Searchd; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
our @ISA = q{Sphinx::Config::Entry}; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub as_string { |
184
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
185
|
2
|
|
|
|
|
3
|
my $ret = qq/ |
186
|
|
|
|
|
|
|
searchd |
187
|
|
|
|
|
|
|
{ |
188
|
|
|
|
|
|
|
/; |
189
|
2
|
|
|
|
|
3
|
foreach my $kv_pair ( @{ $self->{kv_pairs} } ) { |
|
2
|
|
|
|
|
6
|
|
190
|
26
|
|
|
|
|
57
|
my @k = keys %$kv_pair; |
191
|
26
|
|
|
|
|
37
|
my $k = pop @k; |
192
|
26
|
|
|
|
|
39
|
my $v = $kv_pair->{$k}; |
193
|
26
|
|
|
|
|
68
|
$ret .= qq{ $k = $v\n}; |
194
|
|
|
|
|
|
|
} |
195
|
2
|
|
|
|
|
4
|
$ret .= qq/ |
196
|
|
|
|
|
|
|
}/; |
197
|
2
|
|
|
|
|
7
|
return $ret; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
1; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
__END__ |