1 #line 1 "inc/Module/Install/Metadata.pm - /Users/ingy/local/lib/perl5/site_perl/5.8.6/Module/Install/Metadata.pm"
2 package Module::Install::Metadata;
5 use Module::Install::Base;
7 use vars qw($VERSION @ISA);
10 @ISA = 'Module::Install::Base';
14 name module_name abstract author version license
15 distribution_type perl_version tests
19 build_requires requires recommends bundles
23 sub Meta_ScalarKeys { @scalar_keys }
24 sub Meta_TupleKeys { @tuple_keys }
26 foreach my $key (@scalar_keys) {
29 return $self->{values}{$key} if defined wantarray and !@_;
30 $self->{values}{$key} = shift;
35 foreach my $key (@tuple_keys) {
38 return $self->{values}{$key} unless @_;
42 my $module = shift or last;
43 my $version = shift || 0;
44 if ( $module eq 'perl' ) {
45 $version =~ s{^(\d+)\.(\d+)\.(\d+)}
46 {$1 + $2/1_000 + $3/1_000_000}e;
47 $self->perl_version($version);
50 my $rv = [ $module, $version ];
53 push @{ $self->{values}{$key} }, @rv;
60 return $self->{'values'}{'sign'} if defined wantarray and !@_;
61 $self->{'values'}{'sign'} = ( @_ ? $_[0] : 1 );
66 my ( $self, $file ) = @_;
68 unless ( defined($file) ) {
69 my $name = $self->name
70 or die "all_from called with no args without setting name() first";
71 $file = join('/', 'lib', split(/-/, $name)) . '.pm';
72 $file =~ s{.*/}{} unless -e $file;
73 die "all_from: cannot find $file from $name" unless -e $file;
76 $self->version_from($file) unless $self->version;
77 $self->perl_version_from($file) unless $self->perl_version;
79 # The remaining probes read from POD sections; if the file
80 # has an accompanying .pod, use that instead
82 if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
86 $self->author_from($file) unless $self->author;
87 $self->license_from($file) unless $self->license;
88 $self->abstract_from($file) unless $self->abstract;
93 my $provides = ( $self->{values}{provides} ||= {} );
94 %$provides = (%$provides, @_) if @_;
100 return $self unless $self->is_admin;
102 unless (-e 'MANIFEST') {
103 warn "Cannot deduce auto_provides without a MANIFEST, skipping\n";
107 # Avoid spurious warnings as we are not checking manifest here.
109 local $SIG{__WARN__} = sub {1};
110 require ExtUtils::Manifest;
111 local *ExtUtils::Manifest::manicheck = sub { return };
113 require Module::Build;
114 my $build = Module::Build->new(
115 dist_name => $self->{name},
116 dist_version => $self->{version},
117 license => $self->{license},
119 $self->provides(%{ $build->find_dist_packages || {} });
125 my $features = ( $self->{values}{features} ||= [] );
129 if ( @_ == 1 and ref( $_[0] ) ) {
130 # The user used ->feature like ->features by passing in the second
131 # argument as a reference. Accomodate for that.
142 ref($_) ? ( ref($_) eq 'HASH' ) ? %$_
154 while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
155 $self->feature( $name, @$mods );
157 return @{ $self->{values}{features} };
163 push @{ $self->{values}{no_index}{$type} }, @_ if $type;
164 return $self->{values}{no_index};
169 $self->include_deps( 'YAML', 0 );
172 my $data = YAML::LoadFile('META.yml');
174 # Call methods explicitly in case user has already set some values.
175 while ( my ( $key, $value ) = each %$data ) {
176 next unless $self->can($key);
177 if ( ref $value eq 'HASH' ) {
178 while ( my ( $module, $version ) = each %$value ) {
179 $self->can($key)->($self, $module => $version );
183 $self->can($key)->($self, $value);
191 return $self unless $self->is_admin;
192 $self->admin->write_meta;
197 my ( $self, $file ) = @_;
198 require ExtUtils::MM_Unix;
199 $self->version( ExtUtils::MM_Unix->parse_version($file) );
203 my ( $self, $file ) = @_;
204 require ExtUtils::MM_Unix;
207 { DISTNAME => $self->name },
209 )->parse_abstract($file)
214 my ( $self, $file ) = @_;
217 open FH, "< $file" or die "Cannot open $file.pod: $!";
218 do { local $/; <FH> };
221 sub perl_version_from {
222 my ( $self, $file ) = @_;
225 $self->_slurp($file) =~ m/
234 $self->perl_version($1);
237 warn "Cannot determine perl version info from $file\n";
243 my ( $self, $file ) = @_;
244 my $content = $self->_slurp($file);
246 =head \d \s+ (?:authors?)\b \s*
249 =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s*
250 .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s*
253 my $author = $1 || $2;
254 $author =~ s{E<lt>}{<}g;
255 $author =~ s{E<gt>}{>}g;
256 $self->author($author);
259 warn "Cannot determine author info from $file\n";
264 my ( $self, $file ) = @_;
267 $self->_slurp($file) =~ m/
269 (?:licen[cs]e|licensing|copyright|legal)\b
276 my $license_text = $1;
278 'under the same (?:terms|license) as perl itself' => 'perl',
279 'GNU public license' => 'gpl',
280 'GNU lesser public license' => 'gpl',
281 'BSD license' => 'bsd',
282 'Artistic license' => 'artistic',
286 'Artistic' => 'artistic',
288 while ( my ( $pattern, $license ) = splice( @phrases, 0, 2 ) ) {
289 $pattern =~ s{\s+}{\\s+}g;
290 if ( $license_text =~ /\b$pattern\b/i ) {
291 $self->license($license);
297 warn "Cannot determine license info from $file\n";