/usr/share/perl5/Module/CPANfile/Result.pm is in libmodule-cpanfile-perl 1.0002-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | package Module::CPANfile::Result;
use strict;
sub from_prereqs {
my($class, $spec) = @_;
bless {
phase => 'runtime',
spec => $spec,
}, $class;
}
sub new {
bless {
phase => 'runtime', # default phase
features => {},
feature => undef,
spec => {},
}, shift;
}
sub on {
my($self, $phase, $code) = @_;
local $self->{phase} = $phase;
$code->()
}
sub feature {
my($self, $identifier, $description, $code) = @_;
# shortcut: feature identifier => sub { ... }
if (@_ == 3 && ref($description) eq 'CODE') {
$code = $description;
$description = $identifier;
}
unless (ref $description eq '' && ref $code eq 'CODE') {
Carp::croak("Usage: feature 'identifier', 'Description' => sub { ... }");
}
local $self->{feature} = $self->{features}{$identifier}
= { identifier => $identifier, description => $description, spec => {} };
$code->();
}
sub osname { die "TODO" }
sub requires {
my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
->{$self->{phase}}{requires}{$module} = $requirement || 0;
}
sub recommends {
my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
->{$self->{phase}}{recommends}{$module} = $requirement || 0;
}
sub suggests {
my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
->{$self->{phase}}{suggests}{$module} = $requirement || 0;
}
sub conflicts {
my($self, $module, $requirement) = @_;
($self->{feature} ? $self->{feature}{spec} : $self->{spec})
->{$self->{phase}}{conflicts}{$module} = $requirement || 0;
}
# Module::Install compatible shortcuts
sub configure_requires {
my($self, @args) = @_;
$self->on(configure => sub { $self->requires(@args) });
}
sub build_requires {
my($self, @args) = @_;
$self->on(build => sub { $self->requires(@args) });
}
sub test_requires {
my($self, @args) = @_;
$self->on(test => sub { $self->requires(@args) });
}
sub author_requires {
my($self, @args) = @_;
$self->on(develop => sub { $self->requires(@args) });
}
1;
|