line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Relations::Role::Relation; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Relations::Role::Relation::VERSION = '0.400105'; |
3
|
13
|
|
|
13
|
|
4423
|
use strict; |
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
314
|
|
4
|
13
|
|
|
13
|
|
43
|
use Moo::Role; |
|
13
|
|
|
|
|
17
|
|
|
13
|
|
|
|
|
63
|
|
5
|
13
|
|
|
13
|
|
8668
|
use HTML::Entities; |
|
13
|
|
|
|
|
51213
|
|
|
13
|
|
|
|
|
7310
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has node1 => ( |
8
|
|
|
|
|
|
|
is => 'ro' |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
has node2 => ( |
11
|
|
|
|
|
|
|
is => 'ro' |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub bidirectional |
15
|
|
|
|
|
|
|
{ |
16
|
184
|
|
|
184
|
0
|
424
|
return 1; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub has_node |
20
|
|
|
|
|
|
|
{ |
21
|
132
|
|
|
132
|
0
|
126
|
my $self = shift; |
22
|
132
|
|
|
|
|
110
|
my $node = shift; |
23
|
132
|
|
100
|
|
|
735
|
return $self->node1 eq $node || $self->node2 eq $node; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
sub is_between |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
28
|
0
|
|
0
|
|
|
0
|
my $node1 = shift || ""; |
29
|
0
|
|
0
|
|
|
0
|
my $node2 = shift || ""; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
0
|
|
|
0
|
return ($self->node1 eq $node1 && $self->node2 eq $node2) || |
32
|
|
|
|
|
|
|
($self->node1 eq $node2 && $self->node2 eq $node1 && $self->bidirectional); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub involve |
35
|
|
|
|
|
|
|
{ |
36
|
9
|
|
|
9
|
0
|
13
|
my $self = shift; |
37
|
9
|
|
50
|
|
|
25
|
my $node1 = shift || ""; |
38
|
9
|
|
50
|
|
|
24
|
my $node2 = shift || ""; |
39
|
|
|
|
|
|
|
|
40
|
9
|
|
66
|
|
|
109
|
return ($self->node1 eq $node1 && $self->node2 eq $node2) || |
41
|
|
|
|
|
|
|
($self->node1 eq $node2 && $self->node2 eq $node1); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
sub destination |
44
|
|
|
|
|
|
|
{ |
45
|
402
|
|
|
402
|
0
|
331
|
my $self = shift; |
46
|
402
|
|
|
|
|
292
|
my $node = shift; |
47
|
402
|
100
|
33
|
|
|
924
|
if($self->node1 eq $node) |
|
|
50
|
|
|
|
|
|
48
|
|
|
|
|
|
|
{ |
49
|
218
|
|
|
|
|
565
|
return $self->node2; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif($self->node2 eq $node && $self->bidirectional) |
52
|
|
|
|
|
|
|
{ |
53
|
184
|
|
|
|
|
476
|
return $self->node1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
|
|
0
|
return undef; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
sub start |
61
|
|
|
|
|
|
|
{ |
62
|
5
|
|
|
5
|
0
|
7
|
my $self = shift; |
63
|
5
|
|
|
|
|
6
|
my $node = shift; |
64
|
5
|
50
|
0
|
|
|
17
|
if($self->node2 eq $node) |
|
|
0
|
|
|
|
|
|
65
|
|
|
|
|
|
|
{ |
66
|
5
|
|
|
|
|
14
|
return $self->node1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif($self->node1 eq $node && $self->bidirectional) |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
|
|
|
return $self->node1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
|
|
|
return undef; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
sub output |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my $mode = shift; |
81
|
0
|
0
|
|
|
|
|
if($mode eq 'print') |
|
|
0
|
|
|
|
|
|
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
|
|
|
return $self->print; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
elsif($mode eq 'html') |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
|
|
|
return $self->html; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub print |
93
|
|
|
|
|
|
|
{ |
94
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
my $from = shift; |
96
|
0
|
0
|
0
|
|
|
|
if($from && $from eq $self->node1) |
|
|
0
|
0
|
|
|
|
|
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
|
|
|
return $from . " -> " . $self->node2; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
elsif($from && $from eq $self->node2 ) |
101
|
|
|
|
|
|
|
{ |
102
|
0
|
0
|
|
|
|
|
if($self->bidirectional) |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
|
|
|
return $self->node2 . " -> " . $self->node1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
else |
107
|
|
|
|
|
|
|
{ |
108
|
0
|
|
|
|
|
|
return $self->node1 . " -> " . $self->node2; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
else |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
0
|
|
|
|
|
if($self->bidirectional) |
114
|
|
|
|
|
|
|
{ |
115
|
0
|
|
|
|
|
|
return $self->node1 . " <-> " . $self->node2; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
else |
118
|
|
|
|
|
|
|
{ |
119
|
0
|
|
|
|
|
|
return $self->node1 . " -> " . $self->node2; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
sub html |
124
|
|
|
|
|
|
|
{ |
125
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
126
|
0
|
|
|
|
|
|
return encode_entities($self->print); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
sub dump |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
131
|
0
|
|
|
|
|
|
my $io = shift; |
132
|
0
|
|
0
|
|
|
|
my $indent = shift || ""; |
133
|
0
|
|
|
|
|
|
print {$io} $indent . $self->node1 . ";" . $self->node2 . "\n"; |
|
0
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
sub load |
136
|
|
|
|
|
|
|
{ |
137
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
138
|
0
|
|
|
|
|
|
my $data = shift; |
139
|
0
|
|
|
|
|
|
$data =~ s/^\s+//; |
140
|
0
|
|
|
|
|
|
chomp $data; |
141
|
0
|
|
|
|
|
|
my ($node1, $node2) = split ";", $data; |
142
|
0
|
|
|
|
|
|
return $self->new(node1 => $node1, node2 => $node2); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
1; |