1 package C4
::Installer
::PerlModules
;
18 my $type = ref($invocant) || $invocant;
26 unless (defined $self->{prereqs
}) {
27 my $filename = $INC{'C4/Installer/PerlModules.pm'};
28 my $path = dirname
(dirname
(dirname
($filename)));
29 $self->{prereqs
} = Module
::CPANfile
->load("$path/cpanfile")->prereqs;
32 return $self->{prereqs
};
39 my $reqs = $self->prereqs->merged_requirements;
40 foreach my $module ($reqs->required_modules) {
41 $prereq_pm->{$module} = $reqs->requirements_for_module($module);
50 # Reset these arrayref each pass through to ensure current information
51 $self->{'missing_pm'} = [];
52 $self->{'upgrade_pm'} = [];
53 $self->{'current_pm'} = [];
55 foreach my $phase ($self->prereqs->phases) {
56 foreach my $type ($self->prereqs->types_in($phase)) {
57 my $reqs = $self->prereqs->requirements_for($phase, $type);
58 foreach my $module ($reqs->required_modules) {
59 no warnings
; # perl throws warns for invalid $VERSION numbers which some modules use
63 required
=> $type eq 'requires',
66 my $vers = $reqs->structured_requirements_for_module($module);
67 for my $req (@
$vers) {
68 if ( $req->[0] eq '>=' || $req->[0] eq '>' ) {
69 $module_infos->{min_ver
} = $req->[1];
70 } elsif ( $req->[0] eq '<=' || $req->[0] eq '<' ) {
71 $module_infos->{max_ver
} = $req->[1];
73 push @
{$module_infos->{exc_ver
}}, $req->[1];
79 $Readonly::XS
::MAGIC_COOKIE
="Do NOT use or require Readonly::XS unless you're me.";
80 eval "require $module";
84 my $pkg_version = $module->can("VERSION") ?
$module->VERSION : 0;
85 $module_infos->{cur_ver
} = $pkg_version;
86 if ($reqs->accepts_module($module => $pkg_version)) {
93 push @
{ $self->{$attr} }, { $module => $module_infos };
100 return $_[0]->{$_[1]};
108 C4::Installer::PerlModules
112 A module for manipulating Koha Perl dependency list objects.
118 Creates a new PerlModules object
121 C<my $perl_modules = C4::Installer::PerlModules->new;>
125 Returns a hashref of a hash of module information suitable for use in Makefile.PL
128 C<my $perl_modules = C4::Installer::PerlModules->new;
132 PREREQ_PM => $perl_modules->prereq_pm,>
137 C<$perl_modules->versions_info;>
139 This loads info of required modules into three accessors: missing_pm,
140 upgrade_pm, and current_pm. Each of these may be accessed by using the
141 C<get_attr> method. Each accessor returns an anonymous array who's
142 elements are anonymous hashes. They follow this format (NOTE: Upgrade
143 status is indicated by the accessor name.):
147 'Text::CSV::Encoded' => {
154 'Biblio::EndnoteStyle' => {
162 =head2 get_attr(attr_name)
164 Returns an anonymous array containing the contents of the passed in accessor. Valid accessors are:
166 missing_pm - Perl modules used by Koha but not currently installed.
168 upgrade_pm - Perl modules currently installed but below the minimum version required by Koha.
170 current_pm - Perl modules currently installed and up to date as required by Koha.
173 C<my $missing_pm = $perl_modules->get_attr('missing_pm');>
178 Chris Nighswonger <cnighswonger AT foundations DOT edu>
182 Copyright 2010 Foundations Bible College.
186 This file is part of Koha.
188 Koha is free software; you can redistribute it and/or modify it
189 under the terms of the GNU General Public License as published by
190 the Free Software Foundation; either version 3 of the License, or
191 (at your option) any later version.
193 Koha is distributed in the hope that it will be useful, but
194 WITHOUT ANY WARRANTY; without even the implied warranty of
195 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
196 GNU General Public License for more details.
198 You should have received a copy of the GNU General Public License
199 along with Koha; if not, see <http://www.gnu.org/licenses>.
201 =head1 DISCLAIMER OF WARRANTY
203 Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
204 A PARTICULAR PURPOSE. See the GNU General Public License for more details.