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