64
|
|
|
|
|
|
|
~; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _build_table { |
68
|
7
|
|
|
7
|
|
16
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
7
|
|
|
|
|
21
|
my %files = @_; |
71
|
|
|
|
|
|
|
|
72
|
7
|
|
|
|
|
39
|
my @seq_a = $self->_read_file( $files{a} ); |
73
|
7
|
|
|
|
|
35
|
my @seq_b = $self->_read_file( $files{b} ); |
74
|
|
|
|
|
|
|
|
75
|
7
|
|
|
|
|
81
|
my $diff = Algorithm::Diff->new( \@seq_a, \@seq_b ); |
76
|
|
|
|
|
|
|
|
77
|
7
|
|
|
|
|
2489
|
$diff->Base(1); |
78
|
|
|
|
|
|
|
|
79
|
7
|
|
|
|
|
51
|
my $rows = ''; |
80
|
|
|
|
|
|
|
|
81
|
7
|
|
|
|
|
18
|
my ($line_nr_a, $line_nr_b) = (1, 1); |
82
|
7
|
|
|
|
|
38
|
while ( $diff->Next ) { |
83
|
55
|
100
|
|
|
|
947
|
if ( my $count = $diff->Same ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
84
|
27
|
|
|
|
|
457
|
for my $string ( $diff->Same ) { |
85
|
37
|
|
|
|
|
506
|
$rows .= $self->_add_tablerow( |
86
|
|
|
|
|
|
|
line_nr_a => $line_nr_a++, |
87
|
|
|
|
|
|
|
line_nr_b => $line_nr_b++, |
88
|
|
|
|
|
|
|
line_a => $string, |
89
|
|
|
|
|
|
|
line_b => $string, |
90
|
|
|
|
|
|
|
color_a => '', |
91
|
|
|
|
|
|
|
color_b => '', |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( !$diff->Items(2) ) { |
96
|
5
|
|
|
|
|
179
|
my @items_1 = $diff->Items(1); |
97
|
5
|
|
|
|
|
87
|
my @items_2 = $diff->Items(2); |
98
|
|
|
|
|
|
|
|
99
|
5
|
50
|
|
|
|
75
|
my $max = @items_1 > @items_2 ? scalar( @items_1 ) : scalar( @items_2 ); |
100
|
|
|
|
|
|
|
|
101
|
5
|
|
|
|
|
40
|
for my $index ( 1 .. $max ) { |
102
|
5
|
|
50
|
|
|
101
|
$rows .= $self->_add_tablerow( |
|
|
|
50
|
|
|
|
|
103
|
|
|
|
|
|
|
line_nr_a => $line_nr_a++, |
104
|
|
|
|
|
|
|
line_nr_b => '', |
105
|
|
|
|
|
|
|
line_a => $items_1[ $index - 1 ] // '', |
106
|
|
|
|
|
|
|
line_b => $items_2[ $index - 1 ] // '', |
107
|
|
|
|
|
|
|
color_a => 'red', |
108
|
|
|
|
|
|
|
color_b => '', |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
elsif ( !$diff->Items(1) ) { |
113
|
10
|
|
|
|
|
320
|
my @items_1 = $diff->Items(1); |
114
|
10
|
|
|
|
|
130
|
my @items_2 = $diff->Items(2); |
115
|
|
|
|
|
|
|
|
116
|
10
|
50
|
|
|
|
169
|
my $max = @items_1 > @items_2 ? scalar( @items_1 ) : scalar( @items_2 ); |
117
|
|
|
|
|
|
|
|
118
|
10
|
|
|
|
|
25
|
for my $index ( 1 .. $max ) { |
119
|
10
|
|
50
|
|
|
79
|
$rows .= $self->_add_tablerow( |
|
|
|
50
|
|
|
|
|
120
|
|
|
|
|
|
|
line_nr_a => '', |
121
|
|
|
|
|
|
|
line_nr_b => $line_nr_b++, |
122
|
|
|
|
|
|
|
line_a => $items_1[ $index - 1 ] // '', |
123
|
|
|
|
|
|
|
line_b => $items_2[ $index - 1 ] // '', |
124
|
|
|
|
|
|
|
color_a => '', |
125
|
|
|
|
|
|
|
color_b => 'green', |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
else { |
130
|
13
|
|
|
|
|
428
|
my @items_1 = $diff->Items(1); |
131
|
13
|
|
|
|
|
177
|
my @items_2 = $diff->Items(2); |
132
|
|
|
|
|
|
|
|
133
|
13
|
50
|
|
|
|
178
|
my $max = @items_1 > @items_2 ? scalar( @items_1 ) : scalar( @items_2 ); |
134
|
|
|
|
|
|
|
|
135
|
13
|
|
|
|
|
31
|
for my $index ( 1 .. $max ) { |
136
|
26
|
|
100
|
|
|
164
|
$rows .= $self->_add_tablerow( |
|
|
|
50
|
|
|
|
|
137
|
|
|
|
|
|
|
line_nr_a => $line_nr_a++, |
138
|
|
|
|
|
|
|
line_nr_b => $line_nr_b++, |
139
|
|
|
|
|
|
|
line_a => $items_1[ $index - 1 ] // '', |
140
|
|
|
|
|
|
|
line_b => $items_2[ $index - 1 ] // '', |
141
|
|
|
|
|
|
|
color_a => 'red', |
142
|
|
|
|
|
|
|
color_b => 'green', |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
7
|
|
|
|
|
257
|
return $rows; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub _add_tablerow { |
152
|
78
|
|
|
78
|
|
106
|
my $self = shift; |
153
|
|
|
|
|
|
|
|
154
|
78
|
|
|
|
|
310
|
my %params = @_; |
155
|
|
|
|
|
|
|
|
156
|
78
|
|
|
|
|
149
|
my ($line_nr_a, $line_a, $color_a) = @params{qw/line_nr_a line_a color_a/}; |
157
|
78
|
|
|
|
|
121
|
my ($line_nr_b, $line_b, $color_b) = @params{qw/line_nr_b line_b color_b/}; |
158
|
|
|
|
|
|
|
|
159
|
78
|
100
|
|
|
|
176
|
$color_a = $color_a ? qq~style="color: $color_a;"~ : ''; |
160
|
78
|
100
|
|
|
|
141
|
$color_b = $color_b ? qq~style="color: $color_b;"~ : ''; |
161
|
|
|
|
|
|
|
|
162
|
78
|
|
50
|
|
|
268
|
$line_a = encode_entities( $line_a // '' ); |
163
|
78
|
|
50
|
|
|
939
|
$line_b = encode_entities( $line_b // '' ); |
164
|
|
|
|
|
|
|
|
165
|
78
|
|
|
|
|
1351
|
my $row = qq~ |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
| $line_nr_a |
168
|
|
|
|
|
|
|
| $line_a |
169
|
|
|
|
|
|
|
| $line_nr_b |
170
|
|
|
|
|
|
|
| $line_b |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
~; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub _end_table { |
176
|
7
|
|
|
7
|
|
15
|
my $self = shift; |
177
|
|
|
|
|
|
|
|
178
|
7
|
|
|
|
|
18
|
return qq~ |
179
|
|
|
|
|
|
|
|