Bugzilla – Attachment 111667 Details for
Bug 26683
Fix Modules::RequireFilenameMatchesPackage Perl Critic Violations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26683: Decompose Koha::Z3950Responder::RPN into Net::Z3950::RPN::* packages
Bug-26683-Decompose-KohaZ3950ResponderRPN-into-Net.patch (text/plain), 9.08 KB, created by
David Cook
on 2020-10-15 00:14:54 UTC
(
hide
)
Description:
Bug 26683: Decompose Koha::Z3950Responder::RPN into Net::Z3950::RPN::* packages
Filename:
MIME Type:
Creator:
David Cook
Created:
2020-10-15 00:14:54 UTC
Size:
9.08 KB
patch
obsolete
>From 48a166cd50d38cf2eab7bcc8a86eeb10359ee1b4 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 14 Oct 2020 23:29:57 +0000 >Subject: [PATCH] Bug 26683: Decompose Koha::Z3950Responder::RPN into > Net::Z3950::RPN::* packages > >This patch reverts the usage of Net::Z3950::SimpleServer's >samples/render-search.pl example, and instead creates modified packages >which will be loaded before the standard ones due to these being located >higher up in the @INC path. >--- > Koha/Z3950Responder/GenericSession.pm | 1 - > Makefile.PL | 1 + > Net/Z3950/RPN/And.pm | 57 ++++++++++++++++++++++ > Net/Z3950/RPN/AndNot.pm | 53 ++++++++++++++++++++ > Net/Z3950/RPN/Or.pm | 53 ++++++++++++++++++++ > .../Z3950Responder/RPN.pm => Net/Z3950/RPN/Term.pm | 49 ++++++++----------- > 6 files changed, 183 insertions(+), 31 deletions(-) > create mode 100644 Net/Z3950/RPN/And.pm > create mode 100644 Net/Z3950/RPN/AndNot.pm > create mode 100644 Net/Z3950/RPN/Or.pm > rename Koha/Z3950Responder/RPN.pm => Net/Z3950/RPN/Term.pm (80%) > >diff --git a/Koha/Z3950Responder/GenericSession.pm b/Koha/Z3950Responder/GenericSession.pm >index 51fe1a1ef3..737fb4b56a 100644 >--- a/Koha/Z3950Responder/GenericSession.pm >+++ b/Koha/Z3950Responder/GenericSession.pm >@@ -26,7 +26,6 @@ use base qw( Koha::Z3950Responder::Session ); > use Koha::Logger; > use Koha::SearchEngine::Search; > use Koha::SearchEngine::QueryBuilder; >-use Koha::Z3950Responder::RPN; > > =head1 NAME > >diff --git a/Makefile.PL b/Makefile.PL >index b2d48ae65f..45bfe77dce 100644 >--- a/Makefile.PL >+++ b/Makefile.PL >@@ -340,6 +340,7 @@ my $target_map = { > './koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1}, > './kohaversion.pl' => 'INTRANET_CGI_DIR', > './labels' => 'INTRANET_CGI_DIR', >+ './Net' => 'PERL_MODULE_DIR', > './mainpage.pl' => 'INTRANET_CGI_DIR', > './Makefile.PL' => 'NONE', > './MANIFEST.SKIP' => 'NONE', >diff --git a/Net/Z3950/RPN/And.pm b/Net/Z3950/RPN/And.pm >new file mode 100644 >index 0000000000..5987c06d81 >--- /dev/null >+++ b/Net/Z3950/RPN/And.pm >@@ -0,0 +1,57 @@ >+# Copyright The National Library of Finland 2018 >+# >+# This file is part of Koha. >+# >+# 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 Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# 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 A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+package Net::Z3950::RPN::And; >+ >+use Modern::Perl; >+our @ISA = qw(Net::Z3950::RPN::Node); >+ >+=head1 NAME >+ >+Net::Z3950::RPN::And >+ >+=cut >+ >+=head1 SYNOPSIS >+ >+Overrides for the C<Net::Z3950::RPN> classes adding a C<to_koha> method that >+converts the query to a syntax that C<Koha::SearchEngine> understands. >+ >+=cut >+ >+=head1 DESCRIPTION >+ >+The previous method used is described in C<samples/render-search.pl> of >+C<Net::Z3950::SimpleServer>, but Perl critic doesn't like it, so >+we are using whole package overrides here. >+ >+=cut >+ >+=head2 to_koha >+ >+ Convert query to a syntax that C<Koha::SearchEngine> understands. >+ >+=cut >+ >+sub to_koha { >+ my ($self, $mappings) = @_; >+ >+ return '(' . $self->[0]->to_koha($mappings) . ' AND ' . >+ $self->[1]->to_koha($mappings) . ')'; >+} >+ >+1; >diff --git a/Net/Z3950/RPN/AndNot.pm b/Net/Z3950/RPN/AndNot.pm >new file mode 100644 >index 0000000000..7e60c05d4a >--- /dev/null >+++ b/Net/Z3950/RPN/AndNot.pm >@@ -0,0 +1,53 @@ >+# Copyright The National Library of Finland 2018 >+# >+# This file is part of Koha. >+# >+# 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 Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# 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 A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+package Net::Z3950::RPN::AndNot; >+ >+use Modern::Perl; >+our @ISA = qw(Net::Z3950::RPN::Node); >+ >+=head1 NAME >+ >+Net::Z3950::RPN::AndNot >+ >+=head1 SYNOPSIS >+ >+Overrides for the C<Net::Z3950::RPN> classes adding a C<to_koha> method that >+converts the query to a syntax that C<Koha::SearchEngine> understands. >+ >+=head1 DESCRIPTION >+ >+The previous method used is described in C<samples/render-search.pl> of >+C<Net::Z3950::SimpleServer>, but Perl critic doesn't like it, so >+we are using whole package overrides here. >+ >+=cut >+ >+=head2 to_koha >+ >+ Convert query to a syntax that C<Koha::SearchEngine> understands. >+ >+=cut >+ >+sub to_koha { >+ my ($self, $mappings) = @_; >+ >+ return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . >+ $self->[1]->to_koha($mappings) . ')'; >+} >+ >+1; >diff --git a/Net/Z3950/RPN/Or.pm b/Net/Z3950/RPN/Or.pm >new file mode 100644 >index 0000000000..271993abef >--- /dev/null >+++ b/Net/Z3950/RPN/Or.pm >@@ -0,0 +1,53 @@ >+# Copyright The National Library of Finland 2018 >+# >+# This file is part of Koha. >+# >+# 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 Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# 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 A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+package Net::Z3950::RPN::Or; >+ >+use Modern::Perl; >+our @ISA = qw(Net::Z3950::RPN::Node); >+ >+=head1 NAME >+ >+Net::Z3950::RPN::Or >+ >+=head1 SYNOPSIS >+ >+Overrides for the C<Net::Z3950::RPN> classes adding a C<to_koha> method that >+converts the query to a syntax that C<Koha::SearchEngine> understands. >+ >+=head1 DESCRIPTION >+ >+The previous method used is described in C<samples/render-search.pl> of >+C<Net::Z3950::SimpleServer>, but Perl critic doesn't like it, so >+we are using whole package overrides here. >+ >+=cut >+ >+=head2 to_koha >+ >+ Convert query to a syntax that C<Koha::SearchEngine> understands. >+ >+=cut >+ >+sub to_koha { >+ my ($self, $mappings) = @_; >+ >+ return '(' . $self->[0]->to_koha($mappings) . ' OR ' . >+ $self->[1]->to_koha($mappings) . ')'; >+} >+ >+1; >diff --git a/Koha/Z3950Responder/RPN.pm b/Net/Z3950/RPN/Term.pm >similarity index 80% >rename from Koha/Z3950Responder/RPN.pm >rename to Net/Z3950/RPN/Term.pm >index cdc43a723e..62d3089f80 100644 >--- a/Koha/Z3950Responder/RPN.pm >+++ b/Net/Z3950/RPN/Term.pm >@@ -1,5 +1,3 @@ >-#!/usr/bin/perl >- > # Copyright The National Library of Finland 2018 > # > # This file is part of Koha. >@@ -17,11 +15,14 @@ > # You should have received a copy of the GNU General Public License > # along with Koha; if not, see <http://www.gnu.org/licenses>. > >+package Net::Z3950::RPN::Term; >+ > use Modern::Perl; >+our @ISA = qw(Net::Z3950::RPN::Node); > > =head1 NAME > >-Koha::Z3950Responder::RPN >+Net::Z3950::RPN::Term > > =head1 SYNOPSIS > >@@ -30,12 +31,18 @@ converts the query to a syntax that C<Koha::SearchEngine> understands. > > =head1 DESCRIPTION > >-The method used here is described in C<samples/render-search.pl> of >-C<Net::Z3950::SimpleServer>. >+The previous method used is described in C<samples/render-search.pl> of >+C<Net::Z3950::SimpleServer>, but Perl critic doesn't like it, so >+we are using whole package overrides here. >+ >+=cut >+ >+=head2 to_koha >+ >+ Convert query to a syntax that C<Koha::SearchEngine> understands. > > =cut > >-package Net::Z3950::RPN::Term; > sub to_koha { > my ($self, $mappings) = @_; > >@@ -93,6 +100,12 @@ sub to_koha { > return '(' . join(' OR ', @terms) . ')'; > } > >+=head2 escape >+ >+ Escape the term >+ >+=cut >+ > sub escape { > my ($self, $term) = @_; > >@@ -100,28 +113,4 @@ sub escape { > return $term; > } > >-package Net::Z3950::RPN::And; >-sub to_koha { >- my ($self, $mappings) = @_; >- >- return '(' . $self->[0]->to_koha($mappings) . ' AND ' . >- $self->[1]->to_koha($mappings) . ')'; >-} >- >-package Net::Z3950::RPN::Or; >-sub to_koha { >- my ($self, $mappings) = @_; >- >- return '(' . $self->[0]->to_koha($mappings) . ' OR ' . >- $self->[1]->to_koha($mappings) . ')'; >-} >- >-package Net::Z3950::RPN::AndNot; >-sub to_koha { >- my ($self, $mappings) = @_; >- >- return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . >- $self->[1]->to_koha($mappings) . ')'; >-} >- > 1; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26683
:
111657
|
111666
| 111667 |
111669