line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
509
|
use 5.006; #06 -> [pragmas, our] |
|
6
|
|
|
|
|
15
|
|
2
|
6
|
|
|
6
|
|
21
|
use strict; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
118
|
|
3
|
6
|
|
|
6
|
|
17
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
344
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Tempdir::Item; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.001003'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: A result object for things that DO() DZ::R::Tempdir; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
470
|
use Moose qw( has ); |
|
6
|
|
|
|
|
305283
|
|
|
6
|
|
|
|
|
34
|
|
14
|
6
|
|
|
6
|
|
22942
|
use MooseX::LazyRequire; |
|
6
|
|
|
|
|
66136
|
|
|
6
|
|
|
|
|
20
|
|
15
|
6
|
|
|
6
|
|
42005
|
use namespace::autoclean; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
25
|
|
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
6
|
|
331
|
use Carp qw(croak); |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
303
|
|
18
|
6
|
|
|
6
|
|
24
|
use Scalar::Util qw( blessed ); |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
1157
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'status' => ( |
36
|
|
|
|
|
|
|
isa => 'Str', |
37
|
|
|
|
|
|
|
lazy_required => 1, |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'file' => ( |
54
|
|
|
|
|
|
|
isa => 'Dist::Zilla::Role::File', |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
is => 'rw', |
57
|
|
|
|
|
|
|
handles => { name => 'name' }, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _mk_status { |
69
|
24
|
|
|
24
|
|
29
|
my $name = shift; |
70
|
24
|
|
|
|
|
20
|
my $value = shift; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $setter = sub { |
73
|
22
|
|
|
22
|
|
33
|
my $self = shift; |
74
|
22
|
50
|
|
|
|
82
|
return croak( $name . 'is an instance method, not a class method' ) unless blessed($self); |
75
|
22
|
50
|
|
|
|
52
|
return croak( 'too many arguments ( 0 expected ) to ->' . $name ) if @_; |
76
|
22
|
|
|
|
|
636
|
$self->status($value); |
77
|
24
|
|
|
|
|
53
|
}; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $getter = sub { |
80
|
5
|
|
|
5
|
|
107
|
my $self = shift; |
81
|
5
|
50
|
|
|
|
18
|
return croak( $name . 'is an instance method, not a class method' ) unless blessed($self); |
82
|
5
|
50
|
|
|
|
11
|
return croak( 'too many arguments ( 0 expected ) to ->' . $name ) if @_; |
83
|
5
|
|
|
|
|
122
|
$self->status() eq $value; |
84
|
24
|
|
|
|
|
39
|
}; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
{ |
87
|
|
|
|
|
|
|
## no critic ( ProhibitNoStrict ) |
88
|
6
|
|
|
6
|
|
24
|
no strict 'refs'; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
558
|
|
|
24
|
|
|
|
|
23
|
|
89
|
24
|
|
|
|
|
20
|
*{ __PACKAGE__ . q[::set_] . $name } = $setter; |
|
24
|
|
|
|
|
77
|
|
90
|
24
|
|
|
|
|
22
|
*{ __PACKAGE__ . q[::is_] . $name } = $getter; |
|
24
|
|
|
|
|
71
|
|
91
|
|
|
|
|
|
|
} |
92
|
24
|
|
|
|
|
19
|
return 1; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
_mk_status( 'modified', 'M' ); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
_mk_status( 'original', 'O' ); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
_mk_status( 'new', 'N' ); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
_mk_status( 'deleted', 'D' ); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
145
|
|
|
|
|
|
|
|
146
|
6
|
|
|
6
|
|
23
|
no Moose; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
27
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=pod |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=encoding UTF-8 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 NAME |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Dist::Zilla::Tempdir::Item - A result object for things that DO() DZ::R::Tempdir; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 VERSION |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
version 1.001003 |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SYNOPSIS |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $foo = Dist::Zilla::Tempdir::Item->new( |
167
|
|
|
|
|
|
|
name => 'Path/To/File.txt', |
168
|
|
|
|
|
|
|
file => $dzilfile, |
169
|
|
|
|
|
|
|
); |
170
|
|
|
|
|
|
|
$foo->set_new; |
171
|
|
|
|
|
|
|
$foo->is_new; # true |
172
|
|
|
|
|
|
|
$foo->is_deleted; # false |
173
|
|
|
|
|
|
|
$foo->set_deleted; |
174
|
|
|
|
|
|
|
$foo->is_new; # false |
175
|
|
|
|
|
|
|
$foo->is_deleted; # true. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Ultimately, I figured using a character with "C<eq>" every where in extending code |
178
|
|
|
|
|
|
|
was a way to extra bugs that were hard to detect. Going via all the Object-Oriented niceness |
179
|
|
|
|
|
|
|
you'll probably incur* a small performance penalty, but things going B<Bang> when you |
180
|
|
|
|
|
|
|
make a typo or add invisible white-space is a Good Thing. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
* albeit immeasurably insignificant in size, especially for something that will only take |
183
|
|
|
|
|
|
|
15 seconds of run-time every once in a while, not to mention the overhead is drowned by the |
184
|
|
|
|
|
|
|
fact we're doing file-system IO and running many of the files through a complete hashing |
185
|
|
|
|
|
|
|
algorithm to test for modification. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 status |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
isa => Str, |
192
|
|
|
|
|
|
|
is => rw, |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
The internal status character. You can mangle this yourself if you want, and for compatibility with older versions |
195
|
|
|
|
|
|
|
of this dist, you may even have to, but try not to, if it breaks, something something something pieces. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Using the is_* and set_* accessors is a I<much> smarter idea. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
At present, the characters M, O, N and D have defined meanings, but this could change. ( Its not even unforeseeable expanding it to |
200
|
|
|
|
|
|
|
be 2 characters to represent different parts of state, I probably will not do that, but do not pretend I will not ;) ) |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 file |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
isa => Dist::Zilla::Role::File, |
205
|
|
|
|
|
|
|
required => 1, |
206
|
|
|
|
|
|
|
is => rw |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This is the Dist::Zilla::File::* item which we refer to. For items that C<is_deleted>, C<file> is likely to be the file before it got deleted. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
For C<is_new> and C<is_original> files, the item is the file itself, and for C<is_modified>, its the modified version of the file. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 METHODS |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 name |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Proxy for C<< $item->file->name >> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
This is the path to the file relative to the dist root. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 is_modified |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
returns if the file is modified or not. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 set_modified |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sets the state to 'modified' |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 is_original |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
returns if the file is the original file or not. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 set_original |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sets the state to 'original' |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 is_new |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
returns if the file is new or not ( that is, if it wasn't in the dist prior to executing |
239
|
|
|
|
|
|
|
the given code ). |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head2 set_new |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sets the state to 'new' |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head2 is_deleted |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
returns if the file is deleted or not ( that is, if it were deleted during the execution phase ) |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 set_deleted |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sets the state to 'deleted' |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head1 AUTHOR |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
262
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut |