Skip to content

Commit

Permalink
Merge pull request #403 from CPAN-API/file-lazy-default-indexed
Browse files Browse the repository at this point in the history
Actually use "indexed:false" logic for common files
  • Loading branch information
oalders committed Mar 31, 2015
2 parents 5bf7f0a + b6889ff commit 14f2ff6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/MetaCPAN/Document/File.pm
Expand Up @@ -300,7 +300,13 @@ has indexed => (
required => 1,
is => 'rw',
isa => 'Bool',
default => 1,
lazy => 1,
default => sub {
my ($self) = @_;
return 0 if $self->is_in_other_files;
return 0 if !$self->metadata->should_index_file( $self->path );
return 1;
},
);

=head2 level
Expand Down
4 changes: 1 addition & 3 deletions lib/MetaCPAN/Model/Release.pm
Expand Up @@ -245,9 +245,7 @@ sub _build_files {
date => $self->date,
directory => $child->is_dir,
distribution => $self->distribution,
indexed => $self->metadata->should_index_file($fpath)
? 1
: 0,

local_path => $child,
maturity => $self->maturity,
metadata => $self->metadata,
Expand Down
49 changes: 49 additions & 0 deletions t/release/common-files.t
@@ -0,0 +1,49 @@
use Test::More;
use strict;
use warnings;

use lib 't/lib';
use MetaCPAN::TestHelpers;

test_release(
{
name => 'Common-Files-1.1',
author => 'BORISNAT',
authorized => \1,
first => \1,
provides => ['Common::Files'],
modules => {
'lib/Common/Files.pm' => [
{
name => 'Common::Files',
indexed => \1,
authorized => \1,
version => '1.1',
version_numified => 1.1,
associated_pod =>
'BORISNAT/Common-Files-1.1/lib/Common/Files.pm',
},
],
},
extra_tests => sub {
my ($self) = @_;

{
my $file = $self->file_by_path('Makefile.PL');

ok !$file->indexed, 'Makefile.PL not indexed';
ok $file->authorized,
'Makefile.PL authorized, i suppose (not *un*authorized)';
is $file->sloc, 1, 'sloc';
is $file->slop, 3, 'slop';

is scalar( @{ $file->pod_lines } ), 1, 'one pod section';

is $file->abstract, undef, 'no abstract';
}

},
}
);

done_testing;
31 changes: 31 additions & 0 deletions t/var/fakecpan/configs/common-files.yml
@@ -0,0 +1,31 @@
---
name: Common-Files
version: 1.1
abstract: Test common archive files

X_Module_Faker:
cpan_author: BORISNAT
omitted_files:
- Makefile.PL

append:
-
file: lib/Common/Files.pm
content: |
=head1 NAME
Common::Files - testing common files in a release
=cut
-
file: Makefile.PL
# NOTE: YAML::Tiny (CPAN::Meta::YAML) strips the blank lines.
content: |
print "hi";
=pod
some pod
=cut

0 comments on commit 14f2ff6

Please sign in to comment.