File: TrustMetaYml.pm

package info (click to toggle)
libmodule-install-trustmetayml-perl 0.003-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 284 kB
  • sloc: perl: 2,913; makefile: 2
file content (113 lines) | stat: -rw-r--r-- 2,512 bytes parent folder | download | duplicates (4)
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
package Module::Install::TrustMetaYml;

use 5.005;
use strict;

BEGIN {
	$Module::Install::TrustMetaYml::AUTHORITY = 'cpan:TOBYINK';
	$Module::Install::TrustMetaYml::VERSION   = '0.003';
}

use base qw(Module::Install::Base);

sub trust_meta_yml
{
	my ($self, $where) = @_;
	$where ||= 'META.yml';

	$self->perl_version('5.005') unless defined $self->perl_version;
	
	$self->include('YAML::Tiny', 0);
	return $self if $self->is_admin;

	require YAML::Tiny;
	my $data = YAML::Tiny::LoadFile($where);

	$self->perl_version($data->{requires}{perl} || '5.005');
	
	KEY: foreach my $key (qw(requires recommends build_requires))
	{
		next KEY unless ref $data->{$key} eq 'HASH';
		my %deps = %{$data->{$key}};
		DEP: while (my ($pkg, $ver) = each %deps)
		{
			next if $pkg eq 'perl';
			$self->$key($pkg, $ver);
		}
	}
	
	return $self;
}

*trust_meta_yaml = \&trust_meta_yml;

1;

__END__

=encoding utf8

=head1 NAME

Module::Install::TrustMetaYml - trusts META.yml list of dependencies

=head1 SYNOPSIS

In Makefile.PL:

	trust_meta_yml;

=head1 DESCRIPTION

CPAN doesn't trust C<META.yml>'s list of dependencies for a module. Instead it
expects C<Makefile.PL> run on the computer the package is being installed
upon to generate its own list of dependencies (called C<MYMETA.yml> or
C<MYMETA.json>).

This module is a Module::Install plugin that generates C<MYMETA.yml> by simply
passing through the dependencies from C<META.yml>.

It does nothing when run from the module author's development copy.

The module defines two functions which are aliases for each other:

=over

=item C<trust_meta_yml>

=item C<trust_meta_yaml>

=back

=head1 BUGS

Please report any bugs to
L<http://rt.cpan.org/Dist/Display.html?Queue=Module-Install-TrustMetaYml>.

=head1 SEE ALSO

L<Module::Install>, L<Module::Package::RDF>.

=head1 AUTHOR

Toby Inkster E<lt>tobyink@cpan.orgE<gt>.

=head1 CREDITS

Thanks to Chris Williams (BINGOS), Ingy döt Net (INGY) and Florian Ragwitz (FLORA)
for explaining the role of C<MYMETA.json>, and helping me figure out why mine
weren't working.

=head1 COPYRIGHT AND LICENCE

This software is copyright (c) 2011-2012 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.