line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sqitch::Plan::LineList; |
2
|
|
|
|
|
|
|
|
3
|
50
|
|
|
50
|
|
919
|
use 5.010; |
|
50
|
|
|
|
|
220
|
|
4
|
50
|
|
|
50
|
|
322
|
use strict; |
|
50
|
|
|
|
|
119
|
|
|
50
|
|
|
|
|
1201
|
|
5
|
50
|
|
|
50
|
|
291
|
use utf8; |
|
50
|
|
|
|
|
134
|
|
|
50
|
|
|
|
|
338
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 'v1.4.0'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
46
|
|
|
46
|
1
|
2224
|
my $class = shift; |
11
|
46
|
|
|
|
|
126
|
my (@list, %index); |
12
|
46
|
|
|
|
|
171
|
for my $line (@_) { |
13
|
293
|
|
|
|
|
514
|
push @list => $line; |
14
|
293
|
|
|
|
|
1160
|
$index{ $line } = $#list; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
46
|
|
|
|
|
1264
|
return bless { |
18
|
|
|
|
|
|
|
list => \@list, |
19
|
|
|
|
|
|
|
lookup => \%index, |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
1
|
11
|
sub count { scalar @{ shift->{list} } } |
|
3
|
|
|
|
|
22
|
|
24
|
62
|
|
|
62
|
1
|
1006
|
sub items { @{ shift->{list} } } |
|
62
|
|
|
|
|
547
|
|
25
|
7
|
|
|
7
|
1
|
39
|
sub item_at { shift->{list}->[shift] } |
26
|
44
|
|
|
44
|
1
|
248
|
sub index_of { shift->{lookup}{+shift} } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub append { |
29
|
44
|
|
|
44
|
1
|
2090
|
my ( $self, $line ) = @_; |
30
|
44
|
|
|
|
|
110
|
my $list = $self->{list}; |
31
|
44
|
|
|
|
|
196
|
push @{ $list } => $line; |
|
44
|
|
|
|
|
115
|
|
32
|
44
|
|
|
|
|
299
|
$self->{lookup}{$line} = $#$list; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub insert_at { |
36
|
19
|
|
|
19
|
1
|
536
|
my ( $self, $line, $idx ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Add the line to the list. |
39
|
19
|
|
|
|
|
46
|
my $list = $self->{list}; |
40
|
19
|
|
|
|
|
40
|
splice @{ $list }, $idx, 0, $line; |
|
19
|
|
|
|
|
80
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Reindex. |
43
|
19
|
|
|
|
|
35
|
my $index = $self->{lookup}; |
44
|
19
|
|
|
|
|
177
|
$index->{ $list->[$_] } = $_ for $idx..$#$list; |
45
|
19
|
|
|
|
|
57
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 Name |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
App::Sqitch::Plan::LineList - Sqitch deployment plan line list |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 Synopsis |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $list = App::Sqitch::Plan::LineList->new(@lines); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my @lines = $list->items; |
61
|
|
|
|
|
|
|
my $index = $list->index_of($line); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$lines->append($another_line); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 Description |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This module is used internally by L<App::Sqitch::Plan> to manage plan file |
68
|
|
|
|
|
|
|
lines. It's modeled on L<Array::AsHash>, but is much simpler and hews closer |
69
|
|
|
|
|
|
|
to the API of L<App::Sqitch::Plan::ChangeList>. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 Interface |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 Constructors |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head3 C<new> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $plan = App::Sqitch::Plan::LineList->new(map { $_->name => @_ } @changes ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Instantiates and returns a App::Sqitch::Plan::LineList object. The parameters |
80
|
|
|
|
|
|
|
should be a key/value list of lines. Keys may be duplicated, as long as a tag |
81
|
|
|
|
|
|
|
appears between each instance of a key. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 Instance Methods |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 C<count> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head3 C<items> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head3 C<item_at> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head3 C<index_of> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head3 C<append> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head3 C<insert_at> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 See Also |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item L<App::Sqitch::Plan> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The Sqitch plan. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 Author |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
David E. Wheeler <david@justatheory.com> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 License |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Copyright (c) 2012-2023 iovation Inc., David E. Wheeler |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
116
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
117
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
118
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
119
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
120
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
123
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
126
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
127
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
128
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
129
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
130
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
131
|
|
|
|
|
|
|
SOFTWARE. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |