Skip to content

Commit 366764c

Browse files
committed
removed content_cb: not really used, no point in having lazy content
1 parent 618607e commit 366764c

File tree

4 files changed

+30
-54
lines changed

4 files changed

+30
-54
lines changed

lib/MetaCPAN/Document/File.pm

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -614,40 +614,17 @@ These attributes are not stored.
614614
=head2 content
615615
616616
A scalar reference to the content of the file.
617-
Built by calling L</content_cb>.
618617
619618
=cut
620619

621620
has content => (
622621
is => 'ro',
623622
isa => ScalarRef,
624623
lazy => 1,
625-
builder => '_build_content',
624+
default => sub { \"" },
626625
property => 0,
627626
);
628627

629-
sub _build_content {
630-
my $self = shift;
631-
632-
# NOTE: We used to remove the __DATA__ section "for performance reasons"
633-
# however removing lines from the content will throw off pod_lines.
634-
return $self->content_cb->();
635-
}
636-
637-
=head2 content_cb
638-
639-
Callback that returns the content of the file as a ScalarRef.
640-
641-
=cut
642-
643-
has content_cb => (
644-
is => 'ro',
645-
property => 0,
646-
default => sub {
647-
sub { \'' }
648-
},
649-
);
650-
651628
=head2 local_path
652629
653630
This attribute holds the path to the file on the local filesystem.

lib/MetaCPAN/Model/Release.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ sub _build_files {
321321

322322
my $file = $file_set->new_document(
323323
Dlog_trace {"adding file $_"} +{
324-
author => $self->author,
325-
binary => -B $child,
326-
content_cb => sub { \( scalar $child->slurp ) },
324+
author => $self->author,
325+
binary => -B $child,
326+
content => $child->is_dir ? \""
327+
: \( scalar $child->slurp ),
327328
date => $self->date,
328329
directory => $child->is_dir,
329330
distribution => $self->distribution,
330-
indexed => $self->metadata->should_index_file($fpath)
331-
? 1
331+
indexed => $self->metadata->should_index_file($fpath) ? 1
332332
: 0,
333333
local_path => $child,
334334
maturity => $self->maturity,

t/document/file.t

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ PKG
3434

3535
# Passing in "content" will override
3636
# but defaulting to package statements will help avoid buggy tests.
37-
content_cb => sub {
38-
\(
39-
join "\n",
40-
( map { sprintf $pkg_template, $_->{name} } @$mods ),
41-
"\n\n=head1 NAME\n\n${name} - abstract\n\n=cut\n\n",
42-
);
43-
},
37+
content => \(
38+
join "\n",
39+
( map { sprintf $pkg_template, $_->{name} } @$mods ),
40+
"\n\n=head1 NAME\n\n${name} - abstract\n\n=cut\n\n",
41+
),
4442

4543
%args,
4644
);
@@ -184,9 +182,9 @@ package MOBY::Config;
184182
END
185183

186184
my $file = new_file_doc(
187-
path => 't/bar/bat.t',
188-
module => { name => 'MOBY::Config' },
189-
content_cb => sub { \$content }
185+
path => 't/bar/bat.t',
186+
module => { name => 'MOBY::Config' },
187+
content => \$content,
190188
);
191189

192190
is( $file->abstract,
@@ -229,8 +227,8 @@ just a makefile description
229227
230228
END
231229
my $file = new_file_doc(
232-
name => 'Makefile.PL',
233-
content_cb => sub { \$content }
230+
name => 'Makefile.PL',
231+
content => \$content,
234232
);
235233

236234
is( $file->indexed, 0, 'File listed under other files is not indexed' );
@@ -268,7 +266,7 @@ AS-specific methods for Number::Phone
268266
END
269267
my $file = new_file_doc(
270268
module => [ { name => 'Number::Phone::NANP::ASS', version => 1.1 } ],
271-
content_cb => sub { \$content }
269+
content => \$content,
272270
);
273271
is( $file->sloc, 8, '8 lines of code' );
274272
is( $file->slop, 4, '4 lines of pod' );
@@ -297,9 +295,9 @@ C<Perl6Attribute> -- An example attribute metaclass for Perl 6 style attributes
297295
298296
END
299297
my $file = new_file_doc(
300-
name => 'Perl6Attribute.pod',
301-
module => [ { name => 'main', version => 1.1 } ],
302-
content_cb => sub { \$content }
298+
name => 'Perl6Attribute.pod',
299+
module => [ { name => 'main', version => 1.1 } ],
300+
content => \$content,
303301
);
304302
is( $file->documentation, 'Perl6Attribute' );
305303
is( $file->abstract,
@@ -345,8 +343,8 @@ Bar
345343
346344
END
347345
my $file = new_file_doc(
348-
name => 'Foo.pod',
349-
content_cb => sub { \$content }
346+
name => 'Foo.pod',
347+
content => \$content,
350348
);
351349
is( $file->documentation, 'Foo', 'POD in __DATA__ section' );
352350
is( $file->description, 'hot stuff * Foo * Bar' );
@@ -386,7 +384,7 @@ END
386384
foreach my $folder ( 'pod', 'lib', 'docs' ) {
387385
my $file = MetaCPAN::Document::File->new(
388386
author => 'Foo',
389-
content_cb => sub { \$content },
387+
content => \$content,
390388
distribution => 'Foo',
391389
name => 'Baz.pod',
392390
path => $folder . '/Foo/Bar/Baz.pod',
@@ -438,8 +436,8 @@ parsed.
438436
END
439437

440438
my $file = new_file_doc(
441-
name => 'Yo.pm',
442-
content_cb => sub { \$content }
439+
name => 'Yo.pm',
440+
content => \$content,
443441
);
444442

445443
test_attributes $file,
@@ -487,8 +485,8 @@ last-word.
487485
END
488486

489487
my $file = new_file_doc(
490-
name => 'Yo.pm',
491-
content_cb => sub { \$content }
488+
name => 'Yo.pm',
489+
content => \$content,
492490
);
493491

494492
test_attributes $file, {
@@ -540,8 +538,8 @@ POD
540538
};
541539

542540
my $file = new_file_doc(
543-
name => 'Yo.pm',
544-
content_cb => sub { \$content }
541+
name => 'Yo.pm',
542+
content => \$content,
545543
);
546544

547545
test_attributes $file, {

t/release/packages.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ test_release(
4848
'Packages::BOM module starts with UTF-8 BOM';
4949

5050
my $file = $self->file_by_path($path);
51+
5152
is ${ $file->pod },
5253
q[NAME Packages::BOM - package in a file with a BOM],
5354
'pod text';

0 commit comments

Comments
 (0)