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 min_ver => $reqs->requirements_for_module($module),
64 required => $type eq 'requires',
69 $Readonly::XS::MAGIC_COOKIE="Do NOT use or require Readonly::XS unless you're me.";
70 eval "require $module";
74 my $pkg_version = $module->can("VERSION") ? $module->VERSION : 0;
75 $module_infos->{cur_ver} = $pkg_version;
76 if ($reqs->accepts_module($module => $pkg_version)) {
83 push @{ $self->{$attr} }, { $module => $module_infos };
90 return $_[0]->{$_[1]};
98 C4::Installer::PerlModules
102 A module for manipulating Koha Perl dependency list objects.
108 Creates a new PerlModules object
111 C<my $perl_modules = C4::Installer::PerlModules->new;>
115 Returns a hashref of a hash of module information suitable for use in Makefile.PL
118 C<my $perl_modules = C4::Installer::PerlModules->new;
122 PREREQ_PM => $perl_modules->prereq_pm,>
127 C<$perl_modules->versions_info;>
129 This loads info of required modules into three accessors: missing_pm,
130 upgrade_pm, and current_pm. Each of these may be accessed by using the
131 C<get_attr> method. Each accessor returns an anonymous array who's
132 elements are anonymous hashes. They follow this format (NOTE: Upgrade
133 status is indicated by the accessor name.):
137 'Text::CSV::Encoded' => {
144 'Biblio::EndnoteStyle' => {
152 =head2 get_attr(attr_name)
154 Returns an anonymous array containing the contents of the passed in accessor. Valid accessors are:
156 missing_pm - Perl modules used by Koha but not currently installed.
158 upgrade_pm - Perl modules currently installed but below the minimum version required by Koha.
160 current_pm - Perl modules currently installed and up to date as required by Koha.
163 C<my $missing_pm = $perl_modules->get_attr('missing_pm');>
168 Chris Nighswonger <cnighswonger AT foundations DOT edu>
172 Copyright 2010 Foundations Bible College.
176 This file is part of Koha.
178 Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
179 Foundation; either version 2 of the License, or (at your option) any later version.
181 You should have received a copy of the GNU General Public License along with Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
182 Fifth Floor, Boston, MA 02110-1301 USA.
184 =head1 DISCLAIMER OF WARRANTY
186 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
187 A PARTICULAR PURPOSE. See the GNU General Public License for more details.