line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Hexonet::Connector::ResponseParser; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
17
|
use 5.026_000; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use version 0.9917; our $VERSION = version->declare('v2.9.1'); |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub parse { |
11
|
112
|
|
|
112
|
1
|
244
|
my $response = shift; |
12
|
112
|
|
|
|
|
219
|
my %hash = (); |
13
|
112
|
|
|
|
|
643
|
$response =~ s/\r\n/\n/gmsx; |
14
|
112
|
|
|
|
|
1352
|
foreach ( split /\n/msx, $response ) { |
15
|
3991
|
100
|
|
|
|
14812
|
if (/^([^\=]*[^\t\= ])[\t ]*=[\t ]*(.+)/msx) { |
16
|
3734
|
|
|
|
|
8439
|
my $attr = $1; |
17
|
3734
|
|
|
|
|
6711
|
my $value = $2; |
18
|
3734
|
|
|
|
|
15789
|
$value =~ s/[\t ]*$//msx; |
19
|
3734
|
100
|
|
|
|
10597
|
if ( $attr =~ /^property\[([^\]]*)\]/imsx ) { |
20
|
3399
|
100
|
|
|
|
7411
|
if ( !defined $hash{PROPERTY} ) { |
21
|
50
|
|
|
|
|
156
|
$hash{PROPERTY} = {}; |
22
|
|
|
|
|
|
|
} |
23
|
3399
|
|
|
|
|
6930
|
my $prop = uc $1; |
24
|
3399
|
|
|
|
|
6638
|
$prop =~ s/\s//ogmsx; |
25
|
3399
|
100
|
|
|
|
6767
|
if ( defined $hash{PROPERTY}{$prop} ) { |
26
|
3142
|
|
|
|
|
4496
|
push @{ $hash{PROPERTY}{$prop} }, $value; |
|
3142
|
|
|
|
|
8948
|
|
27
|
|
|
|
|
|
|
} else { |
28
|
257
|
|
|
|
|
828
|
$hash{PROPERTY}{$prop} = [ $value ]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} else { |
31
|
335
|
|
|
|
|
1121
|
$hash{ uc $attr } = $value; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
112
|
|
|
|
|
683
|
return \%hash; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub serialize { |
40
|
6
|
|
|
6
|
1
|
48
|
my $h = shift; |
41
|
6
|
|
|
|
|
12
|
my $plain = '[RESPONSE]'; |
42
|
6
|
100
|
|
|
|
15
|
if ( defined $h->{PROPERTY} ) { |
43
|
3
|
|
|
|
|
6
|
my $props = $h->{PROPERTY}; |
44
|
3
|
|
|
|
|
5
|
foreach my $key ( sort keys %{$props} ) { |
|
3
|
|
|
|
|
17
|
|
45
|
5
|
|
|
|
|
9
|
my $i = 0; |
46
|
5
|
|
|
|
|
8
|
foreach my $val ( @{ $props->{$key} } ) { |
|
5
|
|
|
|
|
13
|
|
47
|
11
|
|
|
|
|
38
|
$plain .= "\r\nPROPERTY[${key}][${i}]=${val}"; |
48
|
11
|
|
|
|
|
24
|
$i++; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
6
|
100
|
|
|
|
21
|
if ( defined $h->{CODE} ) { |
53
|
5
|
|
|
|
|
14
|
$plain .= "\r\nCODE=" . $h->{CODE}; |
54
|
|
|
|
|
|
|
} |
55
|
6
|
100
|
|
|
|
15
|
if ( defined $h->{DESCRIPTION} ) { |
56
|
5
|
|
|
|
|
16
|
$plain .= "\r\nDESCRIPTION=" . $h->{DESCRIPTION}; |
57
|
|
|
|
|
|
|
} |
58
|
6
|
100
|
|
|
|
22
|
if ( defined $h->{QUEUETIME} ) { |
59
|
1
|
|
|
|
|
4
|
$plain .= "\r\nQUEUETIME=" . $h->{QUEUETIME}; |
60
|
|
|
|
|
|
|
} |
61
|
6
|
100
|
|
|
|
15
|
if ( defined $h->{RUNTIME} ) { |
62
|
1
|
|
|
|
|
3
|
$plain .= "\r\nRUNTIME=" . $h->{RUNTIME}; |
63
|
|
|
|
|
|
|
} |
64
|
6
|
|
|
|
|
13
|
$plain .= "\r\nEOF\r\n"; |
65
|
6
|
|
|
|
|
16
|
return $plain; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |