line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#=============================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# DESCRIPTION: Serialize to mixied XML and JSON |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# AUTHOR: Aliaksandr P. Zahatski, |
6
|
|
|
|
|
|
|
#=============================================================================== |
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Flow::To::JXML - serialize flow to JSON+XML |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my ( $s, $s1 ); |
14
|
|
|
|
|
|
|
my $f1 = Flow::create_flow( |
15
|
|
|
|
|
|
|
Splice => 200, |
16
|
|
|
|
|
|
|
Join => { |
17
|
|
|
|
|
|
|
Data => Flow::create_flow( |
18
|
|
|
|
|
|
|
sub { |
19
|
|
|
|
|
|
|
return [ grep { $_ > 10 } @_ ]; |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
Splice => 10 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
), |
24
|
|
|
|
|
|
|
Min => Flow::create_flow( |
25
|
|
|
|
|
|
|
sub { |
26
|
|
|
|
|
|
|
return [ grep { $_ == 1 } @_ ]; |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
Splice => 40, |
29
|
|
|
|
|
|
|
) |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
ToJXML => \$s, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
$f1->run( 1, 3, 11 ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Flow::To::JXML - serialize flow to JSON+XML |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package Flow::To::JXML; |
42
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
43
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
448
|
|
|
2
|
|
|
|
|
48
|
|
44
|
2
|
|
|
2
|
|
610
|
use JSON; |
|
2
|
|
|
|
|
11548
|
|
|
2
|
|
|
|
|
11
|
|
45
|
2
|
|
|
2
|
|
302
|
use Flow::To::XML; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
48
|
|
46
|
2
|
|
|
2
|
|
10
|
use base 'Flow::To::XML'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
556
|
|
47
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
48
|
|
|
|
|
|
|
sub flow { |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $xfl = $self->{_xml_flow}; |
51
|
0
|
|
|
|
|
|
$xfl->startTag("flow"); |
52
|
0
|
|
|
|
|
|
$xfl->_get_writer->cdata(JSON->new->utf8->pretty(1)->encode(\@_)); |
53
|
0
|
|
|
|
|
|
$xfl->endTag("flow"); |
54
|
0
|
|
|
|
|
|
return $self->Flow::flow(@_) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub ctl_flow { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $xfl = $self->{_xml_flow}; |
61
|
0
|
|
|
|
|
|
$xfl->startTag("ctl_flow"); |
62
|
0
|
|
|
|
|
|
$xfl->_get_writer->cdata(encode_json(\@_)); |
63
|
0
|
|
|
|
|
|
$xfl->endTag("ctl_flow"); |
64
|
0
|
|
|
|
|
|
return $self->Flow::ctl_flow(@_) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |