1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
|
package My::Module::Meta;
use 5.006;
use strict;
use warnings;
use Carp;
sub new {
my ( $class ) = @_;
ref $class and $class = ref $class;
my $self = {
distribution => $ENV{MAKING_MODULE_DISTRIBUTION},
};
bless $self, $class;
return $self;
}
sub abstract {
return 'Parse regular expressions';
}
sub add_to_cleanup {
return [ qw{ cover_db } ];
}
sub author {
return 'Thomas R. Wyant, III F<wyant at cpan dot org>';
}
sub build_requires {
return +{
'Test::More' => 0.88, # Because of done_testing().
charnames => 0,
lib => 0,
};
}
sub configure_requires {
return +{
'lib' => 0,
'strict' => 0,
'warnings' => 0,
};
}
sub dist_name {
return 'PPIx-Regexp';
}
sub distribution {
my ( $self ) = @_;
return $self->{distribution};
}
sub license {
return 'perl';
}
sub meta_merge {
my ( undef, @extra ) = @_;
return {
'meta-spec' => {
version => 2,
},
dynamic_config => 1,
resources => {
bugtracker => {
web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp',
# web => 'https://github.com/trwyant/perl-PPIx-Regexp/issues',
mailto => 'wyant@cpan.org',
},
license => 'http://dev.perl.org/licenses/',
repository => {
type => 'git',
url => 'git://github.com/trwyant/perl-PPIx-Regexp.git',
web => 'https://github.com/trwyant/perl-PPIx-Regexp',
},
},
@extra,
};
}
sub module_name {
return 'PPIx::Regexp';
}
sub no_index {
return +{
directory => [ qw{ eg inc t tools xt } ],
};
}
sub provides {
my $provides;
local $@ = undef;
eval {
require CPAN::Meta;
require ExtUtils::Manifest;
require Module::Metadata;
my $manifest;
{
local $SIG{__WARN__} = sub {};
$manifest = ExtUtils::Manifest::maniread();
}
keys %{ $manifest || {} }
or return;
# Skeleton so we can use should_index_file() and
# should_index_package().
my $meta = CPAN::Meta->new( {
name => 'Euler',
version => 2.71828,
no_index => no_index(),
},
);
# The Module::Metadata docs say not to use
# package_versions_from_directory() directly, but the 'files =>'
# version of provides() is broken, and has been known to be so
# since 2014, so it's not getting fixed any time soon. So:
foreach my $fn ( sort keys %{ $manifest } ) {
$fn =~ m/ [.] pm \z /smx
or next;
my $pvd = Module::Metadata->package_versions_from_directory(
undef, [ $fn ] );
foreach my $pkg ( keys %{ $pvd } ) {
$meta->should_index_package( $pkg )
and $meta->should_index_file( $pvd->{$pkg}{file} )
and $provides->{$pkg} = $pvd->{$pkg};
}
}
1;
} or return;
return ( provides => $provides );
}
sub requires {
my ( undef, @extra ) = @_; # Invocant unused
## if ( ! $self->distribution() ) {
## }
return {
'Carp' => 0,
'Encode' => 0,
'Exporter' => 0,
'List::Util' => 0,
'PPI::Document' => 1.238, # for postfix deref
'PPI::Dumper' => 1.238,
'Scalar::Util' => 0,
'Task::Weaken' => 0,
'base' => 0,
'constant' => 0,
'overload' => 0,
'strict' => 0,
'warnings' => 0,
@extra,
};
}
sub requires_perl {
return 5.006;
}
sub script_files {
return [
];
}
sub version_from {
return 'lib/PPIx/Regexp.pm';
}
1;
__END__
=head1 NAME
My::Module::Meta - Information needed to build PPIx::Regexp
=head1 SYNOPSIS
use lib qw{ inc };
use My::Module::Meta;
my $meta = My::Module::Meta->new();
use YAML;
print "Required modules:\n", Dump(
$meta->requires() );
=head1 DETAILS
This module centralizes information needed to build C<PPIx::Regexp>. It
is private to the C<PPIx::Regexp> package, and may be changed or
retracted without notice.
=head1 METHODS
This class supports the following public methods:
=head2 new
my $meta = PPIx::Meta->new();
This method instantiates the class.
=head2 abstract
This method returns the distribution's abstract.
=head2 add_to_cleanup
This method returns a reference to an array of files to be added to the
cleanup.
=head2 author
This method returns the name of the distribution author
=head2 build_requires
use YAML;
print Dump( $meta->build_requires() );
This method computes and returns a reference to a hash describing the
modules required to build the C<PPIx::Regexp> package, suitable for
use in a F<Build.PL> C<build_requires> key, or a F<Makefile.PL>
C<< {META_MERGE}->{build_requires} >> or C<BUILD_REQUIRES> key.
=head2 configure_requires
use YAML;
print Dump( $meta->configure_requires() );
This method returns a reference to a hash describing the modules
required to configure the package, suitable for use in a F<Build.PL>
C<configure_requires> key, or a F<Makefile.PL>
C<< {META_MERGE}->{configure_requires} >> or C<CONFIGURE_REQUIRES> key.
=head2 dist_name
This method returns the distribution name.
=head2 distribution
if ( $meta->distribution() ) {
print "Making distribution\n";
} else {
print "Not making distribution\n";
}
This method returns the value of the environment variable
C<MAKING_MODULE_DISTRIBUTION> at the time the object was instantiated.
=head2 license
This method returns the distribution's license.
=head2 meta_merge
use YAML;
print Dump( $meta->meta_merge() );
This method returns a reference to a hash describing the meta-data which
has to be provided by making use of the builder's C<meta_merge>
functionality. This includes the C<dynamic_config> and C<resources>
data.
Any arguments will be appended to the generated array.
=head2 module_name
This method returns the name of the module the distribution is based
on.
=head2 no_index
This method returns the names of things which are not to be indexed
by CPAN.
=head2 provides
use YAML;
print Dump( [ $meta->provides() ] );
This method attempts to load L<Module::Metadata|Module::Metadata>. If
this succeeds, it returns a C<provides> entry suitable for inclusion in
L<meta_merge()|/meta_merge> data (i.e. C<'provides'> followed by a hash
reference). If it can not load the required module, it returns nothing.
=head2 requires
use YAML;
print Dump( $meta->requires() );
This method computes and returns a reference to a hash describing
the modules required to run the C<PPIx::Regexp>
package, suitable for use in a F<Build.PL> C<requires> key, or a
F<Makefile.PL> C<PREREQ_PM> key. Any additional arguments will be
appended to the generated hash. In addition, unless
L<distribution()|/distribution> is true, configuration-specific modules
may be added.
=head2 requires_perl
print 'This package requires Perl ', $meta->requires_perl(), "\n";
This method returns the version of Perl required by the package.
=head2 script_files
This method returns a reference to an array containing the names of
script files provided by this distribution. This array may be empty.
=head2 version_from
This method returns the name of the distribution file from which the
distribution's version is to be derived.
=head1 ATTRIBUTES
This class has no public attributes.
=head1 ENVIRONMENT
=head2 MAKING_MODULE_DISTRIBUTION
This environment variable should be set to a true value if you are
making a distribution. This ensures that no configuration-specific
information makes it into F<META.yml>.
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=PPIx-Regexp>,
L<https://github.com/trwyant/perl-PPIx-Regexp/issues>, or in
electronic mail to the author.
=head1 AUTHOR
Thomas R. Wyant, III F<wyant at cpan dot org>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2010-2023, 2025 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=cut
# ex: set textwidth=72 :
|