line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
591
|
use 5.006; # 06 -> [pragmas, our] |
|
6
|
|
|
|
|
14
|
|
2
|
6
|
|
|
6
|
|
22
|
use strict; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
103
|
|
3
|
6
|
|
|
6
|
|
18
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
309
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Tempdir::Item::State; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.001002'; # TRIAL |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Intermediate state for a file |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
453
|
use Moose qw( has ); |
|
6
|
|
|
|
|
296238
|
|
|
6
|
|
|
|
|
26
|
|
14
|
6
|
|
|
6
|
|
19029
|
use Carp qw( croak ); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
263
|
|
15
|
6
|
|
|
6
|
|
1479
|
use Path::Tiny qw( path ); |
|
6
|
|
|
|
|
14000
|
|
|
6
|
|
|
|
|
2694
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'hash' => ( is => ro =>, lazy_build => 1 ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'file' => ( |
32
|
|
|
|
|
|
|
is => ro =>, |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
handles => { name => name => }, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has 'new_content' => ( is => ro =>, lazy_build => 1 ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has 'new_hash' => ( is => ro =>, lazy_build => 1 ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'storage_prefix' => ( is => ro =>, required => 1 ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has '_digester' => ( is => ro =>, lazy_build => 1 ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub BUILD { |
70
|
14
|
|
|
14
|
1
|
18
|
my ($self) = @_; |
71
|
14
|
|
|
|
|
412
|
$self->hash; |
72
|
14
|
|
|
|
|
345
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _build__digester { |
76
|
14
|
|
|
14
|
|
1502
|
require Digest::SHA; |
77
|
|
|
|
|
|
|
## no critic ( ProhibitMagicNumbers ) |
78
|
14
|
|
|
|
|
6073
|
return Digest::SHA->new(512); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _digest_for { |
82
|
26
|
|
|
26
|
|
29
|
my ( $self, $content ) = @_; |
83
|
26
|
50
|
|
|
|
49
|
if ( not defined $content ) { |
84
|
0
|
|
|
|
|
0
|
return croak('->_digest_for( content ) must have a defined value of content'); |
85
|
|
|
|
|
|
|
} |
86
|
26
|
|
|
|
|
725
|
$self->_digester->reset(); |
87
|
26
|
|
|
|
|
871
|
$self->_digester->add($content); |
88
|
26
|
|
|
|
|
697
|
return $self->_digester->b64digest; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _build_hash { |
92
|
14
|
|
|
14
|
|
16
|
my ($self) = @_; |
93
|
14
|
|
|
|
|
29
|
return $self->_digest_for( $self->_encoded_content ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _build_new_content { |
97
|
12
|
|
|
12
|
|
14
|
my ($self) = @_; |
98
|
12
|
50
|
|
|
|
15
|
return unless $self->on_disk; |
99
|
12
|
|
|
|
|
190
|
return $self->_relpath->slurp_raw(); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _build_new_hash { |
103
|
12
|
|
|
12
|
|
13
|
my ($self) = @_; |
104
|
12
|
50
|
|
|
|
20
|
return unless $self->on_disk; |
105
|
12
|
|
|
|
|
552
|
return $self->_digest_for( $self->new_content ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _encoded_content { |
109
|
28
|
|
|
28
|
|
27
|
my ($self) = @_; |
110
|
28
|
|
|
|
|
21
|
my $content; |
111
|
28
|
|
|
|
|
27
|
my $method = 'content'; |
112
|
28
|
50
|
|
|
|
834
|
if ( $self->file->can('encoded_content') ) { |
113
|
28
|
|
|
|
|
27
|
$method = 'encoded_content'; |
114
|
28
|
|
|
|
|
780
|
$content = $self->file->encoded_content; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else { |
117
|
0
|
|
|
|
|
0
|
$content = $self->file->content; |
118
|
|
|
|
|
|
|
} |
119
|
28
|
50
|
|
|
|
2945
|
if ( not defined $content ) { |
120
|
0
|
|
|
|
|
0
|
croak( $self->file . " returned undef for $method" ); |
121
|
|
|
|
|
|
|
} |
122
|
28
|
|
|
|
|
82
|
return $content; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _relpath { |
126
|
76
|
|
|
76
|
|
80
|
my ($self) = @_; |
127
|
76
|
|
|
|
|
2335
|
my $d = path( $self->storage_prefix ); |
128
|
76
|
|
|
|
|
3939
|
my $out_path = $d->child( $self->file->name ); |
129
|
76
|
|
|
|
|
4195
|
return $out_path; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub write_out { |
139
|
14
|
|
|
14
|
1
|
14
|
my ($self) = @_; |
140
|
14
|
|
|
|
|
23
|
my $out_path = $self->_relpath(); |
141
|
14
|
|
|
|
|
47
|
$out_path->parent->mkpath(1); |
142
|
14
|
|
|
|
|
1079
|
$out_path->spew_raw( $self->_encoded_content ); |
143
|
14
|
|
|
|
|
3697
|
return; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub on_disk { |
153
|
50
|
|
|
50
|
1
|
45
|
my ($self) = @_; |
154
|
50
|
|
|
|
|
67
|
my $out_path = $self->_relpath(); |
155
|
50
|
|
|
|
|
128
|
return -e $out_path; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub on_disk_changed { |
166
|
12
|
|
|
12
|
1
|
317
|
my ($self) = @_; |
167
|
12
|
50
|
|
|
|
30
|
return unless $self->on_disk; |
168
|
12
|
|
|
|
|
574
|
return $self->hash ne $self->new_hash; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
6
|
|
|
6
|
|
28
|
no Moose; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
25
|
|
172
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
__END__ |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=pod |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=encoding UTF-8 |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 NAME |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Dist::Zilla::Tempdir::Item::State - Intermediate state for a file |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 VERSION |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
version 1.001002 |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 C<hash> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Provides a digest hash of C<file>'s content |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 C<file> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
A C<Dist::Zilla::File> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 C<new_content> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Content of C<storage_prefix>/C<file> read from disk. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 C<new_hash> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Hash of C<new_content> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head2 C<storage_prefix> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The root directory to write this file out to, and to read it from. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 METHODS |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 C<BUILD> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Ensures C<hash> is populated at build time. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 C<write_out> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Emits C<file> into C<storage_prefix> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 C<on_disk> |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Returns true if C<file> exists in C<storage_prefix> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 C<on_disk_changed> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Returns true if the file is on disk, and the on-disk hash |
228
|
|
|
|
|
|
|
doesn't match the written out C<file>'s hash. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 AUTHOR |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
239
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=cut |