Skip to content

Commit 87902a0

Browse files
committed
remove special check for hidden packages
Module::Metadata and Parse::PMFile will already exclude modules using the 'hide from PAUSE' trick. There is no need to add an additional check on top of that.
1 parent 5691cb1 commit 87902a0

File tree

4 files changed

+1
-91
lines changed

4 files changed

+1
-91
lines changed

lib/MetaCPAN/Document/File.pm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,11 +917,7 @@ sub set_indexed {
917917
next;
918918
}
919919

920-
$mod->_set_indexed(
921-
$mod->hide_from_pause( ${ $self->content }, $self->name )
922-
? false
923-
: true
924-
);
920+
$mod->_set_indexed($self->name eq $mod->name);
925921
}
926922

927923
if ( my $doc_name = $self->documentation ) {

lib/MetaCPAN/Document/Module.pm

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,6 @@ sub _build_version_numified {
111111
my $bom
112112
= qr/(?:\x00\x00\xfe\xff|\xff\xfe\x00\x00|\xfe\xff|\xff\xfe|\xef\xbb\xbf)/;
113113

114-
sub hide_from_pause {
115-
my ( $self, $content, $file_name ) = @_;
116-
return 0 if defined($file_name) && $file_name =~ m{\.pm\.PL\z};
117-
my $pkg = $self->name;
118-
my $pkg_match = join q[(?:::|')], map quotemeta, split m{::}, $pkg;
119-
120-
# This regexp is *almost* the same as $PKG_REGEXP in Module::Metadata.
121-
# [b] We need to allow/ignore a possible BOM since we read in binary mode.
122-
# Module::Metadata, for example, checks for a BOM and then sets the encoding.
123-
# [s] We change `\s` to `\h` because we want to verify that it's on one line.
124-
# [p] We replace $PKG_NAME_REGEXP with the specific package we're looking for.
125-
# [v] Simplify the optional whitespace/version group ($V_NUM_REGEXP).
126-
return $content =~ / # match a package declaration
127-
^ # start of line
128-
(?:\A$bom)? # possible BOM at the start of the file [b]
129-
[\h\{;]* # intro chars on a line [s]
130-
package # the word 'package'
131-
\h+ # whitespace [s]
132-
($pkg_match) # the package name [p]
133-
(\h+ v?[0-9._]+)? # optional version number (preceded by whitespace) [v]
134-
\h* # optional whitesapce [s]
135-
[;\{] # semicolon line terminator or block start
136-
/mx ? 0 : 1;
137-
}
138-
139114
=head2 set_associated_pod
140115
141116
Expects an instance C<$file> of L<MetaCPAN::Document::File> as first parameter

t/document/file.t

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,6 @@ END
227227
is( $file->abstract,
228228
'An object containing information about how to get access to teh Moby databases, resources, etc. from the mobycentral.config file'
229229
);
230-
is(
231-
$file->module->[0]
232-
->hide_from_pause( ${ $file->content }, $file->name ),
233-
0, 'indexed'
234-
);
235230
is( $file->documentation, 'MOBY::Config' );
236231
is( $file->level, 2 );
237232
test_attributes $file, {
@@ -308,7 +303,6 @@ END
308303
);
309304
is( $file->sloc, 8, '8 lines of code' );
310305
is( $file->slop, 4, '4 lines of pod' );
311-
is( $file->module->[0]->hide_from_pause($content), 1, 'not indexed' );
312306
is(
313307
$file->abstract,
314308
'AS-specific methods for Number::Phone',

t/document/module.t

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,6 @@ use lib 't/lib';
55
use MetaCPAN::Document::Module ();
66
use Test::More;
77

8-
subtest hide_from_pause => sub {
9-
foreach my $test (
10-
11-
# The original:
12-
[ 'No::CommentNL' => "package # hide\n No::CommentNL;" ],
13-
14-
# I'm not sure how PAUSE handles this one but currently we ignore it.
15-
[ 'No::JustNL' => "package \n No::JustNL;" ],
16-
17-
# The good ones:
18-
[ 'Pkg' => 'package Pkg;' ],
19-
[ 'Pkg::Ver' => 'package Pkg::Ver v1.2.3;' ],
20-
[ 'Pkg::Block' => 'package Pkg::Block { our $var = 1 }' ],
21-
[
22-
'Pkg::VerBlock' => 'package Pkg::VerBlock 1.203 { our $var = 1 }'
23-
],
24-
[ 'Pkg::SemiColons' => '; package Pkg::SemiColons; $var' ],
25-
[ 'Pkg::InABlock' => '{ package Pkg::InABlock; $var }' ],
26-
27-
# This doesn't work as a BOM can only appear at the start of a file.
28-
#[ 'Pkg::AfterABOM' => "\xef\xbb\xbfpackage Pkg::AfterABOM" ],
29-
30-
[ 'No::JustVar' => qq["\n\$package No::JustVar;\n"] ],
31-
32-
# This shouldn't match, but there's only so much we can do...
33-
# we're not going to eval the whole file to figure it out.
34-
[ 'Pkg::InsideStr' => qq["\n package Pkg::InsideStr;\n"] ],
35-
36-
[ 'No::Comment' => qq[# package No::Comment;\n] ],
37-
[ 'No::Different' => q[package No::Different::Pkg;] ],
38-
[ 'No::PkgWithNum' => qq["\npackage No::PkgWithNumv2.3;\n"] ],
39-
[ 'No::CrazyChars' => qq["\npackage No::CrazyChars\[0\];\n"] ],
40-
)
41-
{
42-
my ( $name, $content ) = @$test;
43-
44-
subtest $name => sub {
45-
my $module = MetaCPAN::Document::Module->new( name => $name );
46-
47-
SKIP: {
48-
skip( 'Perl 5.14 needed for package block compilation', 1 )
49-
if $] < 5.014;
50-
## no critic
51-
ok eval "sub { no strict; $content }", "code compiles"
52-
or diag $@;
53-
}
54-
55-
my ($hidden) = ( $name =~ /^No::/ ? 1 : 0 );
56-
57-
is $module->hide_from_pause($content), $hidden,
58-
"hide_from_pause is $hidden";
59-
};
60-
}
61-
};
62-
638
subtest set_associated_pod => sub {
649
test_associated_pod( 'Squirrel', [qw( lib/Squirrel.pod )],
6510
'lib/Squirrel.pod' );

0 commit comments

Comments
 (0)