1 #line 1 "inc/Module/Install/Metadata.pm - /Library/Perl/5.8.6/Module/Install/Metadata.pm"
2 package Module::Install::Metadata;
4 use Module::Install::Base;
5 @ISA = qw{Module::Install::Base};
12 name module_name abstract author version license
13 distribution_type perl_version tests
17 build_requires requires recommends bundles
21 sub Meta_ScalarKeys { @scalar_keys }
22 sub Meta_TupleKeys { @tuple_keys }
24 foreach my $key (@scalar_keys) {
27 return $self->{values}{$key} if defined wantarray and !@_;
28 $self->{values}{$key} = shift;
33 foreach my $key (@tuple_keys) {
36 return $self->{values}{$key} unless @_;
40 my $module = shift or last;
41 my $version = shift || 0;
42 if ( $module eq 'perl' ) {
43 $version =~ s{^(\d+)\.(\d+)\.(\d+)}
44 {$1 + $2/1_000 + $3/1_000_000}e;
45 $self->perl_version($version);
48 my $rv = [ $module, $version ];
51 push @{ $self->{values}{$key} }, @rv;
58 return $self->{'values'}{'sign'} if defined wantarray and !@_;
59 $self->{'values'}{'sign'} = ( @_ ? $_[0] : 1 );
66 warn "You MUST provide an explicit true/false value to dynamic_config, skipping\n";
69 $self->{'values'}{'dynamic_config'} = $_[0] ? 1 : 0;
74 my ( $self, $file ) = @_;
76 unless ( defined($file) ) {
77 my $name = $self->name
78 or die "all_from called with no args without setting name() first";
79 $file = join('/', 'lib', split(/-/, $name)) . '.pm';
80 $file =~ s{.*/}{} unless -e $file;
81 die "all_from: cannot find $file from $name" unless -e $file;
84 $self->version_from($file) unless $self->version;
85 $self->perl_version_from($file) unless $self->perl_version;
87 # The remaining probes read from POD sections; if the file
88 # has an accompanying .pod, use that instead
90 if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
94 $self->author_from($file) unless $self->author;
95 $self->license_from($file) unless $self->license;
96 $self->abstract_from($file) unless $self->abstract;
101 my $provides = ( $self->{values}{provides} ||= {} );
102 %$provides = (%$provides, @_) if @_;
108 return $self unless $self->is_admin;
110 unless (-e 'MANIFEST') {
111 warn "Cannot deduce auto_provides without a MANIFEST, skipping\n";
115 # Avoid spurious warnings as we are not checking manifest here.
117 local $SIG{__WARN__} = sub {1};
118 require ExtUtils::Manifest;
119 local *ExtUtils::Manifest::manicheck = sub { return };
121 require Module::Build;
122 my $build = Module::Build->new(
123 dist_name => $self->{name},
124 dist_version => $self->{version},
125 license => $self->{license},
127 $self->provides(%{ $build->find_dist_packages || {} });
133 my $features = ( $self->{values}{features} ||= [] );
137 if ( @_ == 1 and ref( $_[0] ) ) {
138 # The user used ->feature like ->features by passing in the second
139 # argument as a reference. Accomodate for that.
149 ref($_) ? ( ref($_) eq 'HASH' ) ? %$_
161 while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
162 $self->feature( $name, @$mods );
164 return @{ $self->{values}{features} };
170 push @{ $self->{values}{no_index}{$type} }, @_ if $type;
171 return $self->{values}{no_index};
176 $self->include_deps( 'YAML', 0 );
179 my $data = YAML::LoadFile('META.yml');
181 # Call methods explicitly in case user has already set some values.
182 while ( my ( $key, $value ) = each %$data ) {
183 next unless $self->can($key);
184 if ( ref $value eq 'HASH' ) {
185 while ( my ( $module, $version ) = each %$value ) {
186 $self->can($key)->($self, $module => $version );
190 $self->can($key)->($self, $value);
198 return $self unless $self->is_admin;
199 $self->admin->write_meta;
204 my ( $self, $file ) = @_;
205 require ExtUtils::MM_Unix;
206 $self->version( ExtUtils::MM_Unix->parse_version($file) );
210 my ( $self, $file ) = @_;
211 require ExtUtils::MM_Unix;
214 { DISTNAME => $self->name },
216 )->parse_abstract($file)
221 my ( $self, $file ) = @_;
224 open FH, "< $file" or die "Cannot open $file.pod: $!";
225 do { local $/; <FH> };
228 sub perl_version_from {
229 my ( $self, $file ) = @_;
232 $self->_slurp($file) =~ m/
241 $self->perl_version($1);
244 warn "Cannot determine perl version info from $file\n";
250 my ( $self, $file ) = @_;
251 my $content = $self->_slurp($file);
253 =head \d \s+ (?:authors?)\b \s*
256 =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s*
257 .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s*
260 my $author = $1 || $2;
261 $author =~ s{E<lt>}{<}g;
262 $author =~ s{E<gt>}{>}g;
263 $self->author($author);
266 warn "Cannot determine author info from $file\n";
271 my ( $self, $file ) = @_;
274 $self->_slurp($file) =~ m/
276 (?:licen[cs]e|licensing|copyright|legal)\b
283 my $license_text = $1;
285 'under the same (?:terms|license) as perl itself' => 'perl',
286 'GNU public license' => 'gpl',
287 'GNU lesser public license' => 'gpl',
288 'BSD license' => 'bsd',
289 'Artistic license' => 'artistic',
293 'Artistic' => 'artistic',
295 while ( my ( $pattern, $license ) = splice( @phrases, 0, 2 ) ) {
296 $pattern =~ s{\s+}{\\s+}g;
297 if ( $license_text =~ /\b$pattern\b/i ) {
298 $self->license($license);
304 warn "Cannot determine license info from $file\n";